diff --git a/.golangci.yml b/.golangci.yml index 97f40a5..cf67750 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -40,7 +40,7 @@ linters-settings: - blank # Blank section: contains all blank imports. - default # Default section: contains all imports that could not be matched to another section type. - prefix(github.com/pulumi/) # Custom section: groups all imports with the github.com/pulumi/ prefix. - - prefix(github.com/pulumi/pulumi-dockerbuild/) # Custom section: local imports + - prefix(github.com/pulumi/pulumi-docker-build) # Custom section: local imports custom-order: true gocritic: enable-all: true diff --git a/provider/cmd/pulumi-resource-docker-build/main.go b/provider/cmd/pulumi-resource-docker-build/main.go index e6dfaed..f4588c1 100644 --- a/provider/cmd/pulumi-resource-docker-build/main.go +++ b/provider/cmd/pulumi-resource-docker-build/main.go @@ -16,8 +16,9 @@ package main import ( - "github.com/pulumi/pulumi-docker-build/provider" "github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil" + + "github.com/pulumi/pulumi-docker-build/provider" ) func main() { diff --git a/provider/internal/cache.go b/provider/internal/cache.go index 05e939c..f33195c 100644 --- a/provider/internal/cache.go +++ b/provider/internal/cache.go @@ -448,7 +448,7 @@ func (c CacheFrom) String() string { return join(c.Local, c.Registry, c.GHA, c.AZBlob, c.S3, c.Raw) } -func (c CacheFrom) validate(preview bool) (*controllerapi.CacheOptionsEntry, error) { +func (c CacheFrom) validate(_ bool) (*controllerapi.CacheOptionsEntry, error) { if strings.Count(c.String(), "type=") > 1 { return nil, errors.New("cacheFrom should only specify one cache type") } @@ -672,7 +672,7 @@ func (c CacheTo) String() string { return join(c.Inline, c.Local, c.Registry, c.GHA, c.AZBlob, c.S3, c.Raw) } -func (c CacheTo) validate(preview bool) (*controllerapi.CacheOptionsEntry, error) { +func (c CacheTo) validate(_ bool) (*controllerapi.CacheOptionsEntry, error) { if strings.Count(c.String(), "type=") > 1 { return nil, errors.New("cacheTo should only specify one cache type") } diff --git a/provider/internal/export.go b/provider/internal/export.go index 16671d4..7f01f11 100644 --- a/provider/internal/export.go +++ b/provider/internal/export.go @@ -28,6 +28,10 @@ import ( "github.com/pulumi/pulumi-go-provider/infer" ) +const ( + trueLiteral = "true" +) + var ( _ fmt.Stringer = (*Export)(nil) _ fmt.Stringer = (*ExportDocker)(nil) @@ -114,7 +118,7 @@ func (e Export) pushed() bool { if err != nil { return false } - return exp[0].Attrs["push"] == "true" + return exp[0].Attrs["push"] == trueLiteral } if e.Registry != nil { return e.Registry.Push == nil || *e.Registry.Push @@ -182,7 +186,7 @@ func parseExports(inp []string) ([]*controllerapi.ExportEntry, error) { if out.Type == "registry" { out.Type = client.ExporterImage if _, ok := out.Attrs["push"]; !ok { - out.Attrs["push"] = "true" + out.Attrs["push"] = trueLiteral } } diff --git a/provider/internal/host.go b/provider/internal/host.go index cb9ad91..78a6b67 100644 --- a/provider/internal/host.go +++ b/provider/internal/host.go @@ -43,7 +43,7 @@ type host struct { supportsMultipleExports bool } -func newHost(ctx context.Context, config *Config) (*host, error) { +func newHost(_ context.Context, config *Config) (*host, error) { docker, err := newDockerCLI(config) if err != nil { return nil, err diff --git a/provider/internal/image_test.go b/provider/internal/image_test.go index 59395c0..c6670ad 100644 --- a/provider/internal/image_test.go +++ b/provider/internal/image_test.go @@ -84,7 +84,7 @@ func TestImageLifecycle(t *testing.T) { Return(nil) return c }, - op: func(t *testing.T) integration.Operation { + op: func(_ *testing.T) integration.Operation { return integration.Operation{ Inputs: property.NewMap(map[string]property.Value{ "push": property.New(false), @@ -130,7 +130,7 @@ func TestImageLifecycle(t *testing.T) { { name: "tags are required when pushing", client: noClient, - op: func(t *testing.T) integration.Operation { + op: func(_ *testing.T) integration.Operation { return integration.Operation{ Inputs: property.NewMap(map[string]property.Value{ "push": property.New(false), @@ -159,7 +159,7 @@ func TestImageLifecycle(t *testing.T) { { name: "invalid exports", client: noClient, - op: func(t *testing.T) integration.Operation { + op: func(_ *testing.T) integration.Operation { return integration.Operation{ Inputs: property.NewMap(map[string]property.Value{ "push": property.New(false), @@ -192,7 +192,7 @@ func TestImageLifecycle(t *testing.T) { ) return c }, - op: func(t *testing.T) integration.Operation { + op: func(_ *testing.T) integration.Operation { return integration.Operation{ Inputs: property.NewMap(map[string]property.Value{ "push": property.New(false), @@ -219,7 +219,7 @@ func TestImageLifecycle(t *testing.T) { ) return c }, - op: func(t *testing.T) integration.Operation { + op: func(_ *testing.T) integration.Operation { return integration.Operation{ Inputs: property.NewMap(map[string]property.Value{ "push": property.New(false), @@ -252,7 +252,7 @@ func TestImageLifecycle(t *testing.T) { c.EXPECT().Delete(gomock.Any(), "default-dockerfile").Return(nil) return c }, - op: func(t *testing.T) integration.Operation { + op: func(_ *testing.T) integration.Operation { return integration.Operation{ Inputs: property.NewMap(map[string]property.Value{ "push": property.New(false), @@ -294,7 +294,7 @@ func TestImageLifecycle(t *testing.T) { c.EXPECT().Delete(gomock.Any(), "inline-dockerfile").Return(nil) return c }, - op: func(t *testing.T) integration.Operation { + op: func(_ *testing.T) integration.Operation { return integration.Operation{ Inputs: property.NewMap(map[string]property.Value{ "push": property.New(false), @@ -459,7 +459,7 @@ func TestImageDiff(t *testing.T) { is.Pull = true return is }, - inputs: func(t *testing.T, ia ImageArgs) ImageArgs { + inputs: func(_ *testing.T, ia ImageArgs) ImageArgs { ia.Pull = true return ia }, @@ -472,7 +472,7 @@ func TestImageDiff(t *testing.T) { is.Load = true return is }, - inputs: func(t *testing.T, ia ImageArgs) ImageArgs { + inputs: func(_ *testing.T, ia ImageArgs) ImageArgs { ia.Pull = true ia.Load = true return ia @@ -534,7 +534,7 @@ func TestImageDiff(t *testing.T) { { name: "diff if pull changes", state: func(*testing.T, ImageState) ImageState { return baseState }, - inputs: func(t *testing.T, ia ImageArgs) ImageArgs { + inputs: func(_ *testing.T, ia ImageArgs) ImageArgs { ia.Pull = true return ia }, @@ -543,7 +543,7 @@ func TestImageDiff(t *testing.T) { { name: "diff if load changes", state: func(*testing.T, ImageState) ImageState { return baseState }, - inputs: func(t *testing.T, ia ImageArgs) ImageArgs { + inputs: func(_ *testing.T, ia ImageArgs) ImageArgs { ia.Load = true return ia }, @@ -552,7 +552,7 @@ func TestImageDiff(t *testing.T) { { name: "diff if push changes", state: func(*testing.T, ImageState) ImageState { return baseState }, - inputs: func(t *testing.T, ia ImageArgs) ImageArgs { + inputs: func(_ *testing.T, ia ImageArgs) ImageArgs { ia.Push = true return ia }, @@ -561,7 +561,7 @@ func TestImageDiff(t *testing.T) { { name: "diff if buildOnPreview doesn't change", state: func(*testing.T, ImageState) ImageState { return baseState }, - inputs: func(t *testing.T, ia ImageArgs) ImageArgs { + inputs: func(_ *testing.T, ia ImageArgs) ImageArgs { val := true ia.BuildOnPreview = &val return ia @@ -571,7 +571,7 @@ func TestImageDiff(t *testing.T) { { name: "diff if buildOnPreview changes", state: func(*testing.T, ImageState) ImageState { return baseState }, - inputs: func(t *testing.T, ia ImageArgs) ImageArgs { + inputs: func(_ *testing.T, ia ImageArgs) ImageArgs { val := false ia.BuildOnPreview = &val return ia @@ -581,7 +581,7 @@ func TestImageDiff(t *testing.T) { { name: "diff if ssh changes", state: func(*testing.T, ImageState) ImageState { return baseState }, - inputs: func(t *testing.T, ia ImageArgs) ImageArgs { + inputs: func(_ *testing.T, ia ImageArgs) ImageArgs { ia.SSH = []SSH{{ID: "default"}} return ia }, @@ -590,7 +590,7 @@ func TestImageDiff(t *testing.T) { { name: "diff if hosts change", state: func(*testing.T, ImageState) ImageState { return baseState }, - inputs: func(t *testing.T, ia ImageArgs) ImageArgs { + inputs: func(_ *testing.T, ia ImageArgs) ImageArgs { ia.AddHosts = []string{"localhost"} return ia }, @@ -751,7 +751,7 @@ func TestImageDiff(t *testing.T) { }, { name: "diff if local export doesn't exist", - state: func(t *testing.T, state ImageState) ImageState { + state: func(_ *testing.T, state ImageState) ImageState { state.Exports = []Export{ {Local: &ExportLocal{Dest: "not-real"}}, } @@ -767,7 +767,7 @@ func TestImageDiff(t *testing.T) { }, { name: "diff if tar export doesn't exist", - state: func(t *testing.T, state ImageState) ImageState { + state: func(_ *testing.T, state ImageState) ImageState { state.Exports = []Export{ {Tar: &ExportTar{ExportLocal: ExportLocal{Dest: "not-real"}}}, } diff --git a/provider/internal/index_test.go b/provider/internal/index_test.go index 5da04f3..009acd6 100644 --- a/provider/internal/index_test.go +++ b/provider/internal/index_test.go @@ -32,7 +32,7 @@ import ( func TestIndexLifecycle(t *testing.T) { t.Parallel() - realClient := func(t *testing.T) clientF { return RealClientF } + realClient := func(_ *testing.T) clientF { return RealClientF } tests := []struct { name string @@ -44,7 +44,7 @@ func TestIndexLifecycle(t *testing.T) { { name: "not pushed", client: realClient, - op: func(t *testing.T) integration.Operation { + op: func(_ *testing.T) integration.Operation { return integration.Operation{ Inputs: property.NewMap(map[string]property.Value{ "tag": property.New( @@ -63,7 +63,7 @@ func TestIndexLifecycle(t *testing.T) { name: "pushed", skip: os.Getenv("DOCKER_HUB_PASSWORD") == "", client: realClient, - op: func(t *testing.T) integration.Operation { + op: func(_ *testing.T) integration.Operation { return integration.Operation{ Inputs: property.NewMap(map[string]property.Value{ "tag": property.New( @@ -85,7 +85,7 @@ func TestIndexLifecycle(t *testing.T) { }, { name: "expired credentials", - client: func(t *testing.T) clientF { + client: func(_ *testing.T) clientF { ctrl := gomock.NewController(t) c := NewMockClient(ctrl) c.EXPECT().ManifestCreate(gomock.Any(), true, gomock.Any(), gomock.Any()) @@ -93,7 +93,7 @@ func TestIndexLifecycle(t *testing.T) { c.EXPECT().ManifestDelete(gomock.Any(), gomock.Any()).Return(nil) return mockClientF(c) }, - op: func(t *testing.T) integration.Operation { + op: func(_ *testing.T) integration.Operation { return integration.Operation{ Inputs: property.NewMap(map[string]property.Value{ "tag": property.New( @@ -157,7 +157,7 @@ func TestIndexDiff(t *testing.T) { { name: "diff if tag changes", state: func(*testing.T, IndexState) IndexState { return baseState }, - inputs: func(t *testing.T, a IndexArgs) IndexArgs { + inputs: func(_ *testing.T, a IndexArgs) IndexArgs { a.Tag = "new-tag" return a }, diff --git a/provider/provider.go b/provider/provider.go index 982cec4..a87f9cd 100644 --- a/provider/provider.go +++ b/provider/provider.go @@ -15,10 +15,11 @@ package provider import ( - "github.com/pulumi/pulumi-docker-build/provider/internal" gp "github.com/pulumi/pulumi-go-provider" "github.com/pulumi/pulumi/pkg/v3/resource/provider" rpc "github.com/pulumi/pulumi/sdk/v3/proto/go" + + "github.com/pulumi/pulumi-docker-build/provider/internal" ) // Version is initialized by the Go linker to contain the semver of this build.