diff --git a/fix/fixer_galaxy_command.go b/fix/fixer_galaxy_command.go index 781ae216e..599f6b611 100644 --- a/fix/fixer_galaxy_command.go +++ b/fix/fixer_galaxy_command.go @@ -1,8 +1,6 @@ package fix import ( - "strings" - "github.com/mitchellh/mapstructure" ) @@ -15,13 +13,6 @@ func (FixerGalaxyCommand) Fix(input map[string]interface{}) (map[string]interfac Provisioners []interface{} } - var gcUnescape = strings.NewReplacer( - "`$", "$", - "`\"", "\"", - "``", "`", - "`'", "'", - ) - // Decode the input into our structure, if we can var tpl template if err := mapstructure.WeakDecode(input, &tpl); err != nil { @@ -35,12 +26,11 @@ func (FixerGalaxyCommand) Fix(input map[string]interface{}) (map[string]interfac continue } - if ok := provisioners["type"] == "ansible*" || provisioners["type"] == "ansible-local"; !ok { + if ok := provisioners["type"] == "ansible-local"; !ok { continue } if _, ok := provisioners["galaxy_command"]; ok { - provisioners["galaxy_command"] = gcUnescape.Replace(provisioners["galaxy_command"].(string)) // drop galaxycommand if it is also included if _, galaxyCommandIncluded := provisioners["galaxycommand"]; galaxyCommandIncluded { @@ -54,7 +44,11 @@ func (FixerGalaxyCommand) Fix(input map[string]interface{}) (map[string]interfac if !ok { continue } - galaxyCommandString := gcUnescape.Replace(galaxyCommandRaw.(string)) + + galaxyCommandString, ok := galaxyCommandRaw.(string) + if !ok { + continue + } delete(provisioners, "galaxycommand") provisioners["galaxy_command"] = galaxyCommandString @@ -72,5 +66,5 @@ func (FixerGalaxyCommand) Fix(input map[string]interface{}) (map[string]interfac } func (FixerGalaxyCommand) Synopsis() string { - return `Removes escapes from user env vars and updates provisioners to use "galaxy_command" rather than "galaxycommand"` + return `Replaces "galaxycommad" in ansible-local provisioner configs with "galaxy_command"` } diff --git a/fix/fixer_galaxy_command_test.go b/fix/fixer_galaxy_command_test.go index 6d965142e..c052a10c9 100644 --- a/fix/fixer_galaxy_command_test.go +++ b/fix/fixer_galaxy_command_test.go @@ -17,12 +17,12 @@ func TestFixerGalaxyCommand_Fix(t *testing.T) { // set galaxy_command { Input: map[string]interface{}{ - "type": "ansible", + "type": "ansible-local", "galaxy_command": "/usr/local/bin/ansible-galaxy", }, Expected: map[string]interface{}{ - "type": "ansible", + "type": "ansible-local", "galaxy_command": "/usr/local/bin/ansible-galaxy", }, },