-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from janritter/fix/issue-5
- Loading branch information
Showing
7 changed files
with
101 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package iface | ||
|
||
type BackendAPI interface { | ||
GenerateStatefileForBackend(in interface{}) error | ||
GenerateConfigurationForBackend(in interface{}) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package helper | ||
|
||
import ( | ||
"errors" | ||
"log" | ||
"os" | ||
"reflect" | ||
|
||
"github.com/fatih/color" | ||
) | ||
|
||
func RemoveDotTerraformFolder(in interface{}) error { | ||
switch in.(type) { | ||
case map[string]interface{}: | ||
mapped := in.(map[string]interface{}) | ||
if mapped["state_auto_remove_old"] == nil { | ||
color.Blue("Skipping removing of .terraform folder") | ||
|
||
return nil | ||
} | ||
if reflect.TypeOf(mapped["state_auto_remove_old"]).String() != "bool" { | ||
err := errors.New("state_auto_remove_old must be of type bool, was " + reflect.TypeOf(mapped["state_auto_remove_old"]).String()) | ||
log.Println(err) | ||
|
||
return err | ||
} | ||
if !mapped["state_auto_remove_old"].(bool) { | ||
color.Blue("Skipping removing of .terraform folder") | ||
|
||
return nil | ||
} | ||
|
||
default: | ||
err := errors.New("Unknown var-file format") | ||
log.Println(err) | ||
|
||
return err | ||
} | ||
|
||
err := os.RemoveAll(".terraform") | ||
if err != nil { | ||
color.Red(err.Error()) | ||
|
||
return err | ||
} | ||
|
||
color.Green("Removed .terraform folder") | ||
|
||
return nil | ||
} |