mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-08-23 22:26:49 +00:00
* monitor the bootstrap kubeconfig and restart immediately when changes Signed-off-by: haoqing0110 <qhao@redhat.com> * fix comments Signed-off-by: haoqing0110 <qhao@redhat.com> --------- Signed-off-by: haoqing0110 <qhao@redhat.com>
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
package spoke
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/spf13/cobra"
|
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
|
|
|
ocmfeature "open-cluster-management.io/api/feature"
|
|
|
|
commonoptions "open-cluster-management.io/ocm/pkg/common/options"
|
|
"open-cluster-management.io/ocm/pkg/features"
|
|
"open-cluster-management.io/ocm/pkg/registration/spoke"
|
|
"open-cluster-management.io/ocm/pkg/version"
|
|
)
|
|
|
|
func NewRegistrationAgent() *cobra.Command {
|
|
ctx, cancel := context.WithCancel(context.TODO())
|
|
agentOptions := spoke.NewSpokeAgentOptions()
|
|
commonOptions := commonoptions.NewAgentOptions()
|
|
cfg := spoke.NewSpokeAgentConfig(commonOptions, agentOptions, cancel)
|
|
cmdConfig := commonOptions.CommonOpts.
|
|
NewControllerCommandConfig("registration-agent", version.Get(), cfg.RunSpokeAgent).
|
|
WithHealthChecks(cfg.HealthCheckers()...)
|
|
|
|
cmd := cmdConfig.NewCommandWithContext(ctx)
|
|
cmd.Use = agentCmdName
|
|
cmd.Short = "Start the Cluster Registration Agent"
|
|
|
|
flags := cmd.Flags()
|
|
commonOptions.AddFlags(flags)
|
|
agentOptions.AddFlags(flags)
|
|
|
|
utilruntime.Must(features.SpokeMutableFeatureGate.Add(ocmfeature.DefaultSpokeRegistrationFeatureGates))
|
|
features.SpokeMutableFeatureGate.AddFlag(flags)
|
|
return cmd
|
|
}
|