Skip to content

Commit f2123b3

Browse files
authored
Merge pull request docker#1749 from thaJeztah/compose_3.8_compose_credential_spec_fix
Update compose 3.8 to disallow additional properties
2 parents 0d92226 + 7084661 commit f2123b3

3 files changed

Lines changed: 57 additions & 52 deletions

File tree

cli/compose/schema/bindata.go

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

cli/compose/schema/data/config_schema_v3.8.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,14 @@
122122
}
123123
},
124124
"container_name": {"type": "string"},
125-
"credential_spec": {"type": "object", "properties": {
126-
"file": {"type": "string"},
127-
"registry": {"type": "string"}
128-
}},
125+
"credential_spec": {
126+
"type": "object",
127+
"properties": {
128+
"file": {"type": "string"},
129+
"registry": {"type": "string"}
130+
},
131+
"additionalProperties": false
132+
},
129133
"depends_on": {"$ref": "#/definitions/list_of_strings"},
130134
"devices": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
131135
"dns": {"$ref": "#/definitions/string_or_list"},

cli/compose/schema/schema_test.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,6 @@ func TestValidateAllowsXFields(t *testing.T) {
8080
}
8181

8282
func TestValidateCredentialSpecs(t *testing.T) {
83-
config := dict{
84-
"version": "99.99",
85-
"services": dict{
86-
"foo": dict{
87-
"image": "busybox",
88-
"credential_spec": dict{
89-
"config": "foobar",
90-
},
91-
},
92-
},
93-
}
9483
tests := []struct {
9584
version string
9685
expectedErr string
@@ -103,11 +92,23 @@ func TestValidateCredentialSpecs(t *testing.T) {
10392
{version: "3.5", expectedErr: "config"},
10493
{version: "3.6", expectedErr: "config"},
10594
{version: "3.7", expectedErr: "config"},
95+
{version: "3.8", expectedErr: "something"},
10696
}
10797

10898
for _, tc := range tests {
10999
tc := tc
110100
t.Run(tc.version, func(t *testing.T) {
101+
config := dict{
102+
"version": "99.99",
103+
"services": dict{
104+
"foo": dict{
105+
"image": "busybox",
106+
"credential_spec": dict{
107+
tc.expectedErr: "foobar",
108+
},
109+
},
110+
},
111+
}
111112
err := Validate(config, tc.version)
112113
if tc.expectedErr != "" {
113114
assert.ErrorContains(t, err, fmt.Sprintf("Additional property %s is not allowed", tc.expectedErr))

0 commit comments

Comments
 (0)