diff --git a/cmd/acmesolver/main.go b/cmd/acmesolver/main.go index 3cc075dbf..5a85bee95 100644 --- a/cmd/acmesolver/main.go +++ b/cmd/acmesolver/main.go @@ -17,10 +17,9 @@ limitations under the License. package main import ( + "flag" "log" - flag "github.com/spf13/pflag" - "github.com/jetstack/cert-manager/pkg/issuer/acme/http/solver" "github.com/jetstack/cert-manager/pkg/logs" ) diff --git a/cmd/cainjector/main.go b/cmd/cainjector/main.go index 4aa8c2d29..56bbd050a 100644 --- a/cmd/cainjector/main.go +++ b/cmd/cainjector/main.go @@ -27,13 +27,14 @@ import ( ) func main() { - logs.InitLogs(nil) + logs.InitLogs(flag.CommandLine) defer logs.FlushLogs() ctrl.SetLogger(logs.Log) - stopCh := ctrl.SetupSignalHandler() + stopCh := ctrl.SetupSignalHandler() cmd := NewCommandStartInjectorController(os.Stdout, os.Stderr, stopCh) cmd.Flags().AddGoFlagSet(flag.CommandLine) + flag.CommandLine.Parse([]string{}) if err := cmd.Execute(); err != nil { klog.Fatal(err) diff --git a/cmd/controller/main.go b/cmd/controller/main.go index cbc2fa96a..2f0d303c0 100644 --- a/cmd/controller/main.go +++ b/cmd/controller/main.go @@ -28,13 +28,13 @@ import ( ) func main() { + logf.InitLogs(flag.CommandLine) + defer logf.FlushLogs() + stopCh := SetupSignalHandler() cmd := NewCommandStartCertManagerController(stopCh) cmd.Flags().AddGoFlagSet(flag.CommandLine) - logf.InitLogs(cmd.Flags()) - defer logf.FlushLogs() - flag.CommandLine.Parse([]string{}) if err := cmd.Execute(); err != nil { klog.Fatal(err) diff --git a/pkg/logs/BUILD.bazel b/pkg/logs/BUILD.bazel index e76888ac9..44d1f6cb9 100644 --- a/pkg/logs/BUILD.bazel +++ b/pkg/logs/BUILD.bazel @@ -8,7 +8,6 @@ go_library( deps = [ "//pkg/api:go_default_library", "//vendor/github.com/go-logr/logr:go_default_library", - "//vendor/github.com/spf13/pflag:go_default_library", "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", diff --git a/pkg/logs/logs.go b/pkg/logs/logs.go index 5153bbff2..163b63341 100644 --- a/pkg/logs/logs.go +++ b/pkg/logs/logs.go @@ -23,7 +23,6 @@ import ( "time" "github.com/go-logr/logr" - "github.com/spf13/pflag" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -43,7 +42,7 @@ var ( DebugLevel = 3 ) -var logFlushFreq = pflag.Duration("log-flush-frequency", 5*time.Second, "Maximum number of seconds between log flushes") +var logFlushFreq = flag.Duration("log-flush-frequency", 5*time.Second, "Maximum number of seconds between log flushes") // GlogWriter serves as a bridge between the standard log package and the glog package. type GlogWriter struct{} @@ -55,15 +54,11 @@ func (writer GlogWriter) Write(data []byte) (n int, err error) { } // InitLogs initializes logs the way we want for kubernetes. -func InitLogs(fs *pflag.FlagSet) { +func InitLogs(fs *flag.FlagSet) { if fs == nil { - fs = pflag.CommandLine + fs = flag.CommandLine } - - gofs := &flag.FlagSet{} - klog.InitFlags(gofs) - fs.AddGoFlagSet(gofs) - + klog.InitFlags(fs) fs.Set("logtostderr", "true") log.SetOutput(GlogWriter{}) diff --git a/test/e2e/BUILD.bazel b/test/e2e/BUILD.bazel index 81303890f..7d2d1b6b0 100644 --- a/test/e2e/BUILD.bazel +++ b/test/e2e/BUILD.bazel @@ -55,7 +55,6 @@ go_test( "//vendor/github.com/onsi/ginkgo/config:go_default_library", "//vendor/github.com/onsi/ginkgo/reporters:go_default_library", "//vendor/github.com/onsi/gomega:go_default_library", - "//vendor/github.com/spf13/pflag:go_default_library", "//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library", ], ) diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index e892bb401..ad6d96c3b 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -17,6 +17,7 @@ limitations under the License. package e2e import ( + "flag" "fmt" "path" "testing" @@ -26,7 +27,6 @@ import ( ginkgoconfig "github.com/onsi/ginkgo/config" "github.com/onsi/ginkgo/reporters" "github.com/onsi/gomega" - flag "github.com/spf13/pflag" "k8s.io/apimachinery/pkg/util/wait" "github.com/jetstack/cert-manager/pkg/logs" @@ -35,6 +35,9 @@ import ( ) func init() { + logs.InitLogs(flag.CommandLine) + framework.DefaultConfig.AddFlags(flag.CommandLine) + // Turn on verbose by default to get spec names ginkgoconfig.DefaultReporterConfig.Verbose = true // Turn on EmitSpecProgress to get spec progress (especially on interrupt) @@ -46,10 +49,7 @@ func init() { } func TestE2E(t *testing.T) { - logs.InitLogs(flag.CommandLine) defer logs.FlushLogs() - - framework.DefaultConfig.AddFlags(flag.CommandLine) flag.Parse() if err := framework.DefaultConfig.Validate(); err != nil { diff --git a/test/e2e/framework/config/addons.go b/test/e2e/framework/config/addons.go index d0934c9d0..dab0399cc 100644 --- a/test/e2e/framework/config/addons.go +++ b/test/e2e/framework/config/addons.go @@ -17,7 +17,7 @@ limitations under the License. package config import ( - flag "github.com/spf13/pflag" + "flag" ) // Addons contains global configuration for instances of addons diff --git a/test/e2e/framework/config/config.go b/test/e2e/framework/config/config.go index e91ecb00d..62e552ed3 100644 --- a/test/e2e/framework/config/config.go +++ b/test/e2e/framework/config/config.go @@ -17,10 +17,10 @@ limitations under the License. package config import ( + "flag" "fmt" "os" - "github.com/spf13/pflag" utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/client-go/tools/clientcmd" ) @@ -61,7 +61,7 @@ func (c *Config) Validate() error { } // Register flags common to all e2e test suites. -func (c *Config) AddFlags(fs *pflag.FlagSet) { +func (c *Config) AddFlags(fs *flag.FlagSet) { // Kubernetes API server config fs.StringVar(&c.KubeConfig, "kubernetes-config", os.Getenv(clientcmd.RecommendedConfigPathEnvVar), "Path to config containing embedded authinfo for kubernetes. Default value is from environment variable "+clientcmd.RecommendedConfigPathEnvVar) fs.StringVar(&c.KubeContext, "kubernetes-context", "", "config context to use for kuberentes. If unset, will use value from 'current-context'") diff --git a/test/e2e/framework/config/framework.go b/test/e2e/framework/config/framework.go index 63d261ea7..c6c49f2df 100644 --- a/test/e2e/framework/config/framework.go +++ b/test/e2e/framework/config/framework.go @@ -17,7 +17,7 @@ limitations under the License. package config import ( - flag "github.com/spf13/pflag" + "flag" ) type Framework struct { diff --git a/test/e2e/framework/config/ginkgo.go b/test/e2e/framework/config/ginkgo.go index 68c32ce56..feec0d9c6 100644 --- a/test/e2e/framework/config/ginkgo.go +++ b/test/e2e/framework/config/ginkgo.go @@ -17,7 +17,7 @@ limitations under the License. package config import ( - flag "github.com/spf13/pflag" + "flag" ) type Ginkgo struct { diff --git a/test/e2e/framework/config/helm.go b/test/e2e/framework/config/helm.go index 9098f4d7c..a12d8d055 100644 --- a/test/e2e/framework/config/helm.go +++ b/test/e2e/framework/config/helm.go @@ -19,7 +19,7 @@ package config import ( "fmt" - flag "github.com/spf13/pflag" + "flag" ) type Helm struct { diff --git a/test/e2e/framework/config/nginx.go b/test/e2e/framework/config/nginx.go index 1f060d60d..090ee98c2 100644 --- a/test/e2e/framework/config/nginx.go +++ b/test/e2e/framework/config/nginx.go @@ -19,7 +19,7 @@ package config import ( "fmt" - flag "github.com/spf13/pflag" + "flag" ) type Nginx struct { diff --git a/test/e2e/framework/config/pebble.go b/test/e2e/framework/config/pebble.go index 2b39215e9..4a50f6251 100644 --- a/test/e2e/framework/config/pebble.go +++ b/test/e2e/framework/config/pebble.go @@ -17,7 +17,7 @@ limitations under the License. package config import ( - flag "github.com/spf13/pflag" + "flag" ) // Pebble global configuration for new Pebble instances diff --git a/test/e2e/framework/config/suite.go b/test/e2e/framework/config/suite.go index 28abdd580..a189f46bd 100644 --- a/test/e2e/framework/config/suite.go +++ b/test/e2e/framework/config/suite.go @@ -19,7 +19,7 @@ package config import ( "os" - flag "github.com/spf13/pflag" + "flag" ) type Suite struct { diff --git a/test/e2e/framework/config/tiller.go b/test/e2e/framework/config/tiller.go index 30c65b39c..e1d92f0fd 100644 --- a/test/e2e/framework/config/tiller.go +++ b/test/e2e/framework/config/tiller.go @@ -17,9 +17,8 @@ limitations under the License. package config import ( + "flag" "fmt" - - flag "github.com/spf13/pflag" ) type Tiller struct {