From 0454ea684946f42dd6e91f04f628b179f6904d7f Mon Sep 17 00:00:00 2001 From: Vince Prignano Date: Mon, 12 Dec 2022 15:59:08 -0800 Subject: [PATCH] Run golangci-lint --fix (comments, newlines, etc) --- cmd/apigen/main.go | 2 +- config/rootcompute/bootstrap.go | 2 +- .../crdnooverlappinggvr_admission.go | 2 +- pkg/admission/limitranger/admission.go | 8 +++---- pkg/admission/namespacelifecycle/admission.go | 6 ++--- .../pathannotation_admission.go | 14 ++++++------ .../mutating_permission_claims.go | 1 - pkg/admission/reservedcrdgroups/admission.go | 2 +- .../workspacetypeexists/admission.go | 4 ++-- pkg/authorization/bootstrap/policy.go | 2 +- pkg/cache/client/context.go | 4 ++-- pkg/cache/client/round_tripper.go | 22 +++++++++---------- pkg/cache/client/shard/shard.go | 2 +- pkg/cache/server/bootstrap/bootstrap.go | 2 +- pkg/cache/server/crd_lister.go | 8 +++---- pkg/cache/server/handler.go | 4 ++-- pkg/cliplugins/bind/plugin/bind_compute.go | 2 +- pkg/cliplugins/claims/cmd/cmd.go | 3 +-- pkg/cliplugins/crd/plugin/snapshot.go | 4 ++-- pkg/cliplugins/workload/plugin/sync.go | 3 +-- pkg/cliplugins/workload/plugin/workload.go | 2 -- pkg/cliplugins/workspace/plugin/kubeconfig.go | 3 +-- pkg/crdpuller/discovery.go | 1 - pkg/dns/plugin/nsmap/config.go | 2 +- pkg/dns/plugin/nsmap/namespace.go | 1 - pkg/features/kcp_features.go | 2 +- pkg/indexers/indexers.go | 2 +- pkg/informer/informer.go | 5 ++--- pkg/proxy/config.go | 2 +- pkg/proxy/metrics/metrics.go | 2 +- pkg/proxy/options/authentication.go | 8 +++---- .../apis/apibinding/conflict_checker.go | 2 +- .../apibinding_deletion_controller.go | 4 ++-- .../apis/apiresource/negotiation.go | 15 ++++++------- pkg/reconciler/apis/apiresource/startup.go | 2 +- .../apis/crdcleanup/crdcleanup_controller.go | 4 ++-- .../crdcleanup/crdcleanup_controller_test.go | 1 - .../permissionclaimlabel_controller.go | 2 -- ...ermissionclaimlabel_resource_controller.go | 1 - pkg/reconciler/cache/replication/indexers.go | 4 ++-- .../replication/replication_controller.go | 2 +- .../replication_reconcile_unstructured.go | 2 +- pkg/reconciler/committer/committer.go | 7 +++--- .../deployment/deployment_controller.go | 2 +- .../deployment/deployment_controller_test.go | 2 -- .../logicalcluster_resource_deletor.go | 6 ++--- .../logicalcluster_resource_deletor_test.go | 2 +- .../logicalcluster_deletion_controller.go | 2 +- .../location/location_controller.go | 2 +- .../placement/placement_controller.go | 2 +- .../apibinder_initializer_controller.go | 3 +-- .../apiexport/workload_apiexport_reconcile.go | 2 +- .../namespace/namespace_controller.go | 2 +- .../placement/placement_controller.go | 4 ++-- .../workload/placement/placement_reconcile.go | 2 +- .../workload/resource/resource_controller.go | 3 +-- .../workload/resource/resource_reconcile.go | 2 +- .../synctarget/synctarget_controller.go | 1 - .../synctargetexports_controller.go | 1 - pkg/schemacompat/schemacompat.go | 1 - pkg/server/apiextensions.go | 4 +--- pkg/server/bootstrap/identity.go | 4 ++-- pkg/server/controllers.go | 1 - pkg/server/filters/filters.go | 2 +- pkg/server/handler.go | 2 +- pkg/server/options/authorization.go | 4 ++-- pkg/server/requestinfo/util.go | 2 +- pkg/syncer/resourcesync/controller.go | 2 +- pkg/syncer/spec/dns/dns_process.go | 1 - pkg/syncer/spec/mutators/deployment.go | 11 +++++----- pkg/syncer/spec/spec_controller.go | 1 - pkg/syncer/spec/spec_process.go | 4 ++-- pkg/syncer/status/status_controller.go | 1 - pkg/syncer/syncer.go | 2 +- pkg/syncer/tunneler.go | 4 ++-- pkg/tunneler/listener.go | 7 +++--- pkg/tunneler/tunnel.go | 15 ++++++------- .../apiexport_apireconciler_reconcile.go | 4 ++-- .../framework/dynamic/apidefinition/types.go | 2 +- .../framework/dynamic/apiserver/apiserver.go | 6 ++--- .../framework/dynamic/apiserver/discovery.go | 2 -- .../dynamic/apiserver/serving_info.go | 4 ++-- pkg/virtual/framework/fixedgvs/register.go | 1 - .../framework/forwardingregistry/rest.go | 2 +- pkg/virtual/framework/handler/handler.go | 2 +- pkg/virtual/framework/internalapis/import.go | 2 +- .../framework/rootapiserver/root_apiserver.go | 2 +- pkg/virtual/framework/transforming/watcher.go | 4 ++-- .../framework/wrappers/rbac/merging.go | 4 ++-- .../builder/forwarding.go | 4 ++-- pkg/virtual/options/authorization.go | 4 ++-- pkg/virtual/syncer/builder/build.go | 1 - .../syncer_apireconciler_reconcile.go | 1 - .../transformations/defaultsummarizing.go | 17 +++++++------- pkg/virtual/syncer/transformations/types.go | 4 ++-- .../syncer/upsyncer/storage_wrapper.go | 2 +- pkg/virtual/syncer/upsyncer/transformer.go | 4 ++-- pkg/virtual/workspaces/printers/printer.go | 2 +- pkg/virtual/workspaces/registry/rest.go | 8 +++---- .../apibinding/apibinding_deletion_test.go | 2 +- .../apibinding_permissionclaims_test.go | 4 ++-- .../apibinding/apibinding_protected_test.go | 2 +- test/e2e/apibinding/apibinding_test.go | 6 ++--- .../e2e/apibinding/apibinding_webhook_test.go | 2 +- .../apis/wildwest/v1alpha1/register.go | 6 ++--- test/e2e/framework/bind.go | 2 +- test/e2e/framework/expect.go | 4 ++-- test/e2e/framework/kcp.go | 10 ++++----- test/e2e/framework/kubectl.go | 1 - test/e2e/framework/syncer.go | 2 +- test/e2e/framework/util.go | 2 +- test/e2e/quota/quota_test.go | 2 +- .../workspacedeletion/controller_test.go | 8 +++---- .../virtual_workspace_test.go | 2 +- tmc/pkg/coordination/helpers.go | 4 ++-- 115 files changed, 191 insertions(+), 229 deletions(-) diff --git a/cmd/apigen/main.go b/cmd/apigen/main.go index 3f56e745256..db5a40ecb7e 100644 --- a/cmd/apigen/main.go +++ b/cmd/apigen/main.go @@ -300,7 +300,7 @@ func resolveLatestAPIResourceSchemas(logger logr.Logger, previous, current map[m } // compareSchemas compares JSON Schemas by unmarshalling them and comparing their values, instead -// of comparing their raw []byte() representations, as those are not semantically meaningful +// of comparing their raw []byte() representations, as those are not semantically meaningful. func compareSchemas() cmp.Option { return cmp.FilterPath(func(path cmp.Path) bool { return path.String() == "Versions.Schema.Raw" diff --git a/config/rootcompute/bootstrap.go b/config/rootcompute/bootstrap.go index 523f21a7595..1bd20ddce23 100644 --- a/config/rootcompute/bootstrap.go +++ b/config/rootcompute/bootstrap.go @@ -34,7 +34,7 @@ import ( //go:embed *.yaml var fs embed.FS -// RootComuteWorkspace is the workspace to host common kubernetes APIs +// RootComputeClusterName is the workspace to host common kubernetes APIs. var RootComputeClusterName = logicalcluster.NewPath("root:compute") // Bootstrap creates resources in this package by continuously retrying the list. diff --git a/pkg/admission/crdnooverlappinggvr/crdnooverlappinggvr_admission.go b/pkg/admission/crdnooverlappinggvr/crdnooverlappinggvr_admission.go index a6f81aeaab2..cb9182cd049 100644 --- a/pkg/admission/crdnooverlappinggvr/crdnooverlappinggvr_admission.go +++ b/pkg/admission/crdnooverlappinggvr/crdnooverlappinggvr_admission.go @@ -69,7 +69,7 @@ func (p *crdNoOverlappingGVRAdmission) ValidateInitialization() error { return nil } -// Validate checks if the given CRD's Group and Resource don't overlap with bound CRDs +// Validate checks if the given CRD's Group and Resource don't overlap with bound CRDs. func (p *crdNoOverlappingGVRAdmission) Validate(ctx context.Context, a admission.Attributes, _ admission.ObjectInterfaces) error { if a.GetResource().GroupResource() != apiextensions.Resource("customresourcedefinitions") { return nil diff --git a/pkg/admission/limitranger/admission.go b/pkg/admission/limitranger/admission.go index 92047fa862a..0faa497637e 100644 --- a/pkg/admission/limitranger/admission.go +++ b/pkg/admission/limitranger/admission.go @@ -41,7 +41,7 @@ const ( PluginName = "WorkspaceLimitRanger" ) -// Register registers a plugin +// Register registers a plugin. func Register(plugins *admission.Plugins) { plugins.Register(PluginName, func(config io.Reader) (admission.Interface, error) { return &workspaceLimitRanger{ @@ -52,7 +52,7 @@ func Register(plugins *admission.Plugins) { }) } -// workspaceLimitRanger is a delegating multiplexer for the Kubernetes LimitRanger admission control plugin +// workspaceLimitRanger is a delegating multiplexer for the Kubernetes LimitRanger admission control plugin. type workspaceLimitRanger struct { *admission.Handler client kcpkubernetesclient.ClusterInterface @@ -84,7 +84,7 @@ func (l *workspaceLimitRanger) ValidateInitialization() error { return nil } -// Admit admits resources into cluster that do not violate any defined LimitRange in the namespace +// Admit admits resources into cluster that do not violate any defined LimitRange in the namespace. func (l *workspaceLimitRanger) Admit(ctx context.Context, a admission.Attributes, o admission.ObjectInterfaces) (err error) { clusterName, err := genericapirequest.ClusterNameFrom(ctx) if err != nil { @@ -97,7 +97,7 @@ func (l *workspaceLimitRanger) Admit(ctx context.Context, a admission.Attributes return delegate.Admit(ctx, a, o) } -// Validate admits resources into cluster that do not violate any defined LimitRange in the namespace +// Validate admits resources into cluster that do not violate any defined LimitRange in the namespace. func (l *workspaceLimitRanger) Validate(ctx context.Context, a admission.Attributes, o admission.ObjectInterfaces) (err error) { clusterName, err := genericapirequest.ClusterNameFrom(ctx) if err != nil { diff --git a/pkg/admission/namespacelifecycle/admission.go b/pkg/admission/namespacelifecycle/admission.go index 07e0012346c..42755dff54a 100644 --- a/pkg/admission/namespacelifecycle/admission.go +++ b/pkg/admission/namespacelifecycle/admission.go @@ -42,11 +42,11 @@ import ( ) const ( - // PluginName indicates the name of admission plug-in + // PluginName indicates the name of admission plug-in. PluginName = "WorkspaceNamespaceLifecycle" ) -// Register registers a plugin +// Register registers a plugin. func Register(plugins *admission.Plugins) { plugins.Register(PluginName, func(config io.Reader) (admission.Interface, error) { return newWorkspaceNamespaceLifecycle() @@ -91,7 +91,7 @@ var _ = kcpinitializers.WantsKcpInformers(&workspaceNamespaceLifecycle{}) var _ = initializer.WantsExternalKubeInformerFactory(&workspaceNamespaceLifecycle{}) var _ = initializer.WantsExternalKubeClientSet(&workspaceNamespaceLifecycle{}) -// Admit makes an admission decision based on the request attributes +// Admit makes an admission decision based on the request attributes. func (l *workspaceNamespaceLifecycle) Admit(ctx context.Context, a admission.Attributes, o admission.ObjectInterfaces) error { // call legacy namespace lifecycle at first admissionErr := l.legacyNamespaceLifecycle.Admit(ctx, a, o) diff --git a/pkg/admission/pathannotation/pathannotation_admission.go b/pkg/admission/pathannotation/pathannotation_admission.go index 774534723db..fc70a871221 100644 --- a/pkg/admission/pathannotation/pathannotation_admission.go +++ b/pkg/admission/pathannotation/pathannotation_admission.go @@ -163,20 +163,20 @@ func (p *pathAnnotationPlugin) Validate(ctx context.Context, a admission.Attribu return nil } -func (o *pathAnnotationPlugin) ValidateInitialization() error { - if o.logicalClusterLister == nil { +func (p *pathAnnotationPlugin) ValidateInitialization() error { + if p.logicalClusterLister == nil { return fmt.Errorf(PluginName + " plugin needs an LogicalCluster lister") } return nil } -func (o *pathAnnotationPlugin) SetKcpInformers(informers kcpinformers.SharedInformerFactory) { +func (p *pathAnnotationPlugin) SetKcpInformers(informers kcpinformers.SharedInformerFactory) { logicalClusterReady := informers.Core().V1alpha1().LogicalClusters().Informer().HasSynced - o.SetReadyFunc(func() bool { + p.SetReadyFunc(func() bool { return logicalClusterReady() }) - o.logicalClusterLister = informers.Core().V1alpha1().LogicalClusters().Lister() - o.getLogicalCluster = func(clusterName logicalcluster.Name, name string) (*corev1alpha1.LogicalCluster, error) { - return o.logicalClusterLister.Cluster(clusterName).Get(name) + p.logicalClusterLister = informers.Core().V1alpha1().LogicalClusters().Lister() + p.getLogicalCluster = func(clusterName logicalcluster.Name, name string) (*corev1alpha1.LogicalCluster, error) { + return p.logicalClusterLister.Cluster(clusterName).Get(name) } } diff --git a/pkg/admission/permissionclaims/mutating_permission_claims.go b/pkg/admission/permissionclaims/mutating_permission_claims.go index 6753cb1ec7d..02e70328834 100644 --- a/pkg/admission/permissionclaims/mutating_permission_claims.go +++ b/pkg/admission/permissionclaims/mutating_permission_claims.go @@ -112,7 +112,6 @@ func (m *mutatingPermissionClaims) Admit(ctx context.Context, a admission.Attrib u.SetLabels(labels) return nil - } func (m *mutatingPermissionClaims) Validate(ctx context.Context, a admission.Attributes, o admission.ObjectInterfaces) error { diff --git a/pkg/admission/reservedcrdgroups/admission.go b/pkg/admission/reservedcrdgroups/admission.go index 0fb24c26acc..2d2dc8ff7b4 100644 --- a/pkg/admission/reservedcrdgroups/admission.go +++ b/pkg/admission/reservedcrdgroups/admission.go @@ -48,7 +48,7 @@ type reservedCRDGroups struct { // Ensure that the required admission interfaces are implemented. var _ = admission.ValidationInterface(&reservedCRDGroups{}) -// Ensure that CRDs in *.kcp.io group are only created inside system:system-crds workspace +// Ensure that CRDs in *.kcp.dev group are only created inside system:system-crds workspace. func (o *reservedCRDGroups) Validate(ctx context.Context, a admission.Attributes, _ admission.ObjectInterfaces) (err error) { if a.GetResource().GroupResource() != apiextensions.Resource("customresourcedefinitions") { return nil diff --git a/pkg/admission/workspacetypeexists/admission.go b/pkg/admission/workspacetypeexists/admission.go index 1a9571814b1..0eb01f9ce0f 100644 --- a/pkg/admission/workspacetypeexists/admission.go +++ b/pkg/admission/workspacetypeexists/admission.go @@ -208,7 +208,7 @@ func (o *workspacetypeExists) resolveTypeRef(workspacePath logicalcluster.Path, // Validate ensures that // - has a valid type -// - has valid initializers when transitioning to initializing +// - has valid initializers when transitioning to initializing. func (o *workspacetypeExists) Validate(ctx context.Context, a admission.Attributes, _ admission.ObjectInterfaces) (err error) { clusterName, err := genericapirequest.ClusterNameFrom(ctx) if err != nil { @@ -385,7 +385,7 @@ func addAdditionalWorkspaceLabels( } } -// TODO: Move this out of admission to some shared location +// TODO: Move this out of admission to some shared location. type TransitiveTypeResolver interface { Resolve(t *tenancyv1alpha1.WorkspaceType) ([]*tenancyv1alpha1.WorkspaceType, error) } diff --git a/pkg/authorization/bootstrap/policy.go b/pkg/authorization/bootstrap/policy.go index e3c000164a7..3990a9ac044 100644 --- a/pkg/authorization/bootstrap/policy.go +++ b/pkg/authorization/bootstrap/policy.go @@ -43,7 +43,7 @@ const ( SystemKcpWorkspaceAccessGroup = "system:kcp:workspace:access" ) -// ClusterRoleBindings return default rolebindings to the default roles +// ClusterRoleBindings return default rolebindings to the default roles. func clusterRoleBindings() []rbacv1.ClusterRoleBinding { return []rbacv1.ClusterRoleBinding{ clusterRoleBindingCustomName(rbacv1helpers.NewClusterBinding("cluster-admin").Groups(SystemKcpAdminGroup).BindingOrDie(), "system:kcp:admin:cluster-admin"), diff --git a/pkg/cache/client/context.go b/pkg/cache/client/context.go index 91a3639f9e3..523a54f80ea 100644 --- a/pkg/cache/client/context.go +++ b/pkg/cache/client/context.go @@ -25,11 +25,11 @@ import ( type shardKey int const ( - // shardContextKey is the context key for a request + // shardContextKey is the context key for a request. shardContextKey shardKey = iota ) -// WithShardInContext returns a context with the given shard set +// WithShardInContext returns a context with the given shard set. func WithShardInContext(parent context.Context, shard shard.Name) context.Context { return context.WithValue(parent, shardContextKey, shard) } diff --git a/pkg/cache/client/round_tripper.go b/pkg/cache/client/round_tripper.go index 8048eee83cd..0f17f913c22 100644 --- a/pkg/cache/client/round_tripper.go +++ b/pkg/cache/client/round_tripper.go @@ -37,13 +37,13 @@ var ( // // Example: shards/name/remainder // Example: /shards/name/remainder - // Example: prefix/shards/name/remainder + // Example: prefix/shards/name/remainder. shardNameRegex = regexp.MustCompile(`shards/([^/]+)/.+`) ) // WithShardNameFromContextRoundTripper wraps an existing config's with ShardRoundTripper. // -// Note: it is the caller responsibility to make a copy of the rest config +// Note: it is the caller responsibility to make a copy of the rest config. func WithShardNameFromContextRoundTripper(cfg *rest.Config) *rest.Config { cfg.Wrap(func(rt http.RoundTripper) http.RoundTripper { return NewShardRoundTripper(rt) @@ -56,12 +56,12 @@ func WithShardNameFromContextRoundTripper(cfg *rest.Config) *rest.Config { // It changes the URL path to target a shard from the context. // // For example given "amber" shard name in the context it will change -// apis/apis.kcp.io/v1alpha1/apiexports to /shards/amber/apis/apis.kcp.io/v1alpha1/apiexports +// apis/apis.kcp.io/v1alpha1/apiexports to /shards/amber/apis/apis.kcp.io/v1alpha1/apiexports. type ShardRoundTripper struct { delegate http.RoundTripper } -// NewShardRoundTripper creates a new shard aware round tripper +// NewShardRoundTripper creates a new shard aware round tripper. func NewShardRoundTripper(delegate http.RoundTripper) *ShardRoundTripper { return &ShardRoundTripper{ delegate: delegate, @@ -87,7 +87,7 @@ func (c *ShardRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) return c.delegate.RoundTrip(req) } -// generatePath formats the request path to target the specified shard +// generatePath formats the request path to target the specified shard. func generatePath(originalPath string, shard clientshard.Name) (string, error) { // if the originalPath already has the shard then the path was already modified and no change needed if strings.HasPrefix(originalPath, shard.Path()) { @@ -122,7 +122,7 @@ func generatePath(originalPath string, shard clientshard.Name) (string, error) { // WithDefaultShardRoundTripper wraps an existing config's with DefaultShardRoundTripper // -// Note: it is the caller responsibility to make a copy of the rest config +// Note: it is the caller responsibility to make a copy of the rest config. func WithDefaultShardRoundTripper(cfg *rest.Config, shard clientshard.Name) *rest.Config { cfg.Wrap(func(rt http.RoundTripper) http.RoundTripper { return NewDefaultShardRoundTripper(rt, shard) @@ -130,13 +130,13 @@ func WithDefaultShardRoundTripper(cfg *rest.Config, shard clientshard.Name) *res return cfg } -// DefaultShardRoundTripper is a http.RoundTripper that sets a default shard name if not specified in the context +// DefaultShardRoundTripper is a http.RoundTripper that sets a default shard name if not specified in the context. type DefaultShardRoundTripper struct { delegate http.RoundTripper shard clientshard.Name } -// NewDefaultShardRoundTripper creates a new round tripper that sets a default shard name +// NewDefaultShardRoundTripper creates a new round tripper that sets a default shard name. func NewDefaultShardRoundTripper(delegate http.RoundTripper, shard clientshard.Name) *DefaultShardRoundTripper { return &DefaultShardRoundTripper{ delegate: delegate, @@ -153,7 +153,7 @@ func (c *DefaultShardRoundTripper) RoundTrip(req *http.Request) (*http.Response, // WithShardNameFromObjectRoundTripper wraps an existing config with ShardNameFromObjectRoundTripper. // -// Note: it is the caller responsibility to make a copy of the rest config +// Note: it is the caller responsibility to make a copy of the rest config. func WithShardNameFromObjectRoundTripper(cfg *rest.Config, requestInfoResolver func(*http.Request) (string, string, error), supportedResources ...string) *rest.Config { cfg.Wrap(func(rt http.RoundTripper) http.RoundTripper { return NewShardNameFromObjectRoundTripper(rt, requestInfoResolver, supportedResources...) @@ -162,7 +162,7 @@ func WithShardNameFromObjectRoundTripper(cfg *rest.Config, requestInfoResolver f return cfg } -// NewShardNameFromObjectRoundTripper creates a new ShardNameFromObjectRoundTripper for the given resources +// NewShardNameFromObjectRoundTripper creates a new ShardNameFromObjectRoundTripper for the given resources. func NewShardNameFromObjectRoundTripper(delegate http.RoundTripper, requestInfoResolver func(*http.Request) (string, string, error), supportedResources ...string) *ShardNameFromObjectRoundTripper { return &ShardNameFromObjectRoundTripper{ delegate: delegate, @@ -234,7 +234,7 @@ type CacheServiceRoundTripper struct { delegate http.RoundTripper } -// NewCacheServiceRoundTripper creates a new CacheServiceRoundTripper +// NewCacheServiceRoundTripper creates a new CacheServiceRoundTripper. func NewCacheServiceRoundTripper(delegate http.RoundTripper) *CacheServiceRoundTripper { return &CacheServiceRoundTripper{ delegate: delegate, diff --git a/pkg/cache/client/shard/shard.go b/pkg/cache/client/shard/shard.go index 2df19a02e43..6c1460b4b84 100644 --- a/pkg/cache/client/shard/shard.go +++ b/pkg/cache/client/shard/shard.go @@ -49,7 +49,7 @@ func (n Name) String() string { return string(n) } -// Empty returns true if the name of the shard is empty +// Empty returns true if the name of the shard is empty. func (n Name) Empty() bool { return n == "" } diff --git a/pkg/cache/server/bootstrap/bootstrap.go b/pkg/cache/server/bootstrap/bootstrap.go index 3b578455be0..7d9b82ec21b 100644 --- a/pkg/cache/server/bootstrap/bootstrap.go +++ b/pkg/cache/server/bootstrap/bootstrap.go @@ -38,7 +38,7 @@ import ( // We use the same name as the KCP for symmetry. var SystemCRDLogicalCluster = logicalcluster.Name("system:system-crds") -// SystemCacheServerShard holds a default shard name +// SystemCacheServerShard holds a default shard name. const SystemCacheServerShard = "system:cache:server" func Bootstrap(ctx context.Context, apiExtensionsClusterClient kcpapiextensionsclientset.ClusterInterface) error { diff --git a/pkg/cache/server/crd_lister.go b/pkg/cache/server/crd_lister.go index 2910af6b48b..ae3f2abc963 100644 --- a/pkg/cache/server/crd_lister.go +++ b/pkg/cache/server/crd_lister.go @@ -31,7 +31,7 @@ import ( "github.com/kcp-dev/kcp/pkg/cache/server/bootstrap" ) -// crdClusterLister is a CRD lister +// crdClusterLister is a CRD lister. type crdClusterLister struct { lister kcpapiextensionsv1listers.CustomResourceDefinitionClusterLister } @@ -48,7 +48,7 @@ func (c *crdClusterLister) Cluster(name logicalcluster.Name) kcp.ClusterAwareCRD var _ kcp.ClusterAwareCRDClusterLister = &crdClusterLister{} -// crdLister is a CRD lister +// crdLister is a CRD lister. type crdLister struct { *crdClusterLister cluster logicalcluster.Name @@ -56,7 +56,7 @@ type crdLister struct { var _ kcp.ClusterAwareCRDLister = &crdLister{} -// List lists all CustomResourceDefinitions +// List lists all CustomResourceDefinitions. func (c *crdLister) List(ctx context.Context, selector labels.Selector) ([]*apiextensionsv1.CustomResourceDefinition, error) { // TODO: make it shard and cluster aware, for now just return what we have in the system ws return c.lister.List(selector) @@ -66,7 +66,7 @@ func (c *crdLister) Refresh(crd *apiextensionsv1.CustomResourceDefinition) (*api return crd, nil } -// Get gets a CustomResourceDefinition +// Get gets a CustomResourceDefinition. func (c *crdLister) Get(ctx context.Context, name string) (*apiextensionsv1.CustomResourceDefinition, error) { // TODO: make it shard and cluster aware, for now just return what we have in the system ws return c.lister.Cluster(c.cluster).Get(name) diff --git a/pkg/cache/server/handler.go b/pkg/cache/server/handler.go index a4ccf2c580b..b801ccec05d 100644 --- a/pkg/cache/server/handler.go +++ b/pkg/cache/server/handler.go @@ -61,7 +61,7 @@ func init() { // // Note: // not all paths require to have a valid shard name, -// as of today the following paths pass through: "/livez", "/readyz", "/healthz" +// as of today the following paths pass through: "/livez", "/readyz", "/healthz". func WithShardScope(handler http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { if path := req.URL.Path; path == "/livez" || path == "/readyz" || path == "/healthz" { @@ -122,7 +122,7 @@ func WithShardScope(handler http.Handler) http.Handler { // WithServiceScope an HTTP filter that trims "/services/cache" prefix from the URL. // // for example: /services/cache/shards/amber/clusters/*/apis/apis.kcp.io/v1alpha1/apiexports -// is truncated to /shards/amber/clusters/*/apis/apis.kcp.io/v1alpha1/apiexports +// is truncated to /shards/amber/clusters/*/apis/apis.kcp.io/v1alpha1/apiexports. func WithServiceScope(handler http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { if path := req.URL.Path; strings.HasPrefix(path, "/services/cache") { diff --git a/pkg/cliplugins/bind/plugin/bind_compute.go b/pkg/cliplugins/bind/plugin/bind_compute.go index 4164b0e46b8..b03424fd34f 100644 --- a/pkg/cliplugins/bind/plugin/bind_compute.go +++ b/pkg/cliplugins/bind/plugin/bind_compute.go @@ -136,7 +136,7 @@ func (o *BindComputeOptions) Validate() error { return nil } -// Run creates a placement in the workspace, linking to the location workspace +// Run creates a placement in the workspace, linking to the location workspace. func (o *BindComputeOptions) Run(ctx context.Context) error { config, err := o.ClientConfig.ClientConfig() if err != nil { diff --git a/pkg/cliplugins/claims/cmd/cmd.go b/pkg/cliplugins/claims/cmd/cmd.go index df861b2fb6b..8b313a93272 100644 --- a/pkg/cliplugins/claims/cmd/cmd.go +++ b/pkg/cliplugins/claims/cmd/cmd.go @@ -27,7 +27,7 @@ import ( "github.com/kcp-dev/kcp/pkg/cliplugins/claims/plugin" ) -// TODO: Add examples for edit and update claims +// TODO: Add examples for edit and update claims. var ( claimsExample = ` # Lists the permission claims and their respective status related to a specific APIBinding. @@ -40,7 +40,6 @@ var ( // New returns a cobra.Command for claims related actions. func New(streams genericclioptions.IOStreams) *cobra.Command { - cliName := "kubectl" if pflag.CommandLine.Name() == "kubectl-kcp" { cliName = "kubectl kcp" diff --git a/pkg/cliplugins/crd/plugin/snapshot.go b/pkg/cliplugins/crd/plugin/snapshot.go index 733cb011a85..4dc9ab82785 100644 --- a/pkg/cliplugins/crd/plugin/snapshot.go +++ b/pkg/cliplugins/crd/plugin/snapshot.go @@ -46,7 +46,7 @@ type SnapshotOptions struct { OutputFormat string } -// NewSnapshotOptions provides an instance of SnapshotOptions with default values +// NewSnapshotOptions provides an instance of SnapshotOptions with default values. func NewSnapshotOptions(streams genericclioptions.IOStreams) *SnapshotOptions { o := &SnapshotOptions{ Options: base.NewOptions(streams), @@ -59,7 +59,7 @@ func NewSnapshotOptions(streams genericclioptions.IOStreams) *SnapshotOptions { } // BindFlags binds the arguments common to all sub-commands, -// to the corresponding main command flags +// to the corresponding main command flags. func (o *SnapshotOptions) BindFlags(cmd *cobra.Command) { cmd.Flags().StringVarP(&o.Filename, "filename", "f", o.Filename, "Path to a file containing the CRD to convert to an APIResourceSchema, or - for stdin") cmd.Flags().StringVar(&o.Prefix, "prefix", o.Prefix, "Prefix to use for the APIResourceSchema's name, before .") diff --git a/pkg/cliplugins/workload/plugin/sync.go b/pkg/cliplugins/workload/plugin/sync.go index a9e437719f6..4ae1f2c2036 100644 --- a/pkg/cliplugins/workload/plugin/sync.go +++ b/pkg/cliplugins/workload/plugin/sync.go @@ -638,7 +638,7 @@ func (o *SyncOptions) enableSyncerForWorkspace(ctx context.Context, config *rest return string(saTokenBytes), syncerID, syncTarget, nil } -// mergeOwnerReference: merge a slice of ownerReference with a given ownerReferences +// mergeOwnerReference: merge a slice of ownerReference with a given ownerReferences. func mergeOwnerReference(ownerReferences, newOwnerReferences []metav1.OwnerReference) []metav1.OwnerReference { var merged []metav1.OwnerReference @@ -658,7 +658,6 @@ func mergeOwnerReference(ownerReferences, newOwnerReferences []metav1.OwnerRefer } return merged - } // templateInput represents the external input required to render the resources to diff --git a/pkg/cliplugins/workload/plugin/workload.go b/pkg/cliplugins/workload/plugin/workload.go index 32c904de317..d593b9a29ee 100644 --- a/pkg/cliplugins/workload/plugin/workload.go +++ b/pkg/cliplugins/workload/plugin/workload.go @@ -98,7 +98,6 @@ func (o *CordonOptions) Run(ctx context.Context) error { var patchBytes []byte if o.Cordon { patchBytes = []byte(`[{"op":"replace","path":"/spec/unschedulable","value":true}]`) - } else { evict := `` if syncTarget.Spec.EvictAfter != nil { @@ -194,5 +193,4 @@ func (o *DrainOptions) Run(ctx context.Context) error { fmt.Fprintln(o.Out, o.SyncTarget, "draining") return nil - } diff --git a/pkg/cliplugins/workspace/plugin/kubeconfig.go b/pkg/cliplugins/workspace/plugin/kubeconfig.go index ca70fe82bc0..47d3c542c43 100644 --- a/pkg/cliplugins/workspace/plugin/kubeconfig.go +++ b/pkg/cliplugins/workspace/plugin/kubeconfig.go @@ -369,7 +369,6 @@ func findUnresolvedPermissionClaims(out io.Writer, apiBindings []apisv1alpha1.AP } found = true ack = (specClaim.State == apisv1alpha1.ClaimAccepted) || specClaim.State == apisv1alpha1.ClaimRejected - } if !found { fmt.Fprintf(out, "Warning: claim for %s exported but not specified on APIBinding %s\nAdd this claim to the APIBinding's Spec.\n", exportedClaim.String(), binding.Name) @@ -756,7 +755,7 @@ func newKCPClusterClient(clientConfig clientcmd.ClientConfig) (kcpclientset.Clus return kcpclientset.NewForConfig(clusterConfig) } -// TreeOptions contains options for displaying the workspace tree +// TreeOptions contains options for displaying the workspace tree. type TreeOptions struct { *base.Options diff --git a/pkg/crdpuller/discovery.go b/pkg/crdpuller/discovery.go index e013889a704..b0bf868f3bb 100644 --- a/pkg/crdpuller/discovery.go +++ b/pkg/crdpuller/discovery.go @@ -128,7 +128,6 @@ func (sp *schemaPuller) PullCRDs(ctx context.Context, resourceNames ...string) ( for _, apiResource := range apiResourcesList.APIResources { apiResourceNames[gv].Insert(apiResource.Name) } - } crds := map[schema.GroupResource]*apiextensionsv1.CustomResourceDefinition{} diff --git a/pkg/dns/plugin/nsmap/config.go b/pkg/dns/plugin/nsmap/config.go index d42bc6b97f1..30ec6573ccd 100644 --- a/pkg/dns/plugin/nsmap/config.go +++ b/pkg/dns/plugin/nsmap/config.go @@ -31,7 +31,7 @@ import ( ) var ( - // ConfigMapName is the name of the configmap containing logical to physical namespace mappings + // ConfigMapName is the name of the configmap containing logical to physical namespace mappings. ConfigMapName = "config-nsmap" ) diff --git a/pkg/dns/plugin/nsmap/namespace.go b/pkg/dns/plugin/nsmap/namespace.go index 2bfe3ec8fd1..eb4cd2e12e0 100644 --- a/pkg/dns/plugin/nsmap/namespace.go +++ b/pkg/dns/plugin/nsmap/namespace.go @@ -74,5 +74,4 @@ func (m *namespaceRewriter) Rewrite(ctx context.Context, state request.Request) &coredns.NameRewriterResponseRule{RemapStringRewriter: rewriter}, &coredns.ValueRewriterResponseRule{RemapStringRewriter: rewriter}, } - } diff --git a/pkg/features/kcp_features.go b/pkg/features/kcp_features.go index 72e0346e697..bf2902a0004 100644 --- a/pkg/features/kcp_features.go +++ b/pkg/features/kcp_features.go @@ -35,7 +35,7 @@ const ( // // // owner: @username // // alpha: v1.4 - // MyFeature() bool + // MyFeature() bool. // owner: @sttts // alpha: v0.4 diff --git a/pkg/indexers/indexers.go b/pkg/indexers/indexers.go index 3077fcf93b8..12d52420094 100644 --- a/pkg/indexers/indexers.go +++ b/pkg/indexers/indexers.go @@ -128,7 +128,7 @@ func ByIndex[T runtime.Object](indexer cache.Indexer, indexName, indexValue stri } // ByPathAndName returns the instance of T from the indexer with the matching path and name. Path may be a canonical path -// or a cluster name. Note: this depends on the presence of the optional "kcp.dev/path" annotation. +// or a cluster name. Note: this depends on the presence of the optional "kcp.io/path" annotation. func ByPathAndName[T runtime.Object](groupResource schema.GroupResource, indexer cache.Indexer, path logicalcluster.Path, name string) (ret T, err error) { objs, err := indexer.ByIndex(ByLogicalClusterPathAndName, path.Join(name).String()) if err != nil { diff --git a/pkg/informer/informer.go b/pkg/informer/informer.go index 83b237298cb..be658369f53 100644 --- a/pkg/informer/informer.go +++ b/pkg/informer/informer.go @@ -84,7 +84,7 @@ type GVRSource interface { } // genericInformerBase is a base interface that would be satisfied by both -// cluster-aware and cluster-unaware generic informers +// cluster-aware and cluster-unaware generic informers. type genericInformerBase[Informer cache.SharedIndexInformer, Lister genericListerBase] interface { // Informer is the shared index informer returned by the generic informer. // It would be either a SharedIndexInformer or a ScopeableSharedIndexInformer, @@ -829,7 +829,6 @@ func NewCRDGVRSource(informer cache.SharedIndexInformer) (*crdGVRSource, error) crdInformer: informer, crdIndexer: informer.GetIndexer(), }, nil - } func byGroupVersionResourceKeyFunc(group, version, resource string) string { @@ -859,7 +858,7 @@ type crdGVRSource struct { crdIndexer cache.Indexer } -// Hard-code built in types that support list+watch +// Hard-code built in types that support list+watch. var builtInInformableTypes map[schema.GroupVersionResource]GVRPartialMetadata = map[schema.GroupVersionResource]GVRPartialMetadata{ gvrFor("", "v1", "configmaps"): withGVRPartialMetadata(apiextensionsv1.NamespaceScoped, "ConfigMap", "configmap"), gvrFor("", "v1", "events"): withGVRPartialMetadata(apiextensionsv1.NamespaceScoped, "Event", "event"), diff --git a/pkg/proxy/config.go b/pkg/proxy/config.go index 28ac9ab29a7..047a91d34b3 100644 --- a/pkg/proxy/config.go +++ b/pkg/proxy/config.go @@ -68,7 +68,7 @@ func (c *Config) Complete() (CompletedConfig, error) { }}, nil } -// NewConfig returns a new Config for the given options +// NewConfig returns a new Config for the given options. func NewConfig(opts *proxyoptions.Options) (*Config, error) { c := &Config{ Options: opts, diff --git a/pkg/proxy/metrics/metrics.go b/pkg/proxy/metrics/metrics.go index 8de2b7cb626..bf79be797be 100644 --- a/pkg/proxy/metrics/metrics.go +++ b/pkg/proxy/metrics/metrics.go @@ -32,7 +32,7 @@ func WithLatencyTracking(delegate http.Handler) http.Handler { return promhttp.InstrumentHandlerDuration(requestLatencies.HistogramVec, delegate) } -// TODO(csams): enhance metrics to include shard url +// TODO(csams): enhance metrics to include shard url. var ( requestLatencies = compbasemetrics.NewHistogramVec( &compbasemetrics.HistogramOpts{ diff --git a/pkg/proxy/options/authentication.go b/pkg/proxy/options/authentication.go index aa141765457..0f4248dc2fa 100644 --- a/pkg/proxy/options/authentication.go +++ b/pkg/proxy/options/authentication.go @@ -39,14 +39,14 @@ import ( // Authentication wraps BuiltInAuthenticationOptions so we can minimize the // dependencies on apiserver auth machinery, specifically by overriding the // ApplyTo so we can remove those config dependencies not relevant to the -// subset of auth methods we enable in the proxy +// subset of auth methods we enable in the proxy. type Authentication struct { BuiltInOptions *kubeoptions.BuiltInAuthenticationOptions PassOnGroups []string DropGroups []string } -// NewAuthentication creates a default Authentication +// NewAuthentication creates a default Authentication. func NewAuthentication() *Authentication { auth := &Authentication{ BuiltInOptions: kubeoptions.NewBuiltInAuthenticationOptions(). @@ -61,7 +61,7 @@ func NewAuthentication() *Authentication { return auth } -// When configured to enable auth other than ClientCert, this returns true +// When configured to enable auth other than ClientCert, this returns true. func (c *Authentication) AdditionalAuthEnabled() bool { return c.tokenAuthEnabled() || c.serviceAccountAuthEnabled() || c.oidcAuthEnabled() } @@ -149,7 +149,7 @@ func (c *Authentication) ApplyTo(authenticationInfo *genericapiserver.Authentica return nil } -// AddFlags delegates to ClientCertAuthenticationOptions +// AddFlags delegates to ClientCertAuthenticationOptions. func (c *Authentication) AddFlags(fs *pflag.FlagSet) { c.BuiltInOptions.AddFlags(fs) diff --git a/pkg/reconciler/apis/apibinding/conflict_checker.go b/pkg/reconciler/apis/apibinding/conflict_checker.go index 8234bf69afd..c402a8e6efb 100644 --- a/pkg/reconciler/apis/apibinding/conflict_checker.go +++ b/pkg/reconciler/apis/apibinding/conflict_checker.go @@ -28,7 +28,7 @@ import ( apisv1alpha1 "github.com/kcp-dev/kcp/pkg/apis/apis/v1alpha1" ) -// byUID implements sort.Interface based on the UID field of CustomResourceDefinition +// byUID implements sort.Interface based on the UID field of CustomResourceDefinition. type byUID []*apiextensionsv1.CustomResourceDefinition func (u byUID) Len() int { return len(u) } diff --git a/pkg/reconciler/apis/apibindingdeletion/apibinding_deletion_controller.go b/pkg/reconciler/apis/apibindingdeletion/apibinding_deletion_controller.go index 4c0551a2384..fc55443349d 100644 --- a/pkg/reconciler/apis/apibindingdeletion/apibinding_deletion_controller.go +++ b/pkg/reconciler/apis/apibindingdeletion/apibinding_deletion_controller.go @@ -56,11 +56,11 @@ const ( DeletionRecheckEstimateSeconds = 5 // ResourceDeletionFailedReason is the reason for condition BindingResourceDeleteSuccess that deletion of - // some CRs is failed + // some CRs is failed. ResourceDeletionFailedReason = "ResourceDeletionFailed" // ResourceRemainingReason is the reason for condition BindingResourceDeleteSuccess that some CR resource still - // exists when apibinding is deleting + // exists when apibinding is deleting. ResourceRemainingReason = "SomeResourcesRemain" // ResourceFinalizersRemainReason is the reason for condition BindingResourceDeleteSuccess that finalizers on some diff --git a/pkg/reconciler/apis/apiresource/negotiation.go b/pkg/reconciler/apis/apiresource/negotiation.go index 23d6e8d7970..b578af5f67b 100644 --- a/pkg/reconciler/apis/apiresource/negotiation.go +++ b/pkg/reconciler/apis/apiresource/negotiation.go @@ -39,7 +39,6 @@ import ( ) func (c *Controller) process(ctx context.Context, key queueElement) error { - ctx = request.WithCluster(ctx, request.Cluster{Name: key.clusterName}) switch key.theType { @@ -204,7 +203,7 @@ func NegotiatedAPIResourceAsOwnerReference(obj *apiresourcev1alpha1.NegotiatedAP } // isManuallyCreatedCRD detects if a CRD was created manually. -// This can be deduced from the fact that it doesn't have any NegotiatedAPIResource owner reference +// This can be deduced from the fact that it doesn't have any NegotiatedAPIResource owner reference. func (c *Controller) isManuallyCreatedCRD(ctx context.Context, crd *apiextensionsv1.CustomResourceDefinition) bool { for _, reference := range crd.OwnerReferences { if reference.APIVersion == apiresourcev1alpha1.SchemeGroupVersion.String() && @@ -216,7 +215,7 @@ func (c *Controller) isManuallyCreatedCRD(ctx context.Context, crd *apiextension } // enforceCRDToNegotiatedAPIResource sets the Enforced status condition, -// and then updates the schema of the Negotiated API Resource of each CRD version +// and then updates the schema of the Negotiated API Resource of each CRD version. func (c *Controller) enforceCRDToNegotiatedAPIResource(ctx context.Context, clusterName logicalcluster.Name, gvr metav1.GroupVersionResource, crd *apiextensionsv1.CustomResourceDefinition) error { logger := klog.FromContext(ctx) for _, version := range crd.Spec.Versions { @@ -254,7 +253,7 @@ func (c *Controller) enforceCRDToNegotiatedAPIResource(ctx context.Context, clus return nil } -// setPublishingStatusOnNegotiatedAPIResource sets the status (Published / Refused) on the Negotiated API Resource for a CRD version +// setPublishingStatusOnNegotiatedAPIResource sets the status (Published / Refused) on the Negotiated API Resource for a CRD version. func (c *Controller) setPublishingStatusOnNegotiatedAPIResource(ctx context.Context, clusterName logicalcluster.Name, gvr metav1.GroupVersionResource, negotiatedAPIResource *apiresourcev1alpha1.NegotiatedAPIResource, crd *apiextensionsv1.CustomResourceDefinition) { if crdhelpers.IsCRDConditionTrue(crd, apiextensionsv1.Established) && crdhelpers.IsCRDConditionTrue(crd, apiextensionsv1.NamesAccepted) && @@ -284,7 +283,7 @@ func (c *Controller) setPublishingStatusOnNegotiatedAPIResource(ctx context.Cont }) } -// updatePublishingStatusOnNegotiatedAPIResources sets the status (Published / Refused) on the Negotiated API Resource of each CRD version +// updatePublishingStatusOnNegotiatedAPIResources sets the status (Published / Refused) on the Negotiated API Resource of each CRD version. func (c *Controller) updatePublishingStatusOnNegotiatedAPIResources(ctx context.Context, clusterName logicalcluster.Name, gvr metav1.GroupVersionResource, crd *apiextensionsv1.CustomResourceDefinition) error { logger := klog.FromContext(ctx) for _, version := range crd.Spec.Versions { @@ -621,7 +620,7 @@ func (c *Controller) negotiatedAPIResourceIsOrphan(ctx context.Context, clusterN return !negotiatedAPIResource.IsConditionTrue(apiresourcev1alpha1.Enforced), nil } -// publishNegotiatedResource publishes the NegotiatedAPIResource information as a CRD, unless a manually-added CRD already exists for this GVR +// publishNegotiatedResource publishes the NegotiatedAPIResource information as a CRD, unless a manually-added CRD already exists for this GVR. func (c *Controller) publishNegotiatedResource(ctx context.Context, clusterName logicalcluster.Name, gvr metav1.GroupVersionResource, negotiatedApiResource *apiresourcev1alpha1.NegotiatedAPIResource) error { logger := klog.FromContext(ctx) crdName := gvr.Resource @@ -783,7 +782,7 @@ func (c *Controller) publishNegotiatedResource(ctx context.Context, clusterName return nil } -// updateStatusOnRelatedAPIResourceImports udates the status of related compatible APIResourceImports, to set the `Available` condition to `true` +// updateStatusOnRelatedAPIResourceImports udates the status of related compatible APIResourceImports, to set the `Available` condition to `true`. func (c *Controller) updateStatusOnRelatedAPIResourceImports(ctx context.Context, clusterName logicalcluster.Name, gvr metav1.GroupVersionResource, negotiatedApiResource *apiresourcev1alpha1.NegotiatedAPIResource) error { logger := klog.FromContext(ctx) publishedCondition := negotiatedApiResource.FindCondition(apiresourcev1alpha1.Published) @@ -808,7 +807,7 @@ func (c *Controller) updateStatusOnRelatedAPIResourceImports(ctx context.Context return nil } -// cleanupNegotiatedAPIResource does the required cleanup of related resources (CRD,APIResourceImport) after a NegotiatedAPIResource has been deleted +// cleanupNegotiatedAPIResource does the required cleanup of related resources (CRD,APIResourceImport) after a NegotiatedAPIResource has been deleted. func (c *Controller) cleanupNegotiatedAPIResource(ctx context.Context, clusterName logicalcluster.Name, gvr metav1.GroupVersionResource, negotiatedApiResource *apiresourcev1alpha1.NegotiatedAPIResource) error { logger := klog.FromContext(ctx) // In any case change the status on every APIResourceImport with the same GVR, to remove Compatible and Available conditions. diff --git a/pkg/reconciler/apis/apiresource/startup.go b/pkg/reconciler/apis/apiresource/startup.go index 3154e6e550b..91d2e7565d8 100644 --- a/pkg/reconciler/apis/apiresource/startup.go +++ b/pkg/reconciler/apis/apiresource/startup.go @@ -40,7 +40,7 @@ func BindOptions(o *Options, fs *pflag.FlagSet) *Options { return o } -// Options are the options for the cluster controller +// Options are the options for the cluster controller. type Options struct { AutoPublishAPIs bool NumThreads int diff --git a/pkg/reconciler/apis/crdcleanup/crdcleanup_controller.go b/pkg/reconciler/apis/crdcleanup/crdcleanup_controller.go index 23bbe882849..c6897df4ef1 100644 --- a/pkg/reconciler/apis/crdcleanup/crdcleanup_controller.go +++ b/pkg/reconciler/apis/crdcleanup/crdcleanup_controller.go @@ -50,7 +50,7 @@ const ( AgeThreshold time.Duration = time.Minute * 30 ) -// NewController returns a new controller for CRD cleanup +// NewController returns a new controller for CRD cleanup. func NewController( crdInformer kcpapiextensionsv1informers.CustomResourceDefinitionClusterInformer, crdClusterClient kcpapiextensionsclientset.ClusterInterface, @@ -114,7 +114,7 @@ func NewController( return c, nil } -// controller deletes bound CRDs when they are no longer in use by any APIBindings +// controller deletes bound CRDs when they are no longer in use by any APIBindings. type controller struct { queue workqueue.RateLimitingInterface diff --git a/pkg/reconciler/apis/crdcleanup/crdcleanup_controller_test.go b/pkg/reconciler/apis/crdcleanup/crdcleanup_controller_test.go index 75e402d714a..ad2910ff67d 100644 --- a/pkg/reconciler/apis/crdcleanup/crdcleanup_controller_test.go +++ b/pkg/reconciler/apis/crdcleanup/crdcleanup_controller_test.go @@ -154,7 +154,6 @@ func TestBoundCRDDeletion(t *testing.T) { // This should be enough time passing to trigger a delete (if expected) testController(tt.creationTimestamp.Add((AgeThreshold+time.Second)*-1), tt.expectDeletionAfterRequeue) - } }) } diff --git a/pkg/reconciler/apis/permissionclaimlabel/permissionclaimlabel_controller.go b/pkg/reconciler/apis/permissionclaimlabel/permissionclaimlabel_controller.go index f7888e93fc1..effaedec454 100644 --- a/pkg/reconciler/apis/permissionclaimlabel/permissionclaimlabel_controller.go +++ b/pkg/reconciler/apis/permissionclaimlabel/permissionclaimlabel_controller.go @@ -92,7 +92,6 @@ func NewController( }) return c, nil - } // controller reconciles resource labels that make claimed resources visible to an APIExport @@ -224,7 +223,6 @@ func (c *controller) process(ctx context.Context, key string) error { logger.V(2).Info("patching APIBinding", "patch", string(patchBytes)) if _, err := c.kcpClusterClient.Cluster(clusterName.Path()).ApisV1alpha1().APIBindings().Patch(ctx, obj.Name, types.MergePatchType, patchBytes, metav1.PatchOptions{}, "status"); err != nil { errs = append(errs, err) - } } diff --git a/pkg/reconciler/apis/permissionclaimlabel/permissionclaimlabel_resource_controller.go b/pkg/reconciler/apis/permissionclaimlabel/permissionclaimlabel_resource_controller.go index a81a00e4213..70ead9577a0 100644 --- a/pkg/reconciler/apis/permissionclaimlabel/permissionclaimlabel_resource_controller.go +++ b/pkg/reconciler/apis/permissionclaimlabel/permissionclaimlabel_resource_controller.go @@ -79,7 +79,6 @@ func NewResourceController( }) return c, nil - } // resourceController reconciles resources from the ddsif, and will determine if it needs diff --git a/pkg/reconciler/cache/replication/indexers.go b/pkg/reconciler/cache/replication/indexers.go index e3db4801d87..d87d4bccd2b 100644 --- a/pkg/reconciler/cache/replication/indexers.go +++ b/pkg/reconciler/cache/replication/indexers.go @@ -26,11 +26,11 @@ import ( ) const ( - // ByShardAndLogicalClusterAndNamespaceAndName is the name for the index that indexes by an object's shard and logical cluster, namespace and name + // ByShardAndLogicalClusterAndNamespaceAndName is the name for the index that indexes by an object's shard and logical cluster, namespace and name. ByShardAndLogicalClusterAndNamespaceAndName = "kcp-byShardAndLogicalClusterAndNamespaceAndName" ) -// IndexByShardAndLogicalClusterAndNamespace is an index function that indexes by an object's shard and logical cluster, namespace and name +// IndexByShardAndLogicalClusterAndNamespace is an index function that indexes by an object's shard and logical cluster, namespace and name. func IndexByShardAndLogicalClusterAndNamespace(obj interface{}) ([]string, error) { a, err := meta.Accessor(obj) if err != nil { diff --git a/pkg/reconciler/cache/replication/replication_controller.go b/pkg/reconciler/cache/replication/replication_controller.go index b1617e8cc89..5083e521cf2 100644 --- a/pkg/reconciler/cache/replication/replication_controller.go +++ b/pkg/reconciler/cache/replication/replication_controller.go @@ -51,7 +51,7 @@ const ( // // The replicated object will be placed under the same cluster as the original object. // In addition to that, all replicated objects will be placed under the shard taken from the shardName argument. -// For example: shards/{shardName}/clusters/{clusterName}/apis/apis.kcp.io/v1alpha1/apiexports +// For example: shards/{shardName}/clusters/{clusterName}/apis/apis.kcp.io/v1alpha1/apiexports. func NewController( shardName string, dynamicCacheClient kcpdynamic.ClusterInterface, diff --git a/pkg/reconciler/cache/replication/replication_reconcile_unstructured.go b/pkg/reconciler/cache/replication/replication_reconcile_unstructured.go index 2d7e04cf308..c959465063e 100644 --- a/pkg/reconciler/cache/replication/replication_reconcile_unstructured.go +++ b/pkg/reconciler/cache/replication/replication_reconcile_unstructured.go @@ -95,7 +95,7 @@ func (c *controller) handleObjectDeletion(ctx context.Context, cluster logicalcl return nil } -// ensureMeta changes unstructuredCacheObject's metadata to match unstructuredLocalObject's metadata except the ResourceVersion and the shard annotation fields +// ensureMeta changes unstructuredCacheObject's metadata to match unstructuredLocalObject's metadata except the ResourceVersion and the shard annotation fields. func ensureMeta(cacheObject *unstructured.Unstructured, localObject *unstructured.Unstructured) (changed bool, err error) { cacheObjMetaRaw, hasCacheObjMetaRaw, err := unstructured.NestedFieldNoCopy(cacheObject.Object, "metadata") if err != nil { diff --git a/pkg/reconciler/committer/committer.go b/pkg/reconciler/committer/committer.go index 165f87d4156..077b85c1199 100644 --- a/pkg/reconciler/committer/committer.go +++ b/pkg/reconciler/committer/committer.go @@ -32,19 +32,19 @@ import ( "k8s.io/klog/v2" ) -// Resource is a generic wrapper around resources so we can generate patches +// Resource is a generic wrapper around resources so we can generate patches. type Resource[Sp any, St any] struct { metav1.ObjectMeta `json:"metadata,omitempty"` Spec Sp `json:"spec"` Status St `json:"status,omitempty"` } -// ClusterPatcher is just the cluster-aware Patch API with a generic to keep use sites type safe +// ClusterPatcher is just the cluster-aware Patch API with a generic to keep use sites type safe. type ClusterPatcher[R runtime.Object, P Patcher[R]] interface { Cluster(cluster logicalcluster.Path) P } -// Patcher is just the Patch API with a generic to keep use sites type safe +// Patcher is just the Patch API with a generic to keep use sites type safe. type Patcher[R runtime.Object] interface { Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (R, error) } @@ -74,7 +74,6 @@ func NewCommitter[R runtime.Object, P Patcher[R], Sp any, St any](patcher Cluste return nil } - } // NewCommitterScoped returns a function that can patch instances of R based on meta, spec or diff --git a/pkg/reconciler/coordination/deployment/deployment_controller.go b/pkg/reconciler/coordination/deployment/deployment_controller.go index 1dfb6eb6778..6c4e8108487 100644 --- a/pkg/reconciler/coordination/deployment/deployment_controller.go +++ b/pkg/reconciler/coordination/deployment/deployment_controller.go @@ -113,7 +113,7 @@ func NewController( return c, nil } -// controller reconciles watches deployments and coordinates them between SyncTargets +// controller reconciles watches deployments and coordinates them between SyncTargets. type controller struct { upstreamViewQueue workqueue.RateLimitingInterface syncerViewQueue workqueue.RateLimitingInterface diff --git a/pkg/reconciler/coordination/deployment/deployment_controller_test.go b/pkg/reconciler/coordination/deployment/deployment_controller_test.go index 0f50b257cae..9a02ba5548a 100644 --- a/pkg/reconciler/coordination/deployment/deployment_controller_test.go +++ b/pkg/reconciler/coordination/deployment/deployment_controller_test.go @@ -131,7 +131,6 @@ func TestUpstreamViewReconciler(t *testing.T) { for name, tc := range tests { t.Run(name, func(t *testing.T) { - var patcher *mockedPatcher controller := controller{ getDeployment: func(lclusterName logicalcluster.Name, namespace, name string) (*appsv1.Deployment, error) { @@ -256,7 +255,6 @@ func TestSyncerViewReconciler(t *testing.T) { for name, tc := range tests { t.Run(name, func(t *testing.T) { - var patcher *mockedPatcher controller := controller{ getDeployment: func(lclusterName logicalcluster.Name, namespace, name string) (*appsv1.Deployment, error) { diff --git a/pkg/reconciler/core/logicalclusterdeletion/deletion/logicalcluster_resource_deletor.go b/pkg/reconciler/core/logicalclusterdeletion/deletion/logicalcluster_resource_deletor.go index 5910c09e7be..24a01f9556c 100644 --- a/pkg/reconciler/core/logicalclusterdeletion/deletion/logicalcluster_resource_deletor.go +++ b/pkg/reconciler/core/logicalclusterdeletion/deletion/logicalcluster_resource_deletor.go @@ -68,7 +68,7 @@ const ( // This is a copy from namespace deleteor in k8s with some modification: // - change the condition update code // - remove opCache -// - update deleteCollection to delete resources from all namespaces +// - update deleteCollection to delete resources from all namespaces. type WorkspaceResourcesDeleterInterface interface { Delete(ctx context.Context, cluster *corev1alpha1.LogicalCluster) error } @@ -464,7 +464,7 @@ func (d *logicalClusterResourcesDeleter) deleteAllContent(ctx context.Context, w return estimate, "", nil } -// estimateGracefulTermination will estimate the graceful termination required for the specific entity in the logical cluster +// estimateGracefulTermination will estimate the graceful termination required for the specific entity in the logical cluster. func (d *logicalClusterResourcesDeleter) estimateGracefulTermination(ctx context.Context, gvr schema.GroupVersionResource, clusterName logicalcluster.Name, clusterDeletedAt metav1.Time) (int64, error) { logger := klog.FromContext(ctx).WithValues("operation", "estimateGracefulTermination", "gvr", gvr) logger.V(5).Info("running operation") @@ -516,7 +516,7 @@ func (vr isNotVirtualResource) Match(groupVersion string, r *metav1.APIResource) type isNotNamespaceScoped struct{} -// Match checks if the resource is a cluster scoped resource +// Match checks if the resource is a cluster scoped resource. func (n isNotNamespaceScoped) Match(groupVersion string, r *metav1.APIResource) bool { return !r.Namespaced } diff --git a/pkg/reconciler/core/logicalclusterdeletion/deletion/logicalcluster_resource_deletor_test.go b/pkg/reconciler/core/logicalclusterdeletion/deletion/logicalcluster_resource_deletor_test.go index ce045d4d05d..cf132acd6d2 100644 --- a/pkg/reconciler/core/logicalclusterdeletion/deletion/logicalcluster_resource_deletor_test.go +++ b/pkg/reconciler/core/logicalclusterdeletion/deletion/logicalcluster_resource_deletor_test.go @@ -43,7 +43,7 @@ func init() { utilruntime.Must(metav1.AddMetaToScheme(scheme)) } -// TODO:(p0lyn0mial, sttts) rework this test to use Workspace +// TODO:(p0lyn0mial, sttts) rework this test to use Workspace. func TestWorkspaceTerminating(t *testing.T) { now := metav1.Now() ws := &corev1alpha1.LogicalCluster{ diff --git a/pkg/reconciler/core/logicalclusterdeletion/logicalcluster_deletion_controller.go b/pkg/reconciler/core/logicalclusterdeletion/logicalcluster_deletion_controller.go index 0cea442e44b..b34c838e33a 100644 --- a/pkg/reconciler/core/logicalclusterdeletion/logicalcluster_deletion_controller.go +++ b/pkg/reconciler/core/logicalclusterdeletion/logicalcluster_deletion_controller.go @@ -281,7 +281,7 @@ func (c *Controller) patchCondition(ctx context.Context, old, new *corev1alpha1. return err } -// finalizeNamespace removes the specified finalizer and finalizes the logical cluster +// finalizeNamespace removes the specified finalizer and finalizes the logical cluster. func (c *Controller) finalizeWorkspace(ctx context.Context, ws *corev1alpha1.LogicalCluster) error { logger := klog.FromContext(ctx) for i := range ws.Finalizers { diff --git a/pkg/reconciler/scheduling/location/location_controller.go b/pkg/reconciler/scheduling/location/location_controller.go index e7626c4cc38..358eeabd46d 100644 --- a/pkg/reconciler/scheduling/location/location_controller.go +++ b/pkg/reconciler/scheduling/location/location_controller.go @@ -107,7 +107,7 @@ func NewController( return c, nil } -// controller +// controller. type controller struct { queue workqueue.RateLimitingInterface enqueueAfter func(*schedulingv1alpha1.Location, time.Duration) diff --git a/pkg/reconciler/scheduling/placement/placement_controller.go b/pkg/reconciler/scheduling/placement/placement_controller.go index 5be9ff4fead..4824712d77f 100644 --- a/pkg/reconciler/scheduling/placement/placement_controller.go +++ b/pkg/reconciler/scheduling/placement/placement_controller.go @@ -145,7 +145,7 @@ func NewController( return c, nil } -// controller +// controller. type controller struct { queue workqueue.RateLimitingInterface enqueueAfter func(*corev1.Namespace, time.Duration) diff --git a/pkg/reconciler/tenancy/initialization/apibinder_initializer_controller.go b/pkg/reconciler/tenancy/initialization/apibinder_initializer_controller.go index f8b74acd343..350b4a829dd 100644 --- a/pkg/reconciler/tenancy/initialization/apibinder_initializer_controller.go +++ b/pkg/reconciler/tenancy/initialization/apibinder_initializer_controller.go @@ -112,7 +112,6 @@ func NewAPIBinder( apiBindingsInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { c.enqueueAPIBinding(obj, logger) - }, UpdateFunc: func(_, obj interface{}) { c.enqueueAPIBinding(obj, logger) @@ -196,7 +195,7 @@ func (b *APIBinder) enqueueAPIBinding(obj interface{}, logger logr.Logger) { // how the informer is supposed to be configured) whenever a workspacetype changes. If a workspacetype // had a typo in the default set of apibindings, there is a chance the requeuing here would pick up a fix. // -// TODO(sttts): this cannot work in a sharded environment +// TODO(sttts): this cannot work in a sharded environment. func (b *APIBinder) enqueueWorkspaceTypes(obj interface{}, logger logr.Logger) { cwt, ok := obj.(*tenancyv1alpha1.WorkspaceType) if !ok { diff --git a/pkg/reconciler/workload/apiexport/workload_apiexport_reconcile.go b/pkg/reconciler/workload/apiexport/workload_apiexport_reconcile.go index f03cd4368b7..1908f88f1e1 100644 --- a/pkg/reconciler/workload/apiexport/workload_apiexport_reconcile.go +++ b/pkg/reconciler/workload/apiexport/workload_apiexport_reconcile.go @@ -48,7 +48,7 @@ const ( ) // rootComputeResourceSchema are the APIResourceSchemas which should not be added into the APIExport. These are -// APIResourceSchemas of kubernetes in root:compute workspace +// APIResourceSchemas of kubernetes in root:compute workspace. var rootComputeResourceSchema = sets.NewString( "deployments.apps", "services.core", diff --git a/pkg/reconciler/workload/namespace/namespace_controller.go b/pkg/reconciler/workload/namespace/namespace_controller.go index 199c067c1de..eb8815dcb8c 100644 --- a/pkg/reconciler/workload/namespace/namespace_controller.go +++ b/pkg/reconciler/workload/namespace/namespace_controller.go @@ -117,7 +117,7 @@ func NewController( return c, nil } -// controller +// controller. type controller struct { queue workqueue.RateLimitingInterface enqueueAfter func(*corev1.Namespace, time.Duration) diff --git a/pkg/reconciler/workload/placement/placement_controller.go b/pkg/reconciler/workload/placement/placement_controller.go index 5cdf59e6cfd..df3aefce9ae 100644 --- a/pkg/reconciler/workload/placement/placement_controller.go +++ b/pkg/reconciler/workload/placement/placement_controller.go @@ -55,7 +55,7 @@ const ( byLocationWorkspace = ControllerName + "-byLocationWorkspace" ) -// NewController returns a new controller starting the process of selecting synctarget for a placement +// NewController returns a new controller starting the process of selecting synctarget for a placement. func NewController( kcpClusterClient kcpclientset.ClusterInterface, locationInformer schedulinginformers.LocationClusterInformer, @@ -159,7 +159,7 @@ type Patcher = schedulingv1alpha1client.PlacementInterface type Resource = committer.Resource[*PlacementSpec, *PlacementStatus] type CommitFunc = func(context.Context, *Resource, *Resource) error -// controller +// controller. type controller struct { queue workqueue.RateLimitingInterface diff --git a/pkg/reconciler/workload/placement/placement_reconcile.go b/pkg/reconciler/workload/placement/placement_reconcile.go index 911c81d2bc0..adc1e0dd451 100644 --- a/pkg/reconciler/workload/placement/placement_reconcile.go +++ b/pkg/reconciler/workload/placement/placement_reconcile.go @@ -87,7 +87,7 @@ func (c *controller) patchPlacement(ctx context.Context, clusterName logicalclus return c.kcpClusterClient.Cluster(clusterName).SchedulingV1alpha1().Placements().Patch(ctx, name, pt, data, opts, subresources...) } -// listWorkloadAPIBindings list all compute apibindings +// listWorkloadAPIBindings list all compute apibindings. func (c *controller) listWorkloadAPIBindings(clusterName logicalcluster.Name) ([]*apisv1alpha1.APIBinding, error) { apiBindings, err := c.apiBindingLister.Cluster(clusterName).List(labels.Everything()) if err != nil { diff --git a/pkg/reconciler/workload/resource/resource_controller.go b/pkg/reconciler/workload/resource/resource_controller.go index 718893a293d..6d6f2f5fd14 100644 --- a/pkg/reconciler/workload/resource/resource_controller.go +++ b/pkg/reconciler/workload/resource/resource_controller.go @@ -124,7 +124,6 @@ func NewController( !reflect.DeepEqual(scheduleStateAnnotations(oldNS.Annotations), scheduleStateAnnotations(newNS.Annotations)) { c.enqueueNamespace(obj) } - }, DeleteFunc: nil, // Nothing to do. }, @@ -307,7 +306,7 @@ func processNext( return true } -// key is gvr::KEY +// key is gvr::KEY. func (c *Controller) processResource(ctx context.Context, key string) error { logger := klog.FromContext(ctx) parts := strings.SplitN(key, "::", 2) diff --git a/pkg/reconciler/workload/resource/resource_reconcile.go b/pkg/reconciler/workload/resource/resource_reconcile.go index ae70c3880f3..f892024a870 100644 --- a/pkg/reconciler/workload/resource/resource_reconcile.go +++ b/pkg/reconciler/workload/resource/resource_reconcile.go @@ -209,7 +209,7 @@ func propagateDeletionTimestamp(logger logr.Logger, obj metav1.Object) map[strin return annotationPatch } -// computePlacement computes the patch against annotations and labels. Nil means to remove the key.ResourceStatePending +// computePlacement computes the patch against annotations and labels. Nil means to remove the key.ResourceStatePending. func computePlacement(expectedSyncTargetKeys sets.String, expectedDeletedSynctargetKeys map[string]string, obj metav1.Object) (annotationPatch map[string]interface{}, labelPatch map[string]interface{}) { currentSynctargetKeys := getLocations(obj.GetLabels(), false) currentSynctargetKeysDeleting := getDeletingLocations(obj.GetAnnotations()) diff --git a/pkg/reconciler/workload/synctarget/synctarget_controller.go b/pkg/reconciler/workload/synctarget/synctarget_controller.go index 9a1bb01ab58..ef139987949 100644 --- a/pkg/reconciler/workload/synctarget/synctarget_controller.go +++ b/pkg/reconciler/workload/synctarget/synctarget_controller.go @@ -52,7 +52,6 @@ func NewController( syncTargetInformer workloadv1alpha1informers.SyncTargetClusterInformer, workspaceShardInformer corev1alpha1informers.ShardClusterInformer, ) *Controller { - c := &Controller{ queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), ControllerName), kcpClusterClient: kcpClusterClient, diff --git a/pkg/reconciler/workload/synctargetexports/synctargetexports_controller.go b/pkg/reconciler/workload/synctargetexports/synctargetexports_controller.go index 9d4e45c2bc2..36bae2cf010 100644 --- a/pkg/reconciler/workload/synctargetexports/synctargetexports_controller.go +++ b/pkg/reconciler/workload/synctargetexports/synctargetexports_controller.go @@ -68,7 +68,6 @@ func NewController( apiResourceSchemaInformer apisv1alpha1informers.APIResourceSchemaClusterInformer, apiResourceImportInformer apiresourcev1alpha1informers.APIResourceImportClusterInformer, ) (*Controller, error) { - c := &Controller{ queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), ControllerName), kcpClusterClient: kcpClusterClient, diff --git a/pkg/schemacompat/schemacompat.go b/pkg/schemacompat/schemacompat.go index 0f0ad92f3ec..e28163ecf28 100644 --- a/pkg/schemacompat/schemacompat.go +++ b/pkg/schemacompat/schemacompat.go @@ -360,7 +360,6 @@ func lcdForObject(fldPath *field.Path, existing, new *schema.Structural, lcd *sc for _, removedProperty := range existingProperties.Difference(lcdProperties).UnsortedList() { delete(lcd.Properties, removedProperty) } - } else if new.AdditionalProperties != nil && new.AdditionalProperties.Structural != nil { for _, key := range sets.StringKeySet(existing.Properties).List() { existingPropertySchema := existing.Properties[key] diff --git a/pkg/server/apiextensions.go b/pkg/server/apiextensions.go index 621992522b3..5e2689c9075 100644 --- a/pkg/server/apiextensions.go +++ b/pkg/server/apiextensions.go @@ -114,7 +114,6 @@ func (c *apiBindingAwareCRDLister) List(ctx context.Context, selector labels.Sel return nil, err } for _, apiBinding := range apiBindings { - for _, boundResource := range apiBinding.Status.BoundResources { logger := logging.WithObject(logger, &apiextensionsv1.CustomResourceDefinition{ ObjectMeta: metav1.ObjectMeta{ @@ -274,7 +273,7 @@ func shallowCopyCRDAndDeepCopyAnnotations(in *apiextensionsv1.CustomResourceDefi // decorateCRDWithBinding copy and mutate crd by // 1. adding identity annotation -// 2. terminating status when apibinding is deleting +// 2. terminating status when apibinding is deleting. func decorateCRDWithBinding(in *apiextensionsv1.CustomResourceDefinition, identity string, deleteTime *metav1.Time) *apiextensionsv1.CustomResourceDefinition { out := shallowCopyCRDAndDeepCopyAnnotations(in) @@ -380,7 +379,6 @@ func (c *apiBindingAwareCRDLister) get(clusterName logicalcluster.Name, name, id return nil, err } for _, apiBinding := range apiBindings { - for _, boundResource := range apiBinding.Status.BoundResources { // identity is empty string if the request is coming from a regular workspace client. // It is set if the request is coming from the virtual apiexport apiserver client. diff --git a/pkg/server/bootstrap/identity.go b/pkg/server/bootstrap/identity.go index 084009bb8b1..66d40aab0f7 100644 --- a/pkg/server/bootstrap/identity.go +++ b/pkg/server/bootstrap/identity.go @@ -45,7 +45,7 @@ import ( ) var ( - // KcpRootGroupExportNames lists the APIExports in the root workspace for standard kcp groups + // KcpRootGroupExportNames lists the APIExports in the root workspace for standard kcp groups. KcpRootGroupExportNames = map[string]string{ "tenancy.kcp.io": "tenancy.kcp.io", "scheduling.kcp.io": "scheduling.kcp.io", @@ -53,7 +53,7 @@ var ( "apiresource.kcp.io": "apiresource.kcp.io", } - // KcpRootGroupResourceExportNames lists the APIExports in the root workspace for standard kcp group resources + // KcpRootGroupResourceExportNames lists the APIExports in the root workspace for standard kcp group resources. KcpRootGroupResourceExportNames = map[schema.GroupResource]string{ {Group: "core.kcp.io", Resource: "shards"}: "shards.core.kcp.io", } diff --git a/pkg/server/controllers.go b/pkg/server/controllers.go index 1d7d6ef8842..c44958ef35a 100644 --- a/pkg/server/controllers.go +++ b/pkg/server/controllers.go @@ -470,7 +470,6 @@ func (s *Server) installWorkspaceScheduler(ctx context.Context, config *rest.Con }); err != nil { return err } - } workspaceTypeConfig := rest.CopyConfig(config) diff --git a/pkg/server/filters/filters.go b/pkg/server/filters/filters.go index 26cb74ac5d4..f3471905f33 100644 --- a/pkg/server/filters/filters.go +++ b/pkg/server/filters/filters.go @@ -52,7 +52,7 @@ var ( // reClusterName is a regular expression for cluster names. It is based on // modified RFC 1123. It allows for 63 characters for single name and includes // KCP specific ':' separator for workspace nesting. We are not re-using k8s - // validation regex because its purpose is for single name validation + // validation regex because its purpose is for single name validation. reClusterName = regexp.MustCompile(`^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?:)*[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$`) errorScheme = runtime.NewScheme() diff --git a/pkg/server/handler.go b/pkg/server/handler.go index 2cf669612d1..e09781f9d8b 100644 --- a/pkg/server/handler.go +++ b/pkg/server/handler.go @@ -102,7 +102,7 @@ func WithAuditAnnotation(handler http.Handler) http.HandlerFunc { }) } -// WithClusterWorkspaceProjection workspaces to clusterworkspaces +// WithClusterWorkspaceProjection workspaces to clusterworkspaces. func WithClusterWorkspaceProjection(apiHandler http.Handler) http.HandlerFunc { toRedirectPath := path.Join("/apis", tenancyv1alpha1.SchemeGroupVersion.Group, tenancyv1alpha1.SchemeGroupVersion.Version, "clusterworkspaces") diff --git a/pkg/server/options/authorization.go b/pkg/server/options/authorization.go index 64be2360a0c..9323331ae95 100644 --- a/pkg/server/options/authorization.go +++ b/pkg/server/options/authorization.go @@ -49,13 +49,13 @@ func NewAuthorization() *Authorization { } } -// WithAlwaysAllowGroups appends the list of paths to AlwaysAllowGroups +// WithAlwaysAllowGroups appends the list of paths to AlwaysAllowGroups. func (s *Authorization) WithAlwaysAllowGroups(groups ...string) *Authorization { s.AlwaysAllowGroups = append(s.AlwaysAllowGroups, groups...) return s } -// WithAlwaysAllowPaths appends the list of paths to AlwaysAllowPaths +// WithAlwaysAllowPaths appends the list of paths to AlwaysAllowPaths. func (s *Authorization) WithAlwaysAllowPaths(paths ...string) *Authorization { s.AlwaysAllowPaths = append(s.AlwaysAllowPaths, paths...) return s diff --git a/pkg/server/requestinfo/util.go b/pkg/server/requestinfo/util.go index ce95dcded66..140b9370e13 100644 --- a/pkg/server/requestinfo/util.go +++ b/pkg/server/requestinfo/util.go @@ -24,7 +24,7 @@ import ( "k8s.io/apiserver/pkg/server" ) -// NewFactory creates a new RequestInfoFactory for filters to use +// NewFactory creates a new RequestInfoFactory for filters to use. func NewFactory() *request.RequestInfoFactory { return &request.RequestInfoFactory{ APIPrefixes: sets.NewString( diff --git a/pkg/syncer/resourcesync/controller.go b/pkg/syncer/resourcesync/controller.go index f93a58a664f..b153b1b8646 100644 --- a/pkg/syncer/resourcesync/controller.go +++ b/pkg/syncer/resourcesync/controller.go @@ -365,7 +365,7 @@ func (c *Controller) checkSSAR(ctx context.Context, gvr schema.GroupVersionResou return sar.Status.Allowed, nil } -// stopUnusedSyncerInformers stop syncers for gvrs not in requiredGVRs +// stopUnusedSyncerInformers stop syncers for gvrs not in requiredGVRs. func (c *Controller) stopUnusedSyncerInformers(ctx context.Context, requiredGVRs map[schema.GroupVersionResource]bool) { logger := klog.FromContext(ctx) diff --git a/pkg/syncer/spec/dns/dns_process.go b/pkg/syncer/spec/dns/dns_process.go index 7d469c87acb..541c0158f3d 100644 --- a/pkg/syncer/spec/dns/dns_process.go +++ b/pkg/syncer/spec/dns/dns_process.go @@ -67,7 +67,6 @@ func NewDNSProcessor( syncTargetUID types.UID, dnsNamespace string, dnsImage string) *DNSProcessor { - return &DNSProcessor{ downstreamKubeClient: downstreamKubeClient, serviceAccountLister: serviceAccountLister, diff --git a/pkg/syncer/spec/mutators/deployment.go b/pkg/syncer/spec/mutators/deployment.go index 4d866ff4d9d..42a5c5fcf5d 100644 --- a/pkg/syncer/spec/mutators/deployment.go +++ b/pkg/syncer/spec/mutators/deployment.go @@ -58,7 +58,6 @@ func (dm *DeploymentMutator) GVR() schema.GroupVersionResource { func NewDeploymentMutator(upstreamURL *url.URL, secretLister ListSecretFunc, serviceLister listerscorev1.ServiceLister, syncTargetClusterName logicalcluster.Name, syncTargetUID types.UID, syncTargetName, dnsNamespace string) *DeploymentMutator { - return &DeploymentMutator{ upstreamURL: upstreamURL, listSecrets: secretLister, @@ -281,7 +280,7 @@ func (dm *DeploymentMutator) getDNSIPForWorkspace(workspace logicalcluster.Name) return ip, nil } -// resolveDownwardAPIFieldRefEnv replaces the downwardAPI FieldRef EnvVars with the value from the deployment, right now it only replaces the metadata.namespace +// resolveDownwardAPIFieldRefEnv replaces the downwardAPI FieldRef EnvVars with the value from the deployment, right now it only replaces the metadata.namespace. func resolveDownwardAPIFieldRefEnv(envs []corev1.EnvVar, deployment appsv1.Deployment) []corev1.EnvVar { var result []corev1.EnvVar for _, env := range envs { @@ -297,7 +296,7 @@ func resolveDownwardAPIFieldRefEnv(envs []corev1.EnvVar, deployment appsv1.Deplo return result } -// findEnv finds an env in a list of envs +// findEnv finds an env in a list of envs. func findEnv(envs []corev1.EnvVar, name string) (bool, int) { for i := range envs { if envs[i].Name == name { @@ -307,7 +306,7 @@ func findEnv(envs []corev1.EnvVar, name string) (bool, int) { return false, 0 } -// updateEnv updates an env from a list of envs +// updateEnv updates an env from a list of envs. func updateEnv(envs []corev1.EnvVar, overrideEnv corev1.EnvVar) []corev1.EnvVar { found, i := findEnv(envs, overrideEnv.Name) if found { @@ -319,7 +318,7 @@ func updateEnv(envs []corev1.EnvVar, overrideEnv corev1.EnvVar) []corev1.EnvVar return envs } -// findVolumeMount finds a volume mount in a list of volume mounts +// findVolumeMount finds a volume mount in a list of volume mounts. func findVolumeMount(volumeMounts []corev1.VolumeMount, name string) (bool, int) { for i := range volumeMounts { if volumeMounts[i].Name == name { @@ -329,7 +328,7 @@ func findVolumeMount(volumeMounts []corev1.VolumeMount, name string) (bool, int) return false, 0 } -// updateVolumeMount updates a volume mount from a list of volume mounts +// updateVolumeMount updates a volume mount from a list of volume mounts. func updateVolumeMount(volumeMounts []corev1.VolumeMount, overrideVolumeMount corev1.VolumeMount) []corev1.VolumeMount { found, i := findVolumeMount(volumeMounts, overrideVolumeMount.Name) if found { diff --git a/pkg/syncer/spec/spec_controller.go b/pkg/syncer/spec/spec_controller.go index 92dd7d2bac8..7a29d7cf886 100644 --- a/pkg/syncer/spec/spec_controller.go +++ b/pkg/syncer/spec/spec_controller.go @@ -94,7 +94,6 @@ func NewSpecSyncer(syncerLogger logr.Logger, syncTargetClusterName logicalcluste endpointLister listerscorev1.EndpointsLister, dnsNamespace string, dnsImage string) (*Controller, error) { - c := Controller{ queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), controllerName), diff --git a/pkg/syncer/spec/spec_process.go b/pkg/syncer/spec/spec_process.go index 8ce407e1a64..614385763c1 100644 --- a/pkg/syncer/spec/spec_process.go +++ b/pkg/syncer/spec/spec_process.go @@ -296,7 +296,7 @@ func (c *Controller) ensureDownstreamNamespaceExists(ctx context.Context, downst return nil } -// TODO(jmprusi): merge with ensureDownstreamNamespaceExists and make it more generic +// TODO(jmprusi): merge with ensureDownstreamNamespaceExists and make it more generic. func (c *Controller) clusterWideCollisionCheck(ctx context.Context, gvr schema.GroupVersionResource, upstreamObj *unstructured.Unstructured) error { // Check if the resource already exists, if so check if it has the correct namespace locator. syncerInformer, ok := c.syncerInformers.InformerForResource(gvr) @@ -429,7 +429,7 @@ func (c *Controller) applyToDownstream(ctx context.Context, gvr schema.GroupVers // Strip cluster name annotation downstreamAnnotations := downstreamObj.GetAnnotations() delete(downstreamAnnotations, logicalcluster.AnnotationKey) - //TODO(jmprusi): To be removed when switching to the syncer Virtual Workspace transformations. + // TODO(jmprusi): To be removed when switching to the syncer Virtual Workspace transformations. delete(downstreamAnnotations, workloadv1alpha1.InternalClusterStatusAnnotationPrefix+c.syncTargetKey) // If the resource is cluster-scoped, we need to add the namespaceLocator annotation to get be able to // find out the upstream resource from the downstream resource. diff --git a/pkg/syncer/status/status_controller.go b/pkg/syncer/status/status_controller.go index baa5d21622b..968522171b6 100644 --- a/pkg/syncer/status/status_controller.go +++ b/pkg/syncer/status/status_controller.go @@ -61,7 +61,6 @@ type Controller struct { func NewStatusSyncer(syncerLogger logr.Logger, syncTargetClusterName logicalcluster.Name, syncTargetName, syncTargetKey string, advancedSchedulingEnabled bool, upstreamClient kcpdynamic.ClusterInterface, downstreamClient dynamic.Interface, downstreamInformers dynamicinformer.DynamicSharedInformerFactory, syncerInformers resourcesync.SyncerInformerFactory, syncTargetUID types.UID) (*Controller, error) { - c := &Controller{ queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), controllerName), diff --git a/pkg/syncer/syncer.go b/pkg/syncer/syncer.go index bc62457f6da..86e7c7818ea 100644 --- a/pkg/syncer/syncer.go +++ b/pkg/syncer/syncer.go @@ -55,7 +55,7 @@ const ( resyncPeriod = 10 * time.Hour - // TODO(marun) Coordinate this value with the interval configured for the heartbeat controller + // TODO(marun) Coordinate this value with the interval configured for the heartbeat controller. heartbeatInterval = 20 * time.Second ) diff --git a/pkg/syncer/tunneler.go b/pkg/syncer/tunneler.go index 4b1f986a0fa..8e052252b47 100644 --- a/pkg/syncer/tunneler.go +++ b/pkg/syncer/tunneler.go @@ -33,8 +33,8 @@ import ( "github.com/kcp-dev/kcp/pkg/tunneler" ) -// startSyncerTunnel blocks until the context is cancelled trying to establish a tunnel against the specified target -func startSyncerTunnel(ctx context.Context, upstream, downstream *rest.Config, syncTargetClusterName logicalcluster.Name, syncTargetName string) { +// startSyncerTunnel blocks until the context is cancelled trying to establish a tunnel against the specified target. +func startSyncerTunnel(ctx context.Context, upstream, downstream *rest.Config, syncTargetWorkspace logicalcluster.Name, syncTargetName string) { // connect to create the reverse tunnels var ( initBackoff = 5 * time.Second diff --git a/pkg/tunneler/listener.go b/pkg/tunneler/listener.go index 581a9d94b60..8e269c33adb 100644 --- a/pkg/tunneler/listener.go +++ b/pkg/tunneler/listener.go @@ -58,7 +58,7 @@ type Listener struct { // NewListener returns a new Listener, it dials to the Dialer // creating "reverse connection" that are accepted by this Listener. // - client: http client, required for TLS -// - url: a URL to the base of the reverse handler on the Dialer +// - url: a URL to the base of the reverse handler on the Dialer. func NewListener(client *http.Client, url string) (*Listener, error) { err := configureHTTP2Transport(client) if err != nil { @@ -97,7 +97,7 @@ func NewListener(client *http.Client, url string) (*Listener, error) { return ln, nil } -// run establish reverse connections against the server +// run establish reverse connections against the server. func (ln *Listener) run() { defer ln.Close() @@ -193,7 +193,6 @@ func (ln *Listener) grabConn() { return } } - } // Accept blocks and returns a new connection, or an error. @@ -234,7 +233,7 @@ func (ln *Listener) Close() error { // net.Listener interface. func (ln *Listener) Addr() net.Addr { return connAddr{} } -// configureHTTP2Transport enable ping to avoid issues with stale connections +// configureHTTP2Transport enable ping to avoid issues with stale connections. func configureHTTP2Transport(client *http.Client) error { t, ok := client.Transport.(*http.Transport) if !ok { diff --git a/pkg/tunneler/tunnel.go b/pkg/tunneler/tunnel.go index 87df60a9d0d..457a46b2084 100644 --- a/pkg/tunneler/tunnel.go +++ b/pkg/tunneler/tunnel.go @@ -52,20 +52,20 @@ type key struct { } // tunnelPool contains a pool of Dialers to create reverse connections -// based on the workspace and syncer name +// based on the workspace and syncer name. type tunnelPool struct { mu sync.Mutex pool map[key]*Dialer } -// NewtunnelPool returns a tunnelPool +// NewtunnelPool returns a tunnelPool. func newTunnelPool() *tunnelPool { return &tunnelPool{ pool: map[key]*Dialer{}, } } -// getDialer returns a reverse dialer for the id +// getDialer returns a reverse dialer for the id. func (rp *tunnelPool) getDialer(cluster, syncer string) *Dialer { rp.mu.Lock() defer rp.mu.Unlock() @@ -74,7 +74,7 @@ func (rp *tunnelPool) getDialer(cluster, syncer string) *Dialer { } // createDialer creates a reverse dialer with id -// it's a noop if a dialer already exists +// it's a noop if a dialer already exists. func (rp *tunnelPool) createDialer(cluster, syncer string, conn net.Conn) *Dialer { rp.mu.Lock() defer rp.mu.Unlock() @@ -85,10 +85,9 @@ func (rp *tunnelPool) createDialer(cluster, syncer string, conn net.Conn) *Diale d := NewDialer(conn) rp.pool[id] = d return d - } -// deleteDialer delete the reverse dialer for the id +// deleteDialer delete the reverse dialer for the id. func (rp *tunnelPool) deleteDialer(cluster, syncer string) { rp.mu.Lock() defer rp.mu.Unlock() @@ -96,7 +95,7 @@ func (rp *tunnelPool) deleteDialer(cluster, syncer string) { delete(rp.pool, id) } -// SyncerTunnelURL builds the destination url with the Dialer expected format of the URL +// SyncerTunnelURL builds the destination url with the Dialer expected format of the URL. func SyncerTunnelURL(host, ws, target string) (string, error) { if target == "" || ws == "" { return "", fmt.Errorf("target or ws can not be empty") @@ -235,7 +234,7 @@ func WithSyncerTunnel(apiHandler http.Handler) http.HandlerFunc { } } -// flushWriter +// flushWriter. type flushWriter struct { w io.Writer f http.Flusher diff --git a/pkg/virtual/apiexport/controllers/apireconciler/apiexport_apireconciler_reconcile.go b/pkg/virtual/apiexport/controllers/apireconciler/apiexport_apireconciler_reconcile.go index fd3874a4174..188c061ee1f 100644 --- a/pkg/virtual/apiexport/controllers/apireconciler/apiexport_apireconciler_reconcile.go +++ b/pkg/virtual/apiexport/controllers/apireconciler/apiexport_apireconciler_reconcile.go @@ -194,7 +194,7 @@ func (c *APIReconciler) reconcile(ctx context.Context, apiExport *apisv1alpha1.A if c, ok := claims[gvr.GroupResource()]; ok { key, label, err := permissionclaims.ToLabelKeyAndValue(clusterName, apiExport.Name, c) if err != nil { - return fmt.Errorf(fmt.Sprintf("failed to convert permission claim %v to label key and value: %v", c, err)) + return errors.New(fmt.Sprintf("failed to convert permission claim %v to label key and value: %v", c, err)) } claimLabels := []string{label} if gvr.GroupResource() == apisv1alpha1.Resource("apibindings") { @@ -203,7 +203,7 @@ func (c *APIReconciler) reconcile(ctx context.Context, apiExport *apisv1alpha1.A } req, err := labels.NewRequirement(key, selection.In, claimLabels) if err != nil { - return fmt.Errorf(fmt.Sprintf("failed to create label requirement for permission claim %v: %v", c, err)) + return errors.New(fmt.Sprintf("failed to create label requirement for permission claim %v: %v", c, err)) } labelReqs = labels.Requirements{*req} } diff --git a/pkg/virtual/framework/dynamic/apidefinition/types.go b/pkg/virtual/framework/dynamic/apidefinition/types.go index 85b76cf24c2..ad7aad3e5fb 100644 --- a/pkg/virtual/framework/dynamic/apidefinition/types.go +++ b/pkg/virtual/framework/dynamic/apidefinition/types.go @@ -29,7 +29,7 @@ import ( dynamiccontext "github.com/kcp-dev/kcp/pkg/virtual/framework/dynamic/context" ) -// APIDefinition provides access to all the information needed to serve a given API resource +// APIDefinition provides access to all the information needed to serve a given API resource. type APIDefinition interface { // GetAPIResourceSchema returns the API schema this definition serves. GetAPIResourceSchema() *apisv1alpha1.APIResourceSchema diff --git a/pkg/virtual/framework/dynamic/apiserver/apiserver.go b/pkg/virtual/framework/dynamic/apiserver/apiserver.go index 84e2c3e8279..16e32207dae 100644 --- a/pkg/virtual/framework/dynamic/apiserver/apiserver.go +++ b/pkg/virtual/framework/dynamic/apiserver/apiserver.go @@ -39,7 +39,7 @@ var ( scheme = runtime.NewScheme() codecs = serializer.NewCodecFactory(scheme) - // if you modify this, make sure you update the crEncoder + // if you modify this, make sure you update the crEncoder. unversionedVersion = schema.GroupVersion{Group: "", Version: "v1"} unversionedTypes = []runtime.Object{ &metav1.Status{}, @@ -58,12 +58,12 @@ func init() { scheme.AddUnversionedTypes(unversionedVersion, unversionedTypes...) } -// DynamicAPIServerExtraConfig contains additional configuration for the DynamicAPIServer +// DynamicAPIServerExtraConfig contains additional configuration for the DynamicAPIServer. type DynamicAPIServerExtraConfig struct { APISetRetriever apidefinition.APIDefinitionSetGetter } -// DynamicAPIServerConfig contains the configuration for the DynamicAPIServer +// DynamicAPIServerConfig contains the configuration for the DynamicAPIServer. type DynamicAPIServerConfig struct { GenericConfig *genericapiserver.RecommendedConfig ExtraConfig DynamicAPIServerExtraConfig diff --git a/pkg/virtual/framework/dynamic/apiserver/discovery.go b/pkg/virtual/framework/dynamic/apiserver/discovery.go index 4536d6b6418..97dcf16ffcf 100644 --- a/pkg/virtual/framework/dynamic/apiserver/discovery.go +++ b/pkg/virtual/framework/dynamic/apiserver/discovery.go @@ -273,7 +273,6 @@ func (r *rootDiscoveryHandler) ServeHTTP(w http.ResponseWriter, req *http.Reques } for gvr := range apiSet { - if gvr.Group == "" { // Don't include CRDs in the core ("") group in /apis discovery. They // instead are in /api/v1 handled elsewhere. @@ -303,7 +302,6 @@ func (r *rootDiscoveryHandler) ServeHTTP(w http.ResponseWriter, req *http.Reques for _, versions := range apiVersionsForDiscovery { sortGroupDiscoveryByKubeAwareVersion(versions) - } groupList := make([]metav1.APIGroup, 0, len(apiVersionsForDiscovery)) diff --git a/pkg/virtual/framework/dynamic/apiserver/serving_info.go b/pkg/virtual/framework/dynamic/apiserver/serving_info.go index 05062188ba9..896a0dbc3cd 100644 --- a/pkg/virtual/framework/dynamic/apiserver/serving_info.go +++ b/pkg/virtual/framework/dynamic/apiserver/serving_info.go @@ -304,7 +304,7 @@ func CreateServingInfoFor(genericConfig genericapiserver.CompletedConfig, apiRes return ret, nil } -// servingInfo stores enough information to serve the storage for the apiResourceSchema +// servingInfo stores enough information to serve the storage for the apiResourceSchema. type servingInfo struct { logicalClusterName logicalcluster.Name apiResourceSchema *apisv1alpha1.APIResourceSchema @@ -368,7 +368,7 @@ func (u nopConverter) ConvertFieldLabel(gvk schema.GroupVersionKind, label, valu return label, value, nil } -// buildOpenAPIV2 builds OpenAPI v2 for the given apiResourceSpec +// buildOpenAPIV2 builds OpenAPI v2 for the given apiResourceSpec. func buildOpenAPIV2(apiResourceSchema *apisv1alpha1.APIResourceSchema, apiResourceVersion *apisv1alpha1.APIResourceVersion, opts builder.Options) (*spec.Swagger, error) { openapiSchema, err := apiResourceVersion.GetSchema() if err != nil { diff --git a/pkg/virtual/framework/fixedgvs/register.go b/pkg/virtual/framework/fixedgvs/register.go index 5f771407f21..11e789d987d 100644 --- a/pkg/virtual/framework/fixedgvs/register.go +++ b/pkg/virtual/framework/fixedgvs/register.go @@ -100,7 +100,6 @@ func (vw *FixedGroupVersionsVirtualWorkspace) Register(vwName string, rootAPISer // a given virtual workspace, then grab its DiscoveryGroupManager // to reuse it in the next GroupVersionAPIServers for the virtual workspace. vwGroupManager = server.GenericAPIServer.DiscoveryGroupManager - } if firstAPIServer == nil { // If this GroupVersionAPIServer is the first one for diff --git a/pkg/virtual/framework/forwardingregistry/rest.go b/pkg/virtual/framework/forwardingregistry/rest.go index cc71a20761f..d322c138923 100644 --- a/pkg/virtual/framework/forwardingregistry/rest.go +++ b/pkg/virtual/framework/forwardingregistry/rest.go @@ -60,7 +60,7 @@ func (sw *StorageWrappers) Decorate(groupResource schema.GroupResource, storage } } -// NewStorage returns a REST storage that forwards calls to a dynamic client +// NewStorage returns a REST storage that forwards calls to a dynamic client. func NewStorage( ctx context.Context, resource schema.GroupVersionResource, diff --git a/pkg/virtual/framework/handler/handler.go b/pkg/virtual/framework/handler/handler.go index 8a918eaee73..ffa0b80fbe4 100644 --- a/pkg/virtual/framework/handler/handler.go +++ b/pkg/virtual/framework/handler/handler.go @@ -26,7 +26,7 @@ import ( virtualcontext "github.com/kcp-dev/kcp/pkg/virtual/framework/context" ) -// HandlerFactory creates an HTTP handler using the root API server configuration, for dynamic registration +// HandlerFactory creates an HTTP handler using the root API server configuration, for dynamic registration. type HandlerFactory func(rootAPIServerConfig genericapiserver.CompletedConfig) (http.Handler, error) type VirtualWorkspace struct { diff --git a/pkg/virtual/framework/internalapis/import.go b/pkg/virtual/framework/internalapis/import.go index 41310194e12..9df4912d115 100644 --- a/pkg/virtual/framework/internalapis/import.go +++ b/pkg/virtual/framework/internalapis/import.go @@ -35,7 +35,7 @@ import ( "github.com/kcp-dev/kcp/pkg/crdpuller" ) -// InternalAPI describes an API to be imported from some schemes and generated OpenAPI V2 definitions +// InternalAPI describes an API to be imported from some schemes and generated OpenAPI V2 definitions. type InternalAPI struct { Names apiextensionsv1.CustomResourceDefinitionNames GroupVersion schema.GroupVersion diff --git a/pkg/virtual/framework/rootapiserver/root_apiserver.go b/pkg/virtual/framework/rootapiserver/root_apiserver.go index 910066b8e63..37c024a5532 100644 --- a/pkg/virtual/framework/rootapiserver/root_apiserver.go +++ b/pkg/virtual/framework/rootapiserver/root_apiserver.go @@ -64,7 +64,7 @@ type NamedVirtualWorkspace struct { framework.VirtualWorkspace } -// Validate helps ensure that we build this config correctly, because there are lots of bits to remember for now +// Validate helps ensure that we build this config correctly, because there are lots of bits to remember for now. func (c *RootAPIExtraConfig) Validate() error { ret := []error{} diff --git a/pkg/virtual/framework/transforming/watcher.go b/pkg/virtual/framework/transforming/watcher.go index a6ce65cf6a7..cacb3e46668 100644 --- a/pkg/virtual/framework/transforming/watcher.go +++ b/pkg/virtual/framework/transforming/watcher.go @@ -57,12 +57,12 @@ func (w *transformingWatcher) start() { }() } -// Stop implements Interface +// Stop implements Interface. func (w *transformingWatcher) Stop() { w.source.Stop() } -// ResultChan implements Interface +// ResultChan implements Interface. func (w *transformingWatcher) ResultChan() <-chan watch.Event { return w.transformedCh } diff --git a/pkg/virtual/framework/wrappers/rbac/merging.go b/pkg/virtual/framework/wrappers/rbac/merging.go index d9b00bb8066..5cf94975855 100644 --- a/pkg/virtual/framework/wrappers/rbac/merging.go +++ b/pkg/virtual/framework/wrappers/rbac/merging.go @@ -150,7 +150,7 @@ func (l *mergedRoleNamespaceLister) List(selector labels.Selector) (ret []*rbacv return aggregatedList, nil } -// TODO: slaskawi - to be converted to generics once we rebase on Go 1.18 +// TODO: slaskawi - to be converted to generics once we rebase on Go 1.18. func mergeRoles(array []*rbacv1.Role, rolesToBeMergedIn []*rbacv1.Role) []*rbacv1.Role { for _, roleToBeMerged := range rolesToBeMergedIn { foundIndex := -1 @@ -169,7 +169,7 @@ func mergeRoles(array []*rbacv1.Role, rolesToBeMergedIn []*rbacv1.Role) []*rbacv return array } -// TODO: slaskawi - to be converted to generics once we rebase on Go 1.18 +// TODO: slaskawi - to be converted to generics once we rebase on Go 1.18. func mergeClusterRoles(array []*rbacv1.ClusterRole, rolesToBeMergedIn []*rbacv1.ClusterRole) []*rbacv1.ClusterRole { for _, roleToBeMerged := range rolesToBeMergedIn { foundIndex := -1 diff --git a/pkg/virtual/initializingworkspaces/builder/forwarding.go b/pkg/virtual/initializingworkspaces/builder/forwarding.go index b0f7ee1af48..29c459ab064 100644 --- a/pkg/virtual/initializingworkspaces/builder/forwarding.go +++ b/pkg/virtual/initializingworkspaces/builder/forwarding.go @@ -208,8 +208,8 @@ func provideDelegatingClusterWorkspacesRestStorage(getTenancyIdentity func() (st } // withUpdateValidation adds further validation to ensure that a user of this virtual workspace can only -// remove their own initializer from the list -func withUpdateValidation(initializer corev1alpha1.LogicalClusterInitializer) registry.StorageWrapper { +// remove their own initializer from the list. +func withUpdateValidation(initializer tenancyv1alpha1.ClusterWorkspaceInitializer) registry.StorageWrapper { return registry.StorageWrapperFunc(func(resource schema.GroupResource, storage *registry.StoreFuncs) { delegateUpdater := storage.UpdaterFunc storage.UpdaterFunc = func(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { diff --git a/pkg/virtual/options/authorization.go b/pkg/virtual/options/authorization.go index 83a83d9dc77..4a8fe154b63 100644 --- a/pkg/virtual/options/authorization.go +++ b/pkg/virtual/options/authorization.go @@ -48,13 +48,13 @@ func NewAuthorization() *Authorization { } } -// WithAlwaysAllowGroups appends the list of paths to AlwaysAllowGroups +// WithAlwaysAllowGroups appends the list of paths to AlwaysAllowGroups. func (s *Authorization) WithAlwaysAllowGroups(groups ...string) *Authorization { s.AlwaysAllowGroups = append(s.AlwaysAllowGroups, groups...) return s } -// WithAlwaysAllowPaths appends the list of paths to AlwaysAllowPaths +// WithAlwaysAllowPaths appends the list of paths to AlwaysAllowPaths. func (s *Authorization) WithAlwaysAllowPaths(paths ...string) *Authorization { s.AlwaysAllowPaths = append(s.AlwaysAllowPaths, paths...) return s diff --git a/pkg/virtual/syncer/builder/build.go b/pkg/virtual/syncer/builder/build.go index acfa730701b..fc70cb7d53f 100644 --- a/pkg/virtual/syncer/builder/build.go +++ b/pkg/virtual/syncer/builder/build.go @@ -51,7 +51,6 @@ func BuildVirtualWorkspace( kcpClusterClient kcpclientset.ClusterInterface, wildcardKcpInformers kcpinformers.SharedInformerFactory, ) []rootapiserver.NamedVirtualWorkspace { - if !strings.HasSuffix(rootPathPrefix, "/") { rootPathPrefix += "/" } diff --git a/pkg/virtual/syncer/controllers/apireconciler/syncer_apireconciler_reconcile.go b/pkg/virtual/syncer/controllers/apireconciler/syncer_apireconciler_reconcile.go index c21960f14fa..34c51d7a75f 100644 --- a/pkg/virtual/syncer/controllers/apireconciler/syncer_apireconciler_reconcile.go +++ b/pkg/virtual/syncer/controllers/apireconciler/syncer_apireconciler_reconcile.go @@ -68,7 +68,6 @@ func (c *APIReconciler) reconcile(ctx context.Context, apiDomainKey dynamicconte newGVRs := []string{} preservedGVR := []string{} for gr, apiResourceSchema := range apiResourceSchemas { - if c.allowedAPIfilter != nil && !c.allowedAPIfilter(gr) { continue } diff --git a/pkg/virtual/syncer/transformations/defaultsummarizing.go b/pkg/virtual/syncer/transformations/defaultsummarizing.go index 82353d43444..a5a9a75b724 100644 --- a/pkg/virtual/syncer/transformations/defaultsummarizing.go +++ b/pkg/virtual/syncer/transformations/defaultsummarizing.go @@ -31,7 +31,7 @@ var _ SummarizingRules = (*DefaultSummarizingRules)(nil) var _ SummarizingRulesProvider = (*DefaultSummarizingRules)(nil) // DefaultSummarizingRules provides a default minimal implementation of [SummarizingRules]. -// It only adds a status field, which for now is always promoted (see comments below in the code) +// It only adds a status field, which for now is always promoted (see comments below in the code). type DefaultSummarizingRules struct{} type field struct { @@ -41,37 +41,37 @@ type field struct { var _ FieldToSummarize = field{} -// Path implements [Field.Path] +// Path implements [Field.Path]. func (f field) Path() string { return f.FieldPath } -// Path implements [Field.Path] +// Path implements [Field.Path]. func (f field) pathElements() []string { return strings.Split(f.FieldPath, ".") } -// Set implements [Field.Set] +// Set implements [Field.Set]. func (f field) Set(resource *unstructured.Unstructured, value interface{}) error { return unstructured.SetNestedField(resource.UnstructuredContent(), value, f.pathElements()...) } -// Get implements [Field.Get] +// Get implements [Field.Get]. func (f field) Get(resource *unstructured.Unstructured) (interface{}, bool, error) { return unstructured.NestedFieldNoCopy(resource.UnstructuredContent(), f.pathElements()...) } -// Delete implements [Field.Delete] +// Delete implements [Field.Delete]. func (f field) Delete(resource *unstructured.Unstructured) { unstructured.RemoveNestedField(resource.UnstructuredContent(), f.pathElements()...) } -// CanPromoteToUpstream implements [Field.CanPromoteToUpstream] +// CanPromoteToUpstream implements [Field.CanPromoteToUpstream]. func (f field) CanPromoteToUpstream() bool { return f.PromoteToUpstream } -// IsStatus implements [Field.IsStatus] +// IsStatus implements [Field.IsStatus]. func (f field) IsStatus() bool { elements := f.pathElements() return len(elements) == 1 && elements[0] == "status" @@ -123,7 +123,6 @@ func (s *DefaultSummarizingRules) FieldsToSummarize(gvr schema.GroupVersionResou func (s *DefaultSummarizingRules) canPromoteStatusToUpstream(gvr schema.GroupVersionResource) bool { switch gvr { - // TODO(davidfestal): In the future, ingresses and services would have default coordination controllers, // we would never promote their status to the upstream resource, since it is inherently related to // SyncTarget infrastructure details. diff --git a/pkg/virtual/syncer/transformations/types.go b/pkg/virtual/syncer/transformations/types.go index fafe8697b20..2751ac67c9f 100644 --- a/pkg/virtual/syncer/transformations/types.go +++ b/pkg/virtual/syncer/transformations/types.go @@ -39,7 +39,7 @@ type Transformation interface { ToSyncerView(SyncTargetKey string, gvr schema.GroupVersionResource, upstreamResource *unstructured.Unstructured, overridenSyncerViewFields map[string]interface{}, requestedSyncing map[string]helpers.SyncIntent) (newSyncerViewResource *unstructured.Unstructured, err error) } -// TransformationProvider provides an appropriate Transformation based on the content of a resource +// TransformationProvider provides an appropriate Transformation based on the content of a resource. type TransformationProvider interface { TransformationFor(resource metav1.Object) (Transformation, error) } @@ -53,7 +53,7 @@ type SummarizingRules interface { FieldsToSummarize(gvr schema.GroupVersionResource) []FieldToSummarize } -// SummarizingRulesProvider provides appropriate SummarizingRules based on the content of a resource +// SummarizingRulesProvider provides appropriate SummarizingRules based on the content of a resource. type SummarizingRulesProvider interface { SummarizingRulesFor(resource metav1.Object) (SummarizingRules, error) } diff --git a/pkg/virtual/syncer/upsyncer/storage_wrapper.go b/pkg/virtual/syncer/upsyncer/storage_wrapper.go index 08eeada9a7a..50fcde36169 100644 --- a/pkg/virtual/syncer/upsyncer/storage_wrapper.go +++ b/pkg/virtual/syncer/upsyncer/storage_wrapper.go @@ -32,7 +32,7 @@ import ( // WithStaticLabelSelectorAndInWriteCallsCheck returns a StorageWrapper that adds the given label selector to the reading calls // (Get, List and Watch), but also checks that write calls (Create or Update) are refused with an error if the resource -// would not not matched by the given label selector +// would not be matched by the given label selector. func WithStaticLabelSelectorAndInWriteCallsCheck(labelSelector labels.Requirements) forwardingregistry.StorageWrapper { return forwardingregistry.StorageWrapperFunc( func(resource schema.GroupResource, storage *forwardingregistry.StoreFuncs) { diff --git a/pkg/virtual/syncer/upsyncer/transformer.go b/pkg/virtual/syncer/upsyncer/transformer.go index 8c28c87d599..0f08b5d2f68 100644 --- a/pkg/virtual/syncer/upsyncer/transformer.go +++ b/pkg/virtual/syncer/upsyncer/transformer.go @@ -34,11 +34,11 @@ import ( // UpsyncDiffAnnotationPrefix is an internal annotation used on downstream resources to specify a transformation // that should be applied during the Upsyncing of the resource to upstream. -// Format of the annotation is JSONPatch +// Format of the annotation is JSONPatch. const UpsyncDiffAnnotationPrefix = "internal.workload.kcp.io/upsyncdiff" // UpsyncerResourceTransformer defines a very simple transformer which transforms the resource by applying a -// the JSON patch found in the `internal.workload.kcp.io/upsyncdiff` annotation +// the JSON patch found in the `internal.workload.kcp.io/upsyncdiff` annotation. type UpsyncerResourceTransformer struct{} func (rt *UpsyncerResourceTransformer) AfterRead(client dynamic.ResourceInterface, ctx context.Context, gvr schema.GroupVersionResource, upstreamResource *unstructured.Unstructured, eventType *watch.EventType, subresources ...string) (*unstructured.Unstructured, error) { diff --git a/pkg/virtual/workspaces/printers/printer.go b/pkg/virtual/workspaces/printers/printer.go index 0d74fdac434..05e71d1b32a 100644 --- a/pkg/virtual/workspaces/printers/printer.go +++ b/pkg/virtual/workspaces/printers/printer.go @@ -90,7 +90,7 @@ func printWorkspaceList(list *tenancyv1alpha1.ClusterWorkspaceList, options kpri return rows, nil } -// SortableWorkspaces is a list of workspaces that can be sorted +// SortableWorkspaces is a list of workspaces that can be sorted. type SortableWorkspaces []tenancyv1alpha1.ClusterWorkspace func (list SortableWorkspaces) Len() int { diff --git a/pkg/virtual/workspaces/registry/rest.go b/pkg/virtual/workspaces/registry/rest.go index c3e8ef78aa1..f9d83d8eb57 100644 --- a/pkg/virtual/workspaces/registry/rest.go +++ b/pkg/virtual/workspaces/registry/rest.go @@ -77,17 +77,17 @@ func NewREST( return mainRest } -// New returns a new ClusterWorkspace +// New returns a new ClusterWorkspace. func (s *REST) New() runtime.Object { return &tenancyv1alpha1.ClusterWorkspace{} } -// Destroy implements rest.Storage +// Destroy implements rest.Storage. func (s *REST) Destroy() { // Do nothing } -// NewList returns a new ClusterWorkspaceList +// NewList returns a new ClusterWorkspaceList. func (*REST) NewList() runtime.Object { return &tenancyv1alpha1.ClusterWorkspaceList{} } @@ -135,7 +135,7 @@ func (s *REST) Watch(ctx context.Context, options *metainternal.ListOptions) (wa return withProjection{delegate: w, ch: make(chan watch.Event)}, nil } -// Get retrieves a Workspace by name +// Get retrieves a Workspace by name. func (s *REST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) { opts := metav1.GetOptions{} if options != nil { diff --git a/test/e2e/apibinding/apibinding_deletion_test.go b/test/e2e/apibinding/apibinding_deletion_test.go index 254ec117190..4d11d897f60 100644 --- a/test/e2e/apibinding/apibinding_deletion_test.go +++ b/test/e2e/apibinding/apibinding_deletion_test.go @@ -102,7 +102,7 @@ func TestAPIBindingDeletion(t *testing.T) { framework.Eventually(t, func() (bool, string) { _, err = kcpClusterClient.Cluster(consumerWorkspace.Path()).ApisV1alpha1().APIBindings().Create(ctx, apiBinding, metav1.CreateOptions{}) - return err == nil, fmt.Sprintf("%v", err) + return err == nil, err.Error() }, wait.ForeverTestTimeout, time.Millisecond*100) t.Logf("Should have finalizer added in apibinding") diff --git a/test/e2e/apibinding/apibinding_permissionclaims_test.go b/test/e2e/apibinding/apibinding_permissionclaims_test.go index 42e47566786..7084726ab13 100644 --- a/test/e2e/apibinding/apibinding_permissionclaims_test.go +++ b/test/e2e/apibinding/apibinding_permissionclaims_test.go @@ -124,7 +124,7 @@ func TestAPIBindingPermissionClaimsConditions(t *testing.T) { require.NoError(t, err) binding.Spec.PermissionClaims = getAcceptedPermissionClaims(identityHash) _, err = kcpClusterClient.Cluster(consumerWorkspace.Path()).ApisV1alpha1().APIBindings().Update(ctx, binding, metav1.UpdateOptions{}) - return err == nil, fmt.Sprintf("%v", err) + return err == nil, err.Error() }, wait.ForeverTestTimeout, 100*time.Millisecond, "error updating to correct hash") t.Logf("Validate that the permission claims are valid") @@ -268,7 +268,7 @@ func bindConsumerToProvider(ctx context.Context, consumerWorkspace logicalcluste framework.Eventually(t, func() (bool, string) { _, err := kcpClusterClients.Cluster(consumerWorkspace).ApisV1alpha1().APIBindings().Create(ctx, apiBinding, metav1.CreateOptions{}) - return err == nil, fmt.Sprintf("%v", err) + return err == nil, err.Error() }, wait.ForeverTestTimeout, time.Millisecond*100) consumerWorkspaceClient, err := kcpclientset.NewForConfig(cfg) diff --git a/test/e2e/apibinding/apibinding_protected_test.go b/test/e2e/apibinding/apibinding_protected_test.go index d28e361502a..21de55b70f1 100644 --- a/test/e2e/apibinding/apibinding_protected_test.go +++ b/test/e2e/apibinding/apibinding_protected_test.go @@ -97,7 +97,7 @@ func TestProtectedAPI(t *testing.T) { framework.Eventually(t, func() (bool, string) { _, err = kcpClusterClient.Cluster(consumerWorkspace.Path()).ApisV1alpha1().APIBindings().Create(ctx, apiBinding, metav1.CreateOptions{}) - return err == nil, fmt.Sprintf("%v", err) + return err == nil, err.Error() }, wait.ForeverTestTimeout, time.Millisecond*100, "failed to create APIBinding") t.Logf("Make sure APIBinding %q in workspace %q is completed and up-to-date", apiBinding.Name, consumerWorkspace) diff --git a/test/e2e/apibinding/apibinding_test.go b/test/e2e/apibinding/apibinding_test.go index 654ff43b1b4..a60ac67c06b 100644 --- a/test/e2e/apibinding/apibinding_test.go +++ b/test/e2e/apibinding/apibinding_test.go @@ -113,7 +113,7 @@ func TestAPIBindingAPIExportReferenceImmutability(t *testing.T) { framework.Eventually(t, func() (bool, string) { _, err = kcpClusterClient.Cluster(consumerWorkspace.Path()).ApisV1alpha1().APIBindings().Create(ctx, apiBinding, metav1.CreateOptions{}) - return err == nil, fmt.Sprintf("%v", err) + return err == nil, err.Error() }, wait.ForeverTestTimeout, time.Millisecond*100) t.Logf("Make sure we can get the APIBinding we just created") @@ -220,7 +220,7 @@ func TestAPIBinding(t *testing.T) { framework.Eventually(t, func() (bool, string) { _, err = kcpClusterClient.Cluster(consumerWorkspace).ApisV1alpha1().APIBindings().Create(ctx, apiBinding, metav1.CreateOptions{}) - return err == nil, fmt.Sprintf("%v", err) + return err == nil, err.Error() }, wait.ForeverTestTimeout, time.Millisecond*100) t.Logf("Make sure %s API group does NOT show up in workspace %q group discovery", wildwest.GroupName, providerClusterName) @@ -295,7 +295,7 @@ func TestAPIBinding(t *testing.T) { framework.Eventually(t, func() (bool, string) { _, err = kcpClusterClient.Cluster(consumerWorkspace).ApisV1alpha1().APIBindings().Create(ctx, apiBinding, metav1.CreateOptions{}) - return err == nil, fmt.Sprintf("%v", err) + return err == nil, err.Error() }, wait.ForeverTestTimeout, time.Millisecond*100) t.Logf("Make sure %s cowboys2 conflict with already bound %s cowboys", serviceProvider2ClusterName, providerClusterName) diff --git a/test/e2e/apibinding/apibinding_webhook_test.go b/test/e2e/apibinding/apibinding_webhook_test.go index 29bd1d73f99..ecccbd3103d 100644 --- a/test/e2e/apibinding/apibinding_webhook_test.go +++ b/test/e2e/apibinding/apibinding_webhook_test.go @@ -259,7 +259,7 @@ func TestAPIBindingValidatingWebhook(t *testing.T) { framework.Eventually(t, func() (bool, string) { _, err = kcpClients.Cluster(targetClusterName.Path()).ApisV1alpha1().APIBindings().Create(ctx, apiBinding, metav1.CreateOptions{}) - return err == nil, fmt.Sprintf("%v", err) + return err == nil, err.Error() }, wait.ForeverTestTimeout, time.Millisecond*100) scheme := runtime.NewScheme() diff --git a/test/e2e/fixtures/wildwest/apis/wildwest/v1alpha1/register.go b/test/e2e/fixtures/wildwest/apis/wildwest/v1alpha1/register.go index eb035fb3f6b..55b7bf30e0b 100644 --- a/test/e2e/fixtures/wildwest/apis/wildwest/v1alpha1/register.go +++ b/test/e2e/fixtures/wildwest/apis/wildwest/v1alpha1/register.go @@ -24,15 +24,15 @@ import ( "github.com/kcp-dev/kcp/test/e2e/fixtures/wildwest/apis/wildwest" ) -// SchemeGroupVersion is group version used to register these objects +// SchemeGroupVersion is group version used to register these objects. var SchemeGroupVersion = schema.GroupVersion{Group: wildwest.GroupName, Version: "v1alpha1"} -// Kind takes an unqualified kind and returns back a Group qualified GroupKind +// Kind takes an unqualified kind and returns back a Group qualified GroupKind. func Kind(kind string) schema.GroupKind { return SchemeGroupVersion.WithKind(kind).GroupKind() } -// Resource takes an unqualified resource and returns a Group qualified GroupResource +// Resource takes an unqualified resource and returns a Group qualified GroupResource. func Resource(resource string) schema.GroupResource { return SchemeGroupVersion.WithResource(resource).GroupResource() } diff --git a/test/e2e/framework/bind.go b/test/e2e/framework/bind.go index e74f1ebb350..09954d24552 100644 --- a/test/e2e/framework/bind.go +++ b/test/e2e/framework/bind.go @@ -27,7 +27,7 @@ import ( type BindComputeOption func(t *testing.T, w *bindCompute) -// bindCompute construct and run a kcp compute bind command +// bindCompute construct and run a kcp compute bind command. type bindCompute struct { apiExports []string nsSelector string diff --git a/test/e2e/framework/expect.go b/test/e2e/framework/expect.go index e1b1e5131da..c18af5a6ab9 100644 --- a/test/e2e/framework/expect.go +++ b/test/e2e/framework/expect.go @@ -42,7 +42,7 @@ import ( // to be evaluated. type Expectation func(ctx context.Context) (done bool, err error) -// Expecter allows callers to register expectations +// Expecter allows callers to register expectations. type Expecter interface { // ExpectBefore will result in the Expectation being evaluated whenever // state changes, up until the desired timeout is reached. @@ -82,7 +82,7 @@ type expectationRecord struct { *sync.Mutex } -// ExpectationController knows how to register expectations and trigger them +// ExpectationController knows how to register expectations and trigger them. type ExpectationController struct { // expectations are recorded by UUID so they may be removed after they complete expectations map[uuid.UUID]expectationRecord diff --git a/test/e2e/framework/kcp.go b/test/e2e/framework/kcp.go index 647766b1b1e..032aa8fd7cd 100644 --- a/test/e2e/framework/kcp.go +++ b/test/e2e/framework/kcp.go @@ -230,10 +230,10 @@ type RunningServer interface { Artifact(t *testing.T, producer func() (runtime.Object, error)) } -// KcpConfigOption a function that wish to modify a given kcp configuration +// KcpConfigOption a function that wish to modify a given kcp configuration. type KcpConfigOption func(*kcpConfig) *kcpConfig -// WithScratchDirectories adds custom scratch directories to a kcp configuration +// WithScratchDirectories adds custom scratch directories to a kcp configuration. func WithScratchDirectories(artifactDir, dataDir string) KcpConfigOption { return func(cfg *kcpConfig) *kcpConfig { cfg.ArtifactDir = artifactDir @@ -242,7 +242,7 @@ func WithScratchDirectories(artifactDir, dataDir string) KcpConfigOption { } } -// WithCustomArguments applies provided arguments to a given kcp configuration +// WithCustomArguments applies provided arguments to a given kcp configuration. func WithCustomArguments(args ...string) KcpConfigOption { return func(cfg *kcpConfig) *kcpConfig { cfg.Args = args @@ -573,12 +573,12 @@ func (c *kcpServer) filterKcpLogs(logs *bytes.Buffer) string { return output.String() } -// Name exposes the name of this kcp server +// Name exposes the name of this kcp server. func (c *kcpServer) Name() string { return c.name } -// Name exposes the path of the kubeconfig file of this kcp server +// Name exposes the path of the kubeconfig file of this kcp server. func (c *kcpServer) KubeconfigPath() string { return c.kubeconfigPath } diff --git a/test/e2e/framework/kubectl.go b/test/e2e/framework/kubectl.go index 0cf5238f46f..7b30030db89 100644 --- a/test/e2e/framework/kubectl.go +++ b/test/e2e/framework/kubectl.go @@ -36,7 +36,6 @@ import ( func KcpCliPluginCommand() []string { if NoGoRunEnvSet() { return []string{"kubectl", "kcp"} - } else { cmdPath := filepath.Join(RepositoryDir(), "cmd", "kubectl-kcp") return []string{"go", "run", cmdPath} diff --git a/test/e2e/framework/syncer.go b/test/e2e/framework/syncer.go index dde280e66fa..c57b403b11d 100644 --- a/test/e2e/framework/syncer.go +++ b/test/e2e/framework/syncer.go @@ -292,7 +292,7 @@ func (sf *syncerFixture) Start(t *testing.T) *StartedSyncerFixture { } for _, pod := range pods.Items { - //Check if the POD is ready before trying to get the logs, ignore if not to avoid the test failing. + // Check if the POD is ready before trying to get the logs, ignore if not to avoid the test failing. if pod.Status.Phase != corev1.PodRunning { t.Logf("Pod %s is not running", pod.Name) continue diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index 919742f9d81..7c5d73d1a74 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -310,7 +310,7 @@ func Eventually(t *testing.T, condition func() (success bool, reason string), wa }, waitFor, tick, msgAndArgs...) } -// EventuallyReady asserts that the object returned by getter() eventually has a ready condition +// EventuallyReady asserts that the object returned by getter() eventually has a ready condition. func EventuallyReady(t *testing.T, getter func() (conditions.Getter, error), msgAndArgs ...interface{}) { t.Helper() Eventually(t, func() (bool, string) { diff --git a/test/e2e/quota/quota_test.go b/test/e2e/quota/quota_test.go index 1895b69b8e5..6b1bd2a83a4 100644 --- a/test/e2e/quota/quota_test.go +++ b/test/e2e/quota/quota_test.go @@ -176,7 +176,7 @@ func TestKubeQuotaCoreV1TypesFromBinding(t *testing.T) { framework.Eventually(t, func() (bool, string) { _, err = kcpClusterClient.Cluster(userClusterName.Path()).ApisV1alpha1().APIBindings().Create(ctx, binding, metav1.CreateOptions{}) - return err == nil, fmt.Sprintf("%v", err) + return err == nil, err.Error() }, wait.ForeverTestTimeout, 100*time.Millisecond, "error creating APIBinding") t.Logf("Wait for binding to be ready") diff --git a/test/e2e/reconciler/workspacedeletion/controller_test.go b/test/e2e/reconciler/workspacedeletion/controller_test.go index e2fed6a5ceb..12b26a22345 100644 --- a/test/e2e/reconciler/workspacedeletion/controller_test.go +++ b/test/e2e/reconciler/workspacedeletion/controller_test.go @@ -102,7 +102,7 @@ func TestWorkspaceDeletion(t *testing.T) { t.Logf("Wait for default namespace to be created") framework.Eventually(t, func() (bool, string) { _, err := server.kubeClusterClient.Cluster(workspaceCluster).CoreV1().Namespaces().Get(ctx, "default", metav1.GetOptions{}) - return err == nil, fmt.Sprintf("%v", err) + return err == nil, err.Error() }, wait.ForeverTestTimeout, 100*time.Millisecond, "default namespace was never created") t.Logf("Delete default ns should be forbidden") @@ -230,7 +230,7 @@ func TestWorkspaceDeletion(t *testing.T) { nslist, err := rootShardKubeClusterClient.Cluster(wsClusterName.Path()).CoreV1().Namespaces().List(ctx, metav1.ListOptions{}) // 404 could be returned if the sub-workspace is deleted. if apierrors.IsNotFound(err) { - return true, fmt.Sprintf("%v", err) + return true, err.Error() } require.NoError(t, err, "failed to list namespaces in sub-workspace") @@ -242,7 +242,7 @@ func TestWorkspaceDeletion(t *testing.T) { nslist, err := rootShardKubeClusterClient.Cluster(orgClusterName.Path()).CoreV1().Namespaces().List(ctx, metav1.ListOptions{}) // 404 could be returned if the org workspace is deleted. if apierrors.IsNotFound(err) { - return true, fmt.Sprintf("%v", err) + return true, err.Error() } require.NoError(t, err, "failed to list namespaces in org workspace") @@ -254,7 +254,7 @@ func TestWorkspaceDeletion(t *testing.T) { wslist, err := rootShardKcpClusterClient.TenancyV1alpha1().ClusterWorkspaces().Cluster(orgClusterName.Path()).List(ctx, metav1.ListOptions{}) // 404 could be returned if the org workspace is deleted. if apierrors.IsNotFound(err) { - return true, fmt.Sprintf("%v", err) + return true, err.Error() } require.NoError(t, err, "failed to list workspaces in org workspace") diff --git a/test/e2e/virtual/clusterworkspaces/virtual_workspace_test.go b/test/e2e/virtual/clusterworkspaces/virtual_workspace_test.go index fc2f0dfcf1c..2ba38e856f9 100644 --- a/test/e2e/virtual/clusterworkspaces/virtual_workspace_test.go +++ b/test/e2e/virtual/clusterworkspaces/virtual_workspace_test.go @@ -196,7 +196,7 @@ func testWorkspacesVirtualWorkspaces(t *testing.T, standalone bool) { }() // wait for readiness - client := &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}} + client := &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}} //nolint:noctx baseClusterServerURL, err := url.Parse(baseCluster.Server) require.NoError(t, err) virtualWorkspaceServerHost = fmt.Sprintf("https://%s:%s", baseClusterServerURL.Hostname(), portStr) diff --git a/tmc/pkg/coordination/helpers.go b/tmc/pkg/coordination/helpers.go index 6e21d38a227..0bb7fd74921 100644 --- a/tmc/pkg/coordination/helpers.go +++ b/tmc/pkg/coordination/helpers.go @@ -55,7 +55,7 @@ func FilteredSyncerViewsChanged(old, new metav1.Object, keepSyncTarget func(sync } // SyncerViewChanged returns true if the syncer view fields changed between old and new -// for at least one of the SyncTargets on which the resource is synced +// for at least one of the SyncTargets on which the resource is synced. func AnySyncerViewChanged(old, new metav1.Object) bool { return FilteredSyncerViewsChanged(old, new, func(key string) bool { return true @@ -63,7 +63,7 @@ func AnySyncerViewChanged(old, new metav1.Object) bool { } // SyncerViewChanged returns true if the syncer view fields changed between old and new -// for the given SyncTarget +// for the given SyncTarget. func SyncerViewChanged(old, new metav1.Object, syncTargetKey string) bool { return FilteredSyncerViewsChanged(old, new, func(key string) bool { return syncTargetKey == key