Address PR feedback

This commit is contained in:
Edgar Ramírez Mondragón
2022-12-07 10:54:24 -06:00
parent 90eb292721
commit 793eaee0c6
2 changed files with 10 additions and 10 deletions
+4 -4
View File
@@ -25,7 +25,7 @@ var exportCmd = &cobra.Command{
Use: "export", Use: "export",
Short: "Used to export environment variables to a file", Short: "Used to export environment variables to a file",
DisableFlagsInUseLine: true, DisableFlagsInUseLine: true,
Example: "infisical export --env=prod --format=json", Example: "infisical export --env=prod --format=json > secrets.json",
Args: cobra.NoArgs, Args: cobra.NoArgs,
PreRun: toggleDebug, PreRun: toggleDebug,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
@@ -67,13 +67,13 @@ var exportCmd = &cobra.Command{
var output string var output string
if shouldExpandSecrets { if shouldExpandSecrets {
substitutions := util.SubstituteSecrets(envsFromApi) substitutions := util.SubstituteSecrets(envsFromApi)
output, err = formatEnvs(envName, substitutions, format) output, err = formatEnvs(substitutions, format)
if err != nil { if err != nil {
log.Errorln(err) log.Errorln(err)
return return
} }
} else { } else {
output, err = formatEnvs(envName, envsFromApi, format) output, err = formatEnvs(envsFromApi, format)
if err != nil { if err != nil {
log.Errorln(err) log.Errorln(err)
return return
@@ -92,7 +92,7 @@ func init() {
} }
// Format according to the format flag // Format according to the format flag
func formatEnvs(_ string, envs []models.SingleEnvironmentVariable, format string) (string, error) { func formatEnvs(envs []models.SingleEnvironmentVariable, format string) (string, error) {
switch strings.ToLower(format) { switch strings.ToLower(format) {
case FormatDotenv: case FormatDotenv:
return formatAsDotEnv(envs), nil return formatAsDotEnv(envs), nil
+2 -2
View File
@@ -13,9 +13,9 @@ Export environment variables from the platform into a file format.
## Options ## Options
| Option | Description | Default value | | Option | Description | Default value |
| ------------- | ----------------------------------------------------------------------------------------------------------- | ------------- | | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
| `--env` | Used to set the environment that secrets are pulled from. Accepted values: `dev`, `staging`, `test`, `prod` | `dev` | | `--env` | Used to set the environment that secrets are pulled from. Accepted values: `dev`, `staging`, `test`, `prod` | `dev` |
| `--projectId` | Used to link a local project to the platform (required only if injecting via the service token method) | `None` | | `--projectId` | Used to determine from which infisical project your secrets will be exported from (only required if injecting via the service token method). | `None` |
| `--expand` | Parse shell parameter expansions in your secrets (e.g., `${DOMAIN}`) | `true` | | `--expand` | Parse shell parameter expansions in your secrets (e.g., `${DOMAIN}`) | `true` |
| `--format` | Format of the output file. Accepted values: `dotenv`, `csv` and `json` | `dotenv` | | `--format` | Format of the output file. Accepted values: `dotenv`, `csv` and `json` | `dotenv` |