Skip to content

Commit

Permalink
upkeep: updated to use cli component for cleaner code
Browse files Browse the repository at this point in the history
Signed-off-by: ehila <[email protected]>
  • Loading branch information
eggfoobar committed Dec 16, 2021
1 parent ee0dcc6 commit abffb92
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 21 deletions.
23 changes: 3 additions & 20 deletions cmd/cluster-openshift-apiserver-operator/main.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,20 @@
package main

import (
goflag "flag"
"fmt"
"math/rand"
"os"
"time"

"github.com/spf13/cobra"
"github.com/spf13/pflag"

utilflag "k8s.io/component-base/cli/flag"
"k8s.io/component-base/logs"
"k8s.io/component-base/cli"

"github.com/openshift/cluster-openshift-apiserver-operator/pkg/cmd/operator"
"github.com/openshift/cluster-openshift-apiserver-operator/pkg/cmd/resourcegraph"
)

func main() {
rand.Seed(time.Now().UTC().UnixNano())

pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc)
pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)

logs.InitLogs()
logs.AddFlags(pflag.CommandLine)
defer logs.FlushLogs()

command := NewSSCSCommand()
if err := command.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
code := cli.Run(command)
os.Exit(code)
}

func NewSSCSCommand() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ require (
github.com/openshift/client-go v0.0.0-20211209144617-7385dd6338e3
github.com/openshift/library-go v0.0.0-20211214183058-58531ccbde67
github.com/spf13/cobra v1.2.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.0
go.etcd.io/etcd/client/v3 v3.5.0
k8s.io/api v0.23.0
Expand Down Expand Up @@ -76,6 +75,7 @@ require (
github.com/prometheus/procfs v0.6.0 // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.etcd.io/etcd/api/v3 v3.5.0 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.0 // indirect
go.opentelemetry.io/contrib v0.20.0 // indirect
Expand Down
12 changes: 12 additions & 0 deletions vendor/k8s.io/component-base/cli/OWNERS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

125 changes: 125 additions & 0 deletions vendor/k8s.io/component-base/cli/run.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,7 @@ k8s.io/client-go/util/retry
k8s.io/client-go/util/workqueue
# k8s.io/component-base v0.23.0
## explicit; go 1.16
k8s.io/component-base/cli
k8s.io/component-base/cli/flag
k8s.io/component-base/config
k8s.io/component-base/config/v1alpha1
Expand Down

0 comments on commit abffb92

Please sign in to comment.