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

Usage: --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.env

2. --secret-file

Usage: --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.env

3. --ignore-duplicates

Usage: --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-duplicates

Example Usage

  1. Importing environment variables from vars.env and secrets.env without ignoring duplicates:

    bns variables import --var-file=/etc/config/vars.env --secret-file=/etc/config/secrets.env
    
  2. Importing environment variables from vars.env while ignoring duplicates:

    bns variables import --var-file=/etc/config/vars.env --ignore-duplicates
    
  3. Importing environment variables from secrets.env while 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-file and --secret-file are accessible and contain the appropriate environment variables in a valid key=value format.
  • The --ignore-duplicates option is useful in scenarios where maintaining the current environment variable values is critical and should not be overwritten by the import process.