mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-05-20 16:14:23 +00:00
29 lines
756 B
Go
29 lines
756 B
Go
package spoke
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/openshift/library-go/pkg/controller/controllercmd"
|
|
|
|
"open-cluster-management.io/ocm/pkg/version"
|
|
"open-cluster-management.io/ocm/pkg/work/spoke"
|
|
)
|
|
|
|
// NewWorkAgent generates a command to start work agent
|
|
func NewWorkAgent() *cobra.Command {
|
|
o := spoke.NewWorkloadAgentOptions()
|
|
cmdConfig := controllercmd.
|
|
NewControllerCommandConfig("work-agent", version.Get(), o.RunWorkloadAgent)
|
|
cmd := cmdConfig.NewCommand()
|
|
cmd.Use = "agent"
|
|
cmd.Short = "Start the Work Agent"
|
|
|
|
o.AddFlags(cmd)
|
|
|
|
// add disable leader election flag
|
|
flags := cmd.Flags()
|
|
flags.BoolVar(&cmdConfig.DisableLeaderElection, "disable-leader-election", false, "Disable leader election for the agent.")
|
|
|
|
return cmd
|
|
}
|