Skip to content

Commit

Permalink
Merge pull request #5 from argyle-engineering/minor-fixing
Browse files Browse the repository at this point in the history
Minor fixing
  • Loading branch information
Nathan S. Martins authored Jan 16, 2023
2 parents c928ab0 + 57f09b2 commit 13595e2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ If you want to test ksops without having to do a bunch of setup, you can use the

Install gpg and sops and kustomize using brew (or figure it out if you're on Linux)
```shell
brew install sops gnugpg kustomize
brew install sops gnupg kustomize
```

then:
Expand All @@ -41,4 +41,23 @@ gpg --import example/sops_functional_tests_key.asc
kustomize build --enable-alpha-plugins --enable-exec example/
```

This last step will decrypt example.yaml using the test private key.
This last step will decrypt example.yaml using the test private key.

## Development

To release a new version install `goreleaser` and set your GH token:

```shell
export GITHUB_TOKEN="YOUR_GH_TOKEN"
```

Now, create a tag and push it to GitHub:
```shell
git tag -a v0.1.0
git push origin v0.1.0
```

then run:
```shell
goreleaser release
```
16 changes: 5 additions & 11 deletions cmd/ksops/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,13 @@ func main() {
var filteredItems []*yaml.RNode
for i := range items {
item := items[i]
if item.GetKind() == "KSOPSGenerator" && item.GetApiVersion() == "argyle.com/v1" {

// Get the spec RNode
rawSpec := item.Field("spec")
if rawSpec == nil {
return nil, fmt.Errorf("no spec found in KSOPSGenerator")
}
if item.GetKind() == "ksops" && item.GetApiVersion() == "argyle.com/v1" {

// Get the spec yaml & unmarshal it
var spec schema.Spec
err = yaml.Unmarshal([]byte(rawSpec.Value.MustString()), &spec)
err = yaml.Unmarshal([]byte(item.MustString()), &spec)
if err != nil {
return nil, fmt.Errorf("unable to parse KSOPSGenerator spec: %w", err)
return nil, fmt.Errorf("unable to parse ksops spec: %w", err)
}

// Generate secrets here
Expand Down Expand Up @@ -88,8 +82,8 @@ func main() {
}

api := make(framework.GVKFilterMap)
api["KSOPSGenerator"] = make(map[string]kio.Filter)
api["KSOPSGenerator"]["argyle.com/v1"] = kio.FilterFunc(fn)
api["ksops"] = make(map[string]kio.Filter)
api["ksops"]["argyle.com/v1"] = kio.FilterFunc(fn)

p := framework.VersionedAPIProcessor{FilterProvider: api}
cmd := command.Build(&p, command.StandaloneDisabled, false)
Expand Down
7 changes: 3 additions & 4 deletions example/secret-generator.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
apiVersion: argyle.com/v1
kind: KSOPSGenerator
kind: ksops
metadata:
name: secret-generator
annotations:
config.kubernetes.io/function: |
exec:
path: ksops
fail-silently: false
spec:
files:
- ./secret.enc.yaml
files:
- ./secret.enc.yaml

0 comments on commit 13595e2

Please sign in to comment.