func cmdUploadLicense() { if flagCmdUploadLicense { if model.BuildEnterpriseReady != "true" { fmt.Fprintln(os.Stderr, "build must be enterprise ready") os.Exit(1) } if len(flagLicenseFile) == 0 { fmt.Fprintln(os.Stderr, "flag needs an argument: -team_name") flag.Usage() os.Exit(1) } var fileBytes []byte var err error if fileBytes, err = ioutil.ReadFile(flagLicenseFile); err != nil { l4g.Error("%v", err) flushLogAndExit(1) } if _, err := api.SaveLicense(fileBytes); err != nil { l4g.Error("%v", err) flushLogAndExit(1) } else { flushLogAndExit(0) } flushLogAndExit(0) } }
func uploadLicenseCmdF(cmd *cobra.Command, args []string) error { initDBCommandContextCobra(cmd) if len(args) != 1 { return errors.New("Enter one license file to upload") } var fileBytes []byte var err error if fileBytes, err = ioutil.ReadFile(args[0]); err != nil { return err } if _, err := api.SaveLicense(fileBytes); err != nil { return err } CommandPrettyPrintln("Uploaded license file") return nil }