Skip to content

Commit ea0b69c

Browse files
committed
introduce no-cache-filter
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent f63fde4 commit ea0b69c

File tree

5 files changed

+85
-30
lines changed

5 files changed

+85
-30
lines changed

loader/loader_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3917,3 +3917,21 @@ services:
39173917
assert.Equal(t, build.Provenance, "mode=max")
39183918
assert.Equal(t, build.SBOM, "true")
39193919
}
3920+
3921+
func TestNoCacheFilter(t *testing.T) {
3922+
p, err := loadYAML(`
3923+
name: no-cache-filter
3924+
services:
3925+
string:
3926+
build:
3927+
context: .
3928+
no_cache_filter: foo
3929+
list:
3930+
build:
3931+
context: .
3932+
no_cache_filter: [foo, bar]
3933+
`)
3934+
assert.NilError(t, err)
3935+
assert.DeepEqual(t, p.Services["string"].Build.NoCacheFilter, types.StringList{"foo"})
3936+
assert.DeepEqual(t, p.Services["list"].Build.NoCacheFilter, types.StringList{"foo", "bar"})
3937+
}

schema/compose-spec.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
"cache_from": {"type": "array", "items": {"type": "string"}, "description": "List of sources the image builder should use for cache resolution"},
122122
"cache_to": {"type": "array", "items": {"type": "string"}, "description": "Cache destinations for the build cache."},
123123
"no_cache": {"type": ["boolean", "string"], "description": "Do not use cache when building the image."},
124+
"no_cache_filter": {"$ref": "#/definitions/string_or_list", "description": "Do not use build cache for the specified stages."},
124125
"additional_contexts": {"$ref": "#/definitions/list_or_dict", "description": "Additional build contexts to use, specified as a map of name to context path or URL."},
125126
"network": {"type": "string", "description": "Network mode to use for the build. Options include 'default', 'none', 'host', or a network name."},
126127
"provenance": {"type": ["string","boolean"], "description": "Add a provenance attestation"},

types/build.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
Copyright 2020 The Compose Specification Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package types
18+
19+
// BuildConfig is a type for build
20+
type BuildConfig struct {
21+
Context string `yaml:"context,omitempty" json:"context,omitempty"`
22+
Dockerfile string `yaml:"dockerfile,omitempty" json:"dockerfile,omitempty"`
23+
DockerfileInline string `yaml:"dockerfile_inline,omitempty" json:"dockerfile_inline,omitempty"`
24+
Entitlements []string `yaml:"entitlements,omitempty" json:"entitlements,omitempty"`
25+
Args MappingWithEquals `yaml:"args,omitempty" json:"args,omitempty"`
26+
Provenance string `yaml:"provenance,omitempty" json:"provenance,omitempty"`
27+
SBOM string `yaml:"sbom,omitempty" json:"sbom,omitempty"`
28+
SSH SSHConfig `yaml:"ssh,omitempty" json:"ssh,omitempty"`
29+
Labels Labels `yaml:"labels,omitempty" json:"labels,omitempty"`
30+
CacheFrom StringList `yaml:"cache_from,omitempty" json:"cache_from,omitempty"`
31+
CacheTo StringList `yaml:"cache_to,omitempty" json:"cache_to,omitempty"`
32+
NoCache bool `yaml:"no_cache,omitempty" json:"no_cache,omitempty"`
33+
NoCacheFilter StringList `yaml:"no_cache_filter,omitempty" json:"no_cache_filter,omitempty"`
34+
AdditionalContexts Mapping `yaml:"additional_contexts,omitempty" json:"additional_contexts,omitempty"`
35+
Pull bool `yaml:"pull,omitempty" json:"pull,omitempty"`
36+
ExtraHosts HostsList `yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty"`
37+
Isolation string `yaml:"isolation,omitempty" json:"isolation,omitempty"`
38+
Network string `yaml:"network,omitempty" json:"network,omitempty"`
39+
Target string `yaml:"target,omitempty" json:"target,omitempty"`
40+
Secrets []ServiceSecretConfig `yaml:"secrets,omitempty" json:"secrets,omitempty"`
41+
ShmSize UnitBytes `yaml:"shm_size,omitempty" json:"shm_size,omitempty"`
42+
Tags StringList `yaml:"tags,omitempty" json:"tags,omitempty"`
43+
Ulimits map[string]*UlimitsConfig `yaml:"ulimits,omitempty" json:"ulimits,omitempty"`
44+
Platforms StringList `yaml:"platforms,omitempty" json:"platforms,omitempty"`
45+
Privileged bool `yaml:"privileged,omitempty" json:"privileged,omitempty"`
46+
47+
Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
48+
}

types/derived.gen.go

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/types.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -302,36 +302,6 @@ func (s ServiceConfig) GetPullPolicy() (string, time.Duration, error) {
302302
}
303303
}
304304

305-
// BuildConfig is a type for build
306-
type BuildConfig struct {
307-
Context string `yaml:"context,omitempty" json:"context,omitempty"`
308-
Dockerfile string `yaml:"dockerfile,omitempty" json:"dockerfile,omitempty"`
309-
DockerfileInline string `yaml:"dockerfile_inline,omitempty" json:"dockerfile_inline,omitempty"`
310-
Entitlements []string `yaml:"entitlements,omitempty" json:"entitlements,omitempty"`
311-
Args MappingWithEquals `yaml:"args,omitempty" json:"args,omitempty"`
312-
Provenance string `yaml:"provenance,omitempty" json:"provenance,omitempty"`
313-
SBOM string `yaml:"sbom,omitempty" json:"sbom,omitempty"`
314-
SSH SSHConfig `yaml:"ssh,omitempty" json:"ssh,omitempty"`
315-
Labels Labels `yaml:"labels,omitempty" json:"labels,omitempty"`
316-
CacheFrom StringList `yaml:"cache_from,omitempty" json:"cache_from,omitempty"`
317-
CacheTo StringList `yaml:"cache_to,omitempty" json:"cache_to,omitempty"`
318-
NoCache bool `yaml:"no_cache,omitempty" json:"no_cache,omitempty"`
319-
AdditionalContexts Mapping `yaml:"additional_contexts,omitempty" json:"additional_contexts,omitempty"`
320-
Pull bool `yaml:"pull,omitempty" json:"pull,omitempty"`
321-
ExtraHosts HostsList `yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty"`
322-
Isolation string `yaml:"isolation,omitempty" json:"isolation,omitempty"`
323-
Network string `yaml:"network,omitempty" json:"network,omitempty"`
324-
Target string `yaml:"target,omitempty" json:"target,omitempty"`
325-
Secrets []ServiceSecretConfig `yaml:"secrets,omitempty" json:"secrets,omitempty"`
326-
ShmSize UnitBytes `yaml:"shm_size,omitempty" json:"shm_size,omitempty"`
327-
Tags StringList `yaml:"tags,omitempty" json:"tags,omitempty"`
328-
Ulimits map[string]*UlimitsConfig `yaml:"ulimits,omitempty" json:"ulimits,omitempty"`
329-
Platforms StringList `yaml:"platforms,omitempty" json:"platforms,omitempty"`
330-
Privileged bool `yaml:"privileged,omitempty" json:"privileged,omitempty"`
331-
332-
Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
333-
}
334-
335305
// BlkioConfig define blkio config
336306
type BlkioConfig struct {
337307
Weight uint16 `yaml:"weight,omitempty" json:"weight,omitempty"`

0 commit comments

Comments
 (0)