Skip to content

Commit 9d1085f

Browse files
chriskim06k8s-ci-robot
authored andcommitted
Update post installation text (#408)
Repurpose prepCaveats to just add the indentation formatting
1 parent fb7de16 commit 9d1085f

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

cmd/krew/cmd/info.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,24 +73,23 @@ func printPluginInfo(out io.Writer, plugin index.Plugin) {
7373
fmt.Fprintf(out, "DESCRIPTION: \n%s\n", plugin.Spec.Description)
7474
}
7575
if plugin.Spec.Caveats != "" {
76-
fmt.Fprintln(out, prepCaveats(plugin.Spec.Caveats))
76+
fmt.Fprintf(out, "CAVEATS:\n%s\n", indent(plugin.Spec.Caveats))
7777
}
7878
}
7979

80-
// prepCaveats converts caveats string to an indented format ready for printing.
80+
// indent converts strings to an indented format ready for printing.
8181
// Example:
8282
//
83-
// CAVEATS:
8483
// \
8584
// | This plugin is great, use it with great care.
8685
// | Also, plugin will require the following programs to run:
8786
// | * jq
8887
// | * base64
8988
// /
90-
func prepCaveats(s string) string {
91-
out := "CAVEATS:\n\\\n"
89+
func indent(s string) string {
90+
out := "\\\n"
9291
s = strings.TrimRightFunc(s, unicode.IsSpace)
93-
out += regexp.MustCompile("(?m)^").ReplaceAllString(s, " | ")
92+
out += regexp.MustCompile("(?m)^").ReplaceAllString(s, " | ")
9493
out += "\n/"
9594
return out
9695
}

cmd/krew/cmd/install.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,15 @@ Remarks:
132132
failed = append(failed, plugin.Name)
133133
continue
134134
}
135+
fmt.Fprintf(os.Stderr, "Installed plugin: %s\n", plugin.Name)
136+
output := fmt.Sprintf("Use this plugin:\n\tkubectl %s\n", plugin.Name)
137+
if plugin.Spec.Homepage != "" {
138+
output += fmt.Sprintf("Documentation:\n\t%s\n", plugin.Spec.Homepage)
139+
}
135140
if plugin.Spec.Caveats != "" {
136-
fmt.Fprintln(os.Stderr, prepCaveats(plugin.Spec.Caveats))
141+
output += fmt.Sprintf("Caveats:\n%s\n", indent(plugin.Spec.Caveats))
137142
}
138-
fmt.Fprintf(os.Stderr, "Installed plugin: %s\n", plugin.Name)
143+
fmt.Fprintln(os.Stderr, indent(output))
139144
internal.PrintSecurityNotice()
140145
}
141146
if len(failed) > 0 {

0 commit comments

Comments
 (0)