Skip to content

Commit

Permalink
packer: address unused lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lbajolet-hashicorp committed Jul 18, 2024
1 parent 962ccdf commit 3e3b136
Show file tree
Hide file tree
Showing 13 changed files with 0 additions and 135 deletions.
2 changes: 0 additions & 2 deletions builder/file/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ import (
"path/filepath"

"github.com/hashicorp/hcl/v2/hcldec"
"github.com/hashicorp/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
)

const BuilderId = "packer.file"

type Builder struct {
config Config
runner multistep.Runner
}

func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstructure().HCL2Spec() }
Expand Down
13 changes: 0 additions & 13 deletions builder/null/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,6 @@ func testConfig() map[string]interface{} {
}
}

func testConfigStruct(t *testing.T) *Config {
var c Config
warns, errs := c.Prepare(testConfig())
if len(warns) > 0 {
t.Fatalf("bad: %#v", len(warns))
}
if errs != nil {
t.Fatalf("bad: %#v", errs)
}

return &c
}

func testConfigErr(t *testing.T, warns []string, err error) {
if len(warns) > 0 {
t.Fatalf("bad: %#v", warns)
Expand Down
11 changes: 0 additions & 11 deletions command/config_file_unix.go

This file was deleted.

11 changes: 0 additions & 11 deletions command/config_file_windows.go

This file was deleted.

13 changes: 0 additions & 13 deletions command/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package command

import (
"context"
"fmt"
"log"
"os"
Expand All @@ -16,7 +15,6 @@ import (
"testing"

"github.com/google/go-cmp/cmp"
"github.com/hashicorp/go-getter/v2"
"github.com/hashicorp/packer-plugin-sdk/acctest"
"golang.org/x/mod/sumdb/dirhash"
)
Expand Down Expand Up @@ -312,17 +310,6 @@ func (key skipInitTestUnlessEnVar) fn(t *testing.T, tc testCaseInit) {
// }
}

type initTestGoGetPlugin struct {
Src string
Dst string
}

func (opts initTestGoGetPlugin) fn(t *testing.T, _ testCaseInit) {
if _, err := getter.Get(context.Background(), opts.Dst, opts.Src); err != nil {
t.Fatalf("get: %v", err)
}
}

// TestInitCmd aims to test the init command, with output validation
func TestInitCmd(t *testing.T) {
tests := []struct {
Expand Down
29 changes: 0 additions & 29 deletions hcl2template/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,6 @@ var (
Datasource: "string",
}

basicMockBuilder = &MockBuilder{
Config: MockConfig{
NestedMockConfig: builderBasicNestedMockConfig,
Nested: builderBasicNestedMockConfig,
NestedSlice: []NestedMockConfig{
builderBasicNestedMockConfig,
builderBasicNestedMockConfig,
},
},
}

basicMockProvisioner = &MockProvisioner{
Config: MockConfig{
NotSquashed: "value <UNKNOWN>",
Expand Down Expand Up @@ -273,17 +262,6 @@ var (
NestedSlice: []NestedMockConfig{},
},
}
basicMockCommunicator = &MockCommunicator{
Config: MockConfig{
NestedMockConfig: basicNestedMockConfig,
Nested: basicNestedMockConfig,
NestedSlice: []NestedMockConfig{
{
Tags: []MockTag{},
},
},
},
}

emptyMockBuilder = &MockBuilder{
Config: MockConfig{
Expand All @@ -295,13 +273,6 @@ var (
},
}

emptyMockProvisioner = &MockProvisioner{
Config: MockConfig{
NestedMockConfig: NestedMockConfig{Tags: []MockTag{}},
NestedSlice: []NestedMockConfig{},
},
}

dynamicTagList = []MockTag{
{
Key: "first_tag_key",
Expand Down
10 changes: 0 additions & 10 deletions hcl2template/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package hcl2template
import (
"bytes"
"encoding/base64"
"fmt"

"github.com/hashicorp/go-cty-funcs/cidr"
"github.com/hashicorp/go-cty-funcs/collection"
Expand Down Expand Up @@ -226,12 +225,3 @@ var TextDecodeBase64Func = function.New(&function.Spec{
return cty.StringVal(string(decoded)), nil
},
})

var unimplFunc = function.New(&function.Spec{
Type: func([]cty.Value) (cty.Type, error) {
return cty.DynamicPseudoType, fmt.Errorf("function not yet implemented")
},
Impl: func([]cty.Value, cty.Type) (cty.Value, error) {
return cty.DynamicVal, fmt.Errorf("function not yet implemented")
},
})
1 change: 0 additions & 1 deletion hcl2template/types.packer_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
var (
refVBIsoUbuntu1204 = SourceRef{Type: "virtualbox-iso", Name: "ubuntu-1204"}
refAWSEBSUbuntu1604 = SourceRef{Type: "amazon-ebs", Name: "ubuntu-1604"}
refAWSV3MyImage = SourceRef{Type: "amazon-v3-ebs", Name: "my-image"}
refNull = SourceRef{Type: "null", Name: "test"}
pTrue = pointerToBool(true)
)
Expand Down
4 changes: 0 additions & 4 deletions packer/plugin-getter/plugins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ var (
pluginFolderOne = filepath.Join("testdata", "plugins")

pluginFolderTwo = filepath.Join("testdata", "plugins_2")

pluginFolderThree = filepath.Join("testdata", "plugins_3")

pluginFolderWrongChecksums = filepath.Join("testdata", "wrong_checksums")
)

func TestChecksumFileEntry_init(t *testing.T) {
Expand Down
5 changes: 0 additions & 5 deletions packer/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ import (
plugingetter "github.com/hashicorp/packer/packer/plugin-getter"
)

var defaultChecksummer = plugingetter.Checksummer{
Type: "sha256",
Hash: sha256.New(),
}

// PluginConfig helps load and use packer plugins
type PluginConfig struct {
PluginDirectory string
Expand Down
29 changes: 0 additions & 29 deletions packer/plugin_discover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,35 +250,6 @@ func TestMultiPlugin_defaultName_each_plugin_type(t *testing.T) {
}
}

func generateFakePlugins(dirname string, pluginNames []string) (string, []string, func(), error) {
dir, err := os.MkdirTemp("", dirname)
if err != nil {
return "", nil, nil, fmt.Errorf("failed to create temporary test directory: %v", err)
}

cleanUpFunc := func() {
os.RemoveAll(dir)
}

var suffix string
if runtime.GOOS == "windows" {
suffix = ".exe"
}

plugins := make([]string, len(pluginNames))
for i, plugin := range pluginNames {
plug := filepath.Join(dir, plugin+suffix)
plugins[i] = plug
_, err := os.Create(plug)
if err != nil {
cleanUpFunc()
return "", nil, nil, fmt.Errorf("failed to create temporary plugin file (%s): %v", plug, err)
}
}

return dir, plugins, cleanUpFunc, nil
}

// TestHelperProcess isn't a real test. It's used as a helper process
// for multi-component plugin tests.
func TestHelperPlugins(t *testing.T) {
Expand Down
5 changes: 0 additions & 5 deletions packer/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"fmt"
"log"
"sync"
"time"

"github.com/hashicorp/hcl/v2/hcldec"
Expand Down Expand Up @@ -205,10 +204,6 @@ func (r *RetriedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, com
// press before the provisioner is actually run.
type DebuggedProvisioner struct {
Provisioner packersdk.Provisioner

cancelCh chan struct{}
doneCh chan struct{}
lock sync.Mutex
}

func (p *DebuggedProvisioner) ConfigSpec() hcldec.ObjectSpec { return p.ConfigSpec() }
Expand Down
2 changes: 0 additions & 2 deletions post-processor/checksum/post-processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
"github.com/hashicorp/packer/builder/file"
)

const expectedFileContents = "Hello world!"

func TestChecksumSHA1(t *testing.T) {
const config = `
{
Expand Down

0 comments on commit 3e3b136

Please sign in to comment.