Skip to content
This repository was archived by the owner on Apr 27, 2024. It is now read-only.

Commit 4f025cb

Browse files
authored
Merge branch 'adrienkohlbecker:master' into master
2 parents d387bd1 + bed3165 commit 4f025cb

File tree

449 files changed

+192
-169113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

449 files changed

+192
-169113
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: golang:1.11
5+
- image: golang:1.16
66
working_directory: /go/src/github.com/adrienkohlbecker/ejson-kms
77
environment:
88
TEST_RESULTS: /tmp/test-results

CHANGELOG.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
1+
# 4.3.0 - August 22nd, 2021
2+
3+
* Added `bash-ifnotset` and `bash-ifempty` formatters
4+
5+
# 4.2.0 - August 22nd, 2021
6+
7+
* Switched to go modules and go 1.16
8+
* Added darwin/linux arm64 binary
9+
110
# 4.1.0 - March 27th, 2019
211

3-
Added support for yaml files in export subcommand.
12+
* Added support for yaml files in export subcommand.
413

514
# 4.0.0 - January 29th, 2019
615

7-
Vendoring go dependencies using dep rather than gvt
8-
Use go-errors/errors upstream rather than own fork. This is breaking change for projects using this as a library as it changes the return type of most methods from `errors.Error` to `error`.
16+
* Vendoring go dependencies using dep rather than gvt
17+
* Use go-errors/errors upstream rather than own fork. This is breaking change for projects using this as a library as it changes the return type of most methods from `errors.Error` to `error`.
918

1019
# 3.0.0 - October 11th, 2016
1120

12-
Removed the `export` keyword from BASH formatter.
13-
This is a breaking change that provides more secure defaults. Specifically,
21+
* Removed the `export` keyword from BASH formatter.
22+
* This is a breaking change that provides more secure defaults. Specifically,
1423
you will need to export the environment variables yourself if your app needs
1524
them outside of the BASH script.
1625

1726
# 2.0.0 - October 10th, 2016
1827

19-
Changed BASH escaping in export, now uses single quotes and no string processing.
20-
This is a breaking change, but is necessary to preserve multi-line strings such
28+
* Changed BASH escaping in export, now uses single quotes and no string processing.
29+
* This is a breaking change, but is necessary to preserve multi-line strings such
2130
as TLS keys when using the `eval "$(ejson-kms export)"` idiom.
2231

2332
# 1.0.1 - October 6th, 2016
2433

25-
Fixed `echo "foo\nbar" | ejson-kms add` previously added only the first line
34+
* Fixed `echo "foo\nbar" | ejson-kms add` previously added only the first line
2635

2736
# 1.0.0 - September 28th, 2016
2837

29-
Initial release of `ejson-kms`
38+
* Initial release of `ejson-kms`

Gopkg.lock

Lines changed: 0 additions & 192 deletions
This file was deleted.

Gopkg.toml

Lines changed: 0 additions & 29 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ejson-kms
22

3-
[![GoDoc](https://godoc.org/github.com/adrienkohlbecker/ejson-kms?status.svg)](https://godoc.org/github.com/adrienkohlbecker/ejson-kms) [![CircleCI](https://circleci.com/gh/adrienkohlbecker/ejson-kms/tree/master.svg?style=shield)](https://circleci.com/gh/adrienkohlbecker/ejson-kms/tree/master) [![Coverage Status](https://coveralls.io/repos/github/adrienkohlbecker/ejson-kms/badge.svg?branch=master)](https://coveralls.io/github/adrienkohlbecker/ejson-kms?branch=master)
3+
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/adrienkohlbecker/ejson-kms)](https://github.com/adrienkohlbecker/ejson-kms/releases/latest) ![GitHub downloads](https://img.shields.io/github/downloads/adrienkohlbecker/ejson-kms/total) [![GoDoc](https://godoc.org/github.com/adrienkohlbecker/ejson-kms?status.svg)](https://godoc.org/github.com/adrienkohlbecker/ejson-kms) [![CircleCI](https://circleci.com/gh/adrienkohlbecker/ejson-kms/tree/master.svg?style=shield)](https://circleci.com/gh/adrienkohlbecker/ejson-kms/tree/master) [![Coverage Status](https://coveralls.io/repos/github/adrienkohlbecker/ejson-kms/badge.svg?branch=master)](https://coveralls.io/github/adrienkohlbecker/ejson-kms?branch=master)
44

55
`ejson-kms` is a utility for managing a collection of secrets in source control using AWS KMS.
66

@@ -131,10 +131,10 @@ The binaries are signed using the GPG key `C248DE6357445D6302F9A62E74BFD03C20CC2
131131
You can install `ejson-kms` on Linux with the following:
132132

133133
```bash
134-
export EJSON_KMS_VERSION="4.1.0"
134+
export EJSON_KMS_VERSION="4.2.0"
135135
curl -Lo ejson-kms https://github.com/adrienkohlbecker/ejson-kms/releases/download/$EJSON_KMS_VERSION/ejson-kms-$EJSON_KMS_VERSION-linux-amd64
136136
curl -Lo ejson-kms.asc https://github.com/adrienkohlbecker/ejson-kms/releases/download/$EJSON_KMS_VERSION/ejson-kms-$EJSON_KMS_VERSION-linux-amd64.asc
137-
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys C248DE6357445D6302F9A62E74BFD03C20CC21AF
137+
gpg --keyserver keyserver.ubuntu.com --recv-keys C248DE6357445D6302F9A62E74BFD03C20CC21AF
138138
gpg --verify ejson-kms.asc
139139
chmod +x ejson-kms
140140
```

bin/release

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ SHA1=$(git rev-parse HEAD)
1111
git tag --sign --local-user="0x20CC21AF" --annotate --message "$VERSION" "$VERSION" HEAD
1212

1313
VERSION=$VERSION SHA1=$SHA1 GOOS=darwin GOARCH=amd64 bin/build
14+
VERSION=$VERSION SHA1=$SHA1 GOOS=darwin GOARCH=arm64 bin/build
1415
VERSION=$VERSION SHA1=$SHA1 GOOS=linux GOARCH=amd64 bin/build
16+
VERSION=$VERSION SHA1=$SHA1 GOOS=linux GOARCH=arm64 bin/build
1517
VERSION=$VERSION SHA1=$SHA1 GOOS=windows GOARCH=amd64 bin/build

cli/export.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ export: Export a secrets file in it's decrypted form.
1616
Each secret in the file will be decrypted and output to standard out.
1717
A number of formats are available:
1818
19-
* bash: SECRET='password'
20-
* dotenv: SECRET="password"
21-
* json: { "secret": "password" }
22-
* yaml: secret: password
19+
* bash: SECRET='password'
20+
* dotenv: SECRET="password"
21+
* json: { "secret": "password" }
22+
* yaml: secret: password
23+
* bash-ifnotset: : ${SECRET='password'}
24+
* bash-ifempty: : ${SECRET:='password'}
25+
2326
2427
Please be careful when exporting your secrets, do not save them to disk!
2528
`
@@ -44,7 +47,7 @@ func exportCmd() *cobra.Command {
4447
)
4548

4649
cmd.Flags().StringVar(&storePath, "path", storePath, "path of the secrets file")
47-
cmd.Flags().StringVar(&format, "format", format, "format of the generated output (bash|dotenv|json|yaml)")
50+
cmd.Flags().StringVar(&format, "format", format, "format of the generated output (bash|dotenv|json|yaml|bash-ifnotset|bash-ifempty)")
4851

4952
cmd.RunE = func(_ *cobra.Command, args []string) error {
5053

formatter/bash.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,59 @@ func Bash(w io.Writer, creds <-chan Item) error {
3030
return nil
3131

3232
}
33+
34+
// BashIfNotSet implements the Formatter interface.
35+
//
36+
// It outputs the decrypted secrets in the form:
37+
//
38+
// : ${MY_SECRET='my value'}
39+
// : ${ANOTHER_ONE='string with ''quotes'''}
40+
//
41+
// The secret names are capitalized and the no processing is done to the string
42+
// except replacing all `'` with `''`.
43+
//
44+
// This will set the environment variable
45+
// only if it has not been previously set.
46+
func BashIfNotSet(w io.Writer, creds <-chan Item) error {
47+
48+
for item := range creds {
49+
key := strings.ToUpper(item.Name)
50+
value := item.Plaintext
51+
value = strings.Replace(value, "'", "''", -1)
52+
_, err := fmt.Fprintf(w, ": ${%s='%s'}\n", key, value)
53+
if err != nil {
54+
return err
55+
}
56+
}
57+
58+
return nil
59+
60+
}
61+
62+
// BashIfEmpty implements the Formatter interface.
63+
//
64+
// It outputs the decrypted secrets in the form:
65+
//
66+
// : ${MY_SECRET:='my value'}
67+
// : ${ANOTHER_ONE:='string with ''quotes'''}
68+
//
69+
// The secret names are capitalized and the no processing is done to the string
70+
// except replacing all `'` with `''`.
71+
//
72+
// This will set the environment variable
73+
// only if it has not been previously set or if it is an empty string.
74+
func BashIfEmpty(w io.Writer, creds <-chan Item) error {
75+
76+
for item := range creds {
77+
key := strings.ToUpper(item.Name)
78+
value := item.Plaintext
79+
value = strings.Replace(value, "'", "''", -1)
80+
_, err := fmt.Fprintf(w, ": ${%s:='%s'}\n", key, value)
81+
if err != nil {
82+
return err
83+
}
84+
}
85+
86+
return nil
87+
88+
}

0 commit comments

Comments
 (0)