diff --git a/README.md b/README.md index cb55d0c..8aa2658 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ export PLUGIN_SHA="$(openssl dgst -sha256 -hex "$VAULT_PLUGIN_DIR/joao" | awk '{ export VERSION="$($VAULT_PLUGIN_DIR/joao --version)" # register -vault plugin register -sha256="$PLUGIN_SHA" -command=joao -args="vault,server" -version="$VERSION" secret joao +vault plugin register -sha256="$PLUGIN_SHA" -command=joao -args="vault-plugin" -version="$VERSION" secret joao # configure, add `vault` to set a default vault for querying vault write config/1password "host=$OP_CONNECT_HOST" "token=$OP_CONNECT_TOKEN" # vault=my-default-vault diff --git a/main.go b/main.go index 5572f08..6815887 100644 --- a/main.go +++ b/main.go @@ -6,24 +6,26 @@ import ( "os" "git.rob.mx/nidito/chinampa" + "git.rob.mx/nidito/chinampa/pkg/env" + "git.rob.mx/nidito/chinampa/pkg/logger" "git.rob.mx/nidito/chinampa/pkg/runtime" "git.rob.mx/nidito/joao/cmd" "git.rob.mx/nidito/joao/pkg/version" - "github.com/sirupsen/logrus" ) -func main() { - logrus.SetFormatter(&logrus.TextFormatter{ - DisableLevelTruncation: true, - DisableTimestamp: true, - ForceColors: runtime.ColorEnabled(), - }) - - if runtime.DebugEnabled() { - logrus.SetLevel(logrus.DebugLevel) - logrus.Debug("Debugging enabled") +func logLevel() logger.Level { + if os.Getenv(env.Debug) == "trace" { + return logger.LevelTrace + } else if runtime.DebugEnabled() { + return logger.LevelDebug } + return logger.LevelInfo +} + +func main() { + logger.Configure("joao", logLevel()) + chinampa.Register( cmd.Get, cmd.Set, @@ -48,7 +50,7 @@ Secret values are specified using the ﹅!!secret﹅ YAML tag. `, Version: version.Version, }); err != nil { - logrus.Errorf("total failure: %s", err) + logger.Errorf("total failure: %s", err) os.Exit(2) } }