Skip to content

Commit

Permalink
ci(lint): enable gocritic linter (#1605)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 authored Sep 11, 2023
1 parent 0f2d1f3 commit 30fd5cd
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 21 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
linters:
enable:
- gci
- gocritic
- gofumpt
- misspell

Expand Down
7 changes: 3 additions & 4 deletions from_dockerfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package testcontainers

import (
"context"
"path/filepath"
"strings"
"testing"

Expand All @@ -24,7 +23,7 @@ func TestBuildImageFromDockerfile(t *testing.T) {
tag, err := provider.BuildImage(ctx, &ContainerRequest{
// fromDockerfileIncludingRepo {
FromDockerfile: FromDockerfile{
Context: filepath.Join("testdata"),
Context: "testdata",
Dockerfile: "echo.Dockerfile",
Repo: "test-repo",
Tag: "test-tag",
Expand Down Expand Up @@ -61,7 +60,7 @@ func TestBuildImageFromDockerfile_NoRepo(t *testing.T) {

tag, err := provider.BuildImage(ctx, &ContainerRequest{
FromDockerfile: FromDockerfile{
Context: filepath.Join("testdata"),
Context: "testdata",
Dockerfile: "echo.Dockerfile",
Repo: "test-repo",
},
Expand Down Expand Up @@ -96,7 +95,7 @@ func TestBuildImageFromDockerfile_NoTag(t *testing.T) {

tag, err := provider.BuildImage(ctx, &ContainerRequest{
FromDockerfile: FromDockerfile{
Context: filepath.Join("testdata"),
Context: "testdata",
Dockerfile: "echo.Dockerfile",
Tag: "test-tag",
},
Expand Down
8 changes: 3 additions & 5 deletions modulegen/internal/context/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ func (m *TestcontainersModule) ContainerName() string {

if m.IsModule {
name = m.Title()
} else {
if m.TitleName != "" {
r, n := utf8.DecodeRuneInString(m.TitleName)
name = string(unicode.ToLower(r)) + m.TitleName[n:]
}
} else if m.TitleName != "" {
r, n := utf8.DecodeRuneInString(m.TitleName)
name = string(unicode.ToLower(r)) + m.TitleName[n:]
}

return name + "Container"
Expand Down
10 changes: 5 additions & 5 deletions modulegen/internal/mkdocs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ type Generator struct{}
func (g Generator) AddModule(ctx context.Context, tcModule context.TestcontainersModule) error {
moduleMdFile := filepath.Join(ctx.DocsDir(), tcModule.ParentDir(), tcModule.Lower()+".md")
funcMap := template.FuncMap{
"Entrypoint": func() string { return tcModule.Entrypoint() },
"ContainerName": func() string { return tcModule.ContainerName() },
"ParentDir": func() string { return tcModule.ParentDir() },
"ToLower": func() string { return tcModule.Lower() },
"Title": func() string { return tcModule.Title() },
"Entrypoint": tcModule.Entrypoint,
"ContainerName": tcModule.ContainerName,
"ParentDir": tcModule.ParentDir,
"ToLower": tcModule.Lower,
"Title": tcModule.Title,
}
err := GenerateMdFile(moduleMdFile, funcMap, tcModule)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions modulegen/internal/module/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ func (g Generator) AddModule(ctx context.Context, tcModule context.Testcontainer

func generateGoFiles(moduleDir string, tcModule context.TestcontainersModule) error {
funcMap := template.FuncMap{
"Entrypoint": func() string { return tcModule.Entrypoint() },
"ContainerName": func() string { return tcModule.ContainerName() },
"ParentDir": func() string { return tcModule.ParentDir() },
"ToLower": func() string { return tcModule.Lower() },
"Title": func() string { return tcModule.Title() },
"Entrypoint": tcModule.Entrypoint,
"ContainerName": tcModule.ContainerName,
"ParentDir": tcModule.ParentDir,
"ToLower": tcModule.Lower,
"Title": tcModule.Title,
}
return GenerateFiles(moduleDir, tcModule.Lower(), funcMap, tcModule)
}
Expand Down
3 changes: 1 addition & 2 deletions modules/k3s/k3s.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ func getContainerHost(ctx context.Context, opts ...testcontainers.ContainerCusto
return "", err
}

switch p := p.(type) {
case *testcontainers.DockerProvider:
if p, ok := p.(*testcontainers.DockerProvider); ok {
return p.DaemonHost(ctx)
}

Expand Down

0 comments on commit 30fd5cd

Please sign in to comment.