Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Support for Prefixing Secrets during Injection #2849

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Mhammad-riyaz
Copy link

Description 📣

This PR introduces a new --prefix flag to the Infisical CLI run command, allowing users to inject a prefixes to access the secrets. This enhancement provides greater flexibility for developers who need to distinguish between multiple variable sets while maintaining compatibility with existing workflows.

Modified the injectableEnvironment logic to include both prefixed and original variable formats.

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

infisical-cli-prefix.mp4
   runCmd.Flags().String("prefix", "", "add a prefix to all injected environment variable names")


   prefix, err := cmd.Flags().GetString("prefix")
   if err != nil {
	util.HandleError(err, "Unable to parse prefix flag")
    }

            
    if prefix != "" {
       for _, variable := range injectableEnvironment.Variables {
	    parts := strings.SplitN(variable, "=", 2)
	    if len(parts) == 2 {
	        prefixedKey := prefix + parts[0]
	        prefixedVariable := prefixedKey + "=" + parts[1]
                injectableEnvironment.Variables = append(injectableEnvironment.Variables, prefixedVariable)
	     }
	}
    }
            

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant