diff --git a/config/config.go b/config/config.go index 3d59e63..99a762e 100644 --- a/config/config.go +++ b/config/config.go @@ -1,6 +1,9 @@ package config -import "errors" +import ( + "errors" + "strings" +) type Config struct { BaseURL string @@ -14,6 +17,10 @@ type Config struct { var ErrAPIKeyIsRequired = errors.New("api-key is required") func New(baseURL, apiKey, projectName, projectVersion string, projectTags []string) *Config { + if len(projectTags) == 1 && strings.Contains(projectTags[0], ",") { + projectTags = strings.Split(projectTags[0], ",") + } + return &Config{ BaseURL: baseURL, APIKey: apiKey, diff --git a/config/config_test.go b/config/config_test.go index bf306f1..346b507 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -35,6 +35,23 @@ func TestNew(t *testing.T) { ProjectTags: []string{"tag1", "tag2"}, }, }, + { + name: "success tag separator is comma", + args: args{ + baseURL: "https://example.com", + apiKey: "12345", + projectName: "test-project", + projectVersion: "1.0.0", + projectTags: []string{"tag1,tag2"}, + }, + want: &Config{ + BaseURL: "https://example.com", + APIKey: "12345", + ProjectName: "test-project", + ProjectVersion: "1.0.0", + ProjectTags: []string{"tag1", "tag2"}, + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {