Skip to content

Commit c631e78

Browse files
authored
Merge pull request kubernetes#94357 from JeremyShih/fix-golint-error-in-sample-api-server
fix golint failures
2 parents 02b5b60 + a39f502 commit c631e78

File tree

12 files changed

+34
-20
lines changed

12 files changed

+34
-20
lines changed

hack/.golint_failures

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,20 +479,16 @@ staging/src/k8s.io/kubectl/pkg/polymorphichelpers
479479
staging/src/k8s.io/kubectl/pkg/scale
480480
staging/src/k8s.io/kubectl/pkg/util/templates
481481
staging/src/k8s.io/kubelet/config/v1beta1
482-
staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1
483482
staging/src/k8s.io/legacy-cloud-providers/vsphere
484483
staging/src/k8s.io/metrics/pkg/apis/custom_metrics
485484
staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1
486485
staging/src/k8s.io/metrics/pkg/apis/external_metrics
487-
staging/src/k8s.io/metrics/pkg/apis/metrics
488486
staging/src/k8s.io/metrics/pkg/client/custom_metrics
489487
staging/src/k8s.io/metrics/pkg/client/custom_metrics/fake
490488
staging/src/k8s.io/metrics/pkg/client/custom_metrics/scheme
491489
staging/src/k8s.io/metrics/pkg/client/external_metrics
492490
staging/src/k8s.io/metrics/pkg/client/external_metrics/fake
493-
staging/src/k8s.io/sample-apiserver/pkg/admission/plugin/banflunder
494491
staging/src/k8s.io/sample-apiserver/pkg/admission/wardleinitializer
495-
staging/src/k8s.io/sample-apiserver/pkg/apis/wardle
496492
staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1
497493
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer
498494
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder

staging/src/k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1/constants.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@ package v1beta1
1919
const (
2020
// Healthy means that the device is healthy
2121
Healthy = "Healthy"
22-
// UnHealthy means that the device is unhealthy
22+
// Unhealthy means that the device is unhealthy
2323
Unhealthy = "Unhealthy"
2424

25-
// Current version of the API supported by kubelet
25+
// Version means current version of the API supported by kubelet
2626
Version = "v1beta1"
2727
// DevicePluginPath is the folder the Device Plugin is expecting sockets to be on
2828
// Only privileged pods have access to this path
2929
// Note: Placeholder until we find a "standard path"
3030
DevicePluginPath = "/var/lib/kubelet/device-plugins/"
3131
// KubeletSocket is the path of the Kubelet registry socket
3232
KubeletSocket = DevicePluginPath + "kubelet.sock"
33-
// Timeout duration in secs for PreStartContainer RPC
33+
// KubeletPreStartContainerRPCTimeoutInSecs is the timeout duration in secs for PreStartContainer RPC
3434
KubeletPreStartContainerRPCTimeoutInSecs = 30
3535
)
3636

37+
// SupportedVersions provides a list of supported version
3738
var SupportedVersions = [...]string{"v1beta1"}

staging/src/k8s.io/metrics/pkg/apis/metrics/register.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ func Resource(resource string) schema.GroupResource {
3838
}
3939

4040
var (
41+
// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
4142
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
42-
AddToScheme = SchemeBuilder.AddToScheme
43+
// AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme
44+
AddToScheme = SchemeBuilder.AddToScheme
4345
)
4446

4547
func addKnownTypes(scheme *runtime.Scheme) error {

staging/src/k8s.io/metrics/pkg/apis/metrics/types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
// +genclient:nonNamespaced
2828
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
2929

30-
// resource usage metrics of a node.
30+
// NodeMetrics sets resource usage metrics of a node.
3131
type NodeMetrics struct {
3232
metav1.TypeMeta
3333
metav1.ObjectMeta
@@ -59,7 +59,7 @@ type NodeMetricsList struct {
5959
// +genclient:readonly
6060
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
6161

62-
// resource usage metrics of a pod.
62+
// PodMetrics sets resource usage metrics of a pod.
6363
type PodMetrics struct {
6464
metav1.TypeMeta
6565
metav1.ObjectMeta
@@ -86,7 +86,7 @@ type PodMetricsList struct {
8686
Items []PodMetrics
8787
}
8888

89-
// resource usage metrics of a container.
89+
// ContainerMetrics sets resource usage metrics of a container.
9090
type ContainerMetrics struct {
9191
// Container name corresponding to the one from pod.spec.containers.
9292
Name string

staging/src/k8s.io/metrics/pkg/client/custom_metrics/converter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (c *MetricConverter) ConvertResultToVersion(res rest.Result, gv schema.Grou
105105
return metricObj, nil
106106
}
107107

108-
// unsafeConvertToVersionVia is like Scheme.UnsafeConvertToVersion, but it does so via an internal version first.
108+
// UnsafeConvertToVersionVia is like Scheme.UnsafeConvertToVersion, but it does so via an internal version first.
109109
// We use it here to work with the v1beta2 client internally, while preserving backwards compatibility for existing custom metrics adapters
110110
func (c *MetricConverter) UnsafeConvertToVersionVia(obj runtime.Object, externalVersion schema.GroupVersion) (runtime.Object, error) {
111111
objInt, err := c.scheme.UnsafeConvertToVersion(obj, schema.GroupVersion{Group: externalVersion.Group, Version: runtime.APIVersionInternal})

staging/src/k8s.io/sample-apiserver/pkg/admission/plugin/banflunder/admission.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func Register(plugins *admission.Plugins) {
3838
})
3939
}
4040

41+
// DisallowFlunder is a ban flunder admission plugin
4142
type DisallowFlunder struct {
4243
*admission.Handler
4344
lister listers.FischerLister

staging/src/k8s.io/sample-apiserver/pkg/admission/wardleinitializer/wardleinitializer_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ type wantInternalWardleInformerFactory struct {
4646
sf informers.SharedInformerFactory
4747
}
4848

49-
func (self *wantInternalWardleInformerFactory) SetInternalWardleInformerFactory(sf informers.SharedInformerFactory) {
50-
self.sf = sf
49+
func (f *wantInternalWardleInformerFactory) SetInternalWardleInformerFactory(sf informers.SharedInformerFactory) {
50+
f.sf = sf
5151
}
52-
func (self *wantInternalWardleInformerFactory) Admit(ctx context.Context, a admission.Attributes, o admission.ObjectInterfaces) error {
52+
func (f *wantInternalWardleInformerFactory) Admit(ctx context.Context, a admission.Attributes, o admission.ObjectInterfaces) error {
5353
return nil
5454
}
55-
func (self *wantInternalWardleInformerFactory) Handles(o admission.Operation) bool { return false }
56-
func (self *wantInternalWardleInformerFactory) ValidateInitialization() error { return nil }
55+
func (f *wantInternalWardleInformerFactory) Handles(o admission.Operation) bool { return false }
56+
func (f *wantInternalWardleInformerFactory) ValidateInitialization() error { return nil }
5757

5858
var _ admission.Interface = &wantInternalWardleInformerFactory{}
5959
var _ wardleinitializer.WantsInternalWardleInformerFactory = &wantInternalWardleInformerFactory{}

staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ limitations under the License.
1717
// +k8s:deepcopy-gen=package
1818
// +groupName=wardle.example.com
1919

20-
// Package api is the internal version of the API.
20+
// Package wardle is the internal version of the API.
2121
package wardle // import "k8s.io/sample-apiserver/pkg/apis/wardle"

staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/register.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"k8s.io/apimachinery/pkg/runtime/schema"
2222
)
2323

24+
// GroupName is the group name used in this package
2425
const GroupName = "wardle.example.com"
2526

2627
// SchemeGroupVersion is group version used to register these objects
@@ -37,8 +38,10 @@ func Resource(resource string) schema.GroupResource {
3738
}
3839

3940
var (
41+
// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
4042
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
41-
AddToScheme = SchemeBuilder.AddToScheme
43+
// AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme
44+
AddToScheme = SchemeBuilder.AddToScheme
4245
)
4346

4447
// Adds the list of known types to the given scheme.

staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ type FlunderList struct {
2828
Items []Flunder
2929
}
3030

31+
// ReferenceType defines the type of an object reference.
3132
type ReferenceType string
3233

3334
const (
35+
// FlunderReferenceType is used for Flunder references.
3436
FlunderReferenceType = ReferenceType("Flunder")
37+
// FischerReferenceType is used for Fischer references.
3538
FischerReferenceType = ReferenceType("Fischer")
3639
)
3740

41+
// FlunderSpec is the specification of a Flunder.
3842
type FlunderSpec struct {
3943
// A name of another flunder, mutually exclusive to the FischerReference.
4044
FlunderReference string
@@ -44,12 +48,14 @@ type FlunderSpec struct {
4448
ReferenceType ReferenceType
4549
}
4650

51+
// FlunderStatus is the status of a Flunder.
4752
type FlunderStatus struct {
4853
}
4954

5055
// +genclient
5156
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
5257

58+
// Flunder is an example type with a spec and a status.
5359
type Flunder struct {
5460
metav1.TypeMeta
5561
metav1.ObjectMeta
@@ -62,6 +68,7 @@ type Flunder struct {
6268
// +genclient:nonNamespaced
6369
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
6470

71+
// Fischer is an example type with a list of disallowed Flunder.Names
6572
type Fischer struct {
6673
metav1.TypeMeta
6774
metav1.ObjectMeta

0 commit comments

Comments
 (0)