joao/main.go

57 lines
1.6 KiB
Go
Raw Normal View History

// Copyright © 2022 Roberto Hidalgo <joao@un.rob.mx>
2022-12-31 06:14:08 +00:00
// SPDX-License-Identifier: Apache-2.0
package main
import (
2022-12-19 03:09:05 +00:00
"os"
"git.rob.mx/nidito/chinampa"
2023-04-29 00:49:59 +00:00
"git.rob.mx/nidito/chinampa/pkg/env"
"git.rob.mx/nidito/chinampa/pkg/logger"
2022-12-19 03:09:05 +00:00
"git.rob.mx/nidito/chinampa/pkg/runtime"
2023-01-10 07:02:10 +00:00
"git.rob.mx/nidito/joao/cmd"
2022-12-20 05:49:37 +00:00
"git.rob.mx/nidito/joao/pkg/version"
)
2023-04-29 00:49:59 +00:00
func logLevel() logger.Level {
if os.Getenv(env.Debug) == "trace" {
return logger.LevelTrace
} else if runtime.DebugEnabled() {
return logger.LevelDebug
2022-12-19 03:09:05 +00:00
}
2023-04-29 00:49:59 +00:00
return logger.LevelInfo
}
func main() {
logger.Configure("joao", logLevel())
2023-01-11 06:57:58 +00:00
chinampa.Register(
cmd.Get,
cmd.Set,
cmd.Diff,
cmd.Fetch,
cmd.Flush,
cmd.Redact,
2023-01-11 06:57:58 +00:00
cmd.Plugin,
)
chinampa.Register(cmd.GitFilters...)
2023-01-10 07:02:10 +00:00
2022-12-31 06:14:08 +00:00
if err := chinampa.Execute(chinampa.Config{
2023-01-10 07:02:10 +00:00
Name: "joao",
Summary: "A very WIP configuration manager",
Description: `joao makes yaml, json, 1Password and Hashicorp Vault play along nicely.
Keeps config entries encoded as YAML in the filesystem, backs it up to 1Password, and syncs scrubbed copies to git. Robots consume entries via 1Password Connect + Vault.
Schema for configuration and non-secret values live along the code, and are pushed to remote origins. Secrets can optionally and temporally be flushed to disk for editing or other sorts of operations. Git filters are available to prevent secrets from being pushed to remotes. Secrets are grouped into files, and every file gets its own 1Password item.
Secret values are specified using the !!secret YAML tag.
`,
Version: version.Version,
2022-12-31 06:14:08 +00:00
}); err != nil {
2023-04-29 00:49:59 +00:00
logger.Errorf("total failure: %s", err)
2022-12-19 03:09:05 +00:00
os.Exit(2)
}
}