Skip to content

Commit

Permalink
Fix secret backend command CLI flag (#164)
Browse files Browse the repository at this point in the history
* Fix secret backend

* Update main.go

Co-authored-by: Ivan Ilichev <ivan.ilichev@datadoghq.com>

Co-authored-by: Ivan Ilichev <ivan.ilichev@datadoghq.com>
  • Loading branch information
vboulineau and xornivore committed Oct 29, 2020
1 parent 15e9ace commit 39bf5b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 6 additions & 3 deletions main.go
Expand Up @@ -24,6 +24,7 @@ import (
datadoghqv1alpha1 "github.com/DataDog/datadog-operator/api/v1alpha1"
"github.com/DataDog/datadog-operator/controllers"
"github.com/DataDog/datadog-operator/pkg/controller/debug"
"github.com/DataDog/datadog-operator/pkg/secrets"
"github.com/DataDog/datadog-operator/pkg/version"
edsdatadoghqv1alpha1 "github.com/DataDog/extendeddaemonset/api/v1alpha1"
"github.com/DataDog/extendeddaemonset/pkg/controller/metrics"
Expand Down Expand Up @@ -60,13 +61,13 @@ func main() {

// Custom flags
var printVersion, pprofActive, supportExtendedDaemonset bool
var logEncoder string
var logEncoder, secretBackendCommand string
flag.StringVar(&logEncoder, "logEncoder", "json", "log encoding ('json' or 'console')")
flag.StringVar(&secretBackendCommand, "secretBackendCommand", "", "Secret backend command")
logLevel := zap.LevelFlag("loglevel", zapcore.InfoLevel, "Set log level")
flag.BoolVar(&printVersion, "version", false, "Print version and exit")
flag.BoolVar(&pprofActive, "pprof", false, "Enable pprof endpoint")
flag.BoolVar(&supportExtendedDaemonset, "supportExtendedDaemonset", false, "Support usage of Datadog ExtendedDaemonset CRD.")
flag.Parse()

// Parsing flags
flag.Parse()
Expand All @@ -82,9 +83,11 @@ func main() {
version.PrintVersionWriter(os.Stdout, "text")
os.Exit(0)
}

version.PrintVersionLogs(setupLog)

// Dispatch CLI flags to each package
secrets.SetSecretBackendCommand(secretBackendCommand)

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Expand Down
7 changes: 3 additions & 4 deletions pkg/secrets/secrets.go
Expand Up @@ -14,8 +14,6 @@ import (
"os/exec"
"strings"
"time"

"github.com/spf13/pflag"
)

var (
Expand All @@ -28,8 +26,9 @@ const (
payloadVersion = "1.0"
)

func init() {
pflag.StringVarP(&secretBackendCommand, "secretBackendCommand", "", "", "secret backend command")
// SetSecretBackendCommand set the secretBackendCommand var
func SetSecretBackendCommand(command string) {
secretBackendCommand = command
}

// NewSecretBackend returns a new SecretBackend instance
Expand Down

0 comments on commit 39bf5b6

Please sign in to comment.