Skip to content

Commit 8b4ac37

Browse files
committed
introduce --ignore-buildable to ignore buildable images on pull
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent dcbd68a commit 8b4ac37

File tree

5 files changed

+45
-15
lines changed

5 files changed

+45
-15
lines changed

cmd/compose/pull.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type pullOptions struct {
3737
noParallel bool
3838
includeDeps bool
3939
ignorePullFailures bool
40+
noBuildable bool
4041
}
4142

4243
func pullCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
@@ -58,13 +59,14 @@ func pullCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
5859
ValidArgsFunction: completeServiceNames(p),
5960
}
6061
flags := cmd.Flags()
61-
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Pull without printing progress information")
62-
cmd.Flags().BoolVar(&opts.includeDeps, "include-deps", false, "Also pull services declared as dependencies")
62+
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Pull without printing progress information.")
63+
cmd.Flags().BoolVar(&opts.includeDeps, "include-deps", false, "Also pull services declared as dependencies.")
6364
cmd.Flags().BoolVar(&opts.parallel, "parallel", true, "DEPRECATED pull multiple images in parallel.")
6465
flags.MarkHidden("parallel") //nolint:errcheck
6566
cmd.Flags().BoolVar(&opts.parallel, "no-parallel", true, "DEPRECATED disable parallel pulling.")
6667
flags.MarkHidden("no-parallel") //nolint:errcheck
67-
cmd.Flags().BoolVar(&opts.ignorePullFailures, "ignore-pull-failures", false, "Pull what it can and ignores images with pull failures")
68+
cmd.Flags().BoolVar(&opts.ignorePullFailures, "ignore-pull-failures", false, "Pull what it can and ignores images with pull failures.")
69+
cmd.Flags().BoolVar(&opts.noBuildable, "ignore-buildable", false, "Ignore images that can be built.")
6870
return cmd
6971
}
7072

@@ -97,7 +99,8 @@ func runPull(ctx context.Context, backend api.Service, opts pullOptions, service
9799
}
98100

99101
return backend.Pull(ctx, project, api.PullOptions{
100-
Quiet: opts.quiet,
101-
IgnoreFailures: opts.ignorePullFailures,
102+
Quiet: opts.quiet,
103+
IgnoreFailures: opts.ignorePullFailures,
104+
IgnoreBuildable: opts.noBuildable,
102105
})
103106
}

docs/reference/compose_pull.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ Pull service images
55

66
### Options
77

8-
| Name | Type | Default | Description |
9-
|:-------------------------|:-----|:--------|:-------------------------------------------------------|
10-
| `--ignore-pull-failures` | | | Pull what it can and ignores images with pull failures |
11-
| `--include-deps` | | | Also pull services declared as dependencies |
12-
| `-q`, `--quiet` | | | Pull without printing progress information |
8+
| Name | Type | Default | Description |
9+
|:-------------------------|:-----|:--------|:--------------------------------------------------------|
10+
| `--ignore-buildable` | | | Ignore images that can be built. |
11+
| `--ignore-pull-failures` | | | Pull what it can and ignores images with pull failures. |
12+
| `--include-deps` | | | Also pull services declared as dependencies. |
13+
| `-q`, `--quiet` | | | Pull without printing progress information. |
1314

1415

1516
<!---MARKER_GEN_END-->
@@ -62,3 +63,6 @@ $ docker compose pull db
6263
⠹ 77a0c198cde5 Waiting 9.3s
6364
⠹ c8752d5b785c Waiting 9.3s
6465
```
66+
67+
`docker compose pull` will try to pull image for services with a build section. If pull fails, it will let
68+
user know this service image MUST be built. You can skip this by setting `--ignore-buildable` flag

docs/reference/docker_compose_pull.yaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,20 @@ usage: docker compose pull [OPTIONS] [SERVICE...]
77
pname: docker compose
88
plink: docker_compose.yaml
99
options:
10+
- option: ignore-buildable
11+
value_type: bool
12+
default_value: "false"
13+
description: Ignore images that can be built.
14+
deprecated: false
15+
hidden: false
16+
experimental: false
17+
experimentalcli: false
18+
kubernetes: false
19+
swarm: false
1020
- option: ignore-pull-failures
1121
value_type: bool
1222
default_value: "false"
13-
description: Pull what it can and ignores images with pull failures
23+
description: Pull what it can and ignores images with pull failures.
1424
deprecated: false
1525
hidden: false
1626
experimental: false
@@ -20,7 +30,7 @@ options:
2030
- option: include-deps
2131
value_type: bool
2232
default_value: "false"
23-
description: Also pull services declared as dependencies
33+
description: Also pull services declared as dependencies.
2434
deprecated: false
2535
hidden: false
2636
experimental: false
@@ -51,7 +61,7 @@ options:
5161
shorthand: q
5262
value_type: bool
5363
default_value: "false"
54-
description: Pull without printing progress information
64+
description: Pull without printing progress information.
5565
deprecated: false
5666
hidden: false
5767
experimental: false
@@ -99,6 +109,9 @@ examples: |-
99109
⠹ 77a0c198cde5 Waiting 9.3s
100110
⠹ c8752d5b785c Waiting 9.3s
101111
```
112+
113+
`docker compose pull` will try to pull image for services with a build section. If pull fails, it will let
114+
user know this service image MUST be built. You can skip this by setting `--ignore-buildable` flag
102115
deprecated: false
103116
experimental: false
104117
experimentalcli: false

pkg/api/api.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ type PushOptions struct {
193193

194194
// PullOptions group options of the Pull API
195195
type PullOptions struct {
196-
Quiet bool
197-
IgnoreFailures bool
196+
Quiet bool
197+
IgnoreFailures bool
198+
IgnoreBuildable bool
198199
}
199200

200201
// ImagesOptions group options of the Images API

pkg/compose/pull.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ func (s *composeService) pull(ctx context.Context, project *types.Project, opts
102102
}
103103
}
104104

105+
if service.Build != nil && opts.IgnoreBuildable {
106+
w.Event(progress.Event{
107+
ID: service.Name,
108+
Status: progress.Done,
109+
Text: "Skipped - Image can be built",
110+
})
111+
continue
112+
}
113+
105114
if s, ok := imagesBeingPulled[service.Image]; ok {
106115
w.Event(progress.Event{
107116
ID: service.Name,

0 commit comments

Comments
 (0)