Skip to content

Commit

Permalink
fix golint failures
Browse files Browse the repository at this point in the history
some packages under staging/src/k8s.io/sample-apiserver/
  • Loading branch information
joremysh committed Aug 31, 2020
1 parent c182a59 commit a39f502
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 20 deletions.
4 changes: 0 additions & 4 deletions hack/.golint_failures
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ 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
// Note: Placeholder until we find a "standard path"
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"}
4 changes: 3 additions & 1 deletion staging/src/k8s.io/metrics/pkg/apis/metrics/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions staging/src/k8s.io/metrics/pkg/apis/metrics/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func Register(plugins *admission.Plugins) {
})
}

// DisallowFlunder is a ban flunder admission plugin
type DisallowFlunder struct {
*admission.Handler
lister listers.FischerLister
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
2 changes: 1 addition & 1 deletion staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
Expand Down

0 comments on commit a39f502

Please sign in to comment.