func Create(cmd *cli.Cmd) { value := cmd.String(cli.StringArg{ Name: "VALUE", Desc: "Value to be stored as secret", HideValue: true, }) labels := cmd.Strings(cli.StringsOpt{ Name: "l label", Desc: "Label to attach to Secret. This option may be included more than once.", HideValue: true, }) cmd.Action = func() { s := secrets.Secret{ Value: *value, Labels: *labels, } secret, resp, errs := s.Create() if len(errs) > 0 { log.Fatalf("Could not create secret: %s", errs[0]) } if resp.StatusCode != 201 { log.Fatalf("Could not create secret: %s", resp.Status) } printSecretDetail(secret) } }
func Create(cmd *cli.Cmd) { value := cmd.String(cli.StringOpt{ Name: "v value", Desc: "Value to be stored as secret", HideValue: true, }) cmd.Action = func() { s := secrets.Secret{} if *value == "" { log.Fatal("Value must not be an empty string") } s.Value = *value secret, resp, errs := s.Create() if len(errs) > 0 { log.Fatalf("Could not create secret: %s", errs[0]) } if resp.StatusCode != 201 { log.Fatalf("Could not create secret: %s", resp.Status) } printSecretDetail(*secret) } }