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
|
type ExecutionPolicy int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Bypass ExecutionPolicy = iota
|
ExecutionPolicyBypass ExecutionPolicy = iota
|
||||||
AllSigned
|
ExecutionPolicyAllsigned
|
||||||
Default
|
ExecutionPolicyDefault
|
||||||
RemoteSigned
|
ExecutionPolicyRemotesigned
|
||||||
Restricted
|
ExecutionPolicyRestricted
|
||||||
Undefined
|
ExecutionPolicyUndefined
|
||||||
Unrestricted
|
ExecutionPolicyUnrestricted
|
||||||
None // not set
|
ExecutionPolicyNone // not set
|
||||||
)
|
)
|
||||||
|
|
||||||
func (ep *ExecutionPolicy) Decode(v interface{}) (err error) {
|
func (ep *ExecutionPolicy) Decode(v interface{}) (err error) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
func TestExecutionPolicy_Decode(t *testing.T) {
|
func TestExecutionPolicy_Decode(t *testing.T) {
|
||||||
config := map[string]interface{}{
|
config := map[string]interface{}{
|
||||||
"inline": []interface{}{"foo", "bar"},
|
"inline": []interface{}{"foo", "bar"},
|
||||||
"execution_policy": "AllSigned",
|
"execution_policy": "allsigned",
|
||||||
}
|
}
|
||||||
p := new(Provisioner)
|
p := new(Provisioner)
|
||||||
err := p.Prepare(config)
|
err := p.Prepare(config)
|
||||||
|
@ -15,7 +15,7 @@ func TestExecutionPolicy_Decode(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.config.ExecutionPolicy != AllSigned {
|
if p.config.ExecutionPolicy != ExecutionPolicyAllsigned {
|
||||||
t.Fatalf("Expected AllSigned execution policy; got: %s", p.config.ExecutionPolicy)
|
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
|
package powershell
|
||||||
|
@ -7,7 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const _ExecutionPolicyName = "BypassAllSignedDefaultRemoteSignedRestrictedUndefinedUnrestrictedNone"
|
const _ExecutionPolicyName = "bypassallsigneddefaultremotesignedrestrictedundefinedunrestrictednone"
|
||||||
|
|
||||||
var _ExecutionPolicyIndex = [...]uint8{0, 6, 15, 22, 34, 44, 53, 65, 69}
|
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)` +
|
baseCmd := `& { if (Test-Path variable:global:ProgressPreference)` +
|
||||||
`{set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};` +
|
`{set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};` +
|
||||||
`. {{.Vars}}; &'{{.Path}}'; exit $LastExitCode }`
|
`. {{.Vars}}; &'{{.Path}}'; exit $LastExitCode }`
|
||||||
if p.config.ExecutionPolicy == None {
|
if p.config.ExecutionPolicy == ExecutionPolicyNone {
|
||||||
return baseCmd
|
return baseCmd
|
||||||
} else {
|
} else {
|
||||||
return fmt.Sprintf(`powershell -executionpolicy %s "%s"`, p.config.ExecutionPolicy, baseCmd)
|
return fmt.Sprintf(`powershell -executionpolicy %s "%s"`, p.config.ExecutionPolicy, baseCmd)
|
||||||
|
|
Loading…
Reference in New Issue