Exemplo n.º 1
0
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)
	}
}
Exemplo n.º 2
0
func Show(cmd *cli.Cmd) {
	secretUuid := cmd.String(cli.StringArg{
		Name:      "SECRET_UUID",
		Desc:      "UUID of secret to retrieve",
		HideValue: true,
	})

	cmd.Action = func() {
		s := secrets.Secret{}
		secret, resp, errs := s.Show(secretUuid)

		if len(errs) > 0 {
			log.Fatalf("Could not retrieve secret: %s", errs[0])
		}

		if resp.StatusCode != 200 {
			log.Fatalf("Could not retrieve secret: %s", resp.Status)
		}

		printSecretDetail(secret)
	}
}