Skip to content

Commit

Permalink
Remove unused checkXExists methods in toml, terragrunt, terraform_ver…
Browse files Browse the repository at this point in the history
…sion, as these are handled directly from the GetVersionFromX methods

Issue #420
  • Loading branch information
MatthewJohn committed May 9, 2024
1 parent 7df2b96 commit 383fff9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
8 changes: 2 additions & 6 deletions lib/param_parsing/terraform_version.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package param_parsing

import (
"github.com/warrensbox/terraform-switcher/lib"
"os"
"path/filepath"
"strings"

"github.com/warrensbox/terraform-switcher/lib"
)

const terraformVersionFileName = ".terraform-version"
Expand All @@ -22,8 +23,3 @@ func GetParamsFromTerraformVersion(params Params) (Params, error) {
}
return params, nil
}

func terraformVersionFileExists(params Params) bool {
filePath := filepath.Join(params.ChDirPath, terraformVersionFileName)
return lib.CheckFileExist(filePath)
}
8 changes: 2 additions & 6 deletions lib/param_parsing/terragrunt.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package param_parsing

import (
"fmt"
"path/filepath"

"github.com/hashicorp/hcl/v2/gohcl"
"github.com/hashicorp/hcl/v2/hclparse"
"github.com/warrensbox/terraform-switcher/lib"
"path/filepath"
)

const terraGruntFileName = "terragrunt.hcl"
Expand Down Expand Up @@ -37,8 +38,3 @@ func GetVersionFromTerragrunt(params Params) (Params, error) {
}
return params, nil
}

func terraGruntFileExists(params Params) bool {
filePath := filepath.Join(params.ChDirPath, terraGruntFileName)
return lib.CheckFileExist(filePath)
}
10 changes: 3 additions & 7 deletions lib/param_parsing/toml.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package param_parsing

import (
"path/filepath"

"github.com/spf13/viper"
"github.com/warrensbox/terraform-switcher/lib"
"path/filepath"
)

const tfSwitchTOMLFileName = ".tfswitch.toml"

// getParamsTOML parses everything in the toml file, return required version and bin path
func getParamsTOML(params Params) (Params, error) {
tomlPath := filepath.Join(params.ChDirPath, tfSwitchTOMLFileName)
if tomlFileExists(params) {
if lib.CheckFileExist(tomlPath) {
logger.Infof("Reading configuration from %q", tomlPath)
configfileName := lib.GetFileName(tfSwitchTOMLFileName)
viperParser := viper.New()
Expand All @@ -37,8 +38,3 @@ func getParamsTOML(params Params) (Params, error) {
}
return params, nil
}

func tomlFileExists(params Params) bool {
tomlPath := filepath.Join(params.ChDirPath, tfSwitchTOMLFileName)
return lib.CheckFileExist(tomlPath)
}

0 comments on commit 383fff9

Please sign in to comment.