mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 08:27:36 +00:00
add yaml export
This commit is contained in:
@@ -19,6 +19,7 @@ const (
|
|||||||
FormatDotenv string = "dotenv"
|
FormatDotenv string = "dotenv"
|
||||||
FormatJson string = "json"
|
FormatJson string = "json"
|
||||||
FormatCSV string = "csv"
|
FormatCSV string = "csv"
|
||||||
|
FormatYaml string = "yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
// exportCmd represents the export command
|
// exportCmd represents the export command
|
||||||
@@ -101,8 +102,10 @@ func formatEnvs(envs []models.SingleEnvironmentVariable, format string) (string,
|
|||||||
return formatAsJson(envs), nil
|
return formatAsJson(envs), nil
|
||||||
case FormatCSV:
|
case FormatCSV:
|
||||||
return formatAsCSV(envs), nil
|
return formatAsCSV(envs), nil
|
||||||
|
case FormatYaml:
|
||||||
|
return formatAsYaml(envs), nil
|
||||||
default:
|
default:
|
||||||
return "", fmt.Errorf("invalid format flag: %s", format)
|
return "", fmt.Errorf("invalid format type: %s. Available format types are [%s]", format, []string{FormatDotenv, FormatJson, FormatCSV, FormatYaml})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,6 +130,14 @@ func formatAsDotEnv(envs []models.SingleEnvironmentVariable) string {
|
|||||||
return dotenv
|
return dotenv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func formatAsYaml(envs []models.SingleEnvironmentVariable) string {
|
||||||
|
var dotenv string
|
||||||
|
for _, env := range envs {
|
||||||
|
dotenv += fmt.Sprintf("%s: %s\n", env.Key, env.Value)
|
||||||
|
}
|
||||||
|
return dotenv
|
||||||
|
}
|
||||||
|
|
||||||
// Format environment variables as a JSON file
|
// Format environment variables as a JSON file
|
||||||
func formatAsJson(envs []models.SingleEnvironmentVariable) string {
|
func formatAsJson(envs []models.SingleEnvironmentVariable) string {
|
||||||
// Dump as a json array
|
// Dump as a json array
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ var rootCmd = &cobra.Command{
|
|||||||
Short: "Infisical CLI is used to inject environment variables into any process",
|
Short: "Infisical CLI is used to inject environment variables into any process",
|
||||||
Long: `Infisical is a simple, end-to-end encrypted service that enables teams to sync and manage their environment variables across their development life cycle.`,
|
Long: `Infisical is a simple, end-to-end encrypted service that enables teams to sync and manage their environment variables across their development life cycle.`,
|
||||||
CompletionOptions: cobra.CompletionOptions{DisableDefaultCmd: true},
|
CompletionOptions: cobra.CompletionOptions{DisableDefaultCmd: true},
|
||||||
Version: "0.1.10",
|
Version: "0.1.11",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||||
|
|||||||
Reference in New Issue
Block a user