diff --git a/staging/src/open-cluster-management.io/placement/.gitignore b/staging/src/open-cluster-management.io/placement/.gitignore index 2403c91f1..cc2bf2af1 100644 --- a/staging/src/open-cluster-management.io/placement/.gitignore +++ b/staging/src/open-cluster-management.io/placement/.gitignore @@ -1,5 +1,5 @@ # Binaries for programs and plugins -placement +/placement *.exe *.exe~ *.dll diff --git a/staging/src/open-cluster-management.io/placement/cmd/placement/main.go b/staging/src/open-cluster-management.io/placement/cmd/placement/main.go new file mode 100644 index 000000000..4bcad2c81 --- /dev/null +++ b/staging/src/open-cluster-management.io/placement/cmd/placement/main.go @@ -0,0 +1,55 @@ +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" + + "open-cluster-management.io/placement/pkg/cmd/hub" + "open-cluster-management.io/placement/pkg/version" +) + +func main() { + rand.Seed(time.Now().UTC().UnixNano()) + + pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc) + pflag.CommandLine.AddGoFlagSet(goflag.CommandLine) + + logs.InitLogs() + defer logs.FlushLogs() + + command := newPlacementCommand() + if err := command.Execute(); err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + os.Exit(1) + } +} + +func newPlacementCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "placement", + Short: "Placement Controller", + Run: func(cmd *cobra.Command, args []string) { + _ = cmd.Help() + os.Exit(1) + }, + } + + if v := version.Get().String(); len(v) == 0 { + cmd.Version = "" + } else { + cmd.Version = v + } + + cmd.AddCommand(hub.NewController()) + + return cmd +} diff --git a/staging/src/open-cluster-management.io/registration-operator/.gitignore b/staging/src/open-cluster-management.io/registration-operator/.gitignore index d16e15f47..ccc04a1d0 100644 --- a/staging/src/open-cluster-management.io/registration-operator/.gitignore +++ b/staging/src/open-cluster-management.io/registration-operator/.gitignore @@ -1,5 +1,5 @@ # Binaries for programs and plugins -registration-operator +/registration-operator *.exe *.dll *.so diff --git a/staging/src/open-cluster-management.io/registration-operator/cmd/registration-operator/main.go b/staging/src/open-cluster-management.io/registration-operator/cmd/registration-operator/main.go new file mode 100644 index 000000000..956578b9a --- /dev/null +++ b/staging/src/open-cluster-management.io/registration-operator/cmd/registration-operator/main.go @@ -0,0 +1,57 @@ +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" + + "open-cluster-management.io/registration-operator/pkg/cmd/operator" + "open-cluster-management.io/registration-operator/pkg/version" +) + +func main() { + rand.Seed(time.Now().UTC().UnixNano()) + + pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc) + pflag.CommandLine.AddGoFlagSet(goflag.CommandLine) + + logs.AddFlags(pflag.CommandLine) + logs.InitLogs() + defer logs.FlushLogs() + + command := newNucleusCommand() + if err := command.Execute(); err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + os.Exit(1) + } +} + +func newNucleusCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "registration-operator", + Short: "Nucleus Operator", + Run: func(cmd *cobra.Command, args []string) { + _ = cmd.Help() + os.Exit(1) + }, + } + + if v := version.Get().String(); len(v) == 0 { + cmd.Version = "" + } else { + cmd.Version = v + } + + cmd.AddCommand(operator.NewHubOperatorCmd()) + cmd.AddCommand(operator.NewKlusterletOperatorCmd()) + + return cmd +} diff --git a/staging/src/open-cluster-management.io/registration/.gitignore b/staging/src/open-cluster-management.io/registration/.gitignore index 1640fefb0..c497dff57 100644 --- a/staging/src/open-cluster-management.io/registration/.gitignore +++ b/staging/src/open-cluster-management.io/registration/.gitignore @@ -1,5 +1,5 @@ # Binaries for programs and plugins -registration +/registration dev-kubeconfig e2e-kubeconfig integration.test diff --git a/staging/src/open-cluster-management.io/registration/cmd/registration/main.go b/staging/src/open-cluster-management.io/registration/cmd/registration/main.go new file mode 100644 index 000000000..f90ffdf0c --- /dev/null +++ b/staging/src/open-cluster-management.io/registration/cmd/registration/main.go @@ -0,0 +1,64 @@ +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" + + "open-cluster-management.io/registration/pkg/cmd/hub" + "open-cluster-management.io/registration/pkg/cmd/spoke" + "open-cluster-management.io/registration/pkg/cmd/webhook" + "open-cluster-management.io/registration/pkg/version" +) + +// The registration binary contains both the hub-side controllers for the +// registration API and the spoke agent. + +func main() { + rand.Seed(time.Now().UTC().UnixNano()) + + pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc) + pflag.CommandLine.AddGoFlagSet(goflag.CommandLine) + + logs.AddFlags(pflag.CommandLine) + logs.InitLogs() + defer logs.FlushLogs() + + command := newRegistrationCommand() + if err := command.Execute(); err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + os.Exit(1) + } +} + +func newRegistrationCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "registration", + Short: "Spoke Cluster Registration", + Run: func(cmd *cobra.Command, args []string) { + if err := cmd.Help(); err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + } + os.Exit(1) + }, + } + + if v := version.Get().String(); len(v) == 0 { + cmd.Version = "" + } else { + cmd.Version = v + } + + cmd.AddCommand(hub.NewController()) + cmd.AddCommand(spoke.NewAgent()) + cmd.AddCommand(webhook.NewWebhook()) + return cmd +} diff --git a/staging/src/open-cluster-management.io/work/.gitignore b/staging/src/open-cluster-management.io/work/.gitignore index efc54035e..8b0445645 100644 --- a/staging/src/open-cluster-management.io/work/.gitignore +++ b/staging/src/open-cluster-management.io/work/.gitignore @@ -1,5 +1,5 @@ # Binaries for programs and plugins -work +/work *.exe *.dll *.so diff --git a/staging/src/open-cluster-management.io/work/cmd/work/main.go b/staging/src/open-cluster-management.io/work/cmd/work/main.go new file mode 100644 index 000000000..92a10ddb4 --- /dev/null +++ b/staging/src/open-cluster-management.io/work/cmd/work/main.go @@ -0,0 +1,59 @@ +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" + + "open-cluster-management.io/work/pkg/cmd/hub" + "open-cluster-management.io/work/pkg/cmd/spoke" + "open-cluster-management.io/work/pkg/cmd/webhook" + "open-cluster-management.io/work/pkg/version" +) + +func main() { + rand.Seed(time.Now().UTC().UnixNano()) + + pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc) + pflag.CommandLine.AddGoFlagSet(goflag.CommandLine) + + logs.AddFlags(pflag.CommandLine) + logs.InitLogs() + defer logs.FlushLogs() + + command := newWorkCommand() + if err := command.Execute(); err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + os.Exit(1) + } +} + +func newWorkCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "work", + Short: "Spoke Cluster Work", + Run: func(cmd *cobra.Command, args []string) { + _ = cmd.Help() + os.Exit(1) + }, + } + + if v := version.Get().String(); len(v) == 0 { + cmd.Version = "" + } else { + cmd.Version = v + } + + cmd.AddCommand(spoke.NewWorkloadAgent()) + cmd.AddCommand(webhook.NewWebhook()) + cmd.AddCommand(hub.NewHubManager()) + return cmd +}