Skip to content

Commit

Permalink
Merge pull request #1481 from tpdownes/minor_changes
Browse files Browse the repository at this point in the history
Address minor warnings and lint issues
  • Loading branch information
tpdownes authored Jun 20, 2023
2 parents 562d2b1 + c903f30 commit 65344ec
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pkg/modulereader/resreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func GetModuleInfo(source string, kind string) (ModuleInfo, error) {
modPath = source

default:
return ModuleInfo{}, fmt.Errorf("Source is not valid: %s", source)
return ModuleInfo{}, fmt.Errorf("source is not valid: %s", source)
}

reader := Factory(kind)
Expand Down
16 changes: 3 additions & 13 deletions pkg/modulereader/resreader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"reflect"
"testing"

"github.com/spf13/afero"
. "gopkg.in/check.v1"
"gopkg.in/yaml.v3"
)
Expand Down Expand Up @@ -112,7 +111,7 @@ func (s *MySuite) TestGetModuleInfo_Embedded(c *C) {
// Invalid: Unsupported Module Source
badSource := "gcs::https://www.googleapis.com/storage/v1/GoogleCloudPlatform/hpc-toolkit/modules"
moduleInfo, err = GetModuleInfo(badSource, tfKindString)
expectedErr = "Source is not valid: .*"
expectedErr = "source is not valid: .*"
c.Assert(err, ErrorMatches, expectedErr)
}

Expand All @@ -127,7 +126,7 @@ func (s *MySuite) TestGetModuleInfo_Git(c *C) {
// Invalid: Unsupported Module Source
badSource := "gcs::https://www.googleapis.com/storage/v1/GoogleCloudPlatform/hpc-toolkit/modules"
_, err = GetModuleInfo(badSource, tfKindString)
expectedErr = "Source is not valid: .*"
expectedErr = "source is not valid: .*"
c.Assert(err, ErrorMatches, expectedErr)
}

Expand All @@ -148,19 +147,10 @@ func (s *MySuite) TestGetModuleInfo_Local(c *C) {
// Invalid: Unsupported Module Source
badSource := "gcs::https://www.googleapis.com/storage/v1/GoogleCloudPlatform/hpc-toolkit/modules"
moduleInfo, err = GetModuleInfo(badSource, tfKindString)
expectedErr = "Source is not valid: .*"
expectedErr = "source is not valid: .*"
c.Assert(err, ErrorMatches, expectedErr)
}

// hcl_utils.go
func getTestFS() afero.IOFS {
aferoFS := afero.NewMemMapFs()
aferoFS.MkdirAll("modules/network/vpc", 0755)
afero.WriteFile(
aferoFS, "modules/network/vpc/main.tf", []byte(testMainTf), 0644)
return afero.NewIOFS(aferoFS)
}

func (s *MySuite) TestGetHCLInfo(c *C) {
// Invalid source path - path does not exists
fakePath := "./not/a/real/path"
Expand Down
2 changes: 1 addition & 1 deletion pkg/sourcereader/embedded.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (r EmbeddedSourceReader) GetModule(modPath string, copyPath string) error {
return fmt.Errorf("embedded file system is not initialized")
}
if !IsEmbeddedPath(modPath) {
return fmt.Errorf("Source is not valid: %s", modPath)
return fmt.Errorf("source is not valid: %s", modPath)
}

modDir, err := copyFSToTempDir(ModuleFS, modPath)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sourcereader/embedded_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (s *MySuite) TestGetModule_Embedded(c *C) {
// Invalid: Unsupported Module Source by EmbeddedSourceReader
badSource := "gcs::https://www.googleapis.com/storage/v1/GoogleCloudPlatform/hpc-toolkit/modules"
err = reader.GetModule(badSource, dest)
expectedErr = "Source is not valid: .*"
expectedErr = "source is not valid: .*"
c.Assert(err, ErrorMatches, expectedErr)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/sourcereader/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func copyGitModules(srcPath string, destPath string) error {
// GetModule copies the git source to a provided destination (the deployment directory)
func (r GitSourceReader) GetModule(modPath string, copyPath string) error {
if !IsGitPath(modPath) {
return fmt.Errorf("Source is not valid: %s", modPath)
return fmt.Errorf("source is not valid: %s", modPath)
}

modDir, err := ioutil.TempDir("", "git-module-*")
Expand Down
2 changes: 1 addition & 1 deletion pkg/sourcereader/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ func (s *MySuite) TestGetModule_Git(c *C) {
// Invalid: Unsupported Module Source
badSource := "gcs::https://www.googleapis.com/storage/v1/GoogleCloudPlatform/hpc-toolkit/modules"
err = reader.GetModule(badSource, tfKindString)
expectedErr = "Source is not valid: .*"
expectedErr = "source is not valid: .*"
c.Assert(err, ErrorMatches, expectedErr)
}
2 changes: 1 addition & 1 deletion pkg/sourcereader/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type LocalSourceReader struct{}
// GetModule copies the local source to a provided destination (the deployment directory)
func (r LocalSourceReader) GetModule(modPath string, copyPath string) error {
if !IsLocalPath(modPath) {
return fmt.Errorf("Source is not valid: %s", modPath)
return fmt.Errorf("source is not valid: %s", modPath)
}

if _, err := os.Stat(modPath); os.IsNotExist(err) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sourcereader/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,6 @@ func (s *MySuite) TestGetModule_Local(c *C) {
// Invalid: Unsupported Module Source by LocalSourceReader
badSource := "gcs::https://www.googleapis.com/storage/v1/GoogleCloudPlatform/hpc-toolkit/modules"
err = reader.GetModule(badSource, dest)
expectedErr = "Source is not valid: .*"
expectedErr = "source is not valid: .*"
c.Assert(err, ErrorMatches, expectedErr)
}

0 comments on commit 65344ec

Please sign in to comment.