ejson2env

package module
v2.0.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2021 License: MIT Imports: 8 Imported by: 0

README

Build Status codecov Go Report Card

ejson2env

ejson2env is a tool to simplify storing secrets that should be accessible in the shell environment in your git repo. ejson2env is based on the ejson library and extends the ejson file format.

ejson2env exports all of the values in the environment object in the ejson file to the shell environment.

For example, with the below ejson file:

{
    "_public_key": "<public key here>",
    "environment": {
        "SECRET_SHELL_VARIABLE": "<encrypted data>"
    }
}

Running:

$ ejson2env test.ejson

Would result in the following output:

export SECRET_SHELL_VARIABLE=<decrypted data>

You can then have your shell evaluate this output:

$ eval $(ejson2env test.ejson)

Using ejson2env

ejson2env's usage information is described in it's included manual page.

Installing ejson2env

ejson2env is available through a number of different routes and package managers. If you plan on modifying ejson2env, it is suggested that you install via go get.

Go

ejson2env can be installed using the regular go get tool:

$ go get -u github.com/Shopify/ejson2env/cmd/ejson2env

You can then find the compiled binary in $GOPATH/bin

Debian Package

You can download the latest version of the Debian package from the releases page.

Install the downloaded package by calling:

$ dpkg -i ejson2env_1.0.3_amd64.deb
RubyGems

You can install ejson2env using Ruby's Gem tool:

$ gem install ejson2env
Homebrew

Provided your install of Homebrew is configured to pull from Shopify's Homebrew repo, you can install ejson2env by calling:

$ brew install ejson2env

Contributing

Please review the Contributing document if you are interested in helping improve ejson2env!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportEnv

func ExportEnv(w io.Writer, values map[string]string)

ExportEnv writes the passed environment values to the passed io.Writer.

func ExportQuiet

func ExportQuiet(w io.Writer, values map[string]string)

ExportQuiet writes the passed environment values to the passed io.Writer in %s=%s format.

func ExtractEnv

func ExtractEnv(secrets map[string]interface{}) (map[string]string, error)

ExtractEnv extracts the environment values from the map[string]interface{} containing all secrets, and returns a map[string]string containing the key value pairs. If there's an issue (the environment key doesn't exist, for example), returns an error.

func IsEnvError

func IsEnvError(err error) bool

IsEnvError returns true if the passed error is due to the environment being missing or not containing environment variables.

func ReadAndExportEnv

func ReadAndExportEnv(filename, keyDir, privateKey string, exportFunc ExportFunction) error

ReadAndExportEnv wraps the read, extract, and export steps. Returns an error if any step fails.

func ReadAndExtractEnv

func ReadAndExtractEnv(filename, keyDir, privateKey string) (map[string]string, error)

ReadAndExtractEnv wraps the read and extract steps. Returns a map[string]string containing the environment secrets to export.

Types

type ExportFunction

type ExportFunction func(io.Writer, map[string]string)

ExportFunction is implemented in exportSecrets as an easy way to select how secrets are exported

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL