Variables Import
Introduction
The bns variables import command in the Bunnyshell CLI allows you to import environment variables from specified files. These variables can include both plain text variables and secret variables. This command is particularly useful for setting up environment configurations efficiently.
This guide will walk you through the available options and their functionalities.
CLI Options
1. --var-file
--var-fileUsage: --var-file=/path/to/file
Description: Specifies the file from which to import plain text environment variables. The file should be in key=value format.
Example:
bns variables import --var-file=/etc/config/vars.env2. --secret-file
--secret-fileUsage: --secret-file=/path/to/file
Description: Specifies the file from which to import secret environment variables. The file should be in key=value format.
Example:
bns variables import --secret-file=/etc/config/secrets.env3. --ignore-duplicates
--ignore-duplicatesUsage: --ignore-duplicates
Description: When set, the command skips importing variables that already exist in the environment. This prevents overwriting existing variables. This option can only be used in conjunction with --var-file or --secret-file.
Example:
bns variables import --var-file=/etc/config/vars.env --ignore-duplicatesExample Usage
-
Importing environment variables from
vars.envandsecrets.envwithout ignoring duplicates:bns variables import --var-file=/etc/config/vars.env --secret-file=/etc/config/secrets.env -
Importing environment variables from
vars.envwhile ignoring duplicates:bns variables import --var-file=/etc/config/vars.env --ignore-duplicates -
Importing environment variables from
secrets.envwhile ignoring duplicates:bns variables import --secret-file=/etc/config/secrets.env --ignore-duplicates
By using the --ignore-duplicates flag, the command will skip any variable that already exists in the environment, thus ensuring that existing variables are not overwritten.
Important Notes
- Ensure that the paths specified for
--var-fileand--secret-fileare accessible and contain the appropriate environment variables in a validkey=valueformat. - The
--ignore-duplicatesoption is useful in scenarios where maintaining the current environment variable values is critical and should not be overwritten by the import process.
Updated 2 months ago
