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