Skip to content

Commit

Permalink
fix some typos
Browse files Browse the repository at this point in the history
  • Loading branch information
Shuanglu committed Mar 3, 2025
1 parent cb18dab commit 427414e
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/agent/app/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func run(ctx context.Context, opts *options.Options) error {
registerOption := util.ClusterRegisterOption{
ClusterNamespace: opts.ClusterNamespace,
ClusterName: opts.ClusterName,
ClusterLabels: parseLabelsAnnotations(opts.ClusterLables),
ClusterLabels: parseLabelsAnnotations(opts.ClusterLabels),
ClusterAnnotations: parseLabelsAnnotations(opts.ClusterAnnotations),
ReportSecrets: opts.ReportSecrets,
ClusterAPIEndpoint: opts.ClusterAPIEndpoint,
Expand Down
4 changes: 2 additions & 2 deletions cmd/agent/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type Options struct {
// Default value is the current-context.
KarmadaContext string
ClusterName string
ClusterLables []string
ClusterLabels []string
ClusterAnnotations []string
// ClusterNamespace holds the namespace name where the member cluster secrets are stored.
ClusterNamespace string
Expand Down Expand Up @@ -183,7 +183,7 @@ func (o *Options) AddFlags(fs *pflag.FlagSet, allControllers []string) {
fs.StringVar(&o.KarmadaKubeConfig, "karmada-kubeconfig", o.KarmadaKubeConfig, "Path to karmada control plane kubeconfig file.")
fs.StringVar(&o.KarmadaContext, "karmada-context", "", "Name of the cluster context in karmada control plane kubeconfig file.")
fs.StringVar(&o.ClusterName, "cluster-name", o.ClusterName, "Name of member cluster that the agent serves for.")
fs.StringArrayVar(&o.ClusterLables, "cluster-labels", []string{}, "Specify labels for the member cluster in the format <key>=<value> e.g., --cluster-labels=foo=bar. You can use this flag multiple times. Note that it reconciles the labels of the cluster object when the agent restarts.")
fs.StringArrayVar(&o.ClusterLabels, "cluster-labels", []string{}, "Specify labels for the member cluster in the format <key>=<value> e.g., --cluster-labels=foo=bar. You can use this flag multiple times. Note that it reconciles the labels of the cluster object when the agent restarts.")
fs.StringArrayVar(&o.ClusterAnnotations, "cluster-annotations", []string{}, "Specify annotations for the member cluster in the format <key>=<value> e.g., --cluster-annotations=foo=bar. You can use this flag multiple times. Note that it reconciles the annotations of the cluster object when the agent restarts.")
fs.StringVar(&o.ClusterNamespace, "cluster-namespace", DefaultKarmadaClusterNamespace, "Namespace in the control plane where member cluster secrets are stored.")
fs.DurationVar(&o.ClusterStatusUpdateFrequency.Duration, "cluster-status-update-frequency", 10*time.Second, "Specifies how often karmada-agent posts cluster status to karmada-apiserver. Note: be cautious when changing the constant, it must work with ClusterMonitorGracePeriod in karmada-controller-manager.")
Expand Down
6 changes: 3 additions & 3 deletions cmd/agent/app/options/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ func (o *Options) Validate() field.ErrorList {
return outputs
}

if o.ClusterLables != nil {
errs = append(errs, validation.ValidateClusterLabels(parseLabelsAnnotations(o.ClusterLables))...)
if o.ClusterLabels != nil {
errs = append(errs, validation.ValidateClusterLabels(parseLabelsAnnotations(o.ClusterLabels))...)
}

if o.ClusterAnnotations != nil {
errs = append(errs, validation.ValidateClusterAnnotationss(parseLabelsAnnotations(o.ClusterAnnotations))...)
errs = append(errs, validation.ValidateClusterAnnotations(parseLabelsAnnotations(o.ClusterAnnotations))...)
}

if o.ClusterStatusUpdateFrequency.Duration < 0 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/app/options/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestValidateKarmadaAgentConfiguration(t *testing.T) {
},
"invalid ClusterLabels": {
opt: New(func(options *Options) {
options.ClusterLables = []string{"key=invalid=value"}
options.ClusterLabels = []string{"key=invalid=value"}
}),
expectedErrs: field.ErrorList{field.Invalid(newPath.Child("ClusterLabels"), "invalid=value", "a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')")},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/cluster/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func ValidateClusterLabels(labels map[string]string) field.ErrorList {
return metav1validation.ValidateLabels(labels, field.NewPath("Options.ClusterLabels"))
}

// ValidateClusterAnnotationss tests whether the annotations passed are valid
func ValidateClusterAnnotationss(annotations map[string]string) field.ErrorList {
// ValidateClusterAnnotations tests whether the annotations passed are valid
func ValidateClusterAnnotations(annotations map[string]string) field.ErrorList {
return validation.ValidateAnnotations(annotations, field.NewPath("Options.ClusterAnnotations"))
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/util/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func CreateOrUpdateClusterObject(controlPlaneClient karmadaclientset.Interface,
if exist {
clusterCopy := cluster.DeepCopy()
mutate(cluster)
if reflect.DeepEqual(clusterCopy, cluster) {
if reflect.DeepEqual(clusterCopy.ObjectMeta.Annotations, cluster.ObjectMeta.Annotations) && reflect.DeepEqual(clusterCopy.ObjectMeta.Labels, cluster.ObjectMeta.Labels) && reflect.DeepEqual(clusterCopy.Spec, cluster.Spec) {
klog.Warningf("Cluster(%s) already exist and newest", clusterObj.Name)
return cluster, nil
}
Expand Down

0 comments on commit 427414e

Please sign in to comment.