Merge pull request #97374 from geegeea/golint

Fix golint issues in pkg/kubelet/types
This commit is contained in:
Kubernetes Prow Robot 2021-01-05 17:10:03 -08:00 committed by GitHub
commit b39494ce35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 34 deletions

View File

@ -106,7 +106,6 @@ pkg/kubelet/pluginmanager/pluginwatcher
pkg/kubelet/pod/testing pkg/kubelet/pod/testing
pkg/kubelet/preemption pkg/kubelet/preemption
pkg/kubelet/sysctl pkg/kubelet/sysctl
pkg/kubelet/types
pkg/kubemark pkg/kubemark
pkg/proxy/apis/config pkg/proxy/apis/config
pkg/proxy/apis/config/v1alpha1 pkg/proxy/apis/config/v1alpha1

View File

@ -17,21 +17,24 @@ limitations under the License.
package types package types
const ( const (
// system default DNS resolver configuration // ResolvConfDefault is the system default DNS resolver configuration.
ResolvConfDefault = "/etc/resolv.conf" ResolvConfDefault = "/etc/resolv.conf"
// RFC3339NanoFixed is the fixed width version of time.RFC3339Nano.
RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
// RFC3339NanoLenient is the variable width RFC3339 time format for lenient parsing of strings into timestamps.
RFC3339NanoLenient = "2006-01-02T15:04:05.999999999Z07:00"
)
// different container runtimes // Different container runtimes.
const (
DockerContainerRuntime = "docker" DockerContainerRuntime = "docker"
RemoteContainerRuntime = "remote" RemoteContainerRuntime = "remote"
)
// User visible keys for managing node allocatable enforcement on the node. // User visible keys for managing node allocatable enforcement on the node.
const (
NodeAllocatableEnforcementKey = "pods" NodeAllocatableEnforcementKey = "pods"
SystemReservedEnforcementKey = "system-reserved" SystemReservedEnforcementKey = "system-reserved"
KubeReservedEnforcementKey = "kube-reserved" KubeReservedEnforcementKey = "kube-reserved"
NodeAllocatableNoneKey = "none" NodeAllocatableNoneKey = "none"
// fixed width version of time.RFC3339Nano
RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
// variable width RFC3339 time format for lenient parsing of strings into timestamps
RFC3339NanoLenient = "2006-01-02T15:04:05.999999999Z07:00"
) )

View File

@ -14,5 +14,5 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
// Common types in the Kubelet. // Package types contains common types in the Kubelet.
package types // import "k8s.io/kubernetes/pkg/kubelet/types" package types // import "k8s.io/kubernetes/pkg/kubelet/types"

View File

@ -16,6 +16,7 @@ limitations under the License.
package types package types
// Label keys for labels used in this package.
const ( const (
KubernetesPodNameLabel = "io.kubernetes.pod.name" KubernetesPodNameLabel = "io.kubernetes.pod.name"
KubernetesPodNamespaceLabel = "io.kubernetes.pod.namespace" KubernetesPodNamespaceLabel = "io.kubernetes.pod.namespace"
@ -23,18 +24,22 @@ const (
KubernetesContainerNameLabel = "io.kubernetes.container.name" KubernetesContainerNameLabel = "io.kubernetes.container.name"
) )
// GetContainerName returns the value of the KubernetesContainerNameLabel.
func GetContainerName(labels map[string]string) string { func GetContainerName(labels map[string]string) string {
return labels[KubernetesContainerNameLabel] return labels[KubernetesContainerNameLabel]
} }
// GetPodName returns the value of the KubernetesPodNameLabel.
func GetPodName(labels map[string]string) string { func GetPodName(labels map[string]string) string {
return labels[KubernetesPodNameLabel] return labels[KubernetesPodNameLabel]
} }
// GetPodUID returns the value of the KubernetesPodUIDLabel.
func GetPodUID(labels map[string]string) string { func GetPodUID(labels map[string]string) string {
return labels[KubernetesPodUIDLabel] return labels[KubernetesPodUIDLabel]
} }
// GetPodNamespace returns the value of the KubernetesPodNamespaceLabel.
func GetPodNamespace(labels map[string]string) string { func GetPodNamespace(labels map[string]string) string {
return labels[KubernetesPodNamespaceLabel] return labels[KubernetesPodNamespaceLabel]
} }

View File

@ -24,6 +24,7 @@ import (
"k8s.io/kubernetes/pkg/apis/scheduling" "k8s.io/kubernetes/pkg/apis/scheduling"
) )
// Annotation keys for annotations used in this package.
const ( const (
ConfigSourceAnnotationKey = "kubernetes.io/config.source" ConfigSourceAnnotationKey = "kubernetes.io/config.source"
ConfigMirrorAnnotationKey = v1.MirrorPodAnnotationKey ConfigMirrorAnnotationKey = v1.MirrorPodAnnotationKey
@ -34,34 +35,38 @@ const (
// PodOperation defines what changes will be made on a pod configuration. // PodOperation defines what changes will be made on a pod configuration.
type PodOperation int type PodOperation int
// These constants identify the PodOperations that can be made on a pod configuration.
const ( const (
// This is the current pod configuration // SET is the current pod configuration.
SET PodOperation = iota SET PodOperation = iota
// Pods with the given ids are new to this source // ADD signifies pods that are new to this source.
ADD ADD
// Pods with the given ids are gracefully deleted from this source // DELETE signifies pods that are gracefully deleted from this source.
DELETE DELETE
// Pods with the given ids have been removed from this source // REMOVE signifies pods that have been removed from this source.
REMOVE REMOVE
// Pods with the given ids have been updated in this source // UPDATE signifies pods have been updated in this source.
UPDATE UPDATE
// Pods with the given ids have unexpected status in this source, // RECONCILE signifies pods that have unexpected status in this source,
// kubelet should reconcile status with this source // kubelet should reconcile status with this source.
RECONCILE RECONCILE
// These constants identify the sources of pods
// Updates from a file
FileSource = "file"
// Updates from querying a web page
HTTPSource = "http"
// Updates from Kubernetes API Server
ApiserverSource = "api"
// Updates from all sources
AllSource = "*"
NamespaceDefault = metav1.NamespaceDefault
) )
// These constants identify the sources of pods.
const (
// Filesource idenitified updates from a file.
FileSource = "file"
// HTTPSource identifies updates from querying a web page.
HTTPSource = "http"
// ApiserverSource identifies updates from Kubernetes API Server.
ApiserverSource = "api"
// AllSource identifies updates from all sources.
AllSource = "*"
)
// NamespaceDefault is a string representing the default namespace.
const NamespaceDefault = metav1.NamespaceDefault
// PodUpdate defines an operation sent on the channel. You can add or remove single services by // PodUpdate defines an operation sent on the channel. You can add or remove single services by
// sending an array of size one and Op == ADD|REMOVE (with REMOVE, only the ID is required). // sending an array of size one and Op == ADD|REMOVE (with REMOVE, only the ID is required).
// For setting the state of the system to a given state for this source configuration, set // For setting the state of the system to a given state for this source configuration, set
@ -77,7 +82,7 @@ type PodUpdate struct {
Source string Source string
} }
// Gets all validated sources from the specified sources. // GetValidatedSources gets all validated sources from the specified sources.
func GetValidatedSources(sources []string) ([]string, error) { func GetValidatedSources(sources []string) ([]string, error) {
validated := make([]string, 0, len(sources)) validated := make([]string, 0, len(sources))
for _, source := range sources { for _, source := range sources {

View File

@ -20,7 +20,7 @@ import (
"net/http" "net/http"
"time" "time"
"k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
) )
@ -61,7 +61,7 @@ func (t *Timestamp) GetString() string {
return t.time.Format(RFC3339NanoFixed) return t.time.Format(RFC3339NanoFixed)
} }
// A type to help sort container statuses based on container names. // SortedContainerStatuses is a type to help sort container statuses based on container names.
type SortedContainerStatuses []v1.ContainerStatus type SortedContainerStatuses []v1.ContainerStatus
func (s SortedContainerStatuses) Len() int { return len(s) } func (s SortedContainerStatuses) Len() int { return len(s) }
@ -87,6 +87,8 @@ func SortInitContainerStatuses(p *v1.Pod, statuses []v1.ContainerStatus) {
} }
} }
// SortStatusesOfInitContainers returns the statuses of InitContainers of pod p,
// in the order that they appear in its spec.
func SortStatusesOfInitContainers(p *v1.Pod, statusMap map[string]*v1.ContainerStatus) []v1.ContainerStatus { func SortStatusesOfInitContainers(p *v1.Pod, statusMap map[string]*v1.ContainerStatus) []v1.ContainerStatus {
containers := p.Spec.InitContainers containers := p.Spec.InitContainers
statuses := []v1.ContainerStatus{} statuses := []v1.ContainerStatus{}
@ -106,8 +108,8 @@ type Reservation struct {
Kubernetes v1.ResourceList Kubernetes v1.ResourceList
} }
// A pod UID which has been translated/resolved to the representation known to kubelets. // ResolvedPodUID is a pod UID which has been translated/resolved to the representation known to kubelets.
type ResolvedPodUID types.UID type ResolvedPodUID types.UID
// A pod UID for a mirror pod. // MirrorPodUID is a pod UID for a mirror pod.
type MirrorPodUID types.UID type MirrorPodUID types.UID