introduce options struct in the API

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2020-12-16 16:16:39 +01:00
parent 855a879a6a
commit eda6a59379
No known key found for this signature in database
GPG key ID: 9858809D6F8F6E7E
14 changed files with 77 additions and 38 deletions

View file

@ -48,11 +48,11 @@ func (c *composeService) Start(ctx context.Context, project *types.Project, cons
return errdefs.ErrNotImplemented
}
func (c *composeService) Up(context.Context, *types.Project, bool) error {
func (c *composeService) Up(context.Context, *types.Project, compose.UpOptions) error {
return errdefs.ErrNotImplemented
}
func (c *composeService) Down(context.Context, string, bool) error {
func (c *composeService) Down(context.Context, string, compose.DownOptions) error {
return errdefs.ErrNotImplemented
}
@ -68,6 +68,6 @@ func (c *composeService) List(context.Context, string) ([]compose.Stack, error)
return nil, errdefs.ErrNotImplemented
}
func (c *composeService) Convert(context.Context, *types.Project, string) ([]byte, error) {
func (c *composeService) Convert(context.Context, *types.Project, compose.ConvertOptions) ([]byte, error) {
return nil, errdefs.ErrNotImplemented
}

View file

@ -35,9 +35,9 @@ type Service interface {
// Start executes the equivalent to a `compose start`
Start(ctx context.Context, project *types.Project, consumer LogConsumer) error
// Up executes the equivalent to a `compose up`
Up(ctx context.Context, project *types.Project, detach bool) error
Up(ctx context.Context, project *types.Project, options UpOptions) error
// Down executes the equivalent to a `compose down`
Down(ctx context.Context, projectName string, removeOrphans bool) error
Down(ctx context.Context, projectName string, options DownOptions) error
// Logs executes the equivalent to a `compose logs`
Logs(ctx context.Context, projectName string, consumer LogConsumer, options LogOptions) error
// Ps executes the equivalent to a `compose ps`
@ -45,7 +45,25 @@ type Service interface {
// List executes the equivalent to a `docker stack ls`
List(ctx context.Context, projectName string) ([]Stack, error)
// Convert translate compose model into backend's native format
Convert(ctx context.Context, project *types.Project, format string) ([]byte, error)
Convert(ctx context.Context, project *types.Project, options ConvertOptions) ([]byte, error)
}
// UpOptions group options of the Up API
type UpOptions struct {
// Detach will create services and return immediately
Detach bool
}
// DownOptions group options of the Down API
type DownOptions struct {
// RemoveOrphans will cleanup containers that are not declared on the compose model but own the same labels
RemoveOrphans bool
}
// ConvertOptions group options of the Convert API
type ConvertOptions struct {
// Format define the output format used to dump converted application model (json|yaml)
Format string
}
// PortPublisher hold status about published port