Skip to content

Commit

Permalink
Add --include-deps to push command
Browse files Browse the repository at this point in the history
  • Loading branch information
gferon committed Dec 6, 2022
1 parent 6ed9a79 commit 9d7d8c0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cmd/compose/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import (
"github.com/spf13/cobra"

"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/utils"
)

type pushOptions struct {
*projectOptions
composeOptions

IncludeDeps bool
Ignorefailures bool
Quiet bool
}
Expand All @@ -45,6 +46,7 @@ func pushCommand(p *projectOptions, backend api.Service) *cobra.Command {
ValidArgsFunction: completeServiceNames(p),
}
pushCmd.Flags().BoolVar(&opts.Ignorefailures, "ignore-push-failures", false, "Push what it can and ignores images with push failures")
pushCmd.Flags().BoolVar(&opts.IncludeDeps, "include-deps", false, "Also push images of services declared as dependencies")
pushCmd.Flags().BoolVarP(&opts.Quiet, "quiet", "q", false, "Push without printing progress information")

return pushCmd
Expand All @@ -56,6 +58,19 @@ func runPush(ctx context.Context, backend api.Service, opts pushOptions, service
return err
}

if !opts.IncludeDeps {
enabled, err := project.GetServices(services...)
if err != nil {
return err
}
for _, s := range project.Services {
if !utils.StringContains(services, s.Name) {
project.DisabledServices = append(project.DisabledServices, s)
}
}
project.Services = enabled
}

return backend.Push(ctx, project, api.PushOptions{
IgnoreFailures: opts.Ignorefailures,
Quiet: opts.Quiet,
Expand Down
1 change: 1 addition & 0 deletions docs/reference/compose_push.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Push service images
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `--ignore-push-failures` | | | Push what it can and ignores images with push failures |
| `--include-deps` | | | Also push images of services declared as dependencies |
| `-q`, `--quiet` | | | Push without printing progress information |


Expand Down

0 comments on commit 9d7d8c0

Please sign in to comment.