execution policy: make everything more idiomatic
* make possible execution policy values lowercase * prefix execution policies possibilities
This commit is contained in:
parent
e62aba3788
commit
7005958155
|
@ -10,14 +10,14 @@ import (
|
|||
type ExecutionPolicy int
|
||||
|
||||
const (
|
||||
Bypass ExecutionPolicy = iota
|
||||
AllSigned
|
||||
Default
|
||||
RemoteSigned
|
||||
Restricted
|
||||
Undefined
|
||||
Unrestricted
|
||||
None // not set
|
||||
ExecutionPolicyBypass ExecutionPolicy = iota
|
||||
ExecutionPolicyAllsigned
|
||||
ExecutionPolicyDefault
|
||||
ExecutionPolicyRemotesigned
|
||||
ExecutionPolicyRestricted
|
||||
ExecutionPolicyUndefined
|
||||
ExecutionPolicyUnrestricted
|
||||
ExecutionPolicyNone // not set
|
||||
)
|
||||
|
||||
func (ep *ExecutionPolicy) Decode(v interface{}) (err error) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
func TestExecutionPolicy_Decode(t *testing.T) {
|
||||
config := map[string]interface{}{
|
||||
"inline": []interface{}{"foo", "bar"},
|
||||
"execution_policy": "AllSigned",
|
||||
"execution_policy": "allsigned",
|
||||
}
|
||||
p := new(Provisioner)
|
||||
err := p.Prepare(config)
|
||||
|
@ -15,7 +15,7 @@ func TestExecutionPolicy_Decode(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if p.config.ExecutionPolicy != AllSigned {
|
||||
if p.config.ExecutionPolicy != ExecutionPolicyAllsigned {
|
||||
t.Fatalf("Expected AllSigned execution policy; got: %s", p.config.ExecutionPolicy)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by "enumer -type ExecutionPolicy provisioner/powershell/execution_policy.go"; DO NOT EDIT.
|
||||
// Code generated by "enumer -transform snake -trimprefix ExecutionPolicy -type ExecutionPolicy provisioner/powershell/execution_policy.go"; DO NOT EDIT.
|
||||
|
||||
//
|
||||
package powershell
|
||||
|
@ -7,7 +7,7 @@ import (
|
|||
"fmt"
|
||||
)
|
||||
|
||||
const _ExecutionPolicyName = "BypassAllSignedDefaultRemoteSignedRestrictedUndefinedUnrestrictedNone"
|
||||
const _ExecutionPolicyName = "bypassallsigneddefaultremotesignedrestrictedundefinedunrestrictednone"
|
||||
|
||||
var _ExecutionPolicyIndex = [...]uint8{0, 6, 15, 22, 34, 44, 53, 65, 69}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ func (p *Provisioner) defaultExecuteCommand() string {
|
|||
baseCmd := `& { if (Test-Path variable:global:ProgressPreference)` +
|
||||
`{set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};` +
|
||||
`. {{.Vars}}; &'{{.Path}}'; exit $LastExitCode }`
|
||||
if p.config.ExecutionPolicy == None {
|
||||
if p.config.ExecutionPolicy == ExecutionPolicyNone {
|
||||
return baseCmd
|
||||
} else {
|
||||
return fmt.Sprintf(`powershell -executionpolicy %s "%s"`, p.config.ExecutionPolicy, baseCmd)
|
||||
|
|
Loading…
Reference in New Issue