mirror of https://github.com/knative/pkg.git
Fix revive related linting issues (#2131)
This commit is contained in:
parent
ea766de6bd
commit
980a33719a
|
@ -27,7 +27,7 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// Conditions is the interface for a Resource that implements the getter and
|
||||
// ConditionsAccessor is the interface for a Resource that implements the getter and
|
||||
// setter for accessing a Condition collection.
|
||||
// +k8s:deepcopy-gen=true
|
||||
type ConditionsAccessor interface {
|
||||
|
|
|
@ -52,7 +52,7 @@ const (
|
|||
ConditionSeverityInfo ConditionSeverity = "Info"
|
||||
)
|
||||
|
||||
// Conditions defines a readiness condition for a Knative resource.
|
||||
// Condition defines a readiness condition for a Knative resource.
|
||||
// See: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
|
||||
// +k8s:deepcopy-gen=true
|
||||
type Condition struct {
|
||||
|
|
|
@ -33,7 +33,7 @@ func CheckDeprecated(ctx context.Context, obj interface{}) *FieldError {
|
|||
return CheckDeprecatedUpdate(ctx, obj, nil)
|
||||
}
|
||||
|
||||
// CheckDeprecated checks whether the provided named deprecated fields
|
||||
// CheckDeprecatedUpdate checks whether the provided named deprecated fields
|
||||
// are set in a context where deprecation is disallowed.
|
||||
// This is a json shallow check. We will recursively check inlined structs.
|
||||
func CheckDeprecatedUpdate(ctx context.Context, obj, original interface{}) *FieldError {
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
// GroupName is the name of the API group.
|
||||
GroupName = ducktypes.GroupName
|
||||
|
||||
// AddressableDuckVersionLabel is the label we use to declare
|
||||
|
|
|
@ -38,8 +38,10 @@ func Resource(resource string) schema.GroupResource {
|
|||
}
|
||||
|
||||
var (
|
||||
// SchemeBuilder builds a scheme with the types known to the package.
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
// AddToScheme adds the types known to this package to an existing schema.
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to Scheme.
|
||||
|
|
|
@ -37,8 +37,10 @@ func Resource(resource string) schema.GroupResource {
|
|||
}
|
||||
|
||||
var (
|
||||
// SchemeBuilder builds a scheme with the types known to the package.
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
// AddToScheme adds the types known to this package to an existing schema.
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to Scheme.
|
||||
|
|
|
@ -38,8 +38,10 @@ func Resource(resource string) schema.GroupResource {
|
|||
}
|
||||
|
||||
var (
|
||||
// SchemeBuilder builds a scheme with the types known to the package.
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
// AddToScheme adds the types known to this package to an existing schema.
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to Scheme.
|
||||
|
|
|
@ -17,5 +17,6 @@ limitations under the License.
|
|||
package example
|
||||
|
||||
const (
|
||||
// GroupName is the name of the API group.
|
||||
GroupName = "example.knative.dev"
|
||||
)
|
||||
|
|
|
@ -37,8 +37,10 @@ func Resource(resource string) schema.GroupResource {
|
|||
}
|
||||
|
||||
var (
|
||||
// SchemeBuilder builds a scheme with the types known to the package.
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
// AddToScheme adds the types known to this package to an existing schema.
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to Scheme.
|
||||
|
|
|
@ -17,5 +17,6 @@ limitations under the License.
|
|||
package example
|
||||
|
||||
const (
|
||||
// GroupName is the name of the API group.
|
||||
GroupName = "example.knative.dev"
|
||||
)
|
||||
|
|
|
@ -37,8 +37,10 @@ func Resource(resource string) schema.GroupResource {
|
|||
}
|
||||
|
||||
var (
|
||||
// SchemeBuilder builds a scheme with the types known to the package.
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
// AddToScheme adds the types known to this package to an existing schema.
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to Scheme.
|
||||
|
|
|
@ -44,7 +44,7 @@ func (w *ManualWatcher) Watch(name string, o ...Observer) {
|
|||
w.observers[name] = append(w.observers[name], o...)
|
||||
}
|
||||
|
||||
// Watch implements Watcher
|
||||
// ForEach implements Watcher
|
||||
func (w *ManualWatcher) ForEach(f func(string, []Observer) error) error {
|
||||
for k, v := range w.observers {
|
||||
if err := f(k, v); err != nil {
|
||||
|
|
|
@ -477,7 +477,8 @@ func (c *Impl) RunContext(ctx context.Context, threadiness int) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// DEPRECATED use RunContext instead.
|
||||
// Run runs the controller.
|
||||
// DEPRECATED: Use RunContext instead.
|
||||
func (c *Impl) Run(threadiness int, stopCh <-chan struct{}) error {
|
||||
// Create a context that is cancelled when the stopCh is called.
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
|
|
@ -48,7 +48,9 @@ var (
|
|||
// - characters are printable US-ASCII
|
||||
reconcilerTagKey = tag.MustNewKey("reconciler")
|
||||
successTagKey = tag.MustNewKey("success")
|
||||
NamespaceTagKey = tag.MustNewKey(metricskey.LabelNamespaceName)
|
||||
|
||||
// NamespaceTagKey marks metrics with a namespace.
|
||||
NamespaceTagKey = tag.MustNewKey(metricskey.LabelNamespaceName)
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -17,6 +17,8 @@ limitations under the License.
|
|||
package depcheck
|
||||
|
||||
var (
|
||||
// KnownHeavyDependencies is a list of dependencies that are known to increase the
|
||||
// binary's size by a lot.
|
||||
KnownHeavyDependencies = []string{
|
||||
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer",
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ func CheckDistributionData(t ti, name string, wantTags map[string]string, expect
|
|||
}
|
||||
}
|
||||
|
||||
// CheckDistributionRange checks the view with a name matching string name to verify that the DistributionData stats reported
|
||||
// CheckDistributionCount checks the view with a name matching string name to verify that the DistributionData stats reported
|
||||
// are tagged with the tags in wantTags and that expectedCount number of records were reported.
|
||||
func CheckDistributionCount(t ti, name string, wantTags map[string]string, expectedCount int64) {
|
||||
t.Helper()
|
||||
|
|
|
@ -62,7 +62,7 @@ func NewEvent(eventtype, reason, messageFmt string, args ...interface{}) Event {
|
|||
|
||||
// ReconcilerEvent wraps the fields required for recorders to create a
|
||||
// kubernetes recorder Event.
|
||||
type ReconcilerEvent struct { //nolint:golint // for backcompat.
|
||||
type ReconcilerEvent struct { //nolint:revive // for backcompat.
|
||||
EventType string
|
||||
Reason string
|
||||
Format string
|
||||
|
|
|
@ -31,9 +31,13 @@ import (
|
|||
const failedGenerationBump = "NewObservedGenFailure"
|
||||
|
||||
const (
|
||||
DoReconcileKind = "ReconcileKind"
|
||||
DoFinalizeKind = "FinalizeKind"
|
||||
DoObserveKind = "ObserveKind"
|
||||
// DoReconcileKind is the function name for reconciling the resource (as a leader).
|
||||
DoReconcileKind = "ReconcileKind"
|
||||
// DoFinalizeKind is the function name for finalizing the resource (as a leader).
|
||||
DoFinalizeKind = "FinalizeKind"
|
||||
// DoObserveKind is the function name for observing the resource (as a non leader).
|
||||
DoObserveKind = "ObserveKind"
|
||||
// DoObserveFinalizeKind is the function name for observing finalization of the resource (as a non leader).
|
||||
DoObserveFinalizeKind = "ObserveFinalizeKind"
|
||||
)
|
||||
|
||||
|
|
|
@ -22,7 +22,10 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
NamespaceEnvKey = "SYSTEM_NAMESPACE"
|
||||
// NamespaceEnvKey is the environment variable that specifies the system namespace.
|
||||
NamespaceEnvKey = "SYSTEM_NAMESPACE"
|
||||
// ResourceLabelEnvKey is the environment variable that specifies the system resource
|
||||
// label.
|
||||
ResourceLabelEnvKey = "SYSTEM_RESOURCE_LABEL"
|
||||
)
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ func initializeFlags() *EnvironmentFlags {
|
|||
return f
|
||||
}
|
||||
|
||||
// SetupLoggingFlags initializes a logger for tests.
|
||||
// TODO(coryrc): Remove once other repos are moved to call logging.InitializeLogger() directly
|
||||
func SetupLoggingFlags() {
|
||||
logging.InitializeLogger()
|
||||
|
|
|
@ -37,17 +37,28 @@ import (
|
|||
// easy to replicate.
|
||||
|
||||
var (
|
||||
MethodNewStorageBucket = Method("NewStorageBucket")
|
||||
// MethodNewStorageBucket mocks MethodNewStorageBucket.
|
||||
MethodNewStorageBucket = Method("NewStorageBucket")
|
||||
// MethodDeleteStorageBucket mocks NewDeleteStorageBucket.
|
||||
MethodDeleteStorageBucket = Method("NewDeleteStorageBucket")
|
||||
MethodListChildrenFiles = Method("ListChildrenFiles")
|
||||
MethodListDirectChildren = Method("ListDirectChildren")
|
||||
MethodAttrObject = Method("AttrObject")
|
||||
MethodCopyObject = Method("CopyObject")
|
||||
MethodReadObject = Method("ReadObject")
|
||||
MethodWriteObject = Method("WriteObject")
|
||||
MethodDeleteObject = Method("DeleteObject")
|
||||
MethodDownload = Method("Download")
|
||||
MethodUpload = Method("Upload")
|
||||
// MethodListChildrenFiles mocks ListChildrenFiles.
|
||||
MethodListChildrenFiles = Method("ListChildrenFiles")
|
||||
// MethodListDirectChildren mocks ListDirectChildren.
|
||||
MethodListDirectChildren = Method("ListDirectChildren")
|
||||
// MethodAttrObject mocks AttrObject.
|
||||
MethodAttrObject = Method("AttrObject")
|
||||
// MethodCopyObject mocks CopyObject.
|
||||
MethodCopyObject = Method("CopyObject")
|
||||
// MethodReadObject mocks ReadObject.
|
||||
MethodReadObject = Method("ReadObject")
|
||||
// MethodWriteObject mocks WriteObject.
|
||||
MethodWriteObject = Method("WriteObject")
|
||||
// MethodDeleteObject mocks DeleteObject.
|
||||
MethodDeleteObject = Method("DeleteObject")
|
||||
// MethodDownload mocks Download.
|
||||
MethodDownload = Method("Download")
|
||||
// MethodUpload mocks Upload.
|
||||
MethodUpload = Method("Upload")
|
||||
)
|
||||
|
||||
// mock GCS Client
|
||||
|
|
|
@ -64,7 +64,7 @@ type buckets struct {
|
|||
bkt map[bucket]*objects
|
||||
}
|
||||
|
||||
// Error map to return custom errors for specific methods
|
||||
// ReturnError is a custom error for specific methods
|
||||
type ReturnError struct {
|
||||
NumCall uint8
|
||||
Err error
|
||||
|
|
|
@ -98,7 +98,8 @@ func WaitForNewLeaders(ctx context.Context, t *testing.T, client *test.KubeClien
|
|||
return leaders, err
|
||||
}
|
||||
|
||||
// DEPRECATED WaitForNewLeader waits until the holder of the given lease is different from the previousLeader.
|
||||
// WaitForNewLeader waits until the holder of the given lease is different from the previousLeader.
|
||||
// DEPRECATED: Use WaitForNewLeaders.
|
||||
func WaitForNewLeader(ctx context.Context, client *test.KubeClient, lease, namespace, previousLeader string) (string, error) {
|
||||
span := logging.GetEmitableSpan(ctx, "WaitForNewLeader/"+lease)
|
||||
defer span.End()
|
||||
|
|
|
@ -55,7 +55,7 @@ func (e Env) PromoteFromEnv(envVars ...string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Creates an Docker with default Docker command arguments for running interactively
|
||||
// NewDocker creates a Docker instance with default Docker command arguments for running interactively.
|
||||
func NewDocker() Docker {
|
||||
return Docker{NewCommand(defaultDockerCommands...)}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ func WaitForPodDeleted(ctx context.Context, client kubernetes.Interface, name, n
|
|||
return nil
|
||||
}
|
||||
|
||||
// WaitForServiceHasAtLeastOneEndpoint polls the status of the specified Service
|
||||
// WaitForServiceEndpoints polls the status of the specified Service
|
||||
// from client every interval until number of service endpoints = numOfEndpoints
|
||||
func WaitForServiceEndpoints(ctx context.Context, client kubernetes.Interface, svcName string, svcNamespace string, numOfEndpoints int) error {
|
||||
endpointsService := client.CoreV1().Endpoints(svcNamespace)
|
||||
|
|
|
@ -20,6 +20,7 @@ limitations under the License.
|
|||
|
||||
package test
|
||||
|
||||
// T is an interface mimicking *testing.T.
|
||||
// Deprecated: Do not use this. Define your own interface.
|
||||
type T interface {
|
||||
Name() string
|
||||
|
@ -30,6 +31,7 @@ type T interface {
|
|||
Error(args ...interface{})
|
||||
}
|
||||
|
||||
// TLegacy is an interface mimicking *testing.T.
|
||||
// Deprecated: Do not use this. Define your own interface.
|
||||
type TLegacy interface {
|
||||
T
|
||||
|
|
|
@ -26,8 +26,10 @@ import (
|
|||
var SchemeGroupVersion = schema.GroupVersion{Group: "duck.knative.dev", Version: "v3"}
|
||||
|
||||
var (
|
||||
// SchemeBuilder builds a scheme with the types known to the package.
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
// AddToScheme adds the types known to this package to an existing schema.
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to Scheme.
|
||||
|
|
|
@ -85,7 +85,7 @@ type InnerDefaultSubSpec struct {
|
|||
DeprecatedNotJSON string
|
||||
}
|
||||
|
||||
// Adding complication helper.
|
||||
// InnerDefaultStruct is a helper to test defaulting of an inner struct.
|
||||
type InnerDefaultStruct struct {
|
||||
FieldAsString string `json:"fieldAsString,omitempty"`
|
||||
|
||||
|
|
|
@ -26,8 +26,10 @@ import (
|
|||
var SchemeGroupVersion = schema.GroupVersion{Group: "pkg.knative.dev", Version: "v2"}
|
||||
|
||||
var (
|
||||
// SchemeBuilder builds a scheme with the types known to the package.
|
||||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
// AddToScheme adds the types known to this package to an existing schema.
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
// Adds the list of known types to Scheme.
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
"knative.dev/pkg/tracing/config"
|
||||
)
|
||||
|
||||
// FakeZipkineExporter is intended to capture the testing boilerplate of building
|
||||
// FakeZipkinExporter is intended to capture the testing boilerplate of building
|
||||
// up the ConfigOption to pass NewOpenCensusTracer and expose a mechanism for examining
|
||||
// the traces it would have reported. To set it up, use something like:
|
||||
// reporter, co := FakeZipkinExporter()
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
// ZipkinReporterFactory is a factory function which creates a reporter given a config
|
||||
type ZipkinReporterFactory func(*config.Config) (zipkinreporter.Reporter, error)
|
||||
|
||||
// WithZipkinExporter returns a config with zipkin enabled.
|
||||
// DEPRECATED: This function is the legacy entrypoint and should be replaced with one of:
|
||||
// - WithExporter() in production code
|
||||
// - testing/FakeZipkinExporter() in test code.
|
||||
|
|
|
@ -143,6 +143,7 @@ func admissionHandler(rootLogger *zap.SugaredLogger, stats StatsReporter, c Admi
|
|||
}
|
||||
}
|
||||
|
||||
// StatelessAdmissionImpl marks a reconciler as stateless.
|
||||
// Inline this type to implement StatelessAdmissionController.
|
||||
type StatelessAdmissionImpl struct{}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ import (
|
|||
certresources "knative.dev/pkg/webhook/certificates/resources"
|
||||
)
|
||||
|
||||
// ReconcilerOptions is a function to modify the Reconciler.
|
||||
// ReconcilerOption is a function to modify the Reconciler.
|
||||
type ReconcilerOption func(*Reconciler)
|
||||
|
||||
// WithSelector specifies the selector for the webhook.
|
||||
|
|
Loading…
Reference in New Issue