Fix lint issues (#755)
Lint fixes in preparation of https://github.com/pulumi/ci-mgmt/pull/2024.
This commit is contained in:
@@ -40,7 +40,7 @@ linters-settings:
|
|||||||
- blank # Blank section: contains all blank imports.
|
- blank # Blank section: contains all blank imports.
|
||||||
- default # Default section: contains all imports that could not be matched to another section type.
|
- 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/) # 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
|
custom-order: true
|
||||||
gocritic:
|
gocritic:
|
||||||
enable-all: true
|
enable-all: true
|
||||||
|
|||||||
@@ -16,8 +16,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pulumi/pulumi-docker-build/provider"
|
|
||||||
"github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil"
|
"github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil"
|
||||||
|
|
||||||
|
"github.com/pulumi/pulumi-docker-build/provider"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -448,7 +448,7 @@ func (c CacheFrom) String() string {
|
|||||||
return join(c.Local, c.Registry, c.GHA, c.AZBlob, c.S3, c.Raw)
|
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 {
|
if strings.Count(c.String(), "type=") > 1 {
|
||||||
return nil, errors.New("cacheFrom should only specify one cache type")
|
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)
|
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 {
|
if strings.Count(c.String(), "type=") > 1 {
|
||||||
return nil, errors.New("cacheTo should only specify one cache type")
|
return nil, errors.New("cacheTo should only specify one cache type")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ import (
|
|||||||
"github.com/pulumi/pulumi-go-provider/infer"
|
"github.com/pulumi/pulumi-go-provider/infer"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
trueLiteral = "true"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ fmt.Stringer = (*Export)(nil)
|
_ fmt.Stringer = (*Export)(nil)
|
||||||
_ fmt.Stringer = (*ExportDocker)(nil)
|
_ fmt.Stringer = (*ExportDocker)(nil)
|
||||||
@@ -114,7 +118,7 @@ func (e Export) pushed() bool {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return exp[0].Attrs["push"] == "true"
|
return exp[0].Attrs["push"] == trueLiteral
|
||||||
}
|
}
|
||||||
if e.Registry != nil {
|
if e.Registry != nil {
|
||||||
return e.Registry.Push == nil || *e.Registry.Push
|
return e.Registry.Push == nil || *e.Registry.Push
|
||||||
@@ -182,7 +186,7 @@ func parseExports(inp []string) ([]*controllerapi.ExportEntry, error) {
|
|||||||
if out.Type == "registry" {
|
if out.Type == "registry" {
|
||||||
out.Type = client.ExporterImage
|
out.Type = client.ExporterImage
|
||||||
if _, ok := out.Attrs["push"]; !ok {
|
if _, ok := out.Attrs["push"]; !ok {
|
||||||
out.Attrs["push"] = "true"
|
out.Attrs["push"] = trueLiteral
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ type host struct {
|
|||||||
supportsMultipleExports bool
|
supportsMultipleExports bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newHost(ctx context.Context, config *Config) (*host, error) {
|
func newHost(_ context.Context, config *Config) (*host, error) {
|
||||||
docker, err := newDockerCLI(config)
|
docker, err := newDockerCLI(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ func TestImageLifecycle(t *testing.T) {
|
|||||||
Return(nil)
|
Return(nil)
|
||||||
return c
|
return c
|
||||||
},
|
},
|
||||||
op: func(t *testing.T) integration.Operation {
|
op: func(_ *testing.T) integration.Operation {
|
||||||
return integration.Operation{
|
return integration.Operation{
|
||||||
Inputs: property.NewMap(map[string]property.Value{
|
Inputs: property.NewMap(map[string]property.Value{
|
||||||
"push": property.New(false),
|
"push": property.New(false),
|
||||||
@@ -130,7 +130,7 @@ func TestImageLifecycle(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "tags are required when pushing",
|
name: "tags are required when pushing",
|
||||||
client: noClient,
|
client: noClient,
|
||||||
op: func(t *testing.T) integration.Operation {
|
op: func(_ *testing.T) integration.Operation {
|
||||||
return integration.Operation{
|
return integration.Operation{
|
||||||
Inputs: property.NewMap(map[string]property.Value{
|
Inputs: property.NewMap(map[string]property.Value{
|
||||||
"push": property.New(false),
|
"push": property.New(false),
|
||||||
@@ -159,7 +159,7 @@ func TestImageLifecycle(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "invalid exports",
|
name: "invalid exports",
|
||||||
client: noClient,
|
client: noClient,
|
||||||
op: func(t *testing.T) integration.Operation {
|
op: func(_ *testing.T) integration.Operation {
|
||||||
return integration.Operation{
|
return integration.Operation{
|
||||||
Inputs: property.NewMap(map[string]property.Value{
|
Inputs: property.NewMap(map[string]property.Value{
|
||||||
"push": property.New(false),
|
"push": property.New(false),
|
||||||
@@ -192,7 +192,7 @@ func TestImageLifecycle(t *testing.T) {
|
|||||||
)
|
)
|
||||||
return c
|
return c
|
||||||
},
|
},
|
||||||
op: func(t *testing.T) integration.Operation {
|
op: func(_ *testing.T) integration.Operation {
|
||||||
return integration.Operation{
|
return integration.Operation{
|
||||||
Inputs: property.NewMap(map[string]property.Value{
|
Inputs: property.NewMap(map[string]property.Value{
|
||||||
"push": property.New(false),
|
"push": property.New(false),
|
||||||
@@ -219,7 +219,7 @@ func TestImageLifecycle(t *testing.T) {
|
|||||||
)
|
)
|
||||||
return c
|
return c
|
||||||
},
|
},
|
||||||
op: func(t *testing.T) integration.Operation {
|
op: func(_ *testing.T) integration.Operation {
|
||||||
return integration.Operation{
|
return integration.Operation{
|
||||||
Inputs: property.NewMap(map[string]property.Value{
|
Inputs: property.NewMap(map[string]property.Value{
|
||||||
"push": property.New(false),
|
"push": property.New(false),
|
||||||
@@ -252,7 +252,7 @@ func TestImageLifecycle(t *testing.T) {
|
|||||||
c.EXPECT().Delete(gomock.Any(), "default-dockerfile").Return(nil)
|
c.EXPECT().Delete(gomock.Any(), "default-dockerfile").Return(nil)
|
||||||
return c
|
return c
|
||||||
},
|
},
|
||||||
op: func(t *testing.T) integration.Operation {
|
op: func(_ *testing.T) integration.Operation {
|
||||||
return integration.Operation{
|
return integration.Operation{
|
||||||
Inputs: property.NewMap(map[string]property.Value{
|
Inputs: property.NewMap(map[string]property.Value{
|
||||||
"push": property.New(false),
|
"push": property.New(false),
|
||||||
@@ -294,7 +294,7 @@ func TestImageLifecycle(t *testing.T) {
|
|||||||
c.EXPECT().Delete(gomock.Any(), "inline-dockerfile").Return(nil)
|
c.EXPECT().Delete(gomock.Any(), "inline-dockerfile").Return(nil)
|
||||||
return c
|
return c
|
||||||
},
|
},
|
||||||
op: func(t *testing.T) integration.Operation {
|
op: func(_ *testing.T) integration.Operation {
|
||||||
return integration.Operation{
|
return integration.Operation{
|
||||||
Inputs: property.NewMap(map[string]property.Value{
|
Inputs: property.NewMap(map[string]property.Value{
|
||||||
"push": property.New(false),
|
"push": property.New(false),
|
||||||
@@ -459,7 +459,7 @@ func TestImageDiff(t *testing.T) {
|
|||||||
is.Pull = true
|
is.Pull = true
|
||||||
return is
|
return is
|
||||||
},
|
},
|
||||||
inputs: func(t *testing.T, ia ImageArgs) ImageArgs {
|
inputs: func(_ *testing.T, ia ImageArgs) ImageArgs {
|
||||||
ia.Pull = true
|
ia.Pull = true
|
||||||
return ia
|
return ia
|
||||||
},
|
},
|
||||||
@@ -472,7 +472,7 @@ func TestImageDiff(t *testing.T) {
|
|||||||
is.Load = true
|
is.Load = true
|
||||||
return is
|
return is
|
||||||
},
|
},
|
||||||
inputs: func(t *testing.T, ia ImageArgs) ImageArgs {
|
inputs: func(_ *testing.T, ia ImageArgs) ImageArgs {
|
||||||
ia.Pull = true
|
ia.Pull = true
|
||||||
ia.Load = true
|
ia.Load = true
|
||||||
return ia
|
return ia
|
||||||
@@ -534,7 +534,7 @@ func TestImageDiff(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "diff if pull changes",
|
name: "diff if pull changes",
|
||||||
state: func(*testing.T, ImageState) ImageState { return baseState },
|
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
|
ia.Pull = true
|
||||||
return ia
|
return ia
|
||||||
},
|
},
|
||||||
@@ -543,7 +543,7 @@ func TestImageDiff(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "diff if load changes",
|
name: "diff if load changes",
|
||||||
state: func(*testing.T, ImageState) ImageState { return baseState },
|
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
|
ia.Load = true
|
||||||
return ia
|
return ia
|
||||||
},
|
},
|
||||||
@@ -552,7 +552,7 @@ func TestImageDiff(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "diff if push changes",
|
name: "diff if push changes",
|
||||||
state: func(*testing.T, ImageState) ImageState { return baseState },
|
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
|
ia.Push = true
|
||||||
return ia
|
return ia
|
||||||
},
|
},
|
||||||
@@ -561,7 +561,7 @@ func TestImageDiff(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "diff if buildOnPreview doesn't change",
|
name: "diff if buildOnPreview doesn't change",
|
||||||
state: func(*testing.T, ImageState) ImageState { return baseState },
|
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
|
val := true
|
||||||
ia.BuildOnPreview = &val
|
ia.BuildOnPreview = &val
|
||||||
return ia
|
return ia
|
||||||
@@ -571,7 +571,7 @@ func TestImageDiff(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "diff if buildOnPreview changes",
|
name: "diff if buildOnPreview changes",
|
||||||
state: func(*testing.T, ImageState) ImageState { return baseState },
|
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
|
val := false
|
||||||
ia.BuildOnPreview = &val
|
ia.BuildOnPreview = &val
|
||||||
return ia
|
return ia
|
||||||
@@ -581,7 +581,7 @@ func TestImageDiff(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "diff if ssh changes",
|
name: "diff if ssh changes",
|
||||||
state: func(*testing.T, ImageState) ImageState { return baseState },
|
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"}}
|
ia.SSH = []SSH{{ID: "default"}}
|
||||||
return ia
|
return ia
|
||||||
},
|
},
|
||||||
@@ -590,7 +590,7 @@ func TestImageDiff(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "diff if hosts change",
|
name: "diff if hosts change",
|
||||||
state: func(*testing.T, ImageState) ImageState { return baseState },
|
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"}
|
ia.AddHosts = []string{"localhost"}
|
||||||
return ia
|
return ia
|
||||||
},
|
},
|
||||||
@@ -751,7 +751,7 @@ func TestImageDiff(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "diff if local export doesn't exist",
|
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{
|
state.Exports = []Export{
|
||||||
{Local: &ExportLocal{Dest: "not-real"}},
|
{Local: &ExportLocal{Dest: "not-real"}},
|
||||||
}
|
}
|
||||||
@@ -767,7 +767,7 @@ func TestImageDiff(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "diff if tar export doesn't exist",
|
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{
|
state.Exports = []Export{
|
||||||
{Tar: &ExportTar{ExportLocal: ExportLocal{Dest: "not-real"}}},
|
{Tar: &ExportTar{ExportLocal: ExportLocal{Dest: "not-real"}}},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import (
|
|||||||
|
|
||||||
func TestIndexLifecycle(t *testing.T) {
|
func TestIndexLifecycle(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
realClient := func(t *testing.T) clientF { return RealClientF }
|
realClient := func(_ *testing.T) clientF { return RealClientF }
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@@ -44,7 +44,7 @@ func TestIndexLifecycle(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "not pushed",
|
name: "not pushed",
|
||||||
client: realClient,
|
client: realClient,
|
||||||
op: func(t *testing.T) integration.Operation {
|
op: func(_ *testing.T) integration.Operation {
|
||||||
return integration.Operation{
|
return integration.Operation{
|
||||||
Inputs: property.NewMap(map[string]property.Value{
|
Inputs: property.NewMap(map[string]property.Value{
|
||||||
"tag": property.New(
|
"tag": property.New(
|
||||||
@@ -63,7 +63,7 @@ func TestIndexLifecycle(t *testing.T) {
|
|||||||
name: "pushed",
|
name: "pushed",
|
||||||
skip: os.Getenv("DOCKER_HUB_PASSWORD") == "",
|
skip: os.Getenv("DOCKER_HUB_PASSWORD") == "",
|
||||||
client: realClient,
|
client: realClient,
|
||||||
op: func(t *testing.T) integration.Operation {
|
op: func(_ *testing.T) integration.Operation {
|
||||||
return integration.Operation{
|
return integration.Operation{
|
||||||
Inputs: property.NewMap(map[string]property.Value{
|
Inputs: property.NewMap(map[string]property.Value{
|
||||||
"tag": property.New(
|
"tag": property.New(
|
||||||
@@ -85,7 +85,7 @@ func TestIndexLifecycle(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "expired credentials",
|
name: "expired credentials",
|
||||||
client: func(t *testing.T) clientF {
|
client: func(_ *testing.T) clientF {
|
||||||
ctrl := gomock.NewController(t)
|
ctrl := gomock.NewController(t)
|
||||||
c := NewMockClient(ctrl)
|
c := NewMockClient(ctrl)
|
||||||
c.EXPECT().ManifestCreate(gomock.Any(), true, gomock.Any(), gomock.Any())
|
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)
|
c.EXPECT().ManifestDelete(gomock.Any(), gomock.Any()).Return(nil)
|
||||||
return mockClientF(c)
|
return mockClientF(c)
|
||||||
},
|
},
|
||||||
op: func(t *testing.T) integration.Operation {
|
op: func(_ *testing.T) integration.Operation {
|
||||||
return integration.Operation{
|
return integration.Operation{
|
||||||
Inputs: property.NewMap(map[string]property.Value{
|
Inputs: property.NewMap(map[string]property.Value{
|
||||||
"tag": property.New(
|
"tag": property.New(
|
||||||
@@ -157,7 +157,7 @@ func TestIndexDiff(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "diff if tag changes",
|
name: "diff if tag changes",
|
||||||
state: func(*testing.T, IndexState) IndexState { return baseState },
|
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"
|
a.Tag = "new-tag"
|
||||||
return a
|
return a
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,10 +15,11 @@
|
|||||||
package provider
|
package provider
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pulumi/pulumi-docker-build/provider/internal"
|
|
||||||
gp "github.com/pulumi/pulumi-go-provider"
|
gp "github.com/pulumi/pulumi-go-provider"
|
||||||
"github.com/pulumi/pulumi/pkg/v3/resource/provider"
|
"github.com/pulumi/pulumi/pkg/v3/resource/provider"
|
||||||
rpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
|
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.
|
// Version is initialized by the Go linker to contain the semver of this build.
|
||||||
|
|||||||
Reference in New Issue
Block a user