mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Merge pull request #94357 from JeremyShih/fix-golint-error-in-sample-api-server
fix golint failures
This commit is contained in:
		@@ -479,20 +479,16 @@ staging/src/k8s.io/kubectl/pkg/polymorphichelpers
 | 
				
			|||||||
staging/src/k8s.io/kubectl/pkg/scale
 | 
					staging/src/k8s.io/kubectl/pkg/scale
 | 
				
			||||||
staging/src/k8s.io/kubectl/pkg/util/templates
 | 
					staging/src/k8s.io/kubectl/pkg/util/templates
 | 
				
			||||||
staging/src/k8s.io/kubelet/config/v1beta1
 | 
					staging/src/k8s.io/kubelet/config/v1beta1
 | 
				
			||||||
staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1
 | 
					 | 
				
			||||||
staging/src/k8s.io/legacy-cloud-providers/vsphere
 | 
					staging/src/k8s.io/legacy-cloud-providers/vsphere
 | 
				
			||||||
staging/src/k8s.io/metrics/pkg/apis/custom_metrics
 | 
					staging/src/k8s.io/metrics/pkg/apis/custom_metrics
 | 
				
			||||||
staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1
 | 
					staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1
 | 
				
			||||||
staging/src/k8s.io/metrics/pkg/apis/external_metrics
 | 
					staging/src/k8s.io/metrics/pkg/apis/external_metrics
 | 
				
			||||||
staging/src/k8s.io/metrics/pkg/apis/metrics
 | 
					 | 
				
			||||||
staging/src/k8s.io/metrics/pkg/client/custom_metrics
 | 
					staging/src/k8s.io/metrics/pkg/client/custom_metrics
 | 
				
			||||||
staging/src/k8s.io/metrics/pkg/client/custom_metrics/fake
 | 
					staging/src/k8s.io/metrics/pkg/client/custom_metrics/fake
 | 
				
			||||||
staging/src/k8s.io/metrics/pkg/client/custom_metrics/scheme
 | 
					staging/src/k8s.io/metrics/pkg/client/custom_metrics/scheme
 | 
				
			||||||
staging/src/k8s.io/metrics/pkg/client/external_metrics
 | 
					staging/src/k8s.io/metrics/pkg/client/external_metrics
 | 
				
			||||||
staging/src/k8s.io/metrics/pkg/client/external_metrics/fake
 | 
					staging/src/k8s.io/metrics/pkg/client/external_metrics/fake
 | 
				
			||||||
staging/src/k8s.io/sample-apiserver/pkg/admission/plugin/banflunder
 | 
					 | 
				
			||||||
staging/src/k8s.io/sample-apiserver/pkg/admission/wardleinitializer
 | 
					staging/src/k8s.io/sample-apiserver/pkg/admission/wardleinitializer
 | 
				
			||||||
staging/src/k8s.io/sample-apiserver/pkg/apis/wardle
 | 
					 | 
				
			||||||
staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1
 | 
					staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1
 | 
				
			||||||
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer
 | 
					staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer
 | 
				
			||||||
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder
 | 
					staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,10 +19,10 @@ package v1beta1
 | 
				
			|||||||
const (
 | 
					const (
 | 
				
			||||||
	// Healthy means that the device is healthy
 | 
						// Healthy means that the device is healthy
 | 
				
			||||||
	Healthy = "Healthy"
 | 
						Healthy = "Healthy"
 | 
				
			||||||
	// UnHealthy means that the device is unhealthy
 | 
						// Unhealthy means that the device is unhealthy
 | 
				
			||||||
	Unhealthy = "Unhealthy"
 | 
						Unhealthy = "Unhealthy"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Current version of the API supported by kubelet
 | 
						// Version means current version of the API supported by kubelet
 | 
				
			||||||
	Version = "v1beta1"
 | 
						Version = "v1beta1"
 | 
				
			||||||
	// DevicePluginPath is the folder the Device Plugin is expecting sockets to be on
 | 
						// DevicePluginPath is the folder the Device Plugin is expecting sockets to be on
 | 
				
			||||||
	// Only privileged pods have access to this path
 | 
						// Only privileged pods have access to this path
 | 
				
			||||||
@@ -30,8 +30,9 @@ const (
 | 
				
			|||||||
	DevicePluginPath = "/var/lib/kubelet/device-plugins/"
 | 
						DevicePluginPath = "/var/lib/kubelet/device-plugins/"
 | 
				
			||||||
	// KubeletSocket is the path of the Kubelet registry socket
 | 
						// KubeletSocket is the path of the Kubelet registry socket
 | 
				
			||||||
	KubeletSocket = DevicePluginPath + "kubelet.sock"
 | 
						KubeletSocket = DevicePluginPath + "kubelet.sock"
 | 
				
			||||||
	// Timeout duration in secs for PreStartContainer RPC
 | 
						// KubeletPreStartContainerRPCTimeoutInSecs is the timeout duration in secs for PreStartContainer RPC
 | 
				
			||||||
	KubeletPreStartContainerRPCTimeoutInSecs = 30
 | 
						KubeletPreStartContainerRPCTimeoutInSecs = 30
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// SupportedVersions provides a list of supported version
 | 
				
			||||||
var SupportedVersions = [...]string{"v1beta1"}
 | 
					var SupportedVersions = [...]string{"v1beta1"}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,7 +38,9 @@ func Resource(resource string) schema.GroupResource {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
 | 
						// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
 | 
				
			||||||
	SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
 | 
						SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
 | 
				
			||||||
 | 
						// AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme
 | 
				
			||||||
	AddToScheme = SchemeBuilder.AddToScheme
 | 
						AddToScheme = SchemeBuilder.AddToScheme
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,7 +27,7 @@ import (
 | 
				
			|||||||
// +genclient:nonNamespaced
 | 
					// +genclient:nonNamespaced
 | 
				
			||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | 
					// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// resource usage metrics of a node.
 | 
					// NodeMetrics sets resource usage metrics of a node.
 | 
				
			||||||
type NodeMetrics struct {
 | 
					type NodeMetrics struct {
 | 
				
			||||||
	metav1.TypeMeta
 | 
						metav1.TypeMeta
 | 
				
			||||||
	metav1.ObjectMeta
 | 
						metav1.ObjectMeta
 | 
				
			||||||
@@ -59,7 +59,7 @@ type NodeMetricsList struct {
 | 
				
			|||||||
// +genclient:readonly
 | 
					// +genclient:readonly
 | 
				
			||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | 
					// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// resource usage metrics of a pod.
 | 
					// PodMetrics sets resource usage metrics of a pod.
 | 
				
			||||||
type PodMetrics struct {
 | 
					type PodMetrics struct {
 | 
				
			||||||
	metav1.TypeMeta
 | 
						metav1.TypeMeta
 | 
				
			||||||
	metav1.ObjectMeta
 | 
						metav1.ObjectMeta
 | 
				
			||||||
@@ -86,7 +86,7 @@ type PodMetricsList struct {
 | 
				
			|||||||
	Items []PodMetrics
 | 
						Items []PodMetrics
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// resource usage metrics of a container.
 | 
					// ContainerMetrics sets resource usage metrics of a container.
 | 
				
			||||||
type ContainerMetrics struct {
 | 
					type ContainerMetrics struct {
 | 
				
			||||||
	// Container name corresponding to the one from pod.spec.containers.
 | 
						// Container name corresponding to the one from pod.spec.containers.
 | 
				
			||||||
	Name string
 | 
						Name string
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -105,7 +105,7 @@ func (c *MetricConverter) ConvertResultToVersion(res rest.Result, gv schema.Grou
 | 
				
			|||||||
	return metricObj, nil
 | 
						return metricObj, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// unsafeConvertToVersionVia is like Scheme.UnsafeConvertToVersion, but it does so via an internal version first.
 | 
					// UnsafeConvertToVersionVia is like Scheme.UnsafeConvertToVersion, but it does so via an internal version first.
 | 
				
			||||||
// We use it here to work with the v1beta2 client internally, while preserving backwards compatibility for existing custom metrics adapters
 | 
					// We use it here to work with the v1beta2 client internally, while preserving backwards compatibility for existing custom metrics adapters
 | 
				
			||||||
func (c *MetricConverter) UnsafeConvertToVersionVia(obj runtime.Object, externalVersion schema.GroupVersion) (runtime.Object, error) {
 | 
					func (c *MetricConverter) UnsafeConvertToVersionVia(obj runtime.Object, externalVersion schema.GroupVersion) (runtime.Object, error) {
 | 
				
			||||||
	objInt, err := c.scheme.UnsafeConvertToVersion(obj, schema.GroupVersion{Group: externalVersion.Group, Version: runtime.APIVersionInternal})
 | 
						objInt, err := c.scheme.UnsafeConvertToVersion(obj, schema.GroupVersion{Group: externalVersion.Group, Version: runtime.APIVersionInternal})
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,6 +38,7 @@ func Register(plugins *admission.Plugins) {
 | 
				
			|||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// DisallowFlunder is a ban flunder admission plugin
 | 
				
			||||||
type DisallowFlunder struct {
 | 
					type DisallowFlunder struct {
 | 
				
			||||||
	*admission.Handler
 | 
						*admission.Handler
 | 
				
			||||||
	lister listers.FischerLister
 | 
						lister listers.FischerLister
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,14 +46,14 @@ type wantInternalWardleInformerFactory struct {
 | 
				
			|||||||
	sf informers.SharedInformerFactory
 | 
						sf informers.SharedInformerFactory
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (self *wantInternalWardleInformerFactory) SetInternalWardleInformerFactory(sf informers.SharedInformerFactory) {
 | 
					func (f *wantInternalWardleInformerFactory) SetInternalWardleInformerFactory(sf informers.SharedInformerFactory) {
 | 
				
			||||||
	self.sf = sf
 | 
						f.sf = sf
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
func (self *wantInternalWardleInformerFactory) Admit(ctx context.Context, a admission.Attributes, o admission.ObjectInterfaces) error {
 | 
					func (f *wantInternalWardleInformerFactory) Admit(ctx context.Context, a admission.Attributes, o admission.ObjectInterfaces) error {
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
func (self *wantInternalWardleInformerFactory) Handles(o admission.Operation) bool { return false }
 | 
					func (f *wantInternalWardleInformerFactory) Handles(o admission.Operation) bool { return false }
 | 
				
			||||||
func (self *wantInternalWardleInformerFactory) ValidateInitialization() error      { return nil }
 | 
					func (f *wantInternalWardleInformerFactory) ValidateInitialization() error      { return nil }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var _ admission.Interface = &wantInternalWardleInformerFactory{}
 | 
					var _ admission.Interface = &wantInternalWardleInformerFactory{}
 | 
				
			||||||
var _ wardleinitializer.WantsInternalWardleInformerFactory = &wantInternalWardleInformerFactory{}
 | 
					var _ wardleinitializer.WantsInternalWardleInformerFactory = &wantInternalWardleInformerFactory{}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,5 +17,5 @@ limitations under the License.
 | 
				
			|||||||
// +k8s:deepcopy-gen=package
 | 
					// +k8s:deepcopy-gen=package
 | 
				
			||||||
// +groupName=wardle.example.com
 | 
					// +groupName=wardle.example.com
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Package api is the internal version of the API.
 | 
					// Package wardle is the internal version of the API.
 | 
				
			||||||
package wardle // import "k8s.io/sample-apiserver/pkg/apis/wardle"
 | 
					package wardle // import "k8s.io/sample-apiserver/pkg/apis/wardle"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,6 +21,7 @@ import (
 | 
				
			|||||||
	"k8s.io/apimachinery/pkg/runtime/schema"
 | 
						"k8s.io/apimachinery/pkg/runtime/schema"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GroupName is the group name used in this package
 | 
				
			||||||
const GroupName = "wardle.example.com"
 | 
					const GroupName = "wardle.example.com"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SchemeGroupVersion is group version used to register these objects
 | 
					// SchemeGroupVersion is group version used to register these objects
 | 
				
			||||||
@@ -37,7 +38,9 @@ func Resource(resource string) schema.GroupResource {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
 | 
						// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
 | 
				
			||||||
	SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
 | 
						SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
 | 
				
			||||||
 | 
						// AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme
 | 
				
			||||||
	AddToScheme = SchemeBuilder.AddToScheme
 | 
						AddToScheme = SchemeBuilder.AddToScheme
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,13 +28,17 @@ type FlunderList struct {
 | 
				
			|||||||
	Items []Flunder
 | 
						Items []Flunder
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ReferenceType defines the type of an object reference.
 | 
				
			||||||
type ReferenceType string
 | 
					type ReferenceType string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
 | 
						// FlunderReferenceType is used for Flunder references.
 | 
				
			||||||
	FlunderReferenceType = ReferenceType("Flunder")
 | 
						FlunderReferenceType = ReferenceType("Flunder")
 | 
				
			||||||
 | 
						// FischerReferenceType is used for Fischer references.
 | 
				
			||||||
	FischerReferenceType = ReferenceType("Fischer")
 | 
						FischerReferenceType = ReferenceType("Fischer")
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// FlunderSpec is the specification of a Flunder.
 | 
				
			||||||
type FlunderSpec struct {
 | 
					type FlunderSpec struct {
 | 
				
			||||||
	// A name of another flunder, mutually exclusive to the FischerReference.
 | 
						// A name of another flunder, mutually exclusive to the FischerReference.
 | 
				
			||||||
	FlunderReference string
 | 
						FlunderReference string
 | 
				
			||||||
@@ -44,12 +48,14 @@ type FlunderSpec struct {
 | 
				
			|||||||
	ReferenceType ReferenceType
 | 
						ReferenceType ReferenceType
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// FlunderStatus is the status of a Flunder.
 | 
				
			||||||
type FlunderStatus struct {
 | 
					type FlunderStatus struct {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// +genclient
 | 
					// +genclient
 | 
				
			||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | 
					// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Flunder is an example type with a spec and a status.
 | 
				
			||||||
type Flunder struct {
 | 
					type Flunder struct {
 | 
				
			||||||
	metav1.TypeMeta
 | 
						metav1.TypeMeta
 | 
				
			||||||
	metav1.ObjectMeta
 | 
						metav1.ObjectMeta
 | 
				
			||||||
@@ -62,6 +68,7 @@ type Flunder struct {
 | 
				
			|||||||
// +genclient:nonNamespaced
 | 
					// +genclient:nonNamespaced
 | 
				
			||||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | 
					// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Fischer is an example type with a list of disallowed Flunder.Names
 | 
				
			||||||
type Fischer struct {
 | 
					type Fischer struct {
 | 
				
			||||||
	metav1.TypeMeta
 | 
						metav1.TypeMeta
 | 
				
			||||||
	metav1.ObjectMeta
 | 
						metav1.ObjectMeta
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,7 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
 | 
				
			|||||||
	return RegisterDefaults(scheme)
 | 
						return RegisterDefaults(scheme)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// SetDefaults_FlunderSpec sets defaults for Flunder spec
 | 
				
			||||||
func SetDefaults_FlunderSpec(obj *FlunderSpec) {
 | 
					func SetDefaults_FlunderSpec(obj *FlunderSpec) {
 | 
				
			||||||
	if (obj.ReferenceType == nil || len(*obj.ReferenceType) == 0) && len(obj.Reference) != 0 {
 | 
						if (obj.ReferenceType == nil || len(*obj.ReferenceType) == 0) && len(obj.Reference) != 0 {
 | 
				
			||||||
		t := FlunderReferenceType
 | 
							t := FlunderReferenceType
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,6 +22,7 @@ import (
 | 
				
			|||||||
	"k8s.io/apimachinery/pkg/runtime/schema"
 | 
						"k8s.io/apimachinery/pkg/runtime/schema"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GroupName is the group name used in this package
 | 
				
			||||||
const GroupName = "wardle.example.com"
 | 
					const GroupName = "wardle.example.com"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SchemeGroupVersion is group version used to register these objects
 | 
					// SchemeGroupVersion is group version used to register these objects
 | 
				
			||||||
@@ -30,8 +31,10 @@ var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha
 | 
				
			|||||||
var (
 | 
					var (
 | 
				
			||||||
	// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.
 | 
						// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.
 | 
				
			||||||
	// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
 | 
						// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
 | 
				
			||||||
 | 
						// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
 | 
				
			||||||
	SchemeBuilder      runtime.SchemeBuilder
 | 
						SchemeBuilder      runtime.SchemeBuilder
 | 
				
			||||||
	localSchemeBuilder = &SchemeBuilder
 | 
						localSchemeBuilder = &SchemeBuilder
 | 
				
			||||||
 | 
						// AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme
 | 
				
			||||||
	AddToScheme = localSchemeBuilder.AddToScheme
 | 
						AddToScheme = localSchemeBuilder.AddToScheme
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user