Skip to content

Commit f90ce36

Browse files
authored
Skip upgrades for plugins installed via manifest (#626)
* Skip upgrades for plugins installed via manifest * Use warning instead of info
1 parent 7ba6715 commit f90ce36

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

cmd/krew/cmd/upgrade.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ kubectl krew upgrade foo bar"`,
7878
var nErrors int
7979
for _, name := range pluginNames {
8080
indexName, pluginName := pathutil.CanonicalPluginName(name)
81+
if indexName == "detached" {
82+
klog.Warningf("Skipping upgrade for %q because it was installed via manifest\n", pluginName)
83+
continue
84+
}
85+
8186
plugin, err := indexscanner.LoadPluginByName(paths.IndexPluginsPath(indexName), pluginName)
8287
if err != nil {
8388
if !os.IsNotExist(err) {

integration_test/upgrade_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,22 @@ func TestKrewUpgradePluginsFromCustomIndex(t *testing.T) {
8181
}
8282
}
8383

84+
func TestKrewUpgradeSkipsManifestPlugin(t *testing.T) {
85+
skipShort(t)
86+
87+
test, cleanup := NewTest(t)
88+
defer cleanup()
89+
90+
test.WithDefaultIndex().
91+
Krew("install", "--manifest", filepath.Join("testdata", validPlugin+constants.ManifestExtension)).
92+
RunOrFail()
93+
94+
out := string(test.Krew("upgrade").RunOrFailOutput())
95+
if !strings.Contains(out, "Skipping upgrade") {
96+
t.Errorf("expected plugin %q to be skipped during upgrade", validPlugin)
97+
}
98+
}
99+
84100
func TestKrewUpgradeNoSecurityWarningForCustomIndex(t *testing.T) {
85101
skipShort(t)
86102

0 commit comments

Comments
 (0)