Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Commit

Permalink
fix: gofmt + golint
Browse files Browse the repository at this point in the history
  • Loading branch information
thazelart committed Jul 22, 2019
1 parent 0f51325 commit 8a87f31
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
26 changes: 13 additions & 13 deletions internal/config/config.go
Expand Up @@ -30,27 +30,27 @@ const usage = `
// DefaultTerraformConfig is the default TerraformConfig configuration
var DefaultTerraformConfig = TerraformConfig{
Files: map[string]FileConfig{
"main.tf": FileConfig{
"main.tf": {
Mandatory: true,
AuthorizedBlocks: nil,
},
"variables.tf": FileConfig{
"variables.tf": {
Mandatory: true,
AuthorizedBlocks: []string{"variable"},
},
"outputs.tf": FileConfig{
"outputs.tf": {
Mandatory: true,
AuthorizedBlocks: []string{"output"},
},
"providers.tf": FileConfig{
"providers.tf": {
Mandatory: true,
AuthorizedBlocks: []string{"provider"},
},
"backend.tf": FileConfig{
"backend.tf": {
Mandatory: true,
AuthorizedBlocks: []string{"terraform"},
},
"default": FileConfig{
"default": {
Mandatory: false,
AuthorizedBlocks: []string{"resource", "module", "data", "locals"},
},
Expand Down Expand Up @@ -192,14 +192,14 @@ func (globalConfig GlobalConfig) GetAuthorizedBlocks(filename string) ([]string,
_, ok := globalConfig.TerraformConfig.Files[filename]
if ok {
return globalConfig.TerraformConfig.Files[filename].AuthorizedBlocks, nil
} else {
_, ok := globalConfig.TerraformConfig.Files["default"]
if ok {
return globalConfig.TerraformConfig.Files["default"].AuthorizedBlocks, nil
} else {
return nil, fmt.Errorf(" cannot check authorized blocks, their is no file configuration for %s nor default", filename)
}
}

_, ok = globalConfig.TerraformConfig.Files["default"]
if ok {
return globalConfig.TerraformConfig.Files["default"].AuthorizedBlocks, nil
}

return nil, fmt.Errorf(" cannot check authorized blocks, their is no file configuration for %s nor default", filename)
}

// GetMandatoryFiles get the mandatory file list from the globalConfig
Expand Down
2 changes: 1 addition & 1 deletion pkg/hcl/hcl_check.go
Expand Up @@ -37,7 +37,7 @@ func (terraformFileParsedContent TerraformFileParsedContent) VerifyBlocksInFiles
return
}

for blockType, _ := range terraformFileParsedContent {
for blockType := range terraformFileParsedContent {
authorized := utils.Contains(authorizedBlocks, blockType)
if !authorized {
*errs = append(*errs, fmt.Errorf("%s", blockType))
Expand Down
4 changes: 2 additions & 2 deletions pkg/hcl/hcl_parse_test.go
Expand Up @@ -132,8 +132,8 @@ func TestInitTerraformFileParsedContent(t *testing.T) {
func TestGetProviderConfiguration(t *testing.T) {
testFile := fs.File{Path: "/tmp/main.tf", Content: []byte(fileContent)}
expectedResult := map[string][]string{
"google": []string{"project", "version"},
"github": []string{"organization"},
"google": {"project", "version"},
"github": {"organization"},
}

testResult := hcl.GetProviderConfiguration(testFile)
Expand Down

0 comments on commit 8a87f31

Please sign in to comment.