Skip to content

Commit

Permalink
add expand flag to crud sli
Browse files Browse the repository at this point in the history
  • Loading branch information
maidul98 committed Jan 3, 2023
1 parent 7e71e3c commit 59f5ad7
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions cli/packages/cmd/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,25 @@ var secretsCmd = &cobra.Command{
return
}

shouldExpandSecrets, err := cmd.Flags().GetBool("expand")
if err != nil {
log.Errorln("Unable to parse the substitute flag")
log.Debugln(err)
return
}

workspaceFileExists := util.WorkspaceConfigFileExistsInCurrentPath()
if !workspaceFileExists {
log.Error("You have not yet connected to an Infisical Project. Please run [infisical init]")
return
}

secrets, err := util.GetAllEnvironmentVariables("", environmentName)
secrets = util.SubstituteSecrets(secrets)

if shouldExpandSecrets {
secrets = util.SubstituteSecrets(secrets)
}

if err != nil {
log.Debugln(err)
return
Expand Down Expand Up @@ -333,7 +344,7 @@ var secretsDeleteCmd = &cobra.Command{
invalidSecretNamesThatDoNotExist := []string{}

for _, secretKeyFromArg := range args {
if value, ok := secretByKey[secretKeyFromArg]; ok {
if value, ok := secretByKey[strings.ToUpper(secretKeyFromArg)]; ok {
validSecretIdsToDelete = append(validSecretIdsToDelete, value.ID)
} else {
invalidSecretNamesThatDoNotExist = append(invalidSecretNamesThatDoNotExist, secretKeyFromArg)
Expand Down Expand Up @@ -368,10 +379,11 @@ var secretsDeleteCmd = &cobra.Command{

func init() {
secretsCmd.AddCommand(secretsGetCmd)
secretsSetCmd.Flags().String("type", "shared", "Used to set the type for secrets")
// secretsSetCmd.Flags().String("type", "shared", "Used to set the type for secrets")
secretsCmd.AddCommand(secretsSetCmd)
secretsCmd.AddCommand(secretsDeleteCmd)
secretsCmd.PersistentFlags().String("env", "dev", "Used to define the environment name on which actions should be taken on")
secretsCmd.Flags().Bool("expand", true, "Parse shell parameter expansions in your secrets")
rootCmd.AddCommand(secretsCmd)
}

Expand Down Expand Up @@ -403,7 +415,7 @@ func getSecretsByNames(cmd *cobra.Command, args []string) {
}

for _, secretKeyFromArg := range args {
if value, ok := secretsMap[secretKeyFromArg]; ok {
if value, ok := secretsMap[strings.ToUpper(secretKeyFromArg)]; ok {
requestedSecrets = append(requestedSecrets, value)
} else {
requestedSecrets = append(requestedSecrets, models.SingleEnvironmentVariable{
Expand Down

0 comments on commit 59f5ad7

Please sign in to comment.