From 73f24d6beb81c27f26e96566a5fc95a9490cbb87 Mon Sep 17 00:00:00 2001 From: Gurleen Grewal Date: Tue, 22 Dec 2020 11:29:47 -0800 Subject: [PATCH] Fix golint issues in api/admission and api/admissionregistration --- hack/.golint_failures | 4 ---- staging/src/k8s.io/api/admission/v1/register.go | 8 +++++--- staging/src/k8s.io/api/admission/v1beta1/register.go | 8 +++++--- .../src/k8s.io/api/admissionregistration/v1/register.go | 9 ++++++--- staging/src/k8s.io/api/admissionregistration/v1/types.go | 8 ++++++-- .../k8s.io/api/admissionregistration/v1beta1/register.go | 9 ++++++--- .../k8s.io/api/admissionregistration/v1beta1/types.go | 4 ++++ 7 files changed, 32 insertions(+), 18 deletions(-) diff --git a/hack/.golint_failures b/hack/.golint_failures index 5251dac25da..ddaf8c2538d 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -191,10 +191,6 @@ plugin/pkg/admission/eventratelimit/apis/eventratelimit/v1alpha1 plugin/pkg/admission/limitranger plugin/pkg/auth/authorizer/node plugin/pkg/auth/authorizer/rbac -staging/src/k8s.io/api/admission/v1 -staging/src/k8s.io/api/admission/v1beta1 -staging/src/k8s.io/api/admissionregistration/v1 -staging/src/k8s.io/api/admissionregistration/v1beta1 staging/src/k8s.io/api/apiserverinternal/v1alpha1 staging/src/k8s.io/api/apps/v1 staging/src/k8s.io/api/apps/v1beta1 diff --git a/staging/src/k8s.io/api/admission/v1/register.go b/staging/src/k8s.io/api/admission/v1/register.go index b548509ab32..79000535c76 100644 --- a/staging/src/k8s.io/api/admission/v1/register.go +++ b/staging/src/k8s.io/api/admission/v1/register.go @@ -33,12 +33,14 @@ func Resource(resource string) schema.GroupResource { return SchemeGroupVersion.WithResource(resource).GroupResource() } +// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. +// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. var ( - // TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. - // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. + // SchemeBuilder points to a list of functions added to Scheme. SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) localSchemeBuilder = &SchemeBuilder - AddToScheme = localSchemeBuilder.AddToScheme + // AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme. + AddToScheme = localSchemeBuilder.AddToScheme ) // Adds the list of known types to the given scheme. diff --git a/staging/src/k8s.io/api/admission/v1beta1/register.go b/staging/src/k8s.io/api/admission/v1beta1/register.go index 78d21a0c8a7..1c53e755dd1 100644 --- a/staging/src/k8s.io/api/admission/v1beta1/register.go +++ b/staging/src/k8s.io/api/admission/v1beta1/register.go @@ -33,12 +33,14 @@ func Resource(resource string) schema.GroupResource { return SchemeGroupVersion.WithResource(resource).GroupResource() } +// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. +// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. var ( - // TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. - // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. + // SchemeBuilder points to a list of functions added to Scheme. SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) localSchemeBuilder = &SchemeBuilder - AddToScheme = localSchemeBuilder.AddToScheme + // AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme. + AddToScheme = localSchemeBuilder.AddToScheme ) // Adds the list of known types to the given scheme. diff --git a/staging/src/k8s.io/api/admissionregistration/v1/register.go b/staging/src/k8s.io/api/admissionregistration/v1/register.go index 716ce7fc5d2..e42a8bce3be 100644 --- a/staging/src/k8s.io/api/admissionregistration/v1/register.go +++ b/staging/src/k8s.io/api/admissionregistration/v1/register.go @@ -22,6 +22,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" ) +// GroupName is the group name for this API. const GroupName = "admissionregistration.k8s.io" // SchemeGroupVersion is group version used to register these objects @@ -32,12 +33,14 @@ func Resource(resource string) schema.GroupResource { return SchemeGroupVersion.WithResource(resource).GroupResource() } +// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. +// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. var ( - // TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. - // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. + // SchemeBuilder points to a list of functions added to Scheme. SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) localSchemeBuilder = &SchemeBuilder - AddToScheme = localSchemeBuilder.AddToScheme + // AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme. + AddToScheme = localSchemeBuilder.AddToScheme ) // Adds the list of known types to scheme. diff --git a/staging/src/k8s.io/api/admissionregistration/v1/types.go b/staging/src/k8s.io/api/admissionregistration/v1/types.go index 74b87828747..a2dbad4e807 100644 --- a/staging/src/k8s.io/api/admissionregistration/v1/types.go +++ b/staging/src/k8s.io/api/admissionregistration/v1/types.go @@ -63,6 +63,7 @@ type Rule struct { Scope *ScopeType `json:"scope,omitempty" protobuf:"bytes,4,rep,name=scope"` } +// ScopeType specifies a scope for a Rule. type ScopeType string const ( @@ -75,6 +76,7 @@ const ( AllScopes ScopeType = "*" ) +// FailurePolicyType specifies a failure policy that defines how unrecognized errors from the admission endpoint are handled. type FailurePolicyType string const ( @@ -84,16 +86,17 @@ const ( Fail FailurePolicyType = "Fail" ) -// MatchPolicyType specifies the type of match policy +// MatchPolicyType specifies the type of match policy. type MatchPolicyType string const ( - // Exact means requests should only be sent to the webhook if they exactly match a given rule + // Exact means requests should only be sent to the webhook if they exactly match a given rule. Exact MatchPolicyType = "Exact" // Equivalent means requests should be sent to the webhook if they modify a resource listed in rules via another API group or version. Equivalent MatchPolicyType = "Equivalent" ) +// SideEffectClass specifies the types of side effects a webhook may have. type SideEffectClass string const ( @@ -472,6 +475,7 @@ type RuleWithOperations struct { Rule `json:",inline" protobuf:"bytes,2,opt,name=rule"` } +// OperationType specifies an operation for a request. type OperationType string // The constants should be kept in sync with those defined in k8s.io/kubernetes/pkg/admission/interface.go. diff --git a/staging/src/k8s.io/api/admissionregistration/v1beta1/register.go b/staging/src/k8s.io/api/admissionregistration/v1beta1/register.go index d126da9fb71..098744cf634 100644 --- a/staging/src/k8s.io/api/admissionregistration/v1beta1/register.go +++ b/staging/src/k8s.io/api/admissionregistration/v1beta1/register.go @@ -22,6 +22,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" ) +// GroupName is the group name for this API. const GroupName = "admissionregistration.k8s.io" // SchemeGroupVersion is group version used to register these objects @@ -32,12 +33,14 @@ func Resource(resource string) schema.GroupResource { return SchemeGroupVersion.WithResource(resource).GroupResource() } +// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. +// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. var ( - // TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. - // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. + // SchemeBuilder points to a list of functions added to Scheme. SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) localSchemeBuilder = &SchemeBuilder - AddToScheme = localSchemeBuilder.AddToScheme + // AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme. + AddToScheme = localSchemeBuilder.AddToScheme ) // Adds the list of known types to scheme. diff --git a/staging/src/k8s.io/api/admissionregistration/v1beta1/types.go b/staging/src/k8s.io/api/admissionregistration/v1beta1/types.go index 2297b7e130f..67937509f46 100644 --- a/staging/src/k8s.io/api/admissionregistration/v1beta1/types.go +++ b/staging/src/k8s.io/api/admissionregistration/v1beta1/types.go @@ -63,6 +63,7 @@ type Rule struct { Scope *ScopeType `json:"scope,omitempty" protobuf:"bytes,4,rep,name=scope"` } +// ScopeType specifies a scope for a Rule. type ScopeType string const ( @@ -75,6 +76,7 @@ const ( AllScopes ScopeType = "*" ) +// FailurePolicyType specifies a failure policy that defines how unrecognized errors from the admission endpoint are handled. type FailurePolicyType string const ( @@ -94,6 +96,7 @@ const ( Equivalent MatchPolicyType = "Equivalent" ) +// SideEffectClass specifies the types of side effects a webhook may have. type SideEffectClass string const ( @@ -496,6 +499,7 @@ type RuleWithOperations struct { Rule `json:",inline" protobuf:"bytes,2,opt,name=rule"` } +// OperationType specifies an operation for a request. type OperationType string // The constants should be kept in sync with those defined in k8s.io/kubernetes/pkg/admission/interface.go.