diff options
author | Paul Holzinger <pholzing@redhat.com> | 2022-03-11 17:47:39 +0100 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2022-03-15 14:48:10 +0100 |
commit | f8577766d01e994cfb62b7bf7da14631c1a183b5 (patch) | |
tree | 0293770c045de0057a328441414f06b9a1586778 | |
parent | a0ad1f2ad46507f13a16d342b9ccf35a38bae3d5 (diff) | |
download | podman-f8577766d01e994cfb62b7bf7da14631c1a183b5.tar.gz podman-f8577766d01e994cfb62b7bf7da14631c1a183b5.tar.bz2 podman-f8577766d01e994cfb62b7bf7da14631c1a183b5.zip |
pkg/k8s.io/...: fix lint errors
Fix linting errors. We use different/stricter linters, instead of
skipping these packages we should fix it.
Most errors are about naming conventions, since I do not want to change
the names I added the nolint comment there. I also removed some unused
fields where the linter complained.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
-rw-r--r-- | pkg/k8s.io/api/core/v1/resource.go | 1 | ||||
-rw-r--r-- | pkg/k8s.io/api/core/v1/types.go | 85 | ||||
-rw-r--r-- | pkg/k8s.io/apimachinery/pkg/api/resource/math.go | 14 | ||||
-rw-r--r-- | pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go | 14 | ||||
-rw-r--r-- | pkg/k8s.io/apimachinery/pkg/api/resource/suffix.go | 2 | ||||
-rw-r--r-- | pkg/k8s.io/apimachinery/pkg/apis/meta/v1/duration.go | 10 | ||||
-rw-r--r-- | pkg/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time.go | 10 | ||||
-rw-r--r-- | pkg/k8s.io/apimachinery/pkg/apis/meta/v1/time.go | 10 |
8 files changed, 9 insertions, 137 deletions
diff --git a/pkg/k8s.io/api/core/v1/resource.go b/pkg/k8s.io/api/core/v1/resource.go index fcc00d6e0..9270054b3 100644 --- a/pkg/k8s.io/api/core/v1/resource.go +++ b/pkg/k8s.io/api/core/v1/resource.go @@ -26,6 +26,7 @@ func (rn ResourceName) String() string { } // Cpu returns the Cpu limit if specified. +// nolint:golint,stylecheck func (rl *ResourceList) Cpu() *resource.Quantity { return rl.Name(ResourceCPU, resource.DecimalSI) } diff --git a/pkg/k8s.io/api/core/v1/types.go b/pkg/k8s.io/api/core/v1/types.go index fb3128561..d0a36a4a8 100644 --- a/pkg/k8s.io/api/core/v1/types.go +++ b/pkg/k8s.io/api/core/v1/types.go @@ -5869,93 +5869,8 @@ type Secret struct { Type SecretType `json:"type,omitempty" protobuf:"bytes,3,opt,name=type,casttype=SecretType"` } -const MaxSecretSize = 1 * 1024 * 1024 - type SecretType string -const ( - // SecretTypeOpaque is the default. Arbitrary user-defined data - SecretTypeOpaque SecretType = "Opaque" - - // SecretTypeServiceAccountToken contains a token that identifies a service account to the API - // - // Required fields: - // - Secret.Annotations["kubernetes.io/service-account.name"] - the name of the ServiceAccount the token identifies - // - Secret.Annotations["kubernetes.io/service-account.uid"] - the UID of the ServiceAccount the token identifies - // - Secret.Data["token"] - a token that identifies the service account to the API - SecretTypeServiceAccountToken SecretType = "kubernetes.io/service-account-token" - - // ServiceAccountNameKey is the key of the required annotation for SecretTypeServiceAccountToken secrets - ServiceAccountNameKey = "kubernetes.io/service-account.name" - // ServiceAccountUIDKey is the key of the required annotation for SecretTypeServiceAccountToken secrets - ServiceAccountUIDKey = "kubernetes.io/service-account.uid" - // ServiceAccountTokenKey is the key of the required data for SecretTypeServiceAccountToken secrets - ServiceAccountTokenKey = "token" - // ServiceAccountKubeconfigKey is the key of the optional kubeconfig data for SecretTypeServiceAccountToken secrets - ServiceAccountKubeconfigKey = "kubernetes.kubeconfig" - // ServiceAccountRootCAKey is the key of the optional root certificate authority for SecretTypeServiceAccountToken secrets - ServiceAccountRootCAKey = "ca.crt" - // ServiceAccountNamespaceKey is the key of the optional namespace to use as the default for namespaced API calls - ServiceAccountNamespaceKey = "namespace" - - // SecretTypeDockercfg contains a dockercfg file that follows the same format rules as ~/.dockercfg - // - // Required fields: - // - Secret.Data[".dockercfg"] - a serialized ~/.dockercfg file - SecretTypeDockercfg SecretType = "kubernetes.io/dockercfg" - - // DockerConfigKey is the key of the required data for SecretTypeDockercfg secrets - DockerConfigKey = ".dockercfg" - - // SecretTypeDockerConfigJson contains a dockercfg file that follows the same format rules as ~/.docker/config.json - // - // Required fields: - // - Secret.Data[".dockerconfigjson"] - a serialized ~/.docker/config.json file - SecretTypeDockerConfigJson SecretType = "kubernetes.io/dockerconfigjson" - - // DockerConfigJsonKey is the key of the required data for SecretTypeDockerConfigJson secrets - DockerConfigJsonKey = ".dockerconfigjson" - - // SecretTypeBasicAuth contains data needed for basic authentication. - // - // Required at least one of fields: - // - Secret.Data["username"] - username used for authentication - // - Secret.Data["password"] - password or token needed for authentication - SecretTypeBasicAuth SecretType = "kubernetes.io/basic-auth" - - // BasicAuthUsernameKey is the key of the username for SecretTypeBasicAuth secrets - BasicAuthUsernameKey = "username" - // BasicAuthPasswordKey is the key of the password or token for SecretTypeBasicAuth secrets - BasicAuthPasswordKey = "password" - - // SecretTypeSSHAuth contains data needed for SSH authetication. - // - // Required field: - // - Secret.Data["ssh-privatekey"] - private SSH key needed for authentication - SecretTypeSSHAuth SecretType = "kubernetes.io/ssh-auth" - - // SSHAuthPrivateKey is the key of the required SSH private key for SecretTypeSSHAuth secrets - SSHAuthPrivateKey = "ssh-privatekey" - // SecretTypeTLS contains information about a TLS client or server secret. It - // is primarily used with TLS termination of the Ingress resource, but may be - // used in other types. - // - // Required fields: - // - Secret.Data["tls.key"] - TLS private key. - // Secret.Data["tls.crt"] - TLS certificate. - // TODO: Consider supporting different formats, specifying CA/destinationCA. - SecretTypeTLS SecretType = "kubernetes.io/tls" - - // TLSCertKey is the key for tls certificates in a TLS secret. - TLSCertKey = "tls.crt" - // TLSPrivateKeyKey is the key for the private key field in a TLS secret. - TLSPrivateKeyKey = "tls.key" - // SecretTypeBootstrapToken is used during the automated bootstrap process (first - // implemented by kubeadm). It stores tokens that are used to sign well known - // ConfigMaps. They are used for authn. - SecretTypeBootstrapToken SecretType = "bootstrap.kubernetes.io/token" -) - // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // SecretList is a list of Secret. diff --git a/pkg/k8s.io/apimachinery/pkg/api/resource/math.go b/pkg/k8s.io/apimachinery/pkg/api/resource/math.go index 8ffcb9f09..7b4fa5a36 100644 --- a/pkg/k8s.io/apimachinery/pkg/api/resource/math.go +++ b/pkg/k8s.io/apimachinery/pkg/api/resource/math.go @@ -30,11 +30,10 @@ const ( var ( // Commonly needed big.Int values-- treat as read only! - bigTen = big.NewInt(10) - bigZero = big.NewInt(0) - bigOne = big.NewInt(1) - bigThousand = big.NewInt(1000) - big1024 = big.NewInt(1024) + bigTen = big.NewInt(10) + bigZero = big.NewInt(0) + bigOne = big.NewInt(1) + big1024 = big.NewInt(1024) // Commonly needed inf.Dec values-- treat as read only! decZero = inf.NewDec(0, 0) @@ -42,11 +41,6 @@ var ( // Largest (in magnitude) number allowed. maxAllowed = infDecAmount{inf.NewDec((1<<63)-1, 0)} // == max int64 - - // The maximum value we can represent milli-units for. - // Compare with the return value of Quantity.Value() to - // see if it's safe to use Quantity.MilliValue(). - MaxMilliValue = int64(((1 << 63) - 1) / 1000) ) const mostNegative = -(mostPositive + 1) diff --git a/pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go b/pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go index d0e510a1b..fccddc3e0 100644 --- a/pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go +++ b/pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go @@ -138,6 +138,7 @@ const ( var ( // Errors that could happen while parsing a string. + // nolint:golint ErrFormatWrong = errors.New("quantities must match the regular expression '" + splitREString + "'") ErrNumeric = errors.New("unable to parse numeric part of quantity") ErrSuffix = errors.New("unable to parse quantity's suffix") @@ -257,6 +258,7 @@ Suffix: // we encountered a non decimal in the Suffix loop, but the last character // was not a valid exponent err = ErrFormatWrong + // nolint:nakedret return } @@ -387,16 +389,6 @@ func (q Quantity) DeepCopy() Quantity { return q } -// OpenAPISchemaType is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -// -// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators -func (_ Quantity) OpenAPISchemaType() []string { return []string{"string"} } - -// OpenAPISchemaFormat is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -func (_ Quantity) OpenAPISchemaFormat() string { return "" } - // CanonicalizeBytes returns the canonical form of q and its suffix (see comment on Quantity). // // Note about BinarySI: @@ -574,7 +566,7 @@ func (q Quantity) MarshalJSON() ([]byte, error) { copy(out[1:], q.s) return out, nil } - result := make([]byte, int64QuantityExpectedBytes, int64QuantityExpectedBytes) + result := make([]byte, int64QuantityExpectedBytes) result[0] = '"' number, suffix := q.CanonicalizeBytes(result[1:1]) // if the same slice was returned to us that we passed in, avoid another allocation by copying number into diff --git a/pkg/k8s.io/apimachinery/pkg/api/resource/suffix.go b/pkg/k8s.io/apimachinery/pkg/api/resource/suffix.go index 5ed7abe66..6ec527f9c 100644 --- a/pkg/k8s.io/apimachinery/pkg/api/resource/suffix.go +++ b/pkg/k8s.io/apimachinery/pkg/api/resource/suffix.go @@ -165,7 +165,7 @@ func (sh *suffixHandler) constructBytes(base, exponent int32, format Format) (s if exponent == 0 { return nil, true } - result := make([]byte, 8, 8) + result := make([]byte, 8) result[0] = 'e' number := strconv.AppendInt(result[1:1], int64(exponent), 10) if &result[1] == &number[0] { diff --git a/pkg/k8s.io/apimachinery/pkg/apis/meta/v1/duration.go b/pkg/k8s.io/apimachinery/pkg/apis/meta/v1/duration.go index a22b07878..9ea9397e8 100644 --- a/pkg/k8s.io/apimachinery/pkg/apis/meta/v1/duration.go +++ b/pkg/k8s.io/apimachinery/pkg/apis/meta/v1/duration.go @@ -53,13 +53,3 @@ func (d Duration) MarshalJSON() ([]byte, error) { func (d Duration) ToUnstructured() interface{} { return d.Duration.String() } - -// OpenAPISchemaType is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -// -// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators -func (_ Duration) OpenAPISchemaType() []string { return []string{"string"} } - -// OpenAPISchemaFormat is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -func (_ Duration) OpenAPISchemaFormat() string { return "" } diff --git a/pkg/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time.go b/pkg/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time.go index 8eb37f436..1da7d54a0 100644 --- a/pkg/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time.go +++ b/pkg/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time.go @@ -160,16 +160,6 @@ func (t MicroTime) MarshalJSON() ([]byte, error) { return json.Marshal(t.UTC().Format(RFC3339Micro)) } -// OpenAPISchemaType is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -// -// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators -func (_ MicroTime) OpenAPISchemaType() []string { return []string{"string"} } - -// OpenAPISchemaFormat is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -func (_ MicroTime) OpenAPISchemaFormat() string { return "date-time" } - // MarshalQueryParameter converts to a URL query parameter value func (t MicroTime) MarshalQueryParameter() (string, error) { if t.IsZero() { diff --git a/pkg/k8s.io/apimachinery/pkg/apis/meta/v1/time.go b/pkg/k8s.io/apimachinery/pkg/apis/meta/v1/time.go index 421770d43..b84531b1a 100644 --- a/pkg/k8s.io/apimachinery/pkg/apis/meta/v1/time.go +++ b/pkg/k8s.io/apimachinery/pkg/apis/meta/v1/time.go @@ -161,16 +161,6 @@ func (t Time) ToUnstructured() interface{} { return string(buf) } -// OpenAPISchemaType is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -// -// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators -func (_ Time) OpenAPISchemaType() []string { return []string{"string"} } - -// OpenAPISchemaFormat is used by the kube-openapi generator when constructing -// the OpenAPI spec of this type. -func (_ Time) OpenAPISchemaFormat() string { return "date-time" } - // MarshalQueryParameter converts to a URL query parameter value func (t Time) MarshalQueryParameter() (string, error) { if t.IsZero() { |