NewCmd create a new cobra command
()
| 32 | |
| 33 | // NewCmd create a new cobra command |
| 34 | func NewCmd() *cobra.Command { |
| 35 | cmd := cobra.Command{ |
| 36 | Use: "bootstrap [target]", |
| 37 | Args: cobra.ExactArgs(1), |
| 38 | RunE: func(cmd *cobra.Command, args []string) error { |
| 39 | contextLogger := log.FromContext(cmd.Context()) |
| 40 | dest := args[0] |
| 41 | |
| 42 | contextLogger.Info("Installing the manager executable", |
| 43 | "destination", dest, |
| 44 | "version", versions.Version, |
| 45 | "build", versions.Info) |
| 46 | err := fileutils.CopyFile(cmd.Root().Name(), dest) |
| 47 | if err != nil { |
| 48 | panic(err) |
| 49 | } |
| 50 | |
| 51 | contextLogger.Info("Setting 0750 permissions") |
| 52 | err = os.Chmod(dest, 0o750) // #nosec |
| 53 | if err != nil { |
| 54 | panic(err) |
| 55 | } |
| 56 | |
| 57 | contextLogger.Info("Bootstrap completed") |
| 58 | |
| 59 | return nil |
| 60 | }, |
| 61 | } |
| 62 | |
| 63 | return &cmd |
| 64 | } |