From 70059581556756749db14327040199d94b718c8c Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Thu, 23 May 2019 17:05:37 +0200 Subject: [PATCH] execution policy: make everything more idiomatic * make possible execution policy values lowercase * prefix execution policies possibilities --- provisioner/powershell/execution_policy.go | 16 ++++++++-------- provisioner/powershell/execution_policy_test.go | 4 ++-- provisioner/powershell/executionpolicy_enumer.go | 4 ++-- provisioner/powershell/provisioner.go | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/provisioner/powershell/execution_policy.go b/provisioner/powershell/execution_policy.go index 2453957e5..e1c2d0d53 100644 --- a/provisioner/powershell/execution_policy.go +++ b/provisioner/powershell/execution_policy.go @@ -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) { diff --git a/provisioner/powershell/execution_policy_test.go b/provisioner/powershell/execution_policy_test.go index d7ffacf32..ae8680c67 100644 --- a/provisioner/powershell/execution_policy_test.go +++ b/provisioner/powershell/execution_policy_test.go @@ -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) } } diff --git a/provisioner/powershell/executionpolicy_enumer.go b/provisioner/powershell/executionpolicy_enumer.go index ed29b4678..881a74b20 100644 --- a/provisioner/powershell/executionpolicy_enumer.go +++ b/provisioner/powershell/executionpolicy_enumer.go @@ -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} diff --git a/provisioner/powershell/provisioner.go b/provisioner/powershell/provisioner.go index 3a0430d1e..b554ca6f2 100644 --- a/provisioner/powershell/provisioner.go +++ b/provisioner/powershell/provisioner.go @@ -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)