From bcfd04768310a97ae8a5666ca187d896c72f2241 Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Wed, 29 Mar 2023 14:09:28 -0400 Subject: [PATCH] Enforce linting of leading and trailing whitespace in blocks Signed-off-by: Donnie Adams --- .github/PULL_REQUEST_TEMPLATE.md | 4 ++-- .golangci.yml | 1 + integration/client/computeclass/computeclass_test.go | 1 - integration/client/images/images_test.go | 1 - integration/client/volumes/volumeclasses_test.go | 2 -- integration/secrets/secret_test.go | 1 - pkg/apis/internal.acorn.io/v1/imageallowrules.go | 1 - pkg/apis/internal.acorn.io/v1/ports_test.go | 1 - pkg/apis/internal.admin.acorn.io/v1/computeclass.go | 1 - pkg/appdefinition/appdefinition_test.go | 2 -- pkg/autoupgrade/daemon.go | 1 - pkg/cli/builder/table/funcs.go | 1 - pkg/cli/check.go | 1 - pkg/cli/completion.go | 1 - pkg/cli/info_test.go | 1 - pkg/cli/log.go | 1 - pkg/cli/rm_helper.go | 3 --- pkg/cli/run.go | 1 - pkg/cli/secret_rm.go | 1 - pkg/client/app.go | 1 - pkg/controller/appdefinition/checkimageallowed.go | 1 - pkg/controller/appdefinition/pullappimage_test.go | 1 - pkg/controller/appdefinition/pullsecrets.go | 1 - pkg/controller/appdefinition/volume_bind.go | 1 - pkg/controller/tls/certs.go | 6 ------ pkg/controller/tls/letsencrypt.go | 9 --------- pkg/controller/tls/provider.go | 1 - pkg/cosign/cosign.go | 3 --- pkg/cosign/cosign_test.go | 4 ---- pkg/dns/helpers_test.go | 1 - pkg/imageallowrules/imageallowrules.go | 4 ---- pkg/install/check.go | 4 ---- pkg/install/install.go | 1 - pkg/secrets/secret.go | 1 - pkg/server/registry/apigroups/acorn/apps/validator.go | 1 - .../registry/apigroups/acorn/imageallowrules/storage.go | 1 - pkg/server/registry/apigroups/acorn/projects/strategy.go | 1 - .../registry/apigroups/acorn/projects/validator_test.go | 1 - pkg/uninstall/uninstall.go | 1 - 39 files changed, 3 insertions(+), 67 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 5cb9b6e84..bb92cb9f8 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,7 +1,7 @@ ### Checklist - [ ] The title of this PR would make a good line in Acorn's Release Note's Changelog -- [ ] The title of this PR ends with a link to the main issue being address in paranthesis, like: `This is a title (#1216)`. [Here's an example](https://github.com/acorn-io/acorn/pull/1199) -- [ ] All relevant issues are referenced in the PR description. *NOTE: don't use [GitHub keyworkds](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) that auto-close issues* +- [ ] The title of this PR ends with a link to the main issue being address in parentheses, like: `This is a title (#1216)`. [Here's an example](https://github.com/acorn-io/acorn/pull/1199) +- [ ] All relevant issues are referenced in the PR description. *NOTE: don't use [GitHub keywords](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) that auto-close issues* - [ ] Commits follow [contributing guidance](https://github.com/acorn-io/acorn/blob/main/CONTRIBUTING.md#commits) - [ ] Automated tests added to cover the changes. If tests couldn't be added, an explanation is provided in the Verification and Testing section - [ ] Changes to user-facing functionality, API, CLI, and upgrade impacts are clearly called out in PR description diff --git a/.golangci.yml b/.golangci.yml index d096231eb..66bb432ed 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -20,5 +20,6 @@ linters: - thelper - unused - goimports + - whitespace fast: false max-same-issues: 50 diff --git a/integration/client/computeclass/computeclass_test.go b/integration/client/computeclass/computeclass_test.go index 278a4b938..c91028cd2 100644 --- a/integration/client/computeclass/computeclass_test.go +++ b/integration/client/computeclass/computeclass_test.go @@ -158,7 +158,6 @@ func TestCreatingComputeClasses(t *testing.T) { t.Fatal("expected an error to occur when creating an invalid ComputeClass but did not receive one") } } - }) } } diff --git a/integration/client/images/images_test.go b/integration/client/images/images_test.go index ea44b190b..cc7188101 100644 --- a/integration/client/images/images_test.go +++ b/integration/client/images/images_test.go @@ -408,5 +408,4 @@ func TestImageBadTag(t *testing.T) { err = c.ImageTag(ctx, image.Name, "foo@@:badtag") assert.Equal(t, "repository can only contain the characters `abcdefghijklmnopqrstuvwxyz0123456789_-./`: foo@@", err.Error()) - } diff --git a/integration/client/volumes/volumeclasses_test.go b/integration/client/volumes/volumeclasses_test.go index f5f3c8f39..386ddfc53 100644 --- a/integration/client/volumes/volumeclasses_test.go +++ b/integration/client/volumes/volumeclasses_test.go @@ -142,7 +142,6 @@ func TestProjectVolumeClassCreateValidation(t *testing.T) { if err := kclient.Delete(ctx, &tt.volumeClass); err != nil && !apierrors.IsNotFound(err) { t.Fatal(err) } - }) } } @@ -308,7 +307,6 @@ func TestClusterVolumeClassCreateValidation(t *testing.T) { if err := kclient.Delete(ctx, &tt.volumeClass); err != nil && !apierrors.IsNotFound(err) { t.Fatal(err) } - }) } } diff --git a/integration/secrets/secret_test.go b/integration/secrets/secret_test.go index 18ba5ec70..0eeed6dc0 100644 --- a/integration/secrets/secret_test.go +++ b/integration/secrets/secret_test.go @@ -183,7 +183,6 @@ func TestEncryptionEndToEnd(t *testing.T) { }) assert.Equal(t, plainTextData, string(secret.Data["key"])) - } func TestNamespacedDecryption(t *testing.T) { diff --git a/pkg/apis/internal.acorn.io/v1/imageallowrules.go b/pkg/apis/internal.acorn.io/v1/imageallowrules.go index ed9670b84..d4a0f45d5 100644 --- a/pkg/apis/internal.acorn.io/v1/imageallowrules.go +++ b/pkg/apis/internal.acorn.io/v1/imageallowrules.go @@ -24,7 +24,6 @@ func (r *SignatureAnnotations) AsSelector() (labels.Selector, error) { } return metav1.LabelSelectorAsSelector(labelselector) - } type SignatureRules struct { diff --git a/pkg/apis/internal.acorn.io/v1/ports_test.go b/pkg/apis/internal.acorn.io/v1/ports_test.go index 66473a90f..8a791d3c7 100644 --- a/pkg/apis/internal.acorn.io/v1/ports_test.go +++ b/pkg/apis/internal.acorn.io/v1/ports_test.go @@ -30,7 +30,6 @@ func TestParseVolumesWithoutBinding(t *testing.T) { Size: "11G", Class: "aclass", }, vs[1]) - } func TestParseVolumes(t *testing.T) { diff --git a/pkg/apis/internal.admin.acorn.io/v1/computeclass.go b/pkg/apis/internal.admin.acorn.io/v1/computeclass.go index 5ad60765b..7061bee94 100644 --- a/pkg/apis/internal.admin.acorn.io/v1/computeclass.go +++ b/pkg/apis/internal.admin.acorn.io/v1/computeclass.go @@ -104,7 +104,6 @@ func ValidateComputeClass(wc ProjectComputeClassInstance, memory resource.Quanti } return fmt.Errorf("%w: defined memory %v exceeds the maximum memory for the ComputeClass %v of %v", ErrInvalidMemoryForClass, memory.String(), wc.Name, parsedMemory.Max.String()) - } if min := parsedMemory.Min.Value(); memBytes != 0 && memBytes < min { if memBytes == *memDefault { diff --git a/pkg/appdefinition/appdefinition_test.go b/pkg/appdefinition/appdefinition_test.go index 5110a046b..8623f37dd 100644 --- a/pkg/appdefinition/appdefinition_test.go +++ b/pkg/appdefinition/appdefinition_test.go @@ -573,7 +573,6 @@ containers: { }, }, }, appSpec.Containers["a"].Environment) - } func TestWorkdir(t *testing.T) { @@ -1375,7 +1374,6 @@ secrets: { assert.Equal(t, v1.Secret{ Type: "opaque", }, appSpec.Secrets["opt"]) - } func TestImageDataOverride(t *testing.T) { diff --git a/pkg/autoupgrade/daemon.go b/pkg/autoupgrade/daemon.go index 56e44009a..bfc103cbb 100644 --- a/pkg/autoupgrade/daemon.go +++ b/pkg/autoupgrade/daemon.go @@ -165,7 +165,6 @@ func (d *daemon) determineAppsToRefresh(apps map[kclient.ObjectKey]v1.AppInstanc } imageKey := imageAndNamespaceKey{image: img, namespace: app.Namespace} imagesToRefresh[imageKey] = append(imagesToRefresh[imageKey], appKey) - } } diff --git a/pkg/cli/builder/table/funcs.go b/pkg/cli/builder/table/funcs.go index 6832ed4cc..af77143e9 100644 --- a/pkg/cli/builder/table/funcs.go +++ b/pkg/cli/builder/table/funcs.go @@ -149,7 +149,6 @@ func cleanFields(obj any) any { return ro } return obj - } func FormatYAML(data any) (string, error) { diff --git a/pkg/cli/check.go b/pkg/cli/check.go index f7638b156..871d110c0 100644 --- a/pkg/cli/check.go +++ b/pkg/cli/check.go @@ -32,7 +32,6 @@ type Check struct { } func (a *Check) Run(cmd *cobra.Command, args []string) error { - checkOpts := install.CheckOptions{RuntimeImage: a.Image, IngressClassName: a.IngressClassName, Namespace: a.TestNamespace} checkresult := install.RunChecks(cmd.Context(), checkOpts, install.CheckRBAC, diff --git a/pkg/cli/completion.go b/pkg/cli/completion.go index 4df237753..cf08b1176 100644 --- a/pkg/cli/completion.go +++ b/pkg/cli/completion.go @@ -206,7 +206,6 @@ func imagesCompletion(allowDigest bool) completionFunc { result = append(result, digest) } } - } return result, nil diff --git a/pkg/cli/info_test.go b/pkg/cli/info_test.go index 11470d4a8..b778e8b9f 100644 --- a/pkg/cli/info_test.go +++ b/pkg/cli/info_test.go @@ -165,7 +165,6 @@ func TestInfo(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - ctrl := gomock.NewController(t) //Mocked client for cli's client calls. mClient := mocks.NewMockClient(ctrl) diff --git a/pkg/cli/log.go b/pkg/cli/log.go index 4c1c1087b..2d6b1a07f 100644 --- a/pkg/cli/log.go +++ b/pkg/cli/log.go @@ -18,7 +18,6 @@ func NewLogs(c CommandContext) *cobra.Command { Args: cobra.MaximumNArgs(1), ValidArgsFunction: newCompletion(c.ClientFactory, appsThenContainersCompletion).withShouldCompleteOptions(onlyNumArgs(1)).complete, }) - } type Logs struct { diff --git a/pkg/cli/rm_helper.go b/pkg/cli/rm_helper.go index cd553c253..ed85f9792 100644 --- a/pkg/cli/rm_helper.go +++ b/pkg/cli/rm_helper.go @@ -65,7 +65,6 @@ func getVolumesToDelete(arg string, client client.Client, cmd *cobra.Command) ([ if arg == volume.Status.AppName { result = append(result, volume.Name) } - } return result, nil } @@ -109,7 +108,6 @@ func removeContainer(arg string, c client.Client, cmd *cobra.Command, force bool fmt.Println("Removed: " + con) continue - } return nil } @@ -146,7 +144,6 @@ func removeVolume(arg string, c client.Client, cmd *cobra.Command, force bool) e } else { fmt.Printf("Error: No such volume: %s\n", vol) } - } return nil } diff --git a/pkg/cli/run.go b/pkg/cli/run.go index 4c1f02293..1ea922e2c 100644 --- a/pkg/cli/run.go +++ b/pkg/cli/run.go @@ -288,7 +288,6 @@ func (s *Run) Run(cmd *cobra.Command, args []string) error { } if s.Interactive && isDir { - return dev.Dev(cmd.Context(), c, s.File, &dev.Options{ Args: args, Build: client.AcornImageBuildOptions{ diff --git a/pkg/cli/secret_rm.go b/pkg/cli/secret_rm.go index 2fe7c47ab..5421a3ec4 100644 --- a/pkg/cli/secret_rm.go +++ b/pkg/cli/secret_rm.go @@ -24,7 +24,6 @@ type SecretDelete struct { } func (a *SecretDelete) Run(cmd *cobra.Command, args []string) error { - client, err := a.client.CreateDefault() if err != nil { return err diff --git a/pkg/client/app.go b/pkg/client/app.go index 269ef3523..047679f56 100644 --- a/pkg/client/app.go +++ b/pkg/client/app.go @@ -82,7 +82,6 @@ func (c *DefaultClient) AppUpdate(ctx context.Context, name string, opts *AppUpd } func ToAppUpdate(ctx context.Context, c Client, name string, opts *AppUpdateOptions) (*apiv1.App, error) { - app, err := c.AppGet(ctx, name) if err != nil { return nil, err diff --git a/pkg/controller/appdefinition/checkimageallowed.go b/pkg/controller/appdefinition/checkimageallowed.go index 6be1c99a5..fc43951fc 100644 --- a/pkg/controller/appdefinition/checkimageallowed.go +++ b/pkg/controller/appdefinition/checkimageallowed.go @@ -16,7 +16,6 @@ import ( // CheckImageAllowedHandler is a router handler that checks if the image is allowed by the image allow rules and sets a status field accordingly func CheckImageAllowedHandler(transport http.RoundTripper) router.HandlerFunc { return func(req router.Request, resp router.Response) error { - appInstance := req.Object.(*v1.AppInstance) cond := condition.Setter(appInstance, resp, v1.AppInstanceConditionImageAllowed) diff --git a/pkg/controller/appdefinition/pullappimage_test.go b/pkg/controller/appdefinition/pullappimage_test.go index af46e1c05..7f62b98af 100644 --- a/pkg/controller/appdefinition/pullappimage_test.go +++ b/pkg/controller/appdefinition/pullappimage_test.go @@ -8,7 +8,6 @@ import ( ) func TestDetermineDesiredImage(t *testing.T) { - //// Auto-upgrade cases // spec.Image is a pattern, status.image.ID not set, availableAppImage set. Expect the desiredImage to match availableAppImage diff --git a/pkg/controller/appdefinition/pullsecrets.go b/pkg/controller/appdefinition/pullsecrets.go index 4e8e4fc86..dd5cd7970 100644 --- a/pkg/controller/appdefinition/pullsecrets.go +++ b/pkg/controller/appdefinition/pullsecrets.go @@ -50,7 +50,6 @@ func (p *PullSecrets) ForAcorn(acornName, image string) []corev1.LocalObjectRefe Image: image, }, }) - } func (p *PullSecrets) ForContainer(containerName string, containers []corev1.Container) []corev1.LocalObjectReference { diff --git a/pkg/controller/appdefinition/volume_bind.go b/pkg/controller/appdefinition/volume_bind.go index d4fdb644e..a5c0a59fc 100644 --- a/pkg/controller/appdefinition/volume_bind.go +++ b/pkg/controller/appdefinition/volume_bind.go @@ -13,7 +13,6 @@ func ReleaseVolume(req router.Request, resp router.Response) error { if pv.Labels[labels.AcornManaged] == "true" && pv.Status.Phase == corev1.VolumeReleased && pv.Spec.ClaimRef != nil { - app := &v1.AppInstance{} err := req.Get(app, pv.Labels[labels.AcornAppNamespace], pv.Labels[labels.AcornAppName]) if apierror.IsNotFound(err) { diff --git a/pkg/controller/tls/certs.go b/pkg/controller/tls/certs.go index 4fda0958e..8d2eeede4 100644 --- a/pkg/controller/tls/certs.go +++ b/pkg/controller/tls/certs.go @@ -41,7 +41,6 @@ func ProvisionWildcardCert(req router.Request, resp router.Response, domain, tok // Generate wildcard certificate for domain return leUser.provisionCertIfNotExists(req.Ctx, req.Client, wildcardDomain, system.Namespace, system.TLSSecretName) - } // RequireSecretTypeTLS is a middleware that ensures that we only act on TLS-Type secrets @@ -77,7 +76,6 @@ func RenewCert(req router.Request, resp router.Response) error { domain := sec.Annotations[labels.AcornDomain] go func() { - // Do not start a new challenge if we already have one in progress if !lockDomain(domain) { logrus.Debugf("not starting certificate renewal: %v: %s", ErrCertificateRequestInProgress, domain) @@ -108,16 +106,13 @@ func RenewCert(req router.Request, resp router.Response) error { } logrus.Infof("TLS secret %s/%s renewed for domain %s", newSec.Namespace, newSec.Name, domain) - }() return nil - } // ProvisionCerts handles the provisioning of new TLS certificates for AppInstances func ProvisionCerts(req router.Request, resp router.Response) error { - cfg, err := config.Get(req.Ctx, req.Client) if err != nil { return err @@ -225,7 +220,6 @@ func findExistingCertSecret(ctx context.Context, client kclient.Client, target s return &sec, nil } } - } return nil, nil } diff --git a/pkg/controller/tls/letsencrypt.go b/pkg/controller/tls/letsencrypt.go index 078d80205..543332d46 100644 --- a/pkg/controller/tls/letsencrypt.go +++ b/pkg/controller/tls/letsencrypt.go @@ -123,7 +123,6 @@ func (u *LEUser) register() error { u.registration = reg return nil - } func (u *LEUser) toSecret() (*corev1.Secret, error) { @@ -194,7 +193,6 @@ func (u *LEUser) toHash() string { } func ensureLEUser(ctx context.Context, client kclient.Client) (*LEUser, error) { - cfg, err := config.Get(ctx, client) if err != nil { return nil, err @@ -269,7 +267,6 @@ func ensureLEUser(ctx context.Context, client kclient.Client) (*LEUser, error) { logrus.Infof("Registered Let's Encrypt User: %s", newLEUser.email) return newLEUser, nil - } func (u *LEUser) certToSecret(cert *certificate.Resource, domain, namespace, name string) (*corev1.Secret, error) { @@ -302,17 +299,14 @@ func (u *LEUser) certToSecret(cert *certificate.Resource, domain, namespace, nam } return sec, nil - } func (u *LEUser) getCert(ctx context.Context, domain string) (*certificate.Resource, error) { - if strings.HasPrefix(domain, "*.") { return u.dnsChallenge(ctx, domain) } return u.httpChallenge(ctx, domain) - } func lockDomain(domain string) bool { @@ -368,7 +362,6 @@ func stillValid(cert []byte) bool { // mustRenew returns true if the certificate must be renewed, either because the Let's Encrypt settings changed, the certificate is invalid or it's about to expire func (u *LEUser) mustRenew(sec *corev1.Secret) bool { - // (a) let's encrypt user settings changed -> renew if sec.Annotations[labels.AcornLetsEncryptSettingsHash] != u.toHash() { logrus.Infof("let's encrypt settings changed, must renew certificate for %s", sec.Annotations[labels.AcornDomain]) @@ -381,7 +374,6 @@ func (u *LEUser) mustRenew(sec *corev1.Secret) bool { } return false - } func (u *LEUser) dnsChallenge(ctx context.Context, domain string) (*certificate.Resource, error) { @@ -427,7 +419,6 @@ func (u *LEUser) dnsChallenge(ctx context.Context, domain string) (*certificate. } return client.Certificate.Obtain(request) - } func (u *LEUser) httpChallenge(ctx context.Context, domain string) (*certificate.Resource, error) { diff --git a/pkg/controller/tls/provider.go b/pkg/controller/tls/provider.go index 0e6d2034b..bec5ce90e 100644 --- a/pkg/controller/tls/provider.go +++ b/pkg/controller/tls/provider.go @@ -64,7 +64,6 @@ func NewDNSClient(endpoint, domain, token string) DNSClient { } func (d *DNSClient) SetTXTRecord(domain, text string) error { - prefix := strings.TrimSuffix(strings.TrimSuffix(domain, "."), d.domain) var requests []dns.RecordRequest diff --git a/pkg/cosign/cosign.go b/pkg/cosign/cosign.go index 32384046b..bf53fefac 100644 --- a/pkg/cosign/cosign.go +++ b/pkg/cosign/cosign.go @@ -42,7 +42,6 @@ type VerifyOpts struct { // verifySignature checks if the image is signed with the given key and if the annotations match the given rules func VerifySignature(ctx context.Context, c client.Reader, opts VerifyOpts) error { - // --- image name to digest hash imgRef, err := name.ParseReference(opts.ImageRef) if err != nil { @@ -98,7 +97,6 @@ func VerifySignature(ctx context.Context, c client.Reader, opts VerifyOpts) erro logrus.Debugf("Signature %s has digest: %s", sigRefToUse.Name(), sigDigest) if !opts.NoCache { - internalRepo, _, err := imagesystem.GetInternalRepoForNamespace(ctx, c, opts.Namespace) if err != nil { return fmt.Errorf("failed to get internal repo for namespace %s: %w", opts.Namespace, err) @@ -187,7 +185,6 @@ func decodePEM(raw []byte, signatureAlgorithm crypto.Hash) (signature.Verifier, var ErrAnnotationsUnmatched = cosign.NewVerificationError("annotations unmatched") func checkAnnotations(payloads []payload.SimpleContainerImage, annotationRule v1.SignatureAnnotations) error { - sel, err := annotationRule.AsSelector() if err != nil { return fmt.Errorf("failed to parse annotation rule: %w", err) diff --git a/pkg/cosign/cosign_test.go b/pkg/cosign/cosign_test.go index 3c5861d46..81ad2d969 100644 --- a/pkg/cosign/cosign_test.go +++ b/pkg/cosign/cosign_test.go @@ -80,12 +80,10 @@ func pushOCIDir(path string, ref name.Reference) error { fmt.Println(h) return nil - } // TODO: mock oci registry and signatures func TestVerifySignature(t *testing.T) { - imgPath := "./testdata/img.oci" imgDigestExpected := "sha256:245864d0312e7e33201eff111cfc071727f4eaa9edd10a395c367077e200cad2" @@ -228,7 +226,5 @@ func TestVerifySignature(t *testing.T) { if err == nil && tc.shouldError { t.Fatalf("[%d] expected error but got none: %s", ti, tc.description) } - } - } diff --git a/pkg/dns/helpers_test.go b/pkg/dns/helpers_test.go index ef0829414..79d84fee8 100644 --- a/pkg/dns/helpers_test.go +++ b/pkg/dns/helpers_test.go @@ -29,7 +29,6 @@ func TestToRecordRequests(t *testing.T) { // If the only hostname is "localhost", we can't actually CNAME to localhost, so expect an A record for 127.0.0.1 assrt(t, ".foo.com", []string{"app.foo.com"}, nil, nil, []string{"localhost"}, []RecordRequest{{"app", RecordTypeA, []string{"127.0.0.1"}}}) - } func assrt(t *testing.T, domain string, specRulesHosts, statusIPv4s, statusIPv6s, statusHosts []string, expectedRRs []RecordRequest) { diff --git a/pkg/imageallowrules/imageallowrules.go b/pkg/imageallowrules/imageallowrules.go index 1b4146052..683151b1f 100644 --- a/pkg/imageallowrules/imageallowrules.go +++ b/pkg/imageallowrules/imageallowrules.go @@ -33,7 +33,6 @@ func (e *ErrImageNotAllowed) Is(target error) bool { // CheckImageAllowed checks if the image is allowed by the ImageAllowRules on cluster and project level func CheckImageAllowed(ctx context.Context, c client.Reader, namespace, image string, opts ...remote.Option) error { - // Get ImageAllowRules in the same namespace as the AppInstance ImageAllowRulesList := &v1.ImageAllowRulesInstanceList{} if err := c.List(ctx, ImageAllowRulesList, &client.ListOptions{Namespace: namespace}); err != nil { @@ -49,7 +48,6 @@ func CheckImageAllowed(ctx context.Context, c client.Reader, namespace, image st } func CheckImageAgainstRules(ctx context.Context, c client.Reader, namespace string, image string, imageAllowRules []v1.ImageAllowRulesInstance, opts ...remote.Option) error { - if len(imageAllowRules) == 0 { // No ImageAllowRules found, so allow the image return nil @@ -67,13 +65,11 @@ func CheckImageAgainstRules(ctx context.Context, c client.Reader, namespace stri RegistryClientOpts: []ociremote.Option{ociremote.WithRemoteOptions(opts...)}, } for _, ImageAllowRules := range imageAllowRules { - notAllowedErr := &ErrImageNotAllowed{Rule: fmt.Sprintf("%s/%s", ImageAllowRules.Namespace, ImageAllowRules.Name), Image: image} // > Signatures notAllowedErr.SubruleType = "signatures" for ruleIndex, rule := range ImageAllowRules.Signatures.Rules { - verifyOpts.AnnotationRules = rule.Annotations notAllowedErr.SubrulePath = fmt.Sprintf("%d", ruleIndex) diff --git a/pkg/install/check.go b/pkg/install/check.go index 29a553d36..2abda29d3 100644 --- a/pkg/install/check.go +++ b/pkg/install/check.go @@ -75,7 +75,6 @@ func PreInstallChecks(ctx context.Context, opts CheckOptions) []CheckResult { // PostInstallChecks is a list of all checks that are run after the installation. // They are not critical and should not affect the installation process. func PostInstallChecks(ctx context.Context, opts CheckOptions) []CheckResult { - return RunChecks(ctx, opts, CheckDefaultStorageClass, CheckIngressCapability, @@ -113,7 +112,6 @@ func silenceKlog() { } func CheckExec(ctx context.Context, opts CheckOptions) CheckResult { - result := CheckResult{ Name: "Exec", } @@ -251,7 +249,6 @@ func CheckExec(ctx context.Context, opts CheckOptions) CheckResult { result.Passed = true result.Message = "Successfully executed command in container replica" return result - } func CheckIngressCapability(ctx context.Context, opts CheckOptions) CheckResult { @@ -474,7 +471,6 @@ func CheckNodesReady(ctx context.Context, opts CheckOptions) CheckResult { * -> This is a critical check that must be passed for Acorn to be installed. */ func CheckRBAC(ctx context.Context, opts CheckOptions) CheckResult { - result := CheckResult{ Name: "RBAC", } diff --git a/pkg/install/install.go b/pkg/install/install.go index 0a7d469ff..002a243e1 100644 --- a/pkg/install/install.go +++ b/pkg/install/install.go @@ -292,7 +292,6 @@ func TraefikResources() (result []kclient.Object, _ error) { } labels[labels2.AcornManaged] = "true" m.SetLabels(labels) - } return objs, nil diff --git a/pkg/secrets/secret.go b/pkg/secrets/secret.go index 4799f2220..4bf658458 100644 --- a/pkg/secrets/secret.go +++ b/pkg/secrets/secret.go @@ -461,7 +461,6 @@ func GetOrCreateSecret(secrets map[string]*corev1.Secret, req router.Request, ap } secrets[secretName] = secret return secret, nil - } func generate(characters string, tokenLength int) (string, error) { diff --git a/pkg/server/registry/apigroups/acorn/apps/validator.go b/pkg/server/registry/apigroups/acorn/apps/validator.go index 151041938..bad2a1c32 100644 --- a/pkg/server/registry/apigroups/acorn/apps/validator.go +++ b/pkg/server/registry/apigroups/acorn/apps/validator.go @@ -562,7 +562,6 @@ func (s *Validator) resolveLocalImage(ctx context.Context, namespace, image stri if tags.IsLocalReference(image) { return "", false, err } - } else if err != nil { return "", false, err } else { diff --git a/pkg/server/registry/apigroups/acorn/imageallowrules/storage.go b/pkg/server/registry/apigroups/acorn/imageallowrules/storage.go index 6d367f435..5346c9e25 100644 --- a/pkg/server/registry/apigroups/acorn/imageallowrules/storage.go +++ b/pkg/server/registry/apigroups/acorn/imageallowrules/storage.go @@ -10,7 +10,6 @@ import ( ) func NewStorage(c client.WithWatch) rest.Storage { - remoteResource := remote.NewWithSimpleTranslation(&Translator{}, &apiv1.ImageAllowRules{}, c) return stores.NewBuilder(c.Scheme(), &apiv1.ImageAllowRules{}). diff --git a/pkg/server/registry/apigroups/acorn/projects/strategy.go b/pkg/server/registry/apigroups/acorn/projects/strategy.go index eeb9d2a5f..9a059562b 100644 --- a/pkg/server/registry/apigroups/acorn/projects/strategy.go +++ b/pkg/server/registry/apigroups/acorn/projects/strategy.go @@ -122,7 +122,6 @@ func (s *Strategy) allowed(ctx context.Context) (sets.String, bool, error) { if fmt.Sprintf("system:serviceaccount:%s:%s", subject.Namespace, subject.Name) == user.GetName() { rulesName.Insert(crb.RoleRef.Name) } - } } } diff --git a/pkg/server/registry/apigroups/acorn/projects/validator_test.go b/pkg/server/registry/apigroups/acorn/projects/validator_test.go index ccfa2f14a..69b864277 100644 --- a/pkg/server/registry/apigroups/acorn/projects/validator_test.go +++ b/pkg/server/registry/apigroups/acorn/projects/validator_test.go @@ -77,7 +77,6 @@ func TestProjectCreateValidation(t *testing.T) { } else if tt.wantError && err == nil { t.Fatal("expected error for test case") } - }) } } diff --git a/pkg/uninstall/uninstall.go b/pkg/uninstall/uninstall.go index 0dd8ee595..dc32fc008 100644 --- a/pkg/uninstall/uninstall.go +++ b/pkg/uninstall/uninstall.go @@ -351,5 +351,4 @@ func shouldContinue(toDelete, toKeep []kclient.Object) (bool, error) { } return prompt.Bool("Do you want to delete/keep the above resources? "+ "To delete all resources pass run \"acorn uninstall --all\"", false) - }