diff --git a/app/app.go b/app/app.go index 67c78a4..d7877b3 100644 --- a/app/app.go +++ b/app/app.go @@ -10,7 +10,7 @@ import ( const ( APP_NAME = "Git repository manager" APP_DESCRIPTION = "Manage your repository with simple app" - VERSION = "0.1" + VERSION = "0.1.1" ) type GitRepositoryManager struct { diff --git a/app/app_test.go b/app/app_test.go index 56b9267..aae2b0e 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -90,5 +90,5 @@ func Example_test_sync_output() { // Output: // Info: Synchronizing repositories // Info: All repositories are synced - // Info: Current version: 0.1 + // Info: Current version: 0.1.1 } diff --git a/config/config_file_parse.go b/config/config_file_parse.go index 270b49c..b875bf5 100644 --- a/config/config_file_parse.go +++ b/config/config_file_parse.go @@ -3,6 +3,7 @@ package config import ( "errors" "fmt" + "os" "strings" "gopkg.in/yaml.v3" @@ -13,6 +14,8 @@ func GetRepositoryConfig(data []byte, fileExtension string) (Configuration, erro var config Configuration var err error + data = []byte(os.ExpandEnv(string(data))) + switch fileExtension { case "yaml": err = yaml.Unmarshal(data, &config) diff --git a/config/config_file_parse_test.go b/config/config_file_parse_test.go index b334c4c..ed3306f 100644 --- a/config/config_file_parse_test.go +++ b/config/config_file_parse_test.go @@ -2,37 +2,14 @@ package config import ( "fmt" + "os" "reflect" "testing" ) -var exampleYamlConfig = []byte(` -workspace: /tmp -repositories: - - src: "https://github.com/example/example.git" - dest: "example/path" - name: "custom_example" - - src: https://github.com/example/example2.git -`) - -var destinationConfiguration = Configuration{ - Workspace: "/tmp", - Repositories: []RepositoryConfig{ - { - Name: "custom_example", - Dest: "example/path", - Src: "https://github.com/example/example.git", - }, - { - Name: "example2", - Src: "https://github.com/example/example2.git", - Dest: "example2", - }, - }, -} - func TestNotSupportedFileExcension(t *testing.T) { - _, err := GetRepositoryConfig(exampleYamlConfig, "custom") + + _, err := GetRepositoryConfig([]byte("test"), "custom") if err == nil { t.Error("Expected to get error") } @@ -43,6 +20,33 @@ func TestNotSupportedFileExcension(t *testing.T) { func TestGetRepositoryConfigFromYaml(t *testing.T) { + var exampleYamlConfig = []byte(` +workspace: ${HOME} +repositories: + - src: "https://github.com/example/example.git" + dest: "example/path" + name: "custom_example" + - src: https://github.com/example/example2.git +`) + + homedir, _ := os.UserHomeDir() + + var destinationConfiguration = Configuration{ + Workspace: homedir, + Repositories: []RepositoryConfig{ + { + Name: "custom_example", + Dest: "example/path", + Src: "https://github.com/example/example.git", + }, + { + Name: "example2", + Src: "https://github.com/example/example2.git", + Dest: "example2", + }, + }, + } + result, err := GetRepositoryConfig(exampleYamlConfig, "yaml") if err != nil {