Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip upgrades for plugins installed via manifest #626

Merged
merged 2 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/krew/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ kubectl krew upgrade foo bar"`,
var nErrors int
for _, name := range pluginNames {
indexName, pluginName := pathutil.CanonicalPluginName(name)
if indexName == "detached" {
klog.Warningf("Skipping upgrade for %q because it was installed via manifest\n", pluginName)
continue
}

plugin, err := indexscanner.LoadPluginByName(paths.IndexPluginsPath(indexName), pluginName)
if err != nil {
if !os.IsNotExist(err) {
Expand Down
16 changes: 16 additions & 0 deletions integration_test/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ func TestKrewUpgradePluginsFromCustomIndex(t *testing.T) {
}
}

func TestKrewUpgradeSkipsManifestPlugin(t *testing.T) {
skipShort(t)

test, cleanup := NewTest(t)
defer cleanup()

test.WithDefaultIndex().
Krew("install", "--manifest", filepath.Join("testdata", validPlugin+constants.ManifestExtension)).
RunOrFail()

out := string(test.Krew("upgrade").RunOrFailOutput())
if !strings.Contains(out, "Skipping upgrade") {
t.Errorf("expected plugin %q to be skipped during upgrade", validPlugin)
}
}

func TestKrewUpgradeNoSecurityWarningForCustomIndex(t *testing.T) {
skipShort(t)

Expand Down