Files
open-cluster-management/pkg/cmd/spoke/registration.go
Qing Hao 4ebe9d7978 🐛 monitor the bootstrap kubeconfig and restart immediately when changes (#630)
* 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>
2024-09-30 06:24:20 +00:00

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
}