Skip to content
This repository was archived by the owner on Feb 7, 2020. It is now read-only.

Commit 3e8fdcd

Browse files
committed
feat(config): add option for new entry
1 parent 9ece57d commit 3e8fdcd

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

commands/project_build_artifacts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (c *ProjectBuildArtifactCommand) Run(args []string) int {
5757
}
5858

5959
config := helper.NewConfig()
60-
client := gitlab.NewGitlab(config.Host, config.ApiPath, config.Token)
60+
client := gitlab.NewGitlab(config.Gitlab.Host, config.Gitlab.ApiPath, config.Gitlab.Token)
6161

6262
project, err := helper.GetProject(args[0], client)
6363

commands/project_builds_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (c *ProjectBuildsListCommand) Run(args []string) int {
5050
}
5151

5252
config := helper.NewConfig()
53-
client := gitlab.NewGitlab(config.Host, config.ApiPath, config.Token)
53+
client := gitlab.NewGitlab(config.Gitlab.Host, config.Gitlab.ApiPath, config.Gitlab.Token)
5454

5555
project, err := helper.GetProject(args[0], client)
5656

commands/project_list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ func (c *ProjectsListCommand) Run(args []string) int {
3434

3535
config := helper.NewConfig()
3636

37-
gitlab := gitlab.NewGitlab(config.Host, config.ApiPath, config.Token)
37+
client := gitlab.NewGitlab(config.Gitlab.Host, config.Gitlab.ApiPath, config.Gitlab.Token)
3838

3939
c.Ui.Output("Trying to find project from options")
4040

41-
projects, err := gitlab.Projects()
41+
projects, err := client.Projects()
4242

4343
if err != nil {
4444
c.Ui.Error(err.Error())

config.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,37 @@ package gitlab_ci_helper
77

88
import "os"
99

10-
type Config struct {
10+
type GitLabConfig struct {
1111
Host string `json:"host"`
1212
Token string `json:"token"`
1313
ApiPath string `json:"api_path"`
1414
}
1515

16+
type MailerConfig struct {
17+
SubjectPrefix string `json:"subject"`
18+
Sender string `json:"sender"`
19+
Dest []string `json:"dest"`
20+
Host string `json:"host"`
21+
Username string `json:"username"`
22+
Password string `json:"password"`
23+
}
24+
25+
type Config struct {
26+
Gitlab *GitLabConfig `json:"gitlab"`
27+
}
28+
1629
func NewConfig() *Config {
17-
c := &Config{
30+
gitlab := &GitLabConfig{
1831
Host: os.Getenv("GITLAB_HOST"),
1932
Token: os.Getenv("GITLAB_TOKEN"),
2033
ApiPath: os.Getenv("GITLAB_API_PATH"),
2134
}
2235

23-
if c.ApiPath == "" {
24-
c.ApiPath = "/api/v3"
36+
if gitlab.ApiPath == "" {
37+
gitlab.ApiPath = "/api/v3"
2538
}
2639

27-
return c
40+
return &Config{
41+
Gitlab: gitlab,
42+
}
2843
}

0 commit comments

Comments
 (0)