mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 02:20:53 +00:00
@@ -17,17 +17,18 @@ func NewCommand() *cobra.Command {
|
||||
DisableFlagsInUseLine: true,
|
||||
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
|
||||
Args: cobra.ExactValidArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
switch args[0] {
|
||||
case "bash":
|
||||
cmd.Root().GenBashCompletion(os.Stdout)
|
||||
return cmd.Root().GenBashCompletion(os.Stdout)
|
||||
case "zsh":
|
||||
cmd.Root().GenZshCompletion(os.Stdout)
|
||||
return cmd.Root().GenZshCompletion(os.Stdout)
|
||||
case "fish":
|
||||
cmd.Root().GenFishCompletion(os.Stdout, true)
|
||||
return cmd.Root().GenFishCompletion(os.Stdout, true)
|
||||
case "powershell":
|
||||
cmd.Root().GenPowerShellCompletion(os.Stdout)
|
||||
return cmd.Root().GenPowerShellCompletion(os.Stdout)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,9 +104,9 @@ func (r *AnnotateRunner) ExecuteCmd(w io.Writer, pkgPath string) error {
|
||||
return err
|
||||
}
|
||||
// print error message and continue if there are multiple packages to annotate
|
||||
fmt.Fprintf(w, "%s\n", err.Error())
|
||||
_, _ = fmt.Fprintf(w, "%s\n", err.Error())
|
||||
} else {
|
||||
fmt.Fprint(w, "added annotations in the package\n")
|
||||
_, _ = fmt.Fprint(w, "added annotations in the package\n")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ const (
|
||||
|
||||
// ConvertToBuiltInPlugin converts the input plugin file to
|
||||
// kustomize builtin plugin and writes it to proper directory
|
||||
func ConvertToBuiltInPlugin() error {
|
||||
func ConvertToBuiltInPlugin() (retErr error) {
|
||||
root, err := inputFileRoot()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -47,7 +47,12 @@ func ConvertToBuiltInPlugin() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer w.close()
|
||||
defer func() {
|
||||
closeErr := w.Close()
|
||||
if retErr == nil {
|
||||
retErr = closeErr
|
||||
}
|
||||
}()
|
||||
|
||||
// This particular phrasing is required.
|
||||
w.write(
|
||||
@@ -139,10 +144,10 @@ func makeOutputFileName(root string) string {
|
||||
"..", "..", "..", "api", packageForGeneratedCode, root+".go")
|
||||
}
|
||||
|
||||
func (w *writer) close() {
|
||||
func (w *writer) Close() error {
|
||||
// Do this for debugging.
|
||||
// fmt.Println("Generated " + makeOutputFileName(w.root))
|
||||
w.f.Close()
|
||||
return w.f.Close()
|
||||
}
|
||||
|
||||
func (w *writer) write(line string) {
|
||||
|
||||
Reference in New Issue
Block a user