Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
chore: add revive lint and fix related issues
Browse files Browse the repository at this point in the history
Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams committed Feb 6, 2024
1 parent e5c17fb commit c79a694
Show file tree
Hide file tree
Showing 163 changed files with 551 additions and 579 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ linters:
- unused
- goimports
- whitespace
- revive
fast: false
max-same-issues: 50
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ setup-ci-image:
docker build -t acorn:v-ci .
docker save acorn:v-ci | docker exec -i $$(docker ps | grep k3s | awk '{print $$1}') ctr --address /run/k3s/containerd/containerd.sock images import -

GOLANGCI_LINT_VERSION ?= v1.54.2
GOLANGCI_LINT_VERSION ?= v1.55.2
setup-env:
if ! command -v golangci-lint &> /dev/null; then \
echo "Could not find golangci-lint, installing version $(GOLANGCI_LINT_VERSION)."; \
Expand Down
1 change: 1 addition & 0 deletions integration/client/apps/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ func TestAppLog(t *testing.T) {
assert.NotEqual(t, "", msg1.Line)

go func() {
//nolint:revive
for range msgs {
}
}()
Expand Down
40 changes: 20 additions & 20 deletions integration/client/credentials/credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ func TestCredentialCreate(t *testing.T) {
helper.StartController(t)
restConfig := helper.StartAPI(t)

reg, close := helper.StartRegistry(t)
reg1, close1 := helper.StartRegistry(t)
defer close()
defer close1()
reg, cancel := helper.StartRegistry(t)
reg1, cancel1 := helper.StartRegistry(t)
defer cancel()
defer cancel1()

ctx := helper.GetCTX(t)
kclient := helper.MustReturn(kclient.Default)
Expand Down Expand Up @@ -60,10 +60,10 @@ func TestCredentialList(t *testing.T) {
helper.StartController(t)
restConfig := helper.StartAPI(t)

reg, close := helper.StartRegistry(t)
reg1, close1 := helper.StartRegistry(t)
defer close()
defer close1()
reg, cancel := helper.StartRegistry(t)
reg1, cancel1 := helper.StartRegistry(t)
defer cancel()
defer cancel1()

ctx := helper.GetCTX(t)
kclient := helper.MustReturn(kclient.Default)
Expand Down Expand Up @@ -110,10 +110,10 @@ func TestCredentialGet(t *testing.T) {
helper.StartController(t)
restConfig := helper.StartAPI(t)

reg, close := helper.StartRegistry(t)
reg1, close1 := helper.StartRegistry(t)
defer close()
defer close1()
reg, cancel := helper.StartRegistry(t)
reg1, cancel1 := helper.StartRegistry(t)
defer cancel()
defer cancel1()

ctx := helper.GetCTX(t)
kclient := helper.MustReturn(kclient.Default)
Expand Down Expand Up @@ -146,10 +146,10 @@ func TestCredentialUpdate(t *testing.T) {
helper.StartController(t)
restConfig := helper.StartAPI(t)

reg, close := helper.StartRegistry(t)
reg1, close1 := helper.StartRegistry(t)
defer close()
defer close1()
reg, cancel := helper.StartRegistry(t)
reg1, cancel1 := helper.StartRegistry(t)
defer cancel()
defer cancel1()

ctx := helper.GetCTX(t)
kclient := helper.MustReturn(kclient.Default)
Expand Down Expand Up @@ -189,10 +189,10 @@ func TestCredentialDelete(t *testing.T) {
helper.StartController(t)
restConfig := helper.StartAPI(t)

reg, close := helper.StartRegistry(t)
reg1, close1 := helper.StartRegistry(t)
defer close()
defer close1()
reg, cancel := helper.StartRegistry(t)
reg1, cancel1 := helper.StartRegistry(t)
defer cancel()
defer cancel1()

ctx := helper.GetCTX(t)
kclient := helper.MustReturn(kclient.Default)
Expand Down
6 changes: 3 additions & 3 deletions integration/client/imagerules/imageallowrules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import (
func TestImageAllowRules(t *testing.T) {
// TODO(@iwilltry42): Add test for auto-upgrade pattern
helper.StartController(t)
registry, close := helper.StartRegistry(t)
defer close()
registry, cancel := helper.StartRegistry(t)
defer cancel()

ctx := helper.GetCTX(t)
c, project := helper.ClientAndProject(t)
kclient := helper.MustReturn(kclient.Default)

// enable image allow rules in acorn config
helper.EnableFeatureWithRestore(t, ctx, kclient, profiles.FeatureImageAllowRules)
helper.EnableFeatureWithRestore(ctx, t, kclient, profiles.FeatureImageAllowRules)

// Delete any existing IARs from this project namespace
err := kclient.DeleteAllOf(ctx, &internalv1.ImageAllowRuleInstance{}, cclient.InNamespace(c.GetNamespace()))
Expand Down
8 changes: 4 additions & 4 deletions integration/client/imagerules/imageroleauthorizations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ var parentAcornfile []byte

func TestImageRoleAuthorizations(t *testing.T) {
helper.StartController(t)
registry, close := helper.StartRegistry(t)
defer close()
registry, cancel := helper.StartRegistry(t)
defer cancel()

ctx := helper.GetCTX(t)
c, _ := helper.ClientAndProject(t)
kclient := helper.MustReturn(kclient.Default)

// enable image role authorizations in acorn config
helper.EnableFeatureWithRestore(t, ctx, kclient, profiles.FeatureImageRoleAuthorizations)
helper.EnableFeatureWithRestore(ctx, t, kclient, profiles.FeatureImageRoleAuthorizations)

// Delete any existing rules from this project namespace
err := kclient.DeleteAllOf(ctx, &internaladminv1.ImageRoleAuthorizationInstance{}, cclient.InNamespace(c.GetNamespace()))
Expand Down Expand Up @@ -397,7 +397,7 @@ func TestImageRoleAuthorizationConsumerPerms(t *testing.T) {
kclient := helper.MustReturn(kclient.Default)

// enable image role authorizations in acorn config
helper.EnableFeatureWithRestore(t, ctx, kclient, profiles.FeatureImageRoleAuthorizations)
helper.EnableFeatureWithRestore(ctx, t, kclient, profiles.FeatureImageRoleAuthorizations)

// Delete any existing rules from this project namespace
err := kclient.DeleteAllOf(ctx, &internaladminv1.ImageRoleAuthorizationInstance{}, cclient.InNamespace(c.GetNamespace()))
Expand Down
4 changes: 2 additions & 2 deletions integration/client/imagerules/signature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (

func TestImageSignVerify(t *testing.T) {
helper.StartController(t)
registry, close := helper.StartRegistry(t)
defer close()
registry, cancel := helper.StartRegistry(t)
defer cancel()

ctx := helper.GetCTX(t)
c, project := helper.ClientAndProject(t)
Expand Down
12 changes: 6 additions & 6 deletions integration/client/images/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ func TestImageTag(t *testing.T) {

func TestImagePush(t *testing.T) {
helper.StartController(t)
registry, close := helper.StartRegistry(t)
defer close()
registry, cancel := helper.StartRegistry(t)
defer cancel()
restConfig := helper.StartAPI(t)

ctx := helper.GetCTX(t)
Expand Down Expand Up @@ -193,8 +193,8 @@ func TestImagePush(t *testing.T) {

func TestImagePull(t *testing.T) {
helper.StartController(t)
registry, close := helper.StartRegistry(t)
defer close()
registry, cancel := helper.StartRegistry(t)
defer cancel()
restConfig := helper.StartAPI(t)

ctx := helper.GetCTX(t)
Expand Down Expand Up @@ -268,8 +268,8 @@ func TestImagePull(t *testing.T) {

func TestImageDetails(t *testing.T) {
helper.StartController(t)
registry, close := helper.StartRegistry(t)
defer close()
registry, cancel := helper.StartRegistry(t)
defer cancel()
restConfig := helper.StartAPI(t)

ctx := helper.GetCTX(t)
Expand Down
2 changes: 1 addition & 1 deletion integration/helper/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func Subset[V, W any, Z comparable](t *testing.T, first []V, second []W, firstLo

set := make(map[Z]int)
for _, value := range second {
set[secondLookup(value)] += 1
set[secondLookup(value)]++
}

for _, value := range first {
Expand Down
4 changes: 2 additions & 2 deletions integration/helper/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
kclient "sigs.k8s.io/controller-runtime/pkg/client"
)

func EnableFeatureWithRestore(t *testing.T, ctx context.Context, kclient kclient.WithWatch, feature string) {
func EnableFeatureWithRestore(ctx context.Context, t *testing.T, kclient kclient.WithWatch, feature string) {
t.Helper()

// enable feature in acorn config
Expand Down Expand Up @@ -43,7 +43,7 @@ func EnableFeatureWithRestore(t *testing.T, ctx context.Context, kclient kclient
}
}

func SetIgnoreResourceRequirementsWithRestore(t *testing.T, ctx context.Context, kclient kclient.WithWatch) {
func SetIgnoreResourceRequirementsWithRestore(ctx context.Context, t *testing.T, kclient kclient.WithWatch) {
t.Helper()

cfg, err := config.Get(ctx, kclient)
Expand Down
1 change: 1 addition & 0 deletions integration/helper/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func doWatch[T client.Object](t *testing.T, watchFunc watchFunc, cb func(obj T)
}
defer func() {
result.Stop()
//nolint:revive
for range result.ResultChan() {
}
}()
Expand Down
8 changes: 4 additions & 4 deletions integration/run/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1425,8 +1425,8 @@ func TestCrossProjectNetworkConnection(t *testing.T) {
})

// determine pod IPs so we can test network connections
fooIP := getPodIPFromAppName(t, ctx, &kc, fooApp.Name, fooApp.Status.Namespace)
barIP := getPodIPFromAppName(t, ctx, &kc, barApp.Name, barApp.Status.Namespace)
fooIP := getPodIPFromAppName(ctx, t, &kc, fooApp.Name, fooApp.Status.Namespace)
barIP := getPodIPFromAppName(ctx, t, &kc, barApp.Name, barApp.Status.Namespace)

// build an Acorn that just runs a job with the official curl container
curlImage1, err := proj1Client.AcornImageBuild(ctx, "testdata/networkpolicy/curl.Acornfile", nil)
Expand Down Expand Up @@ -1500,7 +1500,7 @@ func TestCrossProjectNetworkConnection(t *testing.T) {
}
}

func getPodIPFromAppName(t *testing.T, ctx context.Context, kc *crClient.WithWatch, appName, namespace string) string {
func getPodIPFromAppName(ctx context.Context, t *testing.T, kc *crClient.WithWatch, appName, namespace string) string {
t.Helper()
selector, err := k8slabels.Parse(fmt.Sprintf("%s=%s", labels.AcornAppName, appName))
if err != nil {
Expand Down Expand Up @@ -1800,7 +1800,7 @@ func TestIgnoreResourceRequirements(t *testing.T) {
kc := helper.MustReturn(kclient.Default)
project := helper.TempProject(t, kc)

helper.SetIgnoreResourceRequirementsWithRestore(t, ctx, kc)
helper.SetIgnoreResourceRequirementsWithRestore(ctx, t, kc)

c, err := client.New(restConfig, project.Name, project.Name)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/admin.acorn.io/group.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package admin_acorn_io
package adminacornio

var Group = "admin.acorn.io"
2 changes: 1 addition & 1 deletion pkg/apis/api.acorn.io/group.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package api_acorn_io
package apiacornio

var Group = "api.acorn.io"
18 changes: 9 additions & 9 deletions pkg/apis/api.acorn.io/v1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
)

func convert_url_Values_To__ContainerReplicaExecOptions(in *url.Values, out *ContainerReplicaExecOptions, s conversion.Scope) error {
func convertURLlValuesToContainerReplicaExecOptions(in *url.Values, out *ContainerReplicaExecOptions, s conversion.Scope) error {
if values, ok := map[string][]string(*in)["command"]; ok && len(values) > 0 {
out.Command = *(*[]string)(unsafe.Pointer(&values))
} else {
Expand All @@ -31,11 +31,11 @@ func convert_url_Values_To__ContainerReplicaExecOptions(in *url.Values, out *Con
return nil
}

func Convert_url_Values_To__ContainerReplicaExecOptions(in, out interface{}, s conversion.Scope) error {
return convert_url_Values_To__ContainerReplicaExecOptions(in.(*url.Values), out.(*ContainerReplicaExecOptions), s)
func ConvertURLValuesToContainerReplicaExecOptions(in, out interface{}, s conversion.Scope) error {
return convertURLlValuesToContainerReplicaExecOptions(in.(*url.Values), out.(*ContainerReplicaExecOptions), s)
}

func convert_url_Values_To__LogOptions(in *url.Values, out *LogOptions, s conversion.Scope) error {
func convertURLValuesToLogOptions(in *url.Values, out *LogOptions, s conversion.Scope) error {
if values, ok := map[string][]string(*in)["tailLines"]; ok && len(values) > 0 {
out.Tail = new(int64)
if err := runtime.Convert_Slice_string_To_int64(&values, out.Tail, s); err != nil {
Expand All @@ -60,11 +60,11 @@ func convert_url_Values_To__LogOptions(in *url.Values, out *LogOptions, s conver
return nil
}

func Convert_url_Values_To__LogOptions(in, out interface{}, s conversion.Scope) error {
return convert_url_Values_To__LogOptions(in.(*url.Values), out.(*LogOptions), s)
func ConvertURLValuesToLogOptions(in, out interface{}, s conversion.Scope) error {
return convertURLValuesToLogOptions(in.(*url.Values), out.(*LogOptions), s)
}

func convert_url_Values_To__ContainerReplicaPortForwardOptions(in *url.Values, out *ContainerReplicaPortForwardOptions, s conversion.Scope) error {
func convertURLValuesToContainerReplicaPortForwardOptions(in *url.Values, out *ContainerReplicaPortForwardOptions, s conversion.Scope) error {
if values, ok := map[string][]string(*in)["port"]; ok && len(values) > 0 {
if err := runtime.Convert_Slice_string_To_int(&values, &out.Port, s); err != nil {
return err
Expand All @@ -75,6 +75,6 @@ func convert_url_Values_To__ContainerReplicaPortForwardOptions(in *url.Values, o
return nil
}

func Convert_url_Values_To__ContainerReplicaPortForwardOptions(in, out interface{}, s conversion.Scope) error {
return convert_url_Values_To__ContainerReplicaPortForwardOptions(in.(*url.Values), out.(*ContainerReplicaPortForwardOptions), s)
func ConvertURLValuesToContainerReplicaPortForwardOptions(in, out interface{}, s conversion.Scope) error {
return convertURLValuesToContainerReplicaPortForwardOptions(in.(*url.Values), out.(*ContainerReplicaPortForwardOptions), s)
}
10 changes: 5 additions & 5 deletions pkg/apis/api.acorn.io/v1/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"net/url"

api_acorn_io "github.com/acorn-io/runtime/pkg/apis/api.acorn.io"
apiacornio "github.com/acorn-io/runtime/pkg/apis/api.acorn.io"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand All @@ -13,7 +13,7 @@ import (
const Version = "v1"

var SchemeGroupVersion = schema.GroupVersion{
Group: api_acorn_io.Group,
Group: apiacornio.Group,
Version: Version,
}

Expand Down Expand Up @@ -83,13 +83,13 @@ func AddToSchemeWithGV(scheme *runtime.Scheme, schemeGroupVersion schema.GroupVe
// Add the watch version that applies
metav1.AddToGroupVersion(scheme, schemeGroupVersion)

if err := scheme.AddConversionFunc((*url.Values)(nil), (*ContainerReplicaPortForwardOptions)(nil), Convert_url_Values_To__ContainerReplicaPortForwardOptions); err != nil {
if err := scheme.AddConversionFunc((*url.Values)(nil), (*ContainerReplicaPortForwardOptions)(nil), ConvertURLValuesToContainerReplicaPortForwardOptions); err != nil {
return err
}
if err := scheme.AddConversionFunc((*url.Values)(nil), (*ContainerReplicaExecOptions)(nil), Convert_url_Values_To__ContainerReplicaExecOptions); err != nil {
if err := scheme.AddConversionFunc((*url.Values)(nil), (*ContainerReplicaExecOptions)(nil), ConvertURLValuesToContainerReplicaExecOptions); err != nil {
return err
}
if err := scheme.AddConversionFunc((*url.Values)(nil), (*LogOptions)(nil), Convert_url_Values_To__LogOptions); err != nil {
if err := scheme.AddConversionFunc((*url.Values)(nil), (*LogOptions)(nil), ConvertURLValuesToLogOptions); err != nil {
return err
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/apis/api.acorn.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ type Image struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

ZZ_Remote bool `json:"remote,omitempty"`
Repo string `json:"repo,omitempty"`
Digest string `json:"digest,omitempty"`
Tags []string `json:"tags,omitempty"`
ZZRemote bool `json:"remote,omitempty"`
Repo string `json:"repo,omitempty"`
Digest string `json:"digest,omitempty"`
Tags []string `json:"tags,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down Expand Up @@ -497,7 +497,7 @@ type Config struct {
LetsEncryptTOSAgree *bool `json:"letsEncryptTOSAgree" name:"lets-encrypt-tos-agree" usage:"Required if --lets-encrypt=enabled. If true, you agree to the Let's Encrypt terms of service (default false)"`
SetPodSecurityEnforceProfile *bool `json:"setPodSecurityEnforceProfile" usage:"Set the PodSecurity profile on created namespaces (default true)"`
PodSecurityEnforceProfile string `json:"podSecurityEnforceProfile" usage:"The name of the PodSecurity profile to set (default baseline)" wrangler:"nullable"`
HttpEndpointPattern *string `json:"httpEndpointPattern" name:"http-endpoint-pattern" usage:"Go template for formatting application http endpoints. Valid variables to use are: App, Container, Namespace, Hash and ClusterDomain. (default pattern is {{hashConcat 8 .Container .App .Namespace | truncate}}.{{.ClusterDomain}})" wrangler:"nullable"`
HTTPEndpointPattern *string `json:"httpEndpointPattern" name:"http-endpoint-pattern" usage:"Go template for formatting application http endpoints. Valid variables to use are: App, Container, Namespace, Hash and ClusterDomain. (default pattern is {{hashConcat 8 .Container .App .Namespace | truncate}}.{{.ClusterDomain}})" wrangler:"nullable"`
InternalClusterDomain string `json:"internalClusterDomain" usage:"The Kubernetes internal cluster domain (default svc.cluster.local)" wrangler:"nullable"`
AcornDNS *string `json:"acornDNS" name:"acorn-dns" usage:"enabled|disabled|auto. If enabled, containers created by Acorn will get public FQDNs. Auto functions as disabled if a custom clusterDomain has been supplied (default auto)"`
AcornDNSEndpoint *string `json:"acornDNSEndpoint" name:"acorn-dns-endpoint" usage:"The URL to access the Acorn DNS service"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/api.acorn.io/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/internal.acorn.io/group.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package internal_acorn_io
package internalacornio

var Group = "internal.acorn.io"
Loading

0 comments on commit c79a694

Please sign in to comment.