Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions acctest/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ type TestTeardownFunc func() error
//
// Users should just use a *testing.T object, which implements this.
type TestT interface {
Error(args ...interface{})
Fatal(args ...interface{})
Skip(args ...interface{})
Error(args ...any)
Fatal(args ...any)
Skip(args ...any)
}

type TestBuilderSet struct {
Expand Down
12 changes: 6 additions & 6 deletions acctest/testing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@ func TestTest_preCheck(t *testing.T) {
// mockT implements TestT for testing
type mockT struct {
ErrorCalled bool
ErrorArgs []interface{}
ErrorArgs []any
FatalCalled bool
FatalArgs []interface{}
FatalArgs []any
SkipCalled bool
SkipArgs []interface{}
SkipArgs []any

f bool
}

func (t *mockT) Error(args ...interface{}) {
func (t *mockT) Error(args ...any) {
t.ErrorCalled = true
t.ErrorArgs = args
t.f = true
}

func (t *mockT) Fatal(args ...interface{}) {
func (t *mockT) Fatal(args ...any) {
t.FatalCalled = true
t.FatalArgs = args
t.f = true
}

func (t *mockT) Skip(args ...interface{}) {
func (t *mockT) Skip(args ...any) {
t.SkipCalled = true
t.SkipArgs = args
t.f = true
Expand Down
2 changes: 1 addition & 1 deletion builder/file/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (a *FileArtifact) String() string {
return fmt.Sprintf("Stored file: %s", a.filename)
}

func (a *FileArtifact) State(name string) interface{} {
func (a *FileArtifact) State(name string) any {
if name == registryimage.ArtifactStateURI {
img, err := registryimage.FromArtifact(a,
registryimage.WithID(path.Base(a.filename)),
Expand Down
2 changes: 1 addition & 1 deletion builder/file/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Builder struct {

func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstructure().HCL2Spec() }

func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
func (b *Builder) Prepare(raws ...any) ([]string, []string, error) {
warnings, errs := b.config.Prepare(raws...)
if errs != nil {
return nil, warnings, errs
Expand Down
2 changes: 1 addition & 1 deletion builder/file/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Config struct {
Content string `mapstructure:"content"`
}

func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
func (c *Config) Prepare(raws ...any) ([]string, error) {
warnings := []string{}

err := config.Decode(c, &config.DecodeOpts{
Expand Down
4 changes: 2 additions & 2 deletions builder/file/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"testing"
)

func testConfig() map[string]interface{} {
return map[string]interface{}{
func testConfig() map[string]any {
return map[string]any{
"source": "src.txt",
"target": "dst.txt",
"content": "Hello, world!",
Expand Down
4 changes: 2 additions & 2 deletions builder/null/artifact_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (a *NullArtifact) String() string {
return "Did not export anything. This is the null builder"
}

func (a *NullArtifact) State(name string) interface{} {
func (a *NullArtifact) State(name string) any {
switch name {
case registryimage.ArtifactStateURI:
img, _ := registryimage.FromArtifact(a,
Expand All @@ -38,7 +38,7 @@ func (a *NullArtifact) State(name string) interface{} {
)
return img
case "generated_data":
return map[interface{}]interface{}{
return map[any]any{
"ID": "Null",
}
default:
Expand Down
2 changes: 1 addition & 1 deletion builder/null/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Builder struct {

func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstructure().HCL2Spec() }

func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
func (b *Builder) Prepare(raws ...any) ([]string, []string, error) {
warnings, errs := b.config.Prepare(raws...)
if errs != nil {
return nil, warnings, errs
Expand Down
2 changes: 1 addition & 1 deletion builder/null/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Config struct {
CommConfig communicator.Config `mapstructure:",squash"`
}

func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
func (c *Config) Prepare(raws ...any) ([]string, error) {

err := config.Decode(c, &config.DecodeOpts{
PluginType: BuilderId,
Expand Down
4 changes: 2 additions & 2 deletions builder/null/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/hashicorp/packer-plugin-sdk/communicator"
)

func testConfig() map[string]interface{} {
return map[string]interface{}{
func testConfig() map[string]any {
return map[string]any{
"ssh_host": "foo",
"ssh_username": "bar",
"ssh_password": "baz",
Expand Down
2 changes: 1 addition & 1 deletion command/build_cancellation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestBuildCommand_RunContext_CtxCancel(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
b := NewParallelTestBuilder(tt.parallelPassingTests)
locked := &LockedBuilder{unlock: make(chan interface{})}
locked := &LockedBuilder{unlock: make(chan any)}
c := &BuildCommand{
Meta: testMetaParallel(t, b, locked),
}
Expand Down
12 changes: 6 additions & 6 deletions command/build_parallel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type ParallelTestBuilder struct {

func (b *ParallelTestBuilder) ConfigSpec() hcldec.ObjectSpec { return nil }

func (b *ParallelTestBuilder) Prepare(raws ...interface{}) ([]string, []string, error) {
func (b *ParallelTestBuilder) Prepare(raws ...any) ([]string, []string, error) {
return nil, nil, nil
}

Expand All @@ -46,11 +46,11 @@ func (b *ParallelTestBuilder) Run(ctx context.Context, ui packersdk.Ui, hook pac
}

// LockedBuilder won't run until unlock is called
type LockedBuilder struct{ unlock chan interface{} }
type LockedBuilder struct{ unlock chan any }

func (b *LockedBuilder) ConfigSpec() hcldec.ObjectSpec { return nil }

func (b *LockedBuilder) Prepare(raws ...interface{}) ([]string, []string, error) {
func (b *LockedBuilder) Prepare(raws ...any) ([]string, []string, error) {
return nil, nil, nil
}

Expand Down Expand Up @@ -93,7 +93,7 @@ func TestBuildParallel_1(t *testing.T) {
// testfile has 6 builds, with first one locks 'forever', other builds
// should go through.
b := NewParallelTestBuilder(5)
locked := &LockedBuilder{unlock: make(chan interface{})}
locked := &LockedBuilder{unlock: make(chan any)}

c := &BuildCommand{
Meta: testMetaParallel(t, b, locked),
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestBuildParallel_2(t *testing.T) {
// testfile has 6 builds, 2 of them lock 'forever', other builds
// should go through.
b := NewParallelTestBuilder(4)
locked := &LockedBuilder{unlock: make(chan interface{})}
locked := &LockedBuilder{unlock: make(chan any)}

c := &BuildCommand{
Meta: testMetaParallel(t, b, locked),
Expand Down Expand Up @@ -151,7 +151,7 @@ func TestBuildParallel_Timeout(t *testing.T) {
// testfile has 6 builds, 1 of them locks 'forever', one locks and times
// out other builds should go through.
b := NewParallelTestBuilder(4)
locked := &LockedBuilder{unlock: make(chan interface{})}
locked := &LockedBuilder{unlock: make(chan any)}

c := &BuildCommand{
Meta: testMetaParallel(t, b, locked),
Expand Down
4 changes: 2 additions & 2 deletions command/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ func (ba *BuildArgs) AddFlagSets(flags *flag.FlagSet) {
//
// Most of the arguments are kept as-is, except for the -var args, where only
// the keys are kept to avoid leaking potential secrets.
func GetCleanedBuildArgs(ba *BuildArgs) map[string]interface{} {
cleanedArgs := map[string]interface{}{
func GetCleanedBuildArgs(ba *BuildArgs) map[string]any {
cleanedArgs := map[string]any{
"debug": ba.Debug,
"force": ba.Force,
"only": ba.Only,
Expand Down
2 changes: 1 addition & 1 deletion command/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c *FixCommand) RunContext(ctx context.Context, cla *FixArgs) int {
defer tplF.Close()

// Decode the JSON into a generic map structure
var templateData map[string]interface{}
var templateData map[string]any
decoder := json.NewDecoder(tplF)
if err := decoder.Decode(&templateData); err != nil {
c.Ui.Error(fmt.Sprintf("Error parsing template: %s", err))
Expand Down
3 changes: 1 addition & 2 deletions command/flag-slice/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (
)

func TestStringFlag_implements(t *testing.T) {
var raw interface{}
raw = new(StringFlag)
var raw any = new(StringFlag)
if _, ok := raw.(flag.Value); !ok {
t.Fatalf("StringFlag should be a Value")
}
Expand Down
32 changes: 16 additions & 16 deletions command/hcl2_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const (
)

var (
amazonSecretsManagerMap = map[string]map[string]interface{}{}
amazonSecretsManagerMap = map[string]map[string]any{}
localsVariableMap = map[string]string{}
timestamp = false
isotime = false
Expand Down Expand Up @@ -392,7 +392,7 @@ func transposeTemplatingCalls(s []byte) []byte {
}
}
id := fmt.Sprintf("autogenerated_%d", len(amazonSecretsManagerMap)+1)
amazonSecretsManagerMap[id] = map[string]interface{}{
amazonSecretsManagerMap[id] = map[string]any{
"name": a[0],
"key": a[1],
}
Expand All @@ -405,7 +405,7 @@ func transposeTemplatingCalls(s []byte) []byte {
}
}
id := fmt.Sprintf("autogenerated_%d", len(amazonSecretsManagerMap)+1)
amazonSecretsManagerMap[id] = map[string]interface{}{
amazonSecretsManagerMap[id] = map[string]any{
"name": a[0],
}
return fmt.Sprintf("${data.amazon-secretsmanager.%s.value}", id)
Expand Down Expand Up @@ -681,7 +681,7 @@ func referencedUserVariables(s []byte) map[string]*template.Variable {
return vars
}

func jsonBodyToHCL2Body(out *hclwrite.Body, kvs map[string]interface{}) {
func jsonBodyToHCL2Body(out *hclwrite.Body, kvs map[string]any) {
ks := []string{}
for k := range kvs {
ks = append(ks, k)
Expand All @@ -692,8 +692,8 @@ func jsonBodyToHCL2Body(out *hclwrite.Body, kvs map[string]interface{}) {
value := kvs[k]

switch value := value.(type) {
case map[string]interface{}:
var mostComplexElem interface{}
case map[string]any:
var mostComplexElem any
for _, randomElem := range value {
if k == "linux_options" || k == "network_interface" || k == "shared_image_gallery" {
break
Expand Down Expand Up @@ -729,12 +729,12 @@ func jsonBodyToHCL2Body(out *hclwrite.Body, kvs map[string]interface{}) {
}
case map[string]string, map[string]int, map[string]float64:
out.SetAttributeValue(k, hcl2shim.HCL2ValueFromConfigValue(value))
case []interface{}:
case []any:
if len(value) == 0 {
continue
}

var mostComplexElem interface{}
var mostComplexElem any
for _, randomElem := range value {
// HACK: we take the most complex element of that slice because
// in hcl2 slices of plain types can be arrays, for example:
Expand All @@ -751,12 +751,12 @@ func jsonBodyToHCL2Body(out *hclwrite.Body, kvs map[string]interface{}) {
}
}
switch mostComplexElem.(type) {
case map[string]interface{}:
case map[string]any:
// this is an object in a slice; so we unwrap it. We
// could try to remove any 's' suffix in the key, but
// this might not work everywhere.
for i := range value {
value := value[i].(map[string]interface{})
value := value[i].(map[string]any)
nestedBlockBody := out.AppendNewBlock(k, nil).Body()
jsonBodyToHCL2Body(nestedBlockBody, value)
}
Expand Down Expand Up @@ -1117,12 +1117,12 @@ func (p *AmazonAmiDatasourceParser) Parse(_ *template.Template) error {
p.out = []byte{}
}

amazonAmiFilters := []map[string]interface{}{}
amazonAmiFilters := []map[string]any{}
i := 1
for _, builder := range p.Builders {
if strings.HasPrefix(builder.Type, "amazon-") {
if sourceAmiFilter, ok := builder.Config["source_ami_filter"]; ok {
sourceAmiFilterCfg := map[string]interface{}{}
sourceAmiFilterCfg := map[string]any{}
if err := mapstructure.Decode(sourceAmiFilter, &sourceAmiFilterCfg); err != nil {
return fmt.Errorf("Failed to write amazon-ami data source: %v", err)
}
Expand Down Expand Up @@ -1211,9 +1211,9 @@ type AwsAccessConfig struct {
PollingConfig *AWSPollingConfig `mapstructure:"aws_polling" required:"false"`
}

func copyAWSAccessConfig(sourceAmi map[string]interface{}, builder map[string]interface{}) (map[string]interface{}, error) {
func copyAWSAccessConfig(sourceAmi map[string]any, builder map[string]any) (map[string]any, error) {
// Transform access config to a map
accessConfigMap := map[string]interface{}{}
accessConfigMap := map[string]any{}
if err := mapstructure.Decode(AwsAccessConfig{}, &accessConfigMap); err != nil {
return sourceAmi, err
}
Expand Down Expand Up @@ -1374,7 +1374,7 @@ func writeProvisioner(typeName string, provisioner *template.Provisioner) []byte

cfg := provisioner.Config
if cfg == nil {
cfg = map[string]interface{}{}
cfg = map[string]any{}
}

if len(provisioner.Except) > 0 {
Expand Down Expand Up @@ -1430,7 +1430,7 @@ func (p *PostProcessorParser) Parse(tpl *template.Template) error {
}
cfg := pp.Config
if cfg == nil {
cfg = map[string]interface{}{}
cfg = map[string]any{}
}

if len(pp.Except) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion datasource/hcp-packer-artifact/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (d *Datasource) ConfigSpec() hcldec.ObjectSpec {
return d.config.FlatMapstructure().HCL2Spec()
}

func (d *Datasource) Configure(raws ...interface{}) error {
func (d *Datasource) Configure(raws ...any) error {
err := config.Decode(&d.config, nil, raws...)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion datasource/hcp-packer-image/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (d *Datasource) ConfigSpec() hcldec.ObjectSpec {
return d.config.FlatMapstructure().HCL2Spec()
}

func (d *Datasource) Configure(raws ...interface{}) error {
func (d *Datasource) Configure(raws ...any) error {
err := config.Decode(&d.config, nil, raws...)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion datasource/hcp-packer-iteration/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (d *Datasource) ConfigSpec() hcldec.ObjectSpec {
return d.config.FlatMapstructure().HCL2Spec()
}

func (d *Datasource) Configure(raws ...interface{}) error {
func (d *Datasource) Configure(raws ...any) error {
err := config.Decode(&d.config, nil, raws...)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion datasource/hcp-packer-version/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (d *Datasource) ConfigSpec() hcldec.ObjectSpec {
return d.config.FlatMapstructure().HCL2Spec()
}

func (d *Datasource) Configure(raws ...interface{}) error {
func (d *Datasource) Configure(raws ...any) error {
err := config.Decode(&d.config, nil, raws...)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion datasource/http/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (d *Datasource) ConfigSpec() hcldec.ObjectSpec {
return d.config.FlatMapstructure().HCL2Spec()
}

func (d *Datasource) Configure(raws ...interface{}) error {
func (d *Datasource) Configure(raws ...any) error {
err := config.Decode(&d.config, nil, raws...)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion datasource/null/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (d *Datasource) ConfigSpec() hcldec.ObjectSpec {
return d.config.FlatMapstructure().HCL2Spec()
}

func (d *Datasource) Configure(raws ...interface{}) error {
func (d *Datasource) Configure(raws ...any) error {
err := config.Decode(&d.config, nil, raws...)
if err != nil {
return err
Expand Down
Loading
Loading