Skip to content

Commit

Permalink
*: enable stylecheck and fix related lint warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
sgotti committed Mar 10, 2023
1 parent 8ad770c commit 669efd9
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 90 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
linters:
enable:
- stylecheck
- errorlint
- wrapcheck

Expand Down
9 changes: 4 additions & 5 deletions cmd/agola/cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ import (
"agola.io/agola/internal/services/config"
"agola.io/agola/internal/services/configstore"
"agola.io/agola/internal/services/executor"
rsexecutor "agola.io/agola/internal/services/executor"
"agola.io/agola/internal/services/gateway"
"agola.io/agola/internal/services/gitserver"
"agola.io/agola/internal/services/notification"
rsscheduler "agola.io/agola/internal/services/runservice"
"agola.io/agola/internal/services/runservice"
"agola.io/agola/internal/services/scheduler"
"agola.io/agola/internal/util"

Expand Down Expand Up @@ -106,15 +105,15 @@ func serve(cmd *cobra.Command, args []string) error {
return errors.Wrapf(err, "config error")
}

var rs *rsscheduler.Runservice
var rs *runservice.Runservice
if isComponentEnabled("runservice") {
rs, err = rsscheduler.NewRunservice(ctx, log.Logger, &c.Runservice)
rs, err = runservice.NewRunservice(ctx, log.Logger, &c.Runservice)
if err != nil {
return errors.Wrapf(err, "failed to start run service scheduler")
}
}

var ex *rsexecutor.Executor
var ex *executor.Executor
if isComponentEnabled("executor") {
ex, err = executor.NewExecutor(ctx, log.Logger, &c.Executor)
if err != nil {
Expand Down
48 changes: 24 additions & 24 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func TestParseOutput(t *testing.T) {
`,
out: &Config{
Runs: []*Run{
&Run{
{
Name: "run01",
DockerRegistriesAuth: map[string]*DockerRegistryAuth{
"index.docker.io": {
Expand All @@ -367,7 +367,7 @@ func TestParseOutput(t *testing.T) {
},
},
Tasks: []*Task{
&Task{
{
Name: "task01",
DockerRegistriesAuth: map[string]*DockerRegistryAuth{
"index.docker.io": {
Expand All @@ -380,19 +380,19 @@ func TestParseOutput(t *testing.T) {
Type: "pod",
Arch: "",
Containers: []*Container{
&Container{
{
Image: "image01",
Environment: map[string]Value{
"ENV01": Value{Type: ValueTypeString, Value: "ENV01"},
"ENVFROMVARIABLE01": Value{Type: ValueTypeFromVariable, Value: "variable01"},
"ENV01": {Type: ValueTypeString, Value: "ENV01"},
"ENVFROMVARIABLE01": {Type: ValueTypeFromVariable, Value: "variable01"},
},
User: "",
},
},
},
Environment: map[string]Value{
"ENV01": Value{Type: ValueTypeString, Value: "ENV01"},
"ENVFROMVARIABLE01": Value{Type: ValueTypeFromVariable, Value: "variable01"},
"ENV01": {Type: ValueTypeString, Value: "ENV01"},
"ENVFROMVARIABLE01": {Type: ValueTypeFromVariable, Value: "variable01"},
},
WorkingDir: defaultWorkingDir,
Shell: "",
Expand Down Expand Up @@ -422,15 +422,15 @@ func TestParseOutput(t *testing.T) {
},
Command: "command03",
Environment: map[string]Value{
"ENV01": Value{Type: ValueTypeString, Value: "ENV01"},
"ENVFROMVARIABLE01": Value{Type: ValueTypeFromVariable, Value: "variable01"},
"ENV01": {Type: ValueTypeString, Value: "ENV01"},
"ENVFROMVARIABLE01": {Type: ValueTypeFromVariable, Value: "variable01"},
},
Tty: util.BoolP(true),
},
&SaveCacheStep{
BaseStep: BaseStep{Type: "save_cache"},
Key: "cache-{{ arch }}",
Contents: []*SaveContent{&SaveContent{SourceDir: "/go/pkg/mod/cache", Paths: []string{"**"}}},
Contents: []*SaveContent{{SourceDir: "/go/pkg/mod/cache", Paths: []string{"**"}}},
},
&CloneStep{BaseStep: BaseStep{Type: "clone"}},
&RunStep{
Expand All @@ -456,15 +456,15 @@ func TestParseOutput(t *testing.T) {
},
Command: "command03",
Environment: map[string]Value{
"ENV01": Value{Type: ValueTypeString, Value: "ENV01"},
"ENVFROMVARIABLE01": Value{Type: ValueTypeFromVariable, Value: "variable01"},
"ENV01": {Type: ValueTypeString, Value: "ENV01"},
"ENVFROMVARIABLE01": {Type: ValueTypeFromVariable, Value: "variable01"},
},
Tty: util.BoolP(true),
},
&SaveCacheStep{
BaseStep: BaseStep{Type: "save_cache"},
Key: "cache-{{ arch }}",
Contents: []*SaveContent{&SaveContent{SourceDir: "/go/pkg/mod/cache", Paths: []string{"**"}}},
Contents: []*SaveContent{{SourceDir: "/go/pkg/mod/cache", Paths: []string{"**"}}},
},
},
IgnoreFailure: false,
Expand Down Expand Up @@ -492,18 +492,18 @@ func TestParseOutput(t *testing.T) {
},
},
Depends: []*Depend{
&Depend{TaskName: "task02", Conditions: []DependCondition{DependConditionOnSuccess, DependConditionOnFailure}},
&Depend{TaskName: "task03", Conditions: nil},
&Depend{TaskName: "task04", Conditions: []DependCondition{DependConditionOnSuccess}},
{TaskName: "task02", Conditions: []DependCondition{DependConditionOnSuccess, DependConditionOnFailure}},
{TaskName: "task03", Conditions: nil},
{TaskName: "task04", Conditions: []DependCondition{DependConditionOnSuccess}},
},
},
&Task{
{
Name: "task02",
Runtime: &Runtime{
Type: "pod",
Arch: "",
Containers: []*Container{
&Container{
{
Image: "image01",
},
},
Expand All @@ -512,13 +512,13 @@ func TestParseOutput(t *testing.T) {
Steps: nil,
Depends: nil,
},
&Task{
{
Name: "task03",
Runtime: &Runtime{
Type: "pod",
Arch: "",
Containers: []*Container{
&Container{
{
Image: "image01",
Volumes: []Volume{{Path: "/mnt/tmpfs", TmpFS: &VolumeTmpFS{Size: resource.NewQuantity(1024*1024*1024, resource.BinarySI)}}},
},
Expand All @@ -528,13 +528,13 @@ func TestParseOutput(t *testing.T) {
Steps: nil,
Depends: nil,
},
&Task{
{
Name: "task04",
Runtime: &Runtime{
Type: "pod",
Arch: "",
Containers: []*Container{
&Container{
{
Image: "image01",
Volumes: []Volume{{Path: "/mnt/tmpfs", TmpFS: &VolumeTmpFS{}}},
},
Expand All @@ -544,13 +544,13 @@ func TestParseOutput(t *testing.T) {
Steps: nil,
Depends: nil,
},
&Task{
{
Name: "task05",
Runtime: &Runtime{
Type: "pod",
Arch: "",
Containers: []*Container{
&Container{
{
Image: "image01",
},
},
Expand Down
32 changes: 16 additions & 16 deletions internal/services/executor/driver/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestDockerPod(t *testing.T) {
ID: uuid.Must(uuid.NewV4()).String(),
TaskID: uuid.Must(uuid.NewV4()).String(),
Containers: []*ContainerConfig{
&ContainerConfig{
{
Cmd: []string{"cat"},
Image: "busybox",
},
Expand All @@ -76,7 +76,7 @@ func TestDockerPod(t *testing.T) {
ID: uuid.Must(uuid.NewV4()).String(),
TaskID: uuid.Must(uuid.NewV4()).String(),
Containers: []*ContainerConfig{
&ContainerConfig{
{
Cmd: []string{"cat"},
Image: "busybox",
},
Expand Down Expand Up @@ -114,7 +114,7 @@ func TestDockerPod(t *testing.T) {
ID: uuid.Must(uuid.NewV4()).String(),
TaskID: uuid.Must(uuid.NewV4()).String(),
Containers: []*ContainerConfig{
&ContainerConfig{
{
Cmd: []string{"cat"},
Image: "busybox",
Env: env,
Expand Down Expand Up @@ -166,11 +166,11 @@ func TestDockerPod(t *testing.T) {
ID: uuid.Must(uuid.NewV4()).String(),
TaskID: uuid.Must(uuid.NewV4()).String(),
Containers: []*ContainerConfig{
&ContainerConfig{
{
Cmd: []string{"cat"},
Image: "busybox",
},
&ContainerConfig{
{
Image: "nginx:1.16",
},
},
Expand All @@ -187,11 +187,11 @@ func TestDockerPod(t *testing.T) {
ID: uuid.Must(uuid.NewV4()).String(),
TaskID: uuid.Must(uuid.NewV4()).String(),
Containers: []*ContainerConfig{
&ContainerConfig{
{
Cmd: []string{"cat"},
Image: "busybox",
},
&ContainerConfig{
{
Image: "nginx:1.16",
},
},
Expand Down Expand Up @@ -226,7 +226,7 @@ func TestDockerPod(t *testing.T) {
ID: uuid.Must(uuid.NewV4()).String(),
TaskID: uuid.Must(uuid.NewV4()).String(),
Containers: []*ContainerConfig{
&ContainerConfig{
{
Cmd: []string{"cat"},
Image: "busybox",
},
Expand Down Expand Up @@ -269,11 +269,11 @@ func TestDockerPod(t *testing.T) {
ID: uuid.Must(uuid.NewV4()).String(),
TaskID: uuid.Must(uuid.NewV4()).String(),
Containers: []*ContainerConfig{
&ContainerConfig{
{
Cmd: []string{"cat"},
Image: "busybox",
},
&ContainerConfig{
{
Image: "nginx:1.16",
},
},
Expand Down Expand Up @@ -315,11 +315,11 @@ func TestDockerPod(t *testing.T) {
ID: uuid.Must(uuid.NewV4()).String(),
TaskID: uuid.Must(uuid.NewV4()).String(),
Containers: []*ContainerConfig{
&ContainerConfig{
{
Cmd: []string{"cat"},
Image: "busybox",
},
&ContainerConfig{
{
Image: "nginx:1.16",
},
},
Expand Down Expand Up @@ -368,7 +368,7 @@ func TestDockerPod(t *testing.T) {
ID: uuid.Must(uuid.NewV4()).String(),
TaskID: uuid.Must(uuid.NewV4()).String(),
Containers: []*ContainerConfig{
&ContainerConfig{
{
Cmd: []string{"cat"},
Image: "busybox",
Volumes: []Volume{
Expand Down Expand Up @@ -409,7 +409,7 @@ func TestDockerPod(t *testing.T) {
ID: uuid.Must(uuid.NewV4()).String(),
TaskID: uuid.Must(uuid.NewV4()).String(),
Containers: []*ContainerConfig{
&ContainerConfig{
{
Cmd: []string{"cat"},
Image: "busybox",
Volumes: []Volume{
Expand Down Expand Up @@ -448,7 +448,7 @@ func TestDockerPod(t *testing.T) {
ID: uuid.Must(uuid.NewV4()).String(),
TaskID: uuid.Must(uuid.NewV4()).String(),
Containers: []*ContainerConfig{
&ContainerConfig{
{
Cmd: []string{"cat"},
Image: "busybox",
Volumes: []Volume{
Expand Down Expand Up @@ -495,7 +495,7 @@ func TestDockerPod(t *testing.T) {
ID: uuid.Must(uuid.NewV4()).String(),
TaskID: uuid.Must(uuid.NewV4()).String(),
Containers: []*ContainerConfig{
&ContainerConfig{
{
Cmd: []string{"cat"},
Image: "busybox",
Volumes: []Volume{
Expand Down
Loading

0 comments on commit 669efd9

Please sign in to comment.