fix pathing
This commit is contained in:
parent
5e49ddb285
commit
3681e2a7ee
|
@ -8,9 +8,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
|
"github.com/hashicorp/packer/packer-plugin-sdk/pathing"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StepTempDir creates a temporary directory that we use in order to
|
// StepTempDir creates a temporary directory that we use in order to
|
||||||
|
@ -21,7 +21,7 @@ type StepTempDir struct {
|
||||||
|
|
||||||
// ConfigTmpDir returns the configuration tmp directory for Docker
|
// ConfigTmpDir returns the configuration tmp directory for Docker
|
||||||
func ConfigTmpDir() (string, error) {
|
func ConfigTmpDir() (string, error) {
|
||||||
configdir, err := packer.ConfigDir()
|
configdir, err := pathing.ConfigDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,10 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/common"
|
"github.com/hashicorp/packer/packer-plugin-sdk/common"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/communicator"
|
"github.com/hashicorp/packer/packer-plugin-sdk/communicator"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
|
"github.com/hashicorp/packer/packer-plugin-sdk/pathing"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
|
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
|
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
|
||||||
ocicommon "github.com/oracle/oci-go-sdk/common"
|
ocicommon "github.com/oracle/oci-go-sdk/common"
|
||||||
|
@ -198,7 +198,7 @@ func (c *Config) Prepare(raws ...interface{}) error {
|
||||||
|
|
||||||
var keyContent []byte
|
var keyContent []byte
|
||||||
if c.KeyFile != "" {
|
if c.KeyFile != "" {
|
||||||
path, err := packer.ExpandUser(c.KeyFile)
|
path, err := pathing.ExpandUser(c.KeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/hashicorp/go-checkpoint"
|
"github.com/hashicorp/go-checkpoint"
|
||||||
"github.com/hashicorp/packer/command"
|
"github.com/hashicorp/packer/command"
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer-plugin-sdk/pathing"
|
||||||
packerVersion "github.com/hashicorp/packer/version"
|
packerVersion "github.com/hashicorp/packer/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ func runCheckpoint(c *config) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
configDir, err := packer.ConfigDir()
|
configDir, err := pathing.ConfigDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERR] Checkpoint setup error: %s", err)
|
log.Printf("[ERR] Checkpoint setup error: %s", err)
|
||||||
checkpointResult <- nil
|
checkpointResult <- nil
|
||||||
|
|
3
main.go
3
main.go
|
@ -20,6 +20,7 @@ import (
|
||||||
"github.com/hashicorp/packer/command"
|
"github.com/hashicorp/packer/command"
|
||||||
"github.com/hashicorp/packer/packer"
|
"github.com/hashicorp/packer/packer"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
|
"github.com/hashicorp/packer/packer-plugin-sdk/pathing"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/tmp"
|
"github.com/hashicorp/packer/packer-plugin-sdk/tmp"
|
||||||
"github.com/hashicorp/packer/packer/plugin"
|
"github.com/hashicorp/packer/packer/plugin"
|
||||||
"github.com/hashicorp/packer/version"
|
"github.com/hashicorp/packer/version"
|
||||||
|
@ -327,7 +328,7 @@ func loadConfig() (*config, error) {
|
||||||
if configFilePath == "" {
|
if configFilePath == "" {
|
||||||
var err error
|
var err error
|
||||||
log.Print("'PACKER_CONFIG' not set; checking the default config file path")
|
log.Print("'PACKER_CONFIG' not set; checking the default config file path")
|
||||||
configFilePath, err = packer.ConfigFile()
|
configFilePath, err = pathing.ConfigFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error detecting default config file path: %s", err)
|
log.Printf("Error detecting default config file path: %s", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,10 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
helperssh "github.com/hashicorp/packer/packer-plugin-sdk/communicator/ssh"
|
helperssh "github.com/hashicorp/packer/packer-plugin-sdk/communicator/ssh"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
|
"github.com/hashicorp/packer/packer-plugin-sdk/pathing"
|
||||||
packerssh "github.com/hashicorp/packer/packer-plugin-sdk/sdk-internals/communicator/ssh"
|
packerssh "github.com/hashicorp/packer/packer-plugin-sdk/sdk-internals/communicator/ssh"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
|
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
|
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
|
||||||
|
@ -287,7 +287,7 @@ func (c *Config) ReadSSHPrivateKeyFile() ([]byte, error) {
|
||||||
var privateKey []byte
|
var privateKey []byte
|
||||||
|
|
||||||
if c.SSHPrivateKeyFile != "" {
|
if c.SSHPrivateKeyFile != "" {
|
||||||
keyPath, err := packer.ExpandUser(c.SSHPrivateKeyFile)
|
keyPath, err := pathing.ExpandUser(c.SSHPrivateKeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []byte{}, fmt.Errorf("Error expanding path for SSH private key: %s", err)
|
return []byte{}, fmt.Errorf("Error expanding path for SSH private key: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ func (c *Config) SSHConfigFunc() func(multistep.StateBag) (*ssh.ClientConfig, er
|
||||||
certPath := ""
|
certPath := ""
|
||||||
if c.SSHCertificateFile != "" {
|
if c.SSHCertificateFile != "" {
|
||||||
var err error
|
var err error
|
||||||
certPath, err = packer.ExpandUser(c.SSHCertificateFile)
|
certPath, err = pathing.ExpandUser(c.SSHCertificateFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -511,7 +511,7 @@ func (c *Config) prepareSSH(ctx *interpolate.Context) []error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.SSHPrivateKeyFile != "" {
|
if c.SSHPrivateKeyFile != "" {
|
||||||
path, err := packer.ExpandUser(c.SSHPrivateKeyFile)
|
path, err := pathing.ExpandUser(c.SSHPrivateKeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf(
|
errs = append(errs, fmt.Errorf(
|
||||||
"ssh_private_key_file is invalid: %s", err))
|
"ssh_private_key_file is invalid: %s", err))
|
||||||
|
@ -520,7 +520,7 @@ func (c *Config) prepareSSH(ctx *interpolate.Context) []error {
|
||||||
"ssh_private_key_file is invalid: %s", err))
|
"ssh_private_key_file is invalid: %s", err))
|
||||||
} else {
|
} else {
|
||||||
if c.SSHCertificateFile != "" {
|
if c.SSHCertificateFile != "" {
|
||||||
certPath, err := packer.ExpandUser(c.SSHCertificateFile)
|
certPath, err := pathing.ExpandUser(c.SSHCertificateFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("invalid identity certificate: #{err}"))
|
errs = append(errs, fmt.Errorf("invalid identity certificate: #{err}"))
|
||||||
}
|
}
|
||||||
|
@ -543,7 +543,7 @@ func (c *Config) prepareSSH(ctx *interpolate.Context) []error {
|
||||||
errs = append(errs, errors.New(
|
errs = append(errs, errors.New(
|
||||||
"ssh_bastion_password or ssh_bastion_private_key_file must be specified"))
|
"ssh_bastion_password or ssh_bastion_private_key_file must be specified"))
|
||||||
} else if c.SSHBastionPrivateKeyFile != "" {
|
} else if c.SSHBastionPrivateKeyFile != "" {
|
||||||
path, err := packer.ExpandUser(c.SSHBastionPrivateKeyFile)
|
path, err := pathing.ExpandUser(c.SSHBastionPrivateKeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf(
|
errs = append(errs, fmt.Errorf(
|
||||||
"ssh_bastion_private_key_file is invalid: %s", err))
|
"ssh_bastion_private_key_file is invalid: %s", err))
|
||||||
|
@ -552,7 +552,7 @@ func (c *Config) prepareSSH(ctx *interpolate.Context) []error {
|
||||||
"ssh_bastion_private_key_file is invalid: %s", err))
|
"ssh_bastion_private_key_file is invalid: %s", err))
|
||||||
} else {
|
} else {
|
||||||
if c.SSHBastionCertificateFile != "" {
|
if c.SSHBastionCertificateFile != "" {
|
||||||
certPath, err := packer.ExpandUser(c.SSHBastionCertificateFile)
|
certPath, err := pathing.ExpandUser(c.SSHBastionCertificateFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("invalid identity certificate: #{err}"))
|
errs = append(errs, fmt.Errorf("invalid identity certificate: #{err}"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,10 @@ import (
|
||||||
|
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
helperssh "github.com/hashicorp/packer/packer-plugin-sdk/communicator/ssh"
|
helperssh "github.com/hashicorp/packer/packer-plugin-sdk/communicator/ssh"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
|
"github.com/hashicorp/packer/packer-plugin-sdk/pathing"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/sdk-internals/communicator/ssh"
|
"github.com/hashicorp/packer/packer-plugin-sdk/sdk-internals/communicator/ssh"
|
||||||
gossh "golang.org/x/crypto/ssh"
|
gossh "golang.org/x/crypto/ssh"
|
||||||
"golang.org/x/crypto/ssh/agent"
|
"golang.org/x/crypto/ssh/agent"
|
||||||
|
@ -273,14 +273,14 @@ func sshBastionConfig(config *Config) (*gossh.ClientConfig, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.SSHBastionPrivateKeyFile != "" {
|
if config.SSHBastionPrivateKeyFile != "" {
|
||||||
path, err := packer.ExpandUser(config.SSHBastionPrivateKeyFile)
|
path, err := pathing.ExpandUser(config.SSHBastionPrivateKeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf(
|
return nil, fmt.Errorf(
|
||||||
"Error expanding path for SSH bastion private key: %s", err)
|
"Error expanding path for SSH bastion private key: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.SSHBastionCertificateFile != "" {
|
if config.SSHBastionCertificateFile != "" {
|
||||||
identityPath, err := packer.ExpandUser(config.SSHBastionCertificateFile)
|
identityPath, err := pathing.ExpandUser(config.SSHBastionCertificateFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Error expanding path for SSH bastion identity certificate: %s", err)
|
return nil, fmt.Errorf("Error expanding path for SSH bastion identity certificate: %s", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package packer
|
package pathing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
|
@ -1,4 +1,4 @@
|
||||||
package packer
|
package pathing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,6 +1,6 @@
|
||||||
// +build darwin freebsd linux netbsd openbsd solaris
|
// +build darwin freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
package packer
|
package pathing
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultConfigFile = ".packerconfig"
|
defaultConfigFile = ".packerconfig"
|
|
@ -1,6 +1,6 @@
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package packer
|
package pathing
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultConfigFile = "packer.config"
|
defaultConfigFile = "packer.config"
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
|
"github.com/hashicorp/packer/packer-plugin-sdk/pathing"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PACKERSPACE is used to represent the spaces that separate args for a command
|
// PACKERSPACE is used to represent the spaces that separate args for a command
|
||||||
|
@ -64,7 +64,7 @@ func (c *Config) Discover() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next, look in the default plugins directory inside the configdir/.packer.d/plugins.
|
// Next, look in the default plugins directory inside the configdir/.packer.d/plugins.
|
||||||
dir, err := packer.ConfigDir()
|
dir, err := pathing.ConfigDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERR] Error loading config directory: %s", err)
|
log.Printf("[ERR] Error loading config directory: %s", err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
checkpoint "github.com/hashicorp/go-checkpoint"
|
checkpoint "github.com/hashicorp/go-checkpoint"
|
||||||
|
"github.com/hashicorp/packer/packer-plugin-sdk/pathing"
|
||||||
packerVersion "github.com/hashicorp/packer/version"
|
packerVersion "github.com/hashicorp/packer/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ func NewCheckpointReporter(disableSignature bool) *CheckpointTelemetry {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
configDir, err := ConfigDir()
|
configDir, err := pathing.ConfigDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[WARN] (telemetry) setup error: %s", err)
|
log.Printf("[WARN] (telemetry) setup error: %s", err)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -16,10 +16,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/hcl/v2/hcldec"
|
"github.com/hashicorp/hcl/v2/hcldec"
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/common"
|
"github.com/hashicorp/packer/packer-plugin-sdk/common"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/guestexec"
|
"github.com/hashicorp/packer/packer-plugin-sdk/guestexec"
|
||||||
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
||||||
|
"github.com/hashicorp/packer/packer-plugin-sdk/pathing"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
|
"github.com/hashicorp/packer/packer-plugin-sdk/template/config"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
|
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
|
||||||
"github.com/hashicorp/packer/packer-plugin-sdk/uuid"
|
"github.com/hashicorp/packer/packer-plugin-sdk/uuid"
|
||||||
|
@ -278,7 +278,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.config.ValidationKeyPath != "" {
|
if p.config.ValidationKeyPath != "" {
|
||||||
path, err := packer.ExpandUser(p.config.ValidationKeyPath)
|
path, err := pathing.ExpandUser(p.config.ValidationKeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error while expanding a tilde in the validation key: %s", err)
|
return fmt.Errorf("Error while expanding a tilde in the validation key: %s", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue