Skip to content

Commit cbeddb1

Browse files
authored
Merge pull request #6480 from thaJeztah/28.x_backport_remove_cli_experimental_remnants
[28.x backport] remove some remnants from CLI "experimental" config option
2 parents 67885d0 + 2ed42a8 commit cbeddb1

File tree

2 files changed

+76
-27
lines changed

2 files changed

+76
-27
lines changed

cli-plugins/manager/candidate_test.go

Lines changed: 75 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@ func (c *fakeCandidate) Metadata() ([]byte, error) {
3232
func TestValidateCandidate(t *testing.T) {
3333
const (
3434
goodPluginName = metadata.NamePrefix + "goodplugin"
35+
builtinName = metadata.NamePrefix + "builtin"
36+
builtinAlias = metadata.NamePrefix + "alias"
3537

36-
builtinName = metadata.NamePrefix + "builtin"
37-
builtinAlias = metadata.NamePrefix + "alias"
38-
39-
badPrefixPath = "/usr/local/libexec/cli-plugins/wobble"
40-
badNamePath = "/usr/local/libexec/cli-plugins/docker-123456"
41-
goodPluginPath = "/usr/local/libexec/cli-plugins/" + goodPluginName
42-
metaExperimental = `{"SchemaVersion": "0.1.0", "Vendor": "e2e-testing", "Experimental": true}`
38+
badPrefixPath = "/usr/local/libexec/cli-plugins/wobble"
39+
badNamePath = "/usr/local/libexec/cli-plugins/docker-123456"
40+
goodPluginPath = "/usr/local/libexec/cli-plugins/" + goodPluginName
4341
)
4442

4543
fakeroot := &cobra.Command{Use: "docker"}
@@ -51,31 +49,83 @@ func TestValidateCandidate(t *testing.T) {
5149
})
5250

5351
for _, tc := range []struct {
54-
name string
55-
c *fakeCandidate
52+
name string
53+
plugin *fakeCandidate
5654

5755
// Either err or invalid may be non-empty, but not both (both can be empty for a good plugin).
5856
err string
5957
invalid string
6058
}{
61-
/* Each failing one of the tests */
62-
{name: "empty path", c: &fakeCandidate{path: ""}, err: "plugin candidate path cannot be empty"},
63-
{name: "bad prefix", c: &fakeCandidate{path: badPrefixPath}, err: fmt.Sprintf("does not have %q prefix", metadata.NamePrefix)},
64-
{name: "bad path", c: &fakeCandidate{path: badNamePath}, invalid: "did not match"},
65-
{name: "builtin command", c: &fakeCandidate{path: builtinName}, invalid: `plugin "builtin" duplicates builtin command`},
66-
{name: "builtin alias", c: &fakeCandidate{path: builtinAlias}, invalid: `plugin "alias" duplicates an alias of builtin command "builtin"`},
67-
{name: "fetch failure", c: &fakeCandidate{path: goodPluginPath, exec: false}, invalid: fmt.Sprintf("failed to fetch metadata: faked a failure to exec %q", goodPluginPath)},
68-
{name: "metadata not json", c: &fakeCandidate{path: goodPluginPath, exec: true, meta: `xyzzy`}, invalid: "invalid character"},
69-
{name: "empty schemaversion", c: &fakeCandidate{path: goodPluginPath, exec: true, meta: `{}`}, invalid: `plugin SchemaVersion "" is not valid`},
70-
{name: "invalid schemaversion", c: &fakeCandidate{path: goodPluginPath, exec: true, meta: `{"SchemaVersion": "xyzzy"}`}, invalid: `plugin SchemaVersion "xyzzy" is not valid`},
71-
{name: "no vendor", c: &fakeCandidate{path: goodPluginPath, exec: true, meta: `{"SchemaVersion": "0.1.0"}`}, invalid: "plugin metadata does not define a vendor"},
72-
{name: "empty vendor", c: &fakeCandidate{path: goodPluginPath, exec: true, meta: `{"SchemaVersion": "0.1.0", "Vendor": ""}`}, invalid: "plugin metadata does not define a vendor"},
73-
// This one should work
74-
{name: "valid", c: &fakeCandidate{path: goodPluginPath, exec: true, meta: `{"SchemaVersion": "0.1.0", "Vendor": "e2e-testing"}`}},
75-
{name: "experimental + allowing experimental", c: &fakeCandidate{path: goodPluginPath, exec: true, meta: metaExperimental}},
59+
// Invalid cases.
60+
{
61+
name: "empty path",
62+
plugin: &fakeCandidate{path: ""},
63+
err: "plugin candidate path cannot be empty",
64+
},
65+
{
66+
name: "bad prefix",
67+
plugin: &fakeCandidate{path: badPrefixPath},
68+
err: fmt.Sprintf("does not have %q prefix", metadata.NamePrefix),
69+
},
70+
{
71+
name: "bad path",
72+
plugin: &fakeCandidate{path: badNamePath},
73+
invalid: "did not match",
74+
},
75+
{
76+
name: "builtin command",
77+
plugin: &fakeCandidate{path: builtinName},
78+
invalid: `plugin "builtin" duplicates builtin command`,
79+
},
80+
{
81+
name: "builtin alias",
82+
plugin: &fakeCandidate{path: builtinAlias},
83+
invalid: `plugin "alias" duplicates an alias of builtin command "builtin"`,
84+
},
85+
{
86+
name: "fetch failure",
87+
plugin: &fakeCandidate{path: goodPluginPath, exec: false},
88+
invalid: fmt.Sprintf("failed to fetch metadata: faked a failure to exec %q", goodPluginPath),
89+
},
90+
{
91+
name: "metadata not json",
92+
plugin: &fakeCandidate{path: goodPluginPath, exec: true, meta: `xyzzy`},
93+
invalid: "invalid character",
94+
},
95+
{
96+
name: "empty schemaversion",
97+
plugin: &fakeCandidate{path: goodPluginPath, exec: true, meta: `{}`},
98+
invalid: `plugin SchemaVersion "" is not valid`,
99+
},
100+
{
101+
name: "invalid schemaversion",
102+
plugin: &fakeCandidate{path: goodPluginPath, exec: true, meta: `{"SchemaVersion": "xyzzy"}`},
103+
invalid: `plugin SchemaVersion "xyzzy" is not valid`,
104+
},
105+
{
106+
name: "no vendor",
107+
plugin: &fakeCandidate{path: goodPluginPath, exec: true, meta: `{"SchemaVersion": "0.1.0"}`},
108+
invalid: "plugin metadata does not define a vendor",
109+
},
110+
{
111+
name: "empty vendor",
112+
plugin: &fakeCandidate{path: goodPluginPath, exec: true, meta: `{"SchemaVersion": "0.1.0", "Vendor": ""}`},
113+
invalid: "plugin metadata does not define a vendor",
114+
},
115+
116+
// Valid cases.
117+
{
118+
name: "valid",
119+
plugin: &fakeCandidate{path: goodPluginPath, exec: true, meta: `{"SchemaVersion": "0.1.0", "Vendor": "e2e-testing"}`},
120+
},
121+
{
122+
// Including the deprecated "experimental" field should not break processing.
123+
name: "with legacy experimental",
124+
plugin: &fakeCandidate{path: goodPluginPath, exec: true, meta: `{"SchemaVersion": "0.1.0", "Vendor": "e2e-testing", "Experimental": true}`},
125+
},
76126
} {
77127
t.Run(tc.name, func(t *testing.T) {
78-
p, err := newPlugin(tc.c, fakeroot.Commands())
128+
p, err := newPlugin(tc.plugin, fakeroot.Commands())
79129
switch {
80130
case tc.err != "":
81131
assert.ErrorContains(t, err, tc.err)

e2e/internal/fixtures/fixtures.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ func SetupConfigWithNotaryURL(t *testing.T, path, notaryURL string) fs.Dir {
4444
"%s": {
4545
"auth": "ZWlhaXM6cGFzc3dvcmQK"
4646
}
47-
},
48-
"experimental": "enabled"
47+
}
4948
}
5049
`, notaryURL)), fs.WithDir("trust", fs.WithDir("private")))
5150
return *dir

0 commit comments

Comments
 (0)