Skip to content

Commit cb36214

Browse files
committed
Add logs and logging flag to cli
Added changelog Tweak docs Cleanup file looping Cleanup code and add cleaner err handing Add comments and rearrange logs Simplify code and add test Add import export test Prepare release v0.2.0
1 parent 688ed0a commit cb36214

File tree

12 files changed

+396
-284
lines changed

12 files changed

+396
-284
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
9+
## [0.2.0] - 2020-05-10
810
### Added
911
- CHANGELOG.md
1012
- CONTRIBUTING.md
1113
- CODE_OF_CONDUCT.md
1214
- `template` command for creating a SealedSecret K8s resource
15+
- Debug flag `--debug` and logs
1316
### Changed
1417
- README.md
1518
- make build will populate the binary to `dist` instead of `bin`
@@ -18,5 +21,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1821
### Added
1922
- `init`, `seal` and `verify` commands
2023

21-
[Unreleased]: https://github.com/dschniepp/sealit/compare/v0.1.0-alpha.2...HEAD
24+
[Unreleased]: https://github.com/dschniepp/sealit/compare/v0.2.0...HEAD
25+
[0.2.0]: https://github.com/dschniepp/sealit/compare/v0.1.0-alpha.2...v0.2.0
2226
[0.1.0-alpha.2]: https://github.com/dschniepp/sealit/releases/tag/v0.1.0-alpha.2

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ __sealit__ is a CLI which provides an opinionated way of doing GitOps based on B
1111
3. Run `sealit init` next to your environment specific values.yaml of your helm chart
1212
4. Change the configuration file `.sealit.yaml` according to your needs
1313
5. Run `sealit seal` to encrypt all secrets. Review if your secrets are encrypted otherwise tweak your config file again.
14-
6. Create a `SealedSecret` resource inside your Helm Chart and reference the secrets from the `values.yaml` similar to `{{ .Values.env.your_secret | trimPrefix "ENC:" }}`
15-
7. Now you can securely commit your secrets and deploy your application based on git to Kubernetes
14+
6. Create a `SealedSecret` resource (`sealit template`) inside your Helm Chart and reference the secrets from the `values.yaml` similar to `{{ .Values.env.your_secret | trimPrefix "ENC:" }}`
15+
7. Now you can securely commit your secrets and deploy your application based on your git repository, to Kubernetes
1616

1717
In the [`example`](example) folder you can find a working solution and structure for using _sealit_, _Sealed Secrets_ and _Helm Charts_.
1818

@@ -152,7 +152,7 @@ If you discover a vulnerabilities within __sealit__, please send an e-mail to Da
152152

153153
## Credits
154154

155-
Thanks to the awesome work of the people behind [SOPS](https://github.com/mozilla/sops) and [_Sealed Secrets_](https://github.com/bitnami-labs/sealed-secrets).
155+
Thanks to the awesome work of the people behind [_SOPS_](https://github.com/mozilla/sops) and [_Sealed Secrets_](https://github.com/bitnami-labs/sealed-secrets).
156156
__sealit__ is heavily influenced by there ideas.
157157

158158
## License

cmd/sealit/main.go

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,28 @@ package main
33
import (
44
"log"
55
"os"
6+
"time"
67

78
"github.com/dschniepp/sealit/internal"
89

10+
"github.com/hashicorp/logutils"
911
"github.com/urfave/cli/v2"
1012
)
1113

1214
func main() {
1315
app := &cli.App{
14-
Name: "sealit",
15-
Usage: "alternative cli for sealed secrets",
16+
Name: "sealit",
17+
Version: "v0.2.0",
18+
Compiled: time.Now(),
19+
Usage: "alternative cli for sealed secrets",
1620
Commands: []*cli.Command{
1721
{
1822
Name: "init",
1923
Aliases: []string{"i"},
2024
Usage: "create a config file in the current dir",
21-
Action: func(c *cli.Context) error {
22-
return internal.Init(c.String("config"), c.Bool("force"))
25+
Action: func(c *cli.Context) (err error) {
26+
err = internal.Init(c.String("config"), c.Bool("force"))
27+
return err
2328
},
2429
Flags: []cli.Flag{
2530
&cli.BoolFlag{
@@ -33,9 +38,10 @@ func main() {
3338
Name: "seal",
3439
Aliases: []string{"s"},
3540
Usage: "seal all secrets",
36-
Action: func(c *cli.Context) error {
37-
sealit := internal.New(c.String("config"), c.String("kubeconfig"))
38-
return sealit.Seal(c.Bool("force"))
41+
Action: func(c *cli.Context) (err error) {
42+
sealit, err := internal.New(c.String("config"), c.String("kubeconfig"))
43+
err = sealit.Seal(c.Bool("force"))
44+
return err
3945
},
4046
Flags: []cli.Flag{
4147
&cli.BoolFlag{
@@ -49,17 +55,19 @@ func main() {
4955
Name: "verify",
5056
Aliases: []string{"v"},
5157
Usage: "verify if all secrets are encrypted",
52-
Action: func(c *cli.Context) error {
53-
sealit := internal.New(c.String("config"), c.String("kubeconfig"))
54-
return sealit.Verify()
58+
Action: func(c *cli.Context) (err error) {
59+
sealit, err := internal.New(c.String("config"), c.String("kubeconfig"))
60+
err = sealit.Verify()
61+
return err
5562
},
5663
},
5764
{
5865
Name: "template",
5966
Aliases: []string{"t"},
6067
Usage: "create a sealed secrets template",
61-
Action: func(c *cli.Context) error {
62-
return internal.Template(c.String("file"))
68+
Action: func(c *cli.Context) (err error) {
69+
err = internal.Template(c.String("file"))
70+
return err
6371
},
6472
Flags: []cli.Flag{
6573
&cli.StringFlag{
@@ -80,6 +88,26 @@ func main() {
8088
Name: "kubeconfig",
8189
Usage: "path to the kubeconfig file",
8290
},
91+
&cli.BoolFlag{
92+
Name: "debug",
93+
Value: false,
94+
Usage: "enable verbose output",
95+
},
96+
},
97+
Before: func(c *cli.Context) (err error) {
98+
filter := &logutils.LevelFilter{
99+
Levels: []logutils.LogLevel{"DEBUG", "WARN", "ERROR"},
100+
MinLevel: logutils.LogLevel("WARN"),
101+
Writer: os.Stderr,
102+
}
103+
104+
if c.Bool("debug") {
105+
filter.MinLevel = "DEBUG"
106+
}
107+
108+
log.SetOutput(filter)
109+
110+
return err
83111
},
84112
}
85113

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.14
44

55
require (
66
github.com/bitnami-labs/sealed-secrets v0.12.2
7+
github.com/hashicorp/logutils v1.0.0
78
github.com/urfave/cli/v2 v2.2.0
89
golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f // indirect
910
gopkg.in/yaml.v3 v3.0.0-20200506231410-2ff61e1afc86

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEo
107107
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
108108
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
109109
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
110+
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
111+
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
110112
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
111113
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
112114
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=

internal/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func ExampleConfig() Config {
2121

2222
return Config{
2323
SealingRuleSets: []SealingRuleSet{
24-
SealingRuleSet{
24+
{
2525
FileRegex: "\\.dev\\.yaml$",
2626
Name: "secret",
2727
Namespace: "default",

0 commit comments

Comments
 (0)