2020-06-18 16:13:24 +02:00
|
|
|
/*
|
|
|
|
Copyright 2020 Docker, Inc.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2020-05-05 10:58:24 +02:00
|
|
|
package compose
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-08-17 17:48:52 +02:00
|
|
|
"io"
|
2020-07-02 16:05:45 +02:00
|
|
|
|
|
|
|
"github.com/compose-spec/compose-go/cli"
|
2020-05-05 10:58:24 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Service manages a compose project
|
|
|
|
type Service interface {
|
|
|
|
// Up executes the equivalent to a `compose up`
|
2020-08-17 17:48:52 +02:00
|
|
|
Up(ctx context.Context, opts *cli.ProjectOptions) error
|
2020-05-05 10:58:24 +02:00
|
|
|
// Down executes the equivalent to a `compose down`
|
2020-08-17 17:48:52 +02:00
|
|
|
Down(ctx context.Context, opts *cli.ProjectOptions) error
|
2020-08-07 10:16:12 +02:00
|
|
|
// Logs executes the equivalent to a `compose logs`
|
2020-08-17 17:48:52 +02:00
|
|
|
Logs(ctx context.Context, opts *cli.ProjectOptions, w io.Writer) error
|
2020-08-07 10:16:12 +02:00
|
|
|
// Ps executes the equivalent to a `compose ps`
|
2020-08-17 17:48:52 +02:00
|
|
|
Ps(ctx context.Context, opts *cli.ProjectOptions) ([]ServiceStatus, error)
|
2020-08-18 08:58:37 +02:00
|
|
|
// Convert translate compose model into backend's native format
|
|
|
|
Convert(ctx context.Context, opts *cli.ProjectOptions) ([]byte, error)
|
2020-05-05 10:58:24 +02:00
|
|
|
}
|
2020-08-17 17:48:52 +02:00
|
|
|
|
2020-08-18 16:56:42 +02:00
|
|
|
// PortPublisher hold status about published port
|
2020-08-18 11:38:23 +02:00
|
|
|
type PortPublisher struct {
|
2020-08-17 17:48:52 +02:00
|
|
|
URL string
|
|
|
|
TargetPort int
|
|
|
|
PublishedPort int
|
|
|
|
Protocol string
|
|
|
|
}
|
|
|
|
|
2020-08-18 16:56:42 +02:00
|
|
|
// ServiceStatus hold status about a service
|
2020-08-17 17:48:52 +02:00
|
|
|
type ServiceStatus struct {
|
2020-08-18 16:56:42 +02:00
|
|
|
ID string
|
|
|
|
Name string
|
|
|
|
Replicas int
|
|
|
|
Desired int
|
|
|
|
Ports []string
|
|
|
|
Publishers []PortPublisher
|
2020-08-18 11:38:23 +02:00
|
|
|
}
|