Skip to content
Permalink
Browse files

Update post installation text (#408)

Repurpose prepCaveats to just add the indentation formatting
  • Loading branch information
chriskim06 authored and k8s-ci-robot committed Nov 30, 2019
1 parent fb7de16 commit 9d1085f8414d1b3da60b9a351b07fd38f53a9cad
Showing with 12 additions and 8 deletions.
  1. +5 −6 cmd/krew/cmd/info.go
  2. +7 −2 cmd/krew/cmd/install.go
@@ -73,24 +73,23 @@ func printPluginInfo(out io.Writer, plugin index.Plugin) {
fmt.Fprintf(out, "DESCRIPTION: \n%s\n", plugin.Spec.Description)
}
if plugin.Spec.Caveats != "" {
fmt.Fprintln(out, prepCaveats(plugin.Spec.Caveats))
fmt.Fprintf(out, "CAVEATS:\n%s\n", indent(plugin.Spec.Caveats))
}
}

// prepCaveats converts caveats string to an indented format ready for printing.
// indent converts strings to an indented format ready for printing.
// Example:
//
// CAVEATS:
// \
// | This plugin is great, use it with great care.
// | Also, plugin will require the following programs to run:
// | * jq
// | * base64
// /
func prepCaveats(s string) string {
out := "CAVEATS:\n\\\n"
func indent(s string) string {
out := "\\\n"
s = strings.TrimRightFunc(s, unicode.IsSpace)
out += regexp.MustCompile("(?m)^").ReplaceAllString(s, " | ")
out += regexp.MustCompile("(?m)^").ReplaceAllString(s, " | ")
out += "\n/"
return out
}
@@ -132,10 +132,15 @@ Remarks:
failed = append(failed, plugin.Name)
continue
}
fmt.Fprintf(os.Stderr, "Installed plugin: %s\n", plugin.Name)
output := fmt.Sprintf("Use this plugin:\n\tkubectl %s\n", plugin.Name)
if plugin.Spec.Homepage != "" {
output += fmt.Sprintf("Documentation:\n\t%s\n", plugin.Spec.Homepage)
}
if plugin.Spec.Caveats != "" {
fmt.Fprintln(os.Stderr, prepCaveats(plugin.Spec.Caveats))
output += fmt.Sprintf("Caveats:\n%s\n", indent(plugin.Spec.Caveats))
}
fmt.Fprintf(os.Stderr, "Installed plugin: %s\n", plugin.Name)
fmt.Fprintln(os.Stderr, indent(output))
internal.PrintSecurityNotice()
}
if len(failed) > 0 {

0 comments on commit 9d1085f

Please sign in to comment.
You can’t perform that action at this time.