regroup shell provisioner params into a common struct
This commit is contained in:
parent
f369ae2178
commit
30a65c858a
|
@ -0,0 +1,42 @@
|
|||
// Package shell defines conde that is common in shells
|
||||
package shell
|
||||
|
||||
import "github.com/hashicorp/packer/common"
|
||||
|
||||
// Provisioner contains common fields to all provisioners
|
||||
type Provisioner struct {
|
||||
common.PackerConfig `mapstructure:",squash"`
|
||||
|
||||
// If true, the script contains binary and line endings will not be
|
||||
// converted from Windows to Unix-style.
|
||||
Binary bool
|
||||
|
||||
// The command used to execute the script. The '{{ .Path }}' variable
|
||||
// should be used to specify where the script goes, {{ .Vars }}
|
||||
// can be used to inject the environment_vars into the environment.
|
||||
ExecuteCommand string `mapstructure:"execute_command"`
|
||||
|
||||
// An inline script to execute. Multiple strings are all executed
|
||||
// in the context of a single shell.
|
||||
Inline []string
|
||||
|
||||
// The remote path where the local shell script will be uploaded to.
|
||||
// This should be set to a writable file that is in a pre-existing directory.
|
||||
// This defaults to remote_folder/remote_file
|
||||
RemotePath string `mapstructure:"remote_path"`
|
||||
|
||||
// The local path of the shell script to upload and execute.
|
||||
Script string
|
||||
|
||||
// An array of multiple scripts to run.
|
||||
Scripts []string
|
||||
|
||||
// Valid Exit Codes - 0 is not always the only valid error code! See
|
||||
// http://www.symantec.com/connect/articles/windows-system-error-codes-exit-codes-description
|
||||
// for examples such as 3010 - "The requested operation is successful.
|
||||
ValidExitCodes []int `mapstructure:"valid_exit_codes"`
|
||||
|
||||
// An array of environment variables that will be injected before
|
||||
// your command(s) are executed.
|
||||
Vars []string `mapstructure:"environment_vars"`
|
||||
}
|
|
@ -13,6 +13,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/hashicorp/packer/common"
|
||||
"github.com/hashicorp/packer/common/shell"
|
||||
"github.com/hashicorp/packer/common/uuid"
|
||||
commonhelper "github.com/hashicorp/packer/helper/common"
|
||||
"github.com/hashicorp/packer/helper/config"
|
||||
|
@ -32,41 +33,13 @@ var psEscape = strings.NewReplacer(
|
|||
)
|
||||
|
||||
type Config struct {
|
||||
common.PackerConfig `mapstructure:",squash"`
|
||||
|
||||
// If true, the script contains binary and line endings will not be
|
||||
// converted from Windows to Unix-style.
|
||||
Binary bool
|
||||
|
||||
// An inline script to execute. Multiple strings are all executed in the
|
||||
// context of a single shell.
|
||||
Inline []string
|
||||
|
||||
// The local path of the powershell script to upload and execute.
|
||||
Script string
|
||||
|
||||
// An array of multiple scripts to run.
|
||||
Scripts []string
|
||||
|
||||
// An array of environment variables that will be injected before your
|
||||
// command(s) are executed.
|
||||
Vars []string `mapstructure:"environment_vars"`
|
||||
|
||||
// The remote path where the local powershell script will be uploaded to.
|
||||
// This should be set to a writable file that is in a pre-existing
|
||||
// directory.
|
||||
RemotePath string `mapstructure:"remote_path"`
|
||||
shell.Provisioner `mapstructure:",squash"`
|
||||
|
||||
// The remote path where the file containing the environment variables
|
||||
// will be uploaded to. This should be set to a writable file that is in a
|
||||
// pre-existing directory.
|
||||
RemoteEnvVarPath string `mapstructure:"remote_env_var_path"`
|
||||
|
||||
// The command used to execute the script. The '{{ .Path }}' variable
|
||||
// should be used to specify where the script goes, {{ .Vars }} can be
|
||||
// used to inject the environment_vars into the environment.
|
||||
ExecuteCommand string `mapstructure:"execute_command"`
|
||||
|
||||
// The command used to execute the elevated script. The '{{ .Path }}'
|
||||
// variable should be used to specify where the script goes, {{ .Vars }}
|
||||
// can be used to inject the environment_vars into the environment.
|
||||
|
@ -91,12 +64,6 @@ type Config struct {
|
|||
ElevatedUser string `mapstructure:"elevated_user"`
|
||||
ElevatedPassword string `mapstructure:"elevated_password"`
|
||||
|
||||
// Valid Exit Codes - 0 is not always the only valid error code! See
|
||||
// http://www.symantec.com/connect/articles/windows-system-error-codes-exit-codes-description
|
||||
// for examples such as 3010 - "The requested operation is successful.
|
||||
// Changes will not be effective until the system is rebooted."
|
||||
ValidExitCodes []int `mapstructure:"valid_exit_codes"`
|
||||
|
||||
ctx interpolate.Context
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/hashicorp/packer/common"
|
||||
"github.com/hashicorp/packer/common/shell"
|
||||
"github.com/hashicorp/packer/helper/config"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/hashicorp/packer/packer/tmp"
|
||||
|
@ -22,29 +23,11 @@ import (
|
|||
)
|
||||
|
||||
type Config struct {
|
||||
common.PackerConfig `mapstructure:",squash"`
|
||||
|
||||
// If true, the script contains binary and line endings will not be
|
||||
// converted from Windows to Unix-style.
|
||||
Binary bool
|
||||
|
||||
// An inline script to execute. Multiple strings are all executed
|
||||
// in the context of a single shell.
|
||||
Inline []string
|
||||
shell.Provisioner `mapstructure:",squash"`
|
||||
|
||||
// The shebang value used when running inline scripts.
|
||||
InlineShebang string `mapstructure:"inline_shebang"`
|
||||
|
||||
// The local path of the shell script to upload and execute.
|
||||
Script string
|
||||
|
||||
// An array of multiple scripts to run.
|
||||
Scripts []string
|
||||
|
||||
// An array of environment variables that will be injected before
|
||||
// your command(s) are executed.
|
||||
Vars []string `mapstructure:"environment_vars"`
|
||||
|
||||
// A duration of how long to pause after the provisioner
|
||||
RawPauseAfter string `mapstructure:"pause_after"`
|
||||
|
||||
|
@ -62,16 +45,6 @@ type Config struct {
|
|||
// This defaults to script_nnn.sh
|
||||
RemoteFile string `mapstructure:"remote_file"`
|
||||
|
||||
// The remote path where the local shell script will be uploaded to.
|
||||
// This should be set to a writable file that is in a pre-existing directory.
|
||||
// This defaults to remote_folder/remote_file
|
||||
RemotePath string `mapstructure:"remote_path"`
|
||||
|
||||
// The command used to execute the script. The '{{ .Path }}' variable
|
||||
// should be used to specify where the script goes, {{ .Vars }}
|
||||
// can be used to inject the environment_vars into the environment.
|
||||
ExecuteCommand string `mapstructure:"execute_command"`
|
||||
|
||||
// The timeout for retrying to start the process. Until this timeout
|
||||
// is reached, if the provisioner can't start a process, it retries.
|
||||
// This can be set high to allow for reboots.
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/hashicorp/packer/common"
|
||||
"github.com/hashicorp/packer/common/shell"
|
||||
"github.com/hashicorp/packer/helper/config"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/hashicorp/packer/packer/tmp"
|
||||
|
@ -25,29 +26,7 @@ const DefaultRemotePath = "c:/Windows/Temp/script.bat"
|
|||
var retryableSleep = 2 * time.Second
|
||||
|
||||
type Config struct {
|
||||
common.PackerConfig `mapstructure:",squash"`
|
||||
|
||||
// If true, the script contains binary and line endings will not be
|
||||
// converted from Windows to Unix-style.
|
||||
Binary bool
|
||||
|
||||
// An inline script to execute. Multiple strings are all executed
|
||||
// in the context of a single shell.
|
||||
Inline []string
|
||||
|
||||
// The local path of the shell script to upload and execute.
|
||||
Script string
|
||||
|
||||
// An array of multiple scripts to run.
|
||||
Scripts []string
|
||||
|
||||
// An array of environment variables that will be injected before
|
||||
// your command(s) are executed.
|
||||
Vars []string `mapstructure:"environment_vars"`
|
||||
|
||||
// The remote path where the local shell script will be uploaded to.
|
||||
// This should be set to a writable file that is in a pre-existing directory.
|
||||
RemotePath string `mapstructure:"remote_path"`
|
||||
shell.Provisioner `mapstructure:",squash"`
|
||||
|
||||
// The command used to execute the script. The '{{ .Path }}' variable
|
||||
// should be used to specify where the script goes, {{ .Vars }}
|
||||
|
@ -63,11 +42,6 @@ type Config struct {
|
|||
// inside the `ExecuteCommand` template.
|
||||
EnvVarFormat string
|
||||
|
||||
// Valid Exit Codes - 0 is not always the only valid error code! See
|
||||
// http://www.symantec.com/connect/articles/windows-system-error-codes-exit-codes-description
|
||||
// for examples such as 3010 - "The requested operation is successful.
|
||||
ValidExitCodes []int `mapstructure:"valid_exit_codes"`
|
||||
|
||||
ctx interpolate.Context
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue