diff --git a/cmd/yurt-manager/app/manager.go b/cmd/yurt-manager/app/manager.go index 54523b88b57..361cd83d043 100644 --- a/cmd/yurt-manager/app/manager.go +++ b/cmd/yurt-manager/app/manager.go @@ -138,7 +138,7 @@ current state towards the desired state.`, return cmd } -// PrintFlags logs the flags in the flagset +// PrintFlags logs the flags in the flagSet func PrintFlags(flags *pflag.FlagSet) { flags.VisitAll(func(flag *pflag.Flag) { klog.V(1).Infof("FLAG: --%s=%q", flag.Name, flag.Value) diff --git a/cmd/yurt-manager/app/options/gatewaycontroller.go b/cmd/yurt-manager/app/options/gatewaycontroller.go index 344f1874e69..68c3309f873 100644 --- a/cmd/yurt-manager/app/options/gatewaycontroller.go +++ b/cmd/yurt-manager/app/options/gatewaycontroller.go @@ -32,7 +32,7 @@ func NewGatewayPickupControllerOptions() *GatewayPickupControllerOptions { } } -// AddFlags adds flags related to nodepool for yurt-manager to the specified FlagSet. +// AddFlags adds flags related to nodePool for yurt-manager to the specified FlagSet. func (g *GatewayPickupControllerOptions) AddFlags(fs *pflag.FlagSet) { if g == nil { return @@ -40,7 +40,7 @@ func (g *GatewayPickupControllerOptions) AddFlags(fs *pflag.FlagSet) { } -// ApplyTo fills up nodepool config with options. +// ApplyTo fills up nodePool config with options. func (g *GatewayPickupControllerOptions) ApplyTo(cfg *config.GatewayPickupControllerConfiguration) error { if g == nil { return nil diff --git a/cmd/yurt-manager/app/options/nodepoolcontroller.go b/cmd/yurt-manager/app/options/nodepoolcontroller.go index 114a2b7c5e9..373439978d6 100644 --- a/cmd/yurt-manager/app/options/nodepoolcontroller.go +++ b/cmd/yurt-manager/app/options/nodepoolcontroller.go @@ -34,7 +34,7 @@ func NewNodePoolControllerOptions() *NodePoolControllerOptions { } } -// AddFlags adds flags related to nodepool for yurt-manager to the specified FlagSet. +// AddFlags adds flags related to nodePool for yurt-manager to the specified FlagSet. func (n *NodePoolControllerOptions) AddFlags(fs *pflag.FlagSet) { if n == nil { return @@ -43,7 +43,7 @@ func (n *NodePoolControllerOptions) AddFlags(fs *pflag.FlagSet) { fs.BoolVar(&n.EnableSyncNodePoolConfigurations, "enable-sync-nodepool-configurations", n.EnableSyncNodePoolConfigurations, "enable to sync nodepool configurations(including labels, annotations, taints in spec) to nodes in the nodepool.") } -// ApplyTo fills up nodepool config with options. +// ApplyTo fills up nodePool config with options. func (o *NodePoolControllerOptions) ApplyTo(cfg *config.NodePoolControllerConfiguration) error { if o == nil { return nil diff --git a/cmd/yurt-manager/app/options/platformadmincontroller.go b/cmd/yurt-manager/app/options/platformadmincontroller.go index 969853905a6..a77a3c231fb 100644 --- a/cmd/yurt-manager/app/options/platformadmincontroller.go +++ b/cmd/yurt-manager/app/options/platformadmincontroller.go @@ -34,14 +34,14 @@ func NewPlatformAdminControllerOptions() *PlatformAdminControllerOptions { } } -// AddFlags adds flags related to nodepool for yurt-manager to the specified FlagSet. +// AddFlags adds flags related to nodePool for yurt-manager to the specified FlagSet. func (n *PlatformAdminControllerOptions) AddFlags(fs *pflag.FlagSet) { if n == nil { return } } -// ApplyTo fills up nodepool config with options. +// ApplyTo fills up nodePool config with options. func (o *PlatformAdminControllerOptions) ApplyTo(cfg *config.PlatformAdminControllerConfiguration) error { if o == nil { return nil diff --git a/cmd/yurt-manager/app/options/yurtappdaemoncontroller.go b/cmd/yurt-manager/app/options/yurtappdaemoncontroller.go index de105bfa8d6..c686779fc50 100644 --- a/cmd/yurt-manager/app/options/yurtappdaemoncontroller.go +++ b/cmd/yurt-manager/app/options/yurtappdaemoncontroller.go @@ -32,7 +32,7 @@ func NewYurtAppDaemonControllerOptions() *YurtAppDaemonControllerOptions { } } -// AddFlags adds flags related to yurtappdaemon for yurt-manager to the specified FlagSet. +// AddFlags adds flags related to YurtAppDaemon for yurt-manager to the specified FlagSet. func (o *YurtAppDaemonControllerOptions) AddFlags(fs *pflag.FlagSet) { if o == nil { return @@ -41,7 +41,7 @@ func (o *YurtAppDaemonControllerOptions) AddFlags(fs *pflag.FlagSet) { //fs.BoolVar(&n.CreateDefaultPool, "create-default-pool", n.CreateDefaultPool, "Create default cloud/edge pools if indicated.") } -// ApplyTo fills up yurtappdaemon config with options. +// ApplyTo fills up YurtAppDaemon config with options. func (o *YurtAppDaemonControllerOptions) ApplyTo(cfg *config.YurtAppDaemonControllerConfiguration) error { if o == nil { return nil diff --git a/cmd/yurt-manager/app/options/yurtappoverridercontroller.go b/cmd/yurt-manager/app/options/yurtappoverridercontroller.go index da9fd8f60ee..671ecc85aa3 100644 --- a/cmd/yurt-manager/app/options/yurtappoverridercontroller.go +++ b/cmd/yurt-manager/app/options/yurtappoverridercontroller.go @@ -32,7 +32,7 @@ func NewYurtAppOverriderControllerOptions() *YurtAppOverriderControllerOptions { } } -// AddFlags adds flags related to nodepool for yurt-manager to the specified FlagSet. +// AddFlags adds flags related to nodePool for yurt-manager to the specified FlagSet. func (n *YurtAppOverriderControllerOptions) AddFlags(fs *pflag.FlagSet) { if n == nil { return @@ -41,7 +41,7 @@ func (n *YurtAppOverriderControllerOptions) AddFlags(fs *pflag.FlagSet) { //fs.BoolVar(&n.CreateDefaultPool, "create-default-pool", n.CreateDefaultPool, "Create default cloud/edge pools if indicated.") } -// ApplyTo fills up nodepool config with options. +// ApplyTo fills up nodePool config with options. func (o *YurtAppOverriderControllerOptions) ApplyTo(cfg *config.YurtAppOverriderControllerConfiguration) error { if o == nil { return nil diff --git a/cmd/yurt-manager/app/options/yurtappsetcontroller.go b/cmd/yurt-manager/app/options/yurtappsetcontroller.go index 6f0d537b8e2..a72b227758b 100644 --- a/cmd/yurt-manager/app/options/yurtappsetcontroller.go +++ b/cmd/yurt-manager/app/options/yurtappsetcontroller.go @@ -32,7 +32,7 @@ func NewYurtAppSetControllerOptions() *YurtAppSetControllerOptions { } } -// AddFlags adds flags related to nodepool for yurt-manager to the specified FlagSet. +// AddFlags adds flags related to nodePool for yurt-manager to the specified FlagSet. func (n *YurtAppSetControllerOptions) AddFlags(fs *pflag.FlagSet) { if n == nil { return @@ -41,7 +41,7 @@ func (n *YurtAppSetControllerOptions) AddFlags(fs *pflag.FlagSet) { //fs.BoolVar(&n.CreateDefaultPool, "create-default-pool", n.CreateDefaultPool, "Create default cloud/edge pools if indicated.") } -// ApplyTo fills up nodepool config with options. +// ApplyTo fills up nodePool config with options. func (o *YurtAppSetControllerOptions) ApplyTo(cfg *config.YurtAppSetControllerConfiguration) error { if o == nil { return nil diff --git a/cmd/yurt-manager/app/options/yurtstaticsetcontroller.go b/cmd/yurt-manager/app/options/yurtstaticsetcontroller.go index fcb27e236d8..9900151f149 100644 --- a/cmd/yurt-manager/app/options/yurtstaticsetcontroller.go +++ b/cmd/yurt-manager/app/options/yurtstaticsetcontroller.go @@ -36,7 +36,7 @@ func NewYurtStaticSetControllerOptions() *YurtStaticSetControllerOptions { } } -// AddFlags adds flags related to yurtstaticset for yurt-manager to the specified FlagSet. +// AddFlags adds flags related to YurtStaticSet for yurt-manager to the specified FlagSet. func (o *YurtStaticSetControllerOptions) AddFlags(fs *pflag.FlagSet) { if o == nil { return @@ -45,7 +45,7 @@ func (o *YurtStaticSetControllerOptions) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&o.UpgradeWorkerImage, "node-servant-image", o.UpgradeWorkerImage, "Specify node servant pod image used for YurtStaticSet upgrade.") } -// ApplyTo fills up yurtstaticset config with options. +// ApplyTo fills up YurtStaticSet config with options. func (o *YurtStaticSetControllerOptions) ApplyTo(cfg *config.YurtStaticSetControllerConfiguration) error { if o == nil { return nil diff --git a/pkg/yurtmanager/webhook/nodepool/v1beta1/nodepool_validation.go b/pkg/yurtmanager/webhook/nodepool/v1beta1/nodepool_validation.go index 5c14370f339..4d2da1f7ded 100644 --- a/pkg/yurtmanager/webhook/nodepool/v1beta1/nodepool_validation.go +++ b/pkg/yurtmanager/webhook/nodepool/v1beta1/nodepool_validation.go @@ -58,7 +58,7 @@ func (webhook *NodePoolHandler) ValidateUpdate(ctx context.Context, oldObj, newO } if allErrs := validateNodePoolSpecUpdate(&newNp.Spec, &oldNp.Spec); len(allErrs) > 0 { - return apierrors.NewInvalid(appsv1beta1.GroupVersion.WithKind("NodePool").GroupKind(), newNp.Name, allErrs) + return apierrors.NewForbidden(appsv1beta1.GroupVersion.WithResource("nodepools").GroupResource(), newNp.Name, allErrs[0]) } return nil @@ -71,7 +71,7 @@ func (webhook *NodePoolHandler) ValidateDelete(_ context.Context, obj runtime.Ob return apierrors.NewBadRequest(fmt.Sprintf("expected a NodePool but got a %T", obj)) } if allErrs := validateNodePoolDeletion(webhook.Client, np); len(allErrs) > 0 { - return apierrors.NewInvalid(appsv1beta1.GroupVersion.WithKind("NodePool").GroupKind(), np.Name, allErrs) + return apierrors.NewForbidden(appsv1beta1.GroupVersion.WithResource("nodepools").GroupResource(), np.Name, allErrs[0]) } return nil @@ -121,12 +121,12 @@ func validateNodePoolSpecUpdate(spec, oldSpec *appsv1beta1.NodePoolSpec) field.E if spec.Type != oldSpec.Type { return field.ErrorList([]*field.Error{ - field.Invalid(field.NewPath("spec").Child("type"), spec.Type, "pool type can't be changed")}) + field.Forbidden(field.NewPath("spec").Child("type"), "pool type can't be changed")}) } if spec.HostNetwork != oldSpec.HostNetwork { return field.ErrorList([]*field.Error{ - field.Invalid(field.NewPath("spec").Child("hostNetwork"), spec.HostNetwork, "pool hostNetwork can't be changed"), + field.Forbidden(field.NewPath("spec").Child("hostNetwork"), "pool hostNetwork can't be changed"), }) } return nil