diff --git a/.golangci.yml b/.golangci.yml index 38dff7e062e..1494ed99aaa 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -38,7 +38,6 @@ linters-settings: disabled: true # TODO: Investigate if it should be enabled. Disabled for now due to many findings. - name: increment-decrement - name: var-naming - disabled: true # TODO: Investigate if it should be enabled. Disabled for now due to many findings. - name: var-declaration - name: package-comments disabled: true # TODO: Investigate if it should be enabled. Disabled for now due to many findings. diff --git a/hack/docs/generate_samples.go b/hack/docs/generate_samples.go index 9f727d74799..58a99aa46a5 100644 --- a/hack/docs/generate_samples.go +++ b/hack/docs/generate_samples.go @@ -27,7 +27,7 @@ import ( // Make sure executing `build_kb` to generate kb executable from the source code const KubebuilderBinName = "/tmp/kubebuilder/bin/kubebuilder" -type tutorial_generator interface { +type tutorialGenerator interface { Prepare() GenerateSampleProject() UpdateTutorial() @@ -52,7 +52,7 @@ func main() { } } -func updateTutorial(generator tutorial_generator) { +func updateTutorial(generator tutorialGenerator) { generator.Prepare() generator.GenerateSampleProject() generator.UpdateTutorial() diff --git a/hack/docs/internal/getting-started/generate_getting_started.go b/hack/docs/internal/getting-started/generate_getting_started.go index aa5ed8b88be..443b637328c 100644 --- a/hack/docs/internal/getting-started/generate_getting_started.go +++ b/hack/docs/internal/getting-started/generate_getting_started.go @@ -39,7 +39,7 @@ func NewSample(binaryPath, samplePath string) Sample { } func (sp *Sample) UpdateTutorial() { - sp.updateApi() + sp.updateAPI() sp.updateSample() sp.updateController() sp.updateControllerTest() @@ -100,7 +100,7 @@ func (sp *Sample) updateControllerTest() { hackutils.CheckError("add spec apis", err) } -func (sp *Sample) updateApi() { +func (sp *Sample) updateAPI() { var err error path := "api/v1alpha1/memcached_types.go" err = pluginutil.InsertCode( @@ -122,10 +122,10 @@ func (sp *Sample) updateApi() { `) hackutils.CheckError("collapse imports in memcached api", err) - err = pluginutil.ReplaceInFile(filepath.Join(sp.ctx.Dir, path), oldSpecApi, newSpecApi) + err = pluginutil.ReplaceInFile(filepath.Join(sp.ctx.Dir, path), oldSpecAPI, newSpecAPI) hackutils.CheckError("replace spec api", err) - err = pluginutil.ReplaceInFile(filepath.Join(sp.ctx.Dir, path), oldStatusApi, newStatusApi) + err = pluginutil.ReplaceInFile(filepath.Join(sp.ctx.Dir, path), oldStatusAPI, newStatusAPI) hackutils.CheckError("replace status api", err) } @@ -242,8 +242,8 @@ func (sp *Sample) CodeGen() { hackutils.CheckError("Failed to run make build-installer for getting started tutorial", err) } -const oldSpecApi = "// Foo is an example field of Memcached. Edit memcached_types.go to remove/update\n\tFoo string `json:\"foo,omitempty\"`" -const newSpecApi = `// Size defines the number of Memcached instances +const oldSpecAPI = "// Foo is an example field of Memcached. Edit memcached_types.go to remove/update\n\tFoo string `json:\"foo,omitempty\"`" +const newSpecAPI = `// Size defines the number of Memcached instances // The following markers will use OpenAPI v3 schema to validate the value // More info: https://book.kubebuilder.io/reference/markers/crd-validation.html // +kubebuilder:validation:Minimum=1 @@ -251,10 +251,10 @@ const newSpecApi = `// Size defines the number of Memcached instances // +kubebuilder:validation:ExclusiveMaximum=false Size int32 ` + "`json:\"size,omitempty\"`" -const oldStatusApi = `// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster +const oldStatusAPI = `// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster // Important: Run "make" to regenerate code after modifying this file` -const newStatusApi = `// Represents the observations of a Memcached's current state. +const newStatusAPI = `// Represents the observations of a Memcached's current state. // Memcached.status.conditions.type are: "Available", "Progressing", and "Degraded" // Memcached.status.conditions.status are one of True, False, Unknown. // Memcached.status.conditions.reason the value should be a CamelCase string and producers of specific diff --git a/hack/docs/internal/multiversion-tutorial/generate_multiversion.go b/hack/docs/internal/multiversion-tutorial/generate_multiversion.go index dc520686069..293eddb2141 100644 --- a/hack/docs/internal/multiversion-tutorial/generate_multiversion.go +++ b/hack/docs/internal/multiversion-tutorial/generate_multiversion.go @@ -93,8 +93,8 @@ func (sp *Sample) UpdateTutorial() { // Update files according to the multiversion sp.updateCronjobV1DueForce() - sp.updateApiV1() - sp.updateApiV2() + sp.updateAPIV1() + sp.updateAPIV2() sp.updateWebhookV2() sp.updateConversionFiles() sp.updateSampleV2() @@ -379,7 +379,7 @@ Most of the conversion is straightforward copying, except for converting our cha hackutils.CheckError("replace covert info at hub v2", err) } -func (sp *Sample) updateApiV1() { +func (sp *Sample) updateAPIV1() { path := "api/v1/cronjob_types.go" err := pluginutil.InsertCode( filepath.Join(sp.ctx.Dir, path), @@ -655,7 +655,7 @@ CronJob controller's `+"`SetupWithManager`"+` method. } -func (sp *Sample) updateApiV2() { +func (sp *Sample) updateAPIV2() { path := "api/v2/cronjob_types.go" err := pluginutil.InsertCode( filepath.Join(sp.ctx.Dir, path), diff --git a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/network-policy/allow-metrics-traffic.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/network-policy/allow-metrics-traffic.go index 0d01f7bb2db..3b3627f5750 100644 --- a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/network-policy/allow-metrics-traffic.go +++ b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/network-policy/allow-metrics-traffic.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package network_policy +package networkpolicy import ( "path/filepath" diff --git a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/network-policy/allow-webhook-traffic.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/network-policy/allow-webhook-traffic.go index a09d19236db..dda53087c62 100644 --- a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/network-policy/allow-webhook-traffic.go +++ b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/network-policy/allow-webhook-traffic.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package network_policy +package networkpolicy import ( "path/filepath" diff --git a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/network-policy/kustomization.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/network-policy/kustomization.go index b2ef298f75b..5a5b54c1b99 100644 --- a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/network-policy/kustomization.go +++ b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/network-policy/kustomization.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package network_policy +package networkpolicy import ( "path/filepath" diff --git a/pkg/plugins/optional/helm/v1alpha/scaffolds/init.go b/pkg/plugins/optional/helm/v1alpha/scaffolds/init.go index 513e78bb0de..9818fc73126 100644 --- a/pkg/plugins/optional/helm/v1alpha/scaffolds/init.go +++ b/pkg/plugins/optional/helm/v1alpha/scaffolds/init.go @@ -34,7 +34,7 @@ import ( "sigs.k8s.io/kubebuilder/v4/pkg/plugins/golang/deploy-image/v1alpha1" "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/helm" "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates" - chart_templates "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates" + charttemplates "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates" templatescertmanager "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates/cert-manager" "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates/manager" templatesmetrics "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates/metrics" @@ -93,7 +93,7 @@ func (s *initScaffolder) Scaffold() error { Force: s.force, }, &templates.HelmIgnore{}, - &chart_templates.HelmHelpers{}, + &charttemplates.HelmHelpers{}, &manager.ManagerDeployment{ Force: s.force, DeployImages: len(imagesEnvVars) > 0, diff --git a/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates/helpers_tpl.go b/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates/helpers_tpl.go index 4e6d351dd1a..35540a8df08 100644 --- a/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates/helpers_tpl.go +++ b/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/chart-templates/helpers_tpl.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package chart_templates +package charttemplates import ( "path/filepath" diff --git a/test/e2e/v4/generate_test.go b/test/e2e/v4/generate_test.go index bfe2c0740a4..8421402bac2 100644 --- a/test/e2e/v4/generate_test.go +++ b/test/e2e/v4/generate_test.go @@ -70,7 +70,7 @@ func GenerateV4(kbc *utils.TestContext) { certManagerTarget, "#")).To(Succeed()) ExpectWithOffset(1, pluginutil.UncommentCode( filepath.Join(kbc.Dir, "config", "prometheus", "kustomization.yaml"), - monitorTlsPatch, "#")).To(Succeed()) + monitorTLSPatch, "#")).To(Succeed()) ExpectWithOffset(1, pluginutil.UncommentCode( filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"), metricsCertPatch, "#")).To(Succeed()) @@ -186,7 +186,7 @@ func GenerateV4WithNetworkPolicies(kbc *utils.TestContext) { metricsCertReplaces, "#")).To(Succeed()) ExpectWithOffset(1, pluginutil.UncommentCode( filepath.Join(kbc.Dir, "config", "prometheus", "kustomization.yaml"), - monitorTlsPatch, "#")).To(Succeed()) + monitorTLSPatch, "#")).To(Succeed()) By("uncomment kustomization.yaml to enable network policy") ExpectWithOffset(1, pluginutil.UncommentCode( @@ -454,7 +454,7 @@ func uncommentKustomizeCoversion(kbc *utils.TestContext) { fmt.Sprintf(certName, kbc.Group, kbc.Domain), "#")).To(Succeed()) } -const monitorTlsPatch = `#patches: +const monitorTLSPatch = `#patches: # - path: monitor_tls_patch.yaml # target: # kind: ServiceMonitor` diff --git a/test/e2e/v4/plugin_cluster_test.go b/test/e2e/v4/plugin_cluster_test.go index ef0842106dd..0db654a9e3c 100644 --- a/test/e2e/v4/plugin_cluster_test.go +++ b/test/e2e/v4/plugin_cluster_test.go @@ -619,10 +619,10 @@ func serviceAccountToken(kbc *utils.TestContext) (out string, err error) { if err != nil { return out, err } - var rawJson string + var rawJSON string getToken := func(g Gomega) { // Output of this is already a valid JWT token. No need to covert this from base64 to string format - rawJson, err = kbc.Kubectl.Command( + rawJSON, err = kbc.Kubectl.Command( "create", "--raw", fmt.Sprintf( "/api/v1/namespaces/%s/serviceaccounts/%s/token", @@ -634,7 +634,7 @@ func serviceAccountToken(kbc *utils.TestContext) (out string, err error) { g.Expect(err).NotTo(HaveOccurred()) var token tokenRequest - err = json.Unmarshal([]byte(rawJson), &token) + err = json.Unmarshal([]byte(rawJSON), &token) g.Expect(err).NotTo(HaveOccurred()) out = token.Status.Token