Skip to content

Commit

Permalink
Remove unused flags and update documentation
Browse files Browse the repository at this point in the history
The --plain flag is only currently made available in contexts where one item is returned, and where one field is of particular importance. For example, command "enclave configs tokens create" returns one token, and that token's secret value is by far its most important field.
  • Loading branch information
Piccirello committed Jan 14, 2020
1 parent fbcf644 commit d2b61a4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
26 changes: 10 additions & 16 deletions pkg/cmd/enclave_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ var secretsCmd = &cobra.Command{
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
jsonFlag := utils.OutputJSON
plain := utils.GetBoolFlag(cmd, "plain")
raw := utils.GetBoolFlag(cmd, "raw")
onlyNames := utils.GetBoolFlag(cmd, "only-names")

Expand All @@ -56,9 +55,9 @@ var secretsCmd = &cobra.Command{
}

if onlyNames {
printer.SecretsNames(secrets, jsonFlag, plain)
printer.SecretsNames(secrets, jsonFlag, false)
} else {
printer.Secrets(secrets, []string{}, jsonFlag, plain, raw)
printer.Secrets(secrets, []string{}, jsonFlag, false, raw)
}
},
}
Expand All @@ -68,8 +67,8 @@ var secretsGetCmd = &cobra.Command{
Short: "Get the value of one or more secrets",
Long: `Get the value of one or more secrets.
Ex: output the secrets "api_key" and "crypto_key":
doppler secrets get api_key crypto_key`,
Ex: output the secrets "API_KEY" and "CRYPTO_KEY":
doppler enclave secrets get API_KEY CRYPTO_KEY`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
jsonFlag := utils.OutputJSON
Expand All @@ -95,12 +94,11 @@ var secretsSetCmd = &cobra.Command{
Short: "Set the value of one or more secrets",
Long: `Set the value of one or more secrets.
Ex: set the secrets "api_key" and "crypto_key":
doppler secrets set api_key=123 crypto_key=456`,
Ex: set the secrets "API_KEY" and "CRYPTO_KEY":
doppler enclave secrets set API_KEY=123 CRYPTO_KEY=456`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
jsonFlag := utils.OutputJSON
plain := utils.GetBoolFlag(cmd, "plain")
raw := utils.GetBoolFlag(cmd, "raw")
silent := utils.GetBoolFlag(cmd, "silent")

Expand All @@ -123,7 +121,7 @@ doppler secrets set api_key=123 crypto_key=456`,
}

if !silent {
printer.Secrets(response, keys, jsonFlag, plain, raw)
printer.Secrets(response, keys, jsonFlag, false, raw)
}
},
}
Expand All @@ -133,12 +131,11 @@ var secretsDeleteCmd = &cobra.Command{
Short: "Delete the value of one or more secrets",
Long: `Delete the value of one or more secrets.
Ex: delete the secrets "api_key" and "crypto_key":
doppler secrets delete api_key crypto_key`,
Ex: delete the secrets "API_KEY" and "CRYPTO_KEY":
doppler enclave secrets delete API_KEY CRYPTO_KEY`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
jsonFlag := utils.OutputJSON
plain := utils.GetBoolFlag(cmd, "plain")
raw := utils.GetBoolFlag(cmd, "raw")
silent := utils.GetBoolFlag(cmd, "silent")
yes := utils.GetBoolFlag(cmd, "yes")
Expand All @@ -156,7 +153,7 @@ doppler secrets delete api_key crypto_key`,
}

if !silent {
printer.Secrets(response, []string{}, jsonFlag, plain, raw)
printer.Secrets(response, []string{}, jsonFlag, false, raw)
}
}
},
Expand Down Expand Up @@ -247,7 +244,6 @@ $ doppler enclave secrets download --format=env --no-file`,
func init() {
secretsCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)")
secretsCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)")
secretsCmd.Flags().Bool("plain", false, "print values without formatting")
secretsCmd.Flags().Bool("raw", false, "print the raw secret value without processing variables")
secretsCmd.Flags().Bool("only-names", false, "only print the secret names; omit all values")

Expand All @@ -259,14 +255,12 @@ func init() {

secretsSetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)")
secretsSetCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)")
secretsSetCmd.Flags().Bool("plain", false, "print values without formatting")
secretsSetCmd.Flags().Bool("raw", false, "print the raw secret value without processing variables")
secretsSetCmd.Flags().Bool("silent", false, "do not output the response")
secretsCmd.AddCommand(secretsSetCmd)

secretsDeleteCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)")
secretsDeleteCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)")
secretsDeleteCmd.Flags().Bool("plain", false, "print values without formatting")
secretsDeleteCmd.Flags().Bool("raw", false, "print the raw secret value without processing variables")
secretsDeleteCmd.Flags().Bool("silent", false, "do not output the response")
secretsDeleteCmd.Flags().Bool("yes", false, "proceed without confirmation")
Expand Down
2 changes: 1 addition & 1 deletion pkg/models/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/
package models

// ComputedSecret holds computed and raw value
// ComputedSecret holds all info about a secret
type ComputedSecret struct {
Name string `json:"name"`
RawValue string `json:"raw"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/models/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func ParseActivityLog(log map[string]interface{}) ActivityLog {
return parsedLog
}

// ParseSecrets for specified project and config
// ParseSecrets parse secrets
func ParseSecrets(response []byte) (map[string]ComputedSecret, error) {
var result map[string]interface{}
err := json.Unmarshal(response, &result)
Expand Down

0 comments on commit d2b61a4

Please sign in to comment.