mirror of
https://github.com/hashicorp/packer.git
synced 2025-12-18 23:16:06 -05:00
packer: address unused lint errors
This commit is contained in:
parent
962ccdfc80
commit
3e3b136f3c
13 changed files with 0 additions and 135 deletions
|
|
@ -16,7 +16,6 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
"github.com/hashicorp/hcl/v2/hcldec"
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
)
|
||||
|
||||
|
|
@ -24,7 +23,6 @@ const BuilderId = "packer.file"
|
|||
|
||||
type Builder struct {
|
||||
config Config
|
||||
runner multistep.Runner
|
||||
}
|
||||
|
||||
func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstructure().HCL2Spec() }
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
//go:build darwin || freebsd || linux || netbsd || openbsd || solaris
|
||||
// +build darwin freebsd linux netbsd openbsd solaris
|
||||
|
||||
package command
|
||||
|
||||
const (
|
||||
defaultConfigDir = ".packer.d"
|
||||
)
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package command
|
||||
|
||||
const (
|
||||
defaultConfigDir = "packer.d"
|
||||
)
|
||||
|
|
@ -6,7 +6,6 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
|
@ -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"
|
||||
)
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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>",
|
||||
|
|
@ -273,17 +262,6 @@ var (
|
|||
NestedSlice: []NestedMockConfig{},
|
||||
},
|
||||
}
|
||||
basicMockCommunicator = &MockCommunicator{
|
||||
Config: MockConfig{
|
||||
NestedMockConfig: basicNestedMockConfig,
|
||||
Nested: basicNestedMockConfig,
|
||||
NestedSlice: []NestedMockConfig{
|
||||
{
|
||||
Tags: []MockTag{},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
emptyMockBuilder = &MockBuilder{
|
||||
Config: MockConfig{
|
||||
|
|
@ -295,13 +273,6 @@ var (
|
|||
},
|
||||
}
|
||||
|
||||
emptyMockProvisioner = &MockProvisioner{
|
||||
Config: MockConfig{
|
||||
NestedMockConfig: NestedMockConfig{Tags: []MockTag{}},
|
||||
NestedSlice: []NestedMockConfig{},
|
||||
},
|
||||
}
|
||||
|
||||
dynamicTagList = []MockTag{
|
||||
{
|
||||
Key: "first_tag_key",
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -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")
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/hcl/v2/hcldec"
|
||||
|
|
@ -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() }
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ import (
|
|||
"github.com/hashicorp/packer/builder/file"
|
||||
)
|
||||
|
||||
const expectedFileContents = "Hello world!"
|
||||
|
||||
func TestChecksumSHA1(t *testing.T) {
|
||||
const config = `
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue