-
Notifications
You must be signed in to change notification settings - Fork 371
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
Print security notice when index is added #616
Changes from 3 commits
90d2da2
be13d52
018003f
56ac20d
c2d0f7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import ( | |
"sigs.k8s.io/krew/internal/installation" | ||
"sigs.k8s.io/krew/internal/installation/receipt" | ||
"sigs.k8s.io/krew/internal/pathutil" | ||
"sigs.k8s.io/krew/pkg/constants" | ||
) | ||
|
||
func init() { | ||
|
@@ -104,7 +105,9 @@ kubectl krew upgrade foo bar"`, | |
return errors.Wrapf(err, "failed to upgrade plugin %q", pluginDisplayName) | ||
} | ||
fmt.Fprintf(os.Stderr, "Upgraded plugin: %s\n", pluginDisplayName) | ||
internal.PrintSecurityNotice(plugin.Name) | ||
if indexName == constants.DefaultIndexName { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TestKrewInstallDoesntShowSecurityWarningForCustomIndex There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
internal.PrintSecurityNotice(plugin.Name) | ||
} | ||
} | ||
if nErrors > 0 { | ||
fmt.Fprintf(os.Stderr, "WARNING: Some plugins failed to upgrade, check logs above.\n") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,19 @@ func TestKrewIndexAddUnsafe(t *testing.T) { | |
} | ||
} | ||
|
||
func TestKrewIndexAddShowsSecurityWarning(t *testing.T) { | ||
skipShort(t) | ||
|
||
test, cleanup := NewTest(t) | ||
defer cleanup() | ||
|
||
test.WithEnv(constants.EnableMultiIndexSwitch, 1).WithDefaultIndex() | ||
out := string(test.Krew("index", "add", "foo", test.TempDir().Path("index/"+constants.DefaultIndexName)).RunOrFailOutput()) | ||
if !strings.Contains(out, "WARNING") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also check for a more specific message? Just in case when |
||
t.Errorf("expected output to contain warning when adding custom index: %v", out) | ||
} | ||
} | ||
|
||
func TestKrewIndexList(t *testing.T) { | ||
skipShort(t) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
We are already using multiline string litrals with odd indentation. Then let's not bother about prettifying the trailing newline.