From 3b625a8f80dda28e65d2090f99c2ebdfc9e25959 Mon Sep 17 00:00:00 2001 From: Jack Murdock Date: Wed, 17 Apr 2019 17:54:40 -0700 Subject: [PATCH] fix cipher yaml loading (#56) * fix cipher yaml loading * [skip ci] prepare for v0.4.1 release --- CHANGELOG.md | 6 +++++- cipher/noop.json | 7 ------- cipher/noop.yaml | 5 +++++ cipher/viper.go | 9 +-------- 4 files changed, 11 insertions(+), 16 deletions(-) delete mode 100644 cipher/noop.json create mode 100644 cipher/noop.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 745179c..ad0b9ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [v0.4.1] +- fixed cipher yaml loading + ## [v0.4.0] - Added kid and alg to `db` package - Updated loading cipher options @@ -95,7 +98,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Initial creation - Created `db` and `xvault` package -[Unreleased]: https://github.com/Comcast/codex/compare/v0.4.0...HEAD +[Unreleased]: https://github.com/Comcast/codex/compare/v0.4.1..HEAD +[v0.4.1]: https://github.com/Comcast/codex/compare/v0.4.0...v0.4.1 [v0.4.0]: https://github.com/Comcast/codex/compare/v0.3.3...v0.4.0 [v0.3.3]: https://github.com/Comcast/codex/compare/v0.3.2...v0.3.3 [v0.3.2]: https://github.com/Comcast/codex/compare/v0.3.1...v0.3.2 diff --git a/cipher/noop.json b/cipher/noop.json deleted file mode 100644 index b4131b2..0000000 --- a/cipher/noop.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "cipher": [ - { - "type": "none" - } - ] -} \ No newline at end of file diff --git a/cipher/noop.yaml b/cipher/noop.yaml new file mode 100644 index 0000000..4a8ef1e --- /dev/null +++ b/cipher/noop.yaml @@ -0,0 +1,5 @@ +cipher: +- type: none + kid: none +- type: box + kid: rip \ No newline at end of file diff --git a/cipher/viper.go b/cipher/viper.go index 22945ca..afb73f4 100644 --- a/cipher/viper.go +++ b/cipher/viper.go @@ -1,7 +1,6 @@ package cipher import ( - "encoding/json" "github.com/go-kit/kit/log" "github.com/goph/emperror" "github.com/spf13/viper" @@ -62,12 +61,6 @@ func (c *Ciphers) Get(alg AlgorithmType, KID string) (Decrypt, bool) { // FromViper produces an Options from a (possibly nil) Viper instance. // cipher key is expected func FromViper(v *viper.Viper) (o Options, err error) { - obj := v.Get("cipher") - data, err := json.Marshal(obj) - if err != nil { - return []Config{}, emperror.Wrap(err, "failed to load cipher config") - } - - err = json.Unmarshal(data, &o) + err = v.UnmarshalKey(CipherKey, &o) return }