Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: envkey/envkey-source
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.2.0
Choose a base ref
...
head repository: envkey/envkey-source
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Sep 14, 2018

  1. fix test live ENVKEY

    danenania committed Sep 14, 2018
    Copy the full SHA
    326a378 View commit details
  2. Releasing 1.2.0

    danenania committed Sep 14, 2018
    Copy the full SHA
    88d4a42 View commit details

Commits on Sep 28, 2018

  1. Copy the full SHA
    cade881 View commit details
  2. Releasing 1.2.1

    danenania committed Sep 28, 2018
    Copy the full SHA
    c70dd76 View commit details

Commits on Oct 9, 2018

  1. Copy the full SHA
    219af4b View commit details
  2. Releasing 1.2.2

    danenania committed Oct 9, 2018
    Copy the full SHA
    c95f312 View commit details

Commits on Oct 28, 2018

  1. Copy the full SHA
    0ed640d View commit details

Commits on Nov 9, 2018

  1. Copy the full SHA
    3b8a5da View commit details
  2. Releasing 1.2.4

    danenania committed Nov 9, 2018
    Copy the full SHA
    5532103 View commit details

Commits on Nov 13, 2018

  1. add flag for .env format

    Seth Pollack committed Nov 13, 2018
    Copy the full SHA
    c54db78 View commit details

Commits on Nov 14, 2018

  1. add test case

    Seth Pollack committed Nov 14, 2018
    Copy the full SHA
    4fd5f6e View commit details

Commits on Nov 15, 2018

  1. reset version.go

    danenania committed Nov 15, 2018
    Copy the full SHA
    7d19abf View commit details
  2. Copy the full SHA
    26425f6 View commit details
  3. Releasing 1.2.5

    danenania committed Nov 15, 2018
    Copy the full SHA
    50fd8e2 View commit details

Commits on Nov 18, 2018

  1. Copy the full SHA
    bfc1763 View commit details

Commits on Mar 1, 2019

  1. Copy the full SHA
    cdde1d8 View commit details
  2. Releasing 1.2.6

    danenania committed Mar 1, 2019
    Copy the full SHA
    84b7b8d View commit details
  3. Copy the full SHA
    b354c2e View commit details
  4. Copy the full SHA
    a64c834 View commit details
  5. Releasing 1.2.7

    danenania committed Mar 1, 2019
    Copy the full SHA
    8083d90 View commit details
  6. Copy the full SHA
    5172dc3 View commit details
  7. Releasing 1.2.8

    danenania committed Mar 1, 2019
    Copy the full SHA
    8e94ab2 View commit details

Commits on Mar 28, 2019

  1. Releasing 1.2.9

    danenania committed Mar 28, 2019
    Copy the full SHA
    d03c4a7 View commit details

Commits on Apr 16, 2019

  1. Update (c)

    danenania authored Apr 16, 2019
    Copy the full SHA
    e65fdaa View commit details

Commits on Jun 12, 2019

  1. Copy the full SHA
    fe4fe17 View commit details

Commits on Sep 5, 2019

  1. Copy the full SHA
    9b12d1b View commit details
  2. README fix

    danenania authored Sep 5, 2019
    Copy the full SHA
    2cc925e View commit details
  3. Update README.md

    danenania authored Sep 5, 2019
    Copy the full SHA
    b745b03 View commit details

Commits on May 24, 2020

  1. Copy the full SHA
    234369a View commit details

Commits on Sep 16, 2020

  1. Copy the full SHA
    ad8b9b9 View commit details

Commits on Feb 2, 2021

  1. Update LICENSE copyright

    danenania authored Feb 2, 2021
    Copy the full SHA
    2b21f54 View commit details
  2. Copy the full SHA
    f4e1df6 View commit details

Commits on Mar 6, 2021

  1. install script: fail over to envkey-source-releases.s3.amazonaws.com …

    …(public S3 bucket controlled by EnvKey) for envkey-source binary if request to Github Releases fails--workaround for htting low Github rate limits
    danenania committed Mar 6, 2021
    Copy the full SHA
    9f61cb9 View commit details

Commits on Apr 5, 2021

  1. Copy the full SHA
    1909663 View commit details
  2. Releasing 1.2.10

    danenania committed Apr 5, 2021
    Copy the full SHA
    2d914fa View commit details
  3. Copy the full SHA
    3821daa View commit details

Commits on Jun 3, 2021

  1. Copy the full SHA
    2c8b6b4 View commit details

Commits on Mar 10, 2022

  1. Update README for v2

    danenania authored Mar 10, 2022
    Copy the full SHA
    cfab5c6 View commit details
Showing with 393 additions and 30 deletions.
  1. +4 −1 .goreleaser.yml
  2. +1 −1 LICENSE
  3. +29 −11 README.md
  4. +10 −5 cmd/root.go
  5. +11 −0 go.mod
  6. +305 −0 go.sum
  7. +12 −2 install.sh
  8. +1 −1 release.sh
  9. +4 −2 shell/shell.go
  10. +15 −6 shell/shell_test/shell_test.go
  11. +1 −1 version.txt
5 changes: 4 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
builds:
- binary: envkey-source
ldflags: '-extldflags "-static"'
ldflags:
- '-s -w'
- '-extldflags "-static"'
env:
- CGO_ENABLED=0
- GOROOT_FINAL=/usr/go
goos:
- darwin
- linux
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright © 2017 Envkey Inc. <support@envkey.com>
Copyright © 2021 Envkey Inc. <support@envkey.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
40 changes: 29 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,9 +2,15 @@

Integrate [EnvKey](https://www.envkey.com) with any language, either in development or on a server, by making your configuration available through the shell as environment variables.

# v2

Now that [EnvKey v2](https://v2.envkey.com) has been released, you can find version 2 of envkey-source in [a subdirectory of the EnvKey v2 monorepo](https://github.com/envkey/envkey/tree/main/public/sdks/envkey-source). Using v2 requires an EnvKey v2 organization (it won't work with ENVKEYs generated in a v1 org).

[Here's a guide on migrating from v1 to v2.](https://docs-v2.envkey.com/docs/migrating-from-v1)

## Installation

envkey-source compiles into a simple static binary with no dependencies, which makes installation a simple matter of fetching the right binary for your platform and putting it in your `PATH`. An `install.sh` script is available to simplify this.
envkey-source compiles into a simple static binary with no dependencies, which makes installation a simple matter of fetching the right binary for your platform and putting it in your `PATH`. An `install.sh` script is available to simplify this, as well as a [homebrew tap](https://github.com/envkey/homebrew-envkey).

**Install via bash:**

@@ -14,6 +20,8 @@ curl -s https://raw.githubusercontent.com/envkey/envkey-source/master/install.sh

***Note:** the install.sh script writes, then deletes a couple temporary files to the current directory during installation, so make sure you have write permissions for whatever directory you run this command in. In locked down environments, you may want to run it in `$HOME` to be safe.*

***Another Note:** the install.sh script downloads the appropriate envkey-source binary from Github Releases by default, but Github has a fairly low rate limit for unauthenticated requests. For added redundancy, it will fail over to envkey-source-releases.s3.amazonaws.com (an S3 bucket controlled by EnvKey) and download the binary from there if the request to Github Releases fails.*

**Install manually:**

Find the [release](https://github.com/envkey/envkey-source/releases) for your platform and architecture, and stick the appropriate binary somewhere in your `PATH` (or wherever you like really).
@@ -55,16 +63,19 @@ echo "$SOME_VAR"
### Flags

```text
--cache cache encrypted config as a local backup (default is true when .env file exists, false otherwise)
--no-cache do NOT cache encrypted config as a local backup even when .env file exists
--cache-dir string cache directory (default is $HOME/.envkey/cache)
--env-file string ENVKEY-containing env file name (default ".env")
--pam-compatible change output format to be compatible with /etc/environment on Linux
-f, --force overwrite existing environment variables and/or other entries in .env file
-h, --help help for envkey-source
-v, --version prints the version
--verbose print verbose output (default is false)
--timeout float timeout in seconds for http requests (default 2)
--cache cache encrypted config as a local backup (default is true when .env file exists, false otherwise)
--no-cache do NOT cache encrypted config as a local backup even when .env file exists
--cache-dir string cache directory (default is $HOME/.envkey/cache)
--dot-env-compatible change output to .env format
--env-file string ENVKEY-containing env file name (default ".env")
--pam-compatible change output format to be compatible with /etc/environment on Linux
-f, --force overwrite existing environment variables and/or other entries in .env file
-h, --help help for envkey-source
-v, --version prints the version
--verbose print verbose output (default is false)
--timeout float timeout in seconds for http requests (default 10)
--retries uint8 number of times to retry requests on failure (default 3)
--retryBackoff float retry backoff factor: {retryBackoff} * (2 ^ {retries - 1}) (default 1)
```

### Errors
@@ -203,6 +214,13 @@ fi

and rerun `direnv allow`.

## x509 error / ca-certificates

On a stripped down OS like Alpine Linux, you may get an `x509: certificate signed by unknown authority` error when `envkey-source` attempts to load your config. [envkey-fetch](https://github.com/envkey/envkey-fetch) (which `envkey-source` wraps) tries to handle this by including its own set of trusted CAs via [gocertifi](https://github.com/certifi/gocertifi), but if you're getting this error anyway, you can fix it by ensuring that the `ca-certificates` dependency is installed. On Alpine you'll want to run:
```
apk add --no-cache ca-certificates
```

## Other EnvKey Libraries

[envkey-fetch](https://github.com/envkey/envkey-fetch) - lower level command line tool that simply accepts an `ENVKEY` and spits out decrypted config as json. Handles core fetching, decryption, verification, web of trust, redundancy, and caching logic. Does most of the work behind the scenes for this library.
15 changes: 10 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -38,8 +38,11 @@ var shouldNotCache bool
var force bool
var printVersion bool
var pamCompatible bool
var dotEnvCompatible bool
var verboseOutput bool
var timeoutSeconds float64
var retries uint8
var retryBackoff float64

// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
@@ -67,13 +70,13 @@ You can also pass an ENVKEY directly (not recommended for real workflows):
}
}

opts := fetch.FetchOptions{cacheEnabled, cacheDir, "envkey-source", version.Version, verboseOutput, timeoutSeconds}
opts := fetch.FetchOptions{cacheEnabled, cacheDir, "envkey-source", version.Version, verboseOutput, timeoutSeconds, retries, retryBackoff}
if len(args) > 0 {
fmt.Println(shell.Source(args[0], force, opts, pamCompatible))
fmt.Println(shell.Source(args[0], force, opts, pamCompatible, dotEnvCompatible))
} else {
godotenv.Load(envFile)
envkey := os.Getenv("ENVKEY")
fmt.Println(shell.Source(envkey, force, opts, pamCompatible))
fmt.Println(shell.Source(envkey, force, opts, pamCompatible, dotEnvCompatible))
}
},
}
@@ -95,9 +98,11 @@ func init() {
RootCmd.Flags().StringVar(&cacheDir, "cache-dir", "", "cache directory (default is $HOME/.envkey/cache)")
RootCmd.Flags().StringVar(&envFile, "env-file", ".env", "ENVKEY-containing env file name")
RootCmd.Flags().BoolVar(&verboseOutput, "verbose", false, "print verbose output (default is false)")
RootCmd.Flags().Float64Var(&timeoutSeconds, "timeout", 2.0, "timeout in seconds for http requests")

RootCmd.Flags().Float64Var(&timeoutSeconds, "timeout", 20.0, "timeout in seconds for http requests")
RootCmd.Flags().Uint8Var(&retries, "retries", 3, "number of times to retry requests on failure")
RootCmd.Flags().Float64Var(&retryBackoff, "retryBackoff", 1, "retry backoff factor: {retryBackoff} * (2 ^ {retries - 1})")
RootCmd.Flags().BoolVar(&pamCompatible, "pam-compatible", false, "change output format to be compatible with /etc/environment on Linux")
RootCmd.Flags().BoolVar(&dotEnvCompatible, "dot-env-compatible", false, "change output to .env format")

// differences between bash syntax and the /etc/environment format, as parsed by PAM
// (https://github.com/linux-pam/linux-pam/blob/master/modules/pam_env/pam_env.c#L194)
11 changes: 11 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/envkey/envkey-source

go 1.16

require (
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054 // indirect
github.com/envkey/envkey-fetch v1.2.8
github.com/joho/godotenv v1.3.0
github.com/spf13/cobra v1.1.3
github.com/stretchr/testify v1.7.0
)
Loading