Skip to content

Commit 2c0caf5

Browse files
author
Jacek Ciwiś
committed
Configuration fixes
1 parent f8e2641 commit 2c0caf5

File tree

4 files changed

+15
-21
lines changed

4 files changed

+15
-21
lines changed

Taskfile.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '2'
22

33
vars:
4-
VERSION: 0.4.0
4+
VERSION: 0.5.0
55
GIT_COMMIT:
66
sh: git log -n 1 --format=%h
77
GIT_AUTHOR:

config.go

+8-17
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type globalConfigType struct {
2222
logFormat string
2323
logOutput string
2424
jiraMigrationSuccessTag string
25-
jiraMigrationFailTag string
25+
jiraMigrationFailedTag string
2626
jiraMigrationSkipTag string
2727
}
2828

@@ -43,10 +43,9 @@ func checkTogglToken() bool {
4343
viper.Set(fmt.Sprintf("%v", "default_client.stachursky_mode"), "FILL_IT")
4444
viper.Set(fmt.Sprintf("%v", "log_format"), "text")
4545
viper.Set(fmt.Sprintf("%v", "log_output"), "stdout")
46-
viper.Set(fmt.Sprintf("%v", "logged_tag"), "logged")
47-
viper.Set(fmt.Sprintf("%v", "jiraMigrationSuccess"), "logged")
48-
viper.Set(fmt.Sprintf("%v", "jiraMigrationFail"), "jira-migration-failed")
49-
viper.Set(fmt.Sprintf("%v", "jiraMigrationSkip"), "jira-migration-skip")
46+
viper.Set(fmt.Sprintf("%v", "jira_migration_success_tag"), "logged")
47+
viper.Set(fmt.Sprintf("%v", "jira_migration_failed_tag"), "jira-migration-failed")
48+
viper.Set(fmt.Sprintf("%v", "jira_migration_skip_tag"), "jira-migration-skip")
5049
viper.Set(fmt.Sprintf("%v", "period"), 1)
5150

5251
err := viper.WriteConfig()
@@ -88,22 +87,14 @@ func generateClientConfigTemplate(configPath string) {
8887
func parseGlobalConfig() globalConfigType {
8988
clientDefaultConfigPath := "default_client"
9089

91-
clientDefaultConfig := clientConfig{
92-
jiraUsername: getString("jira_username", clientDefaultConfigPath, globalConfig.defaultClient.jiraUsername),
93-
jiraPassword: getString("jira_password", clientDefaultConfigPath, globalConfig.defaultClient.jiraPassword),
94-
jiraClientUser: getString("jira_client_user", clientDefaultConfigPath, globalConfig.defaultClient.jiraClientUser),
95-
jiraHost: getString("jira_host", clientDefaultConfigPath, globalConfig.defaultClient.jiraHost),
96-
stachurskyMode: getInt("stachursky_mode", clientDefaultConfigPath, globalConfig.defaultClient.stachurskyMode),
97-
}
98-
9990
globalConfig := globalConfigType{
100-
defaultClient: clientDefaultConfig,
91+
defaultClient: parseClientConfig(clientDefaultConfigPath, globalConfig),
10192
period: viper.GetInt("period"),
10293
logFormat: viper.GetString("log_format"),
10394
logOutput: viper.GetString("log_output"),
104-
jiraMigrationSuccessTag: viper.GetString("logged_tag"),
105-
jiraMigrationFailTag: viper.GetString("jira-migration-failed"),
106-
jiraMigrationSkipTag: viper.GetString("jira-migration-skip"),
95+
jiraMigrationSuccessTag: viper.GetString("jira_migration_success_tag"),
96+
jiraMigrationFailedTag: viper.GetString("jira_migration_failed_tag"),
97+
jiraMigrationSkipTag: viper.GetString("jira_migration_skip_tag"),
10798
}
10899

109100
return globalConfig

go.sum

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc
1515
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
1616
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
1717
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
18+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1819
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1920
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
2021
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
@@ -78,6 +79,7 @@ github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181
7879
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
7980
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
8081
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
82+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
8183
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
8284
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
8385
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
@@ -108,6 +110,7 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
108110
github.com/spf13/viper v1.6.1 h1:VPZzIkznI1YhVMRi6vNFLHSwhnhReBfgTxIPccpfdZk=
109111
github.com/spf13/viper v1.6.1/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k=
110112
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
113+
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
111114
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
112115
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
113116
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=

main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@ func main() {
186186
"response": jr,
187187
}).Error(err)
188188

189-
timeEntry.Tags = append(timeEntry.Tags, globalConfig.jiraMigrationFailTag)
190-
log.Info(fmt.Sprintf("Add %v tag", globalConfig.jiraMigrationFailTag))
189+
timeEntry.Tags = append(timeEntry.Tags, globalConfig.jiraMigrationFailedTag)
190+
log.Info(fmt.Sprintf("Add %v tag", globalConfig.jiraMigrationFailedTag))
191191
} else {
192192
log.Info(fmt.Sprintf("Jira workload added"))
193-
timeEntry.Tags = removeTag(timeEntry.Tags, globalConfig.jiraMigrationFailTag)
193+
timeEntry.Tags = removeTag(timeEntry.Tags, globalConfig.jiraMigrationFailedTag)
194194
timeEntry.Tags = append(timeEntry.Tags, globalConfig.jiraMigrationSuccessTag)
195195
log.Info(fmt.Sprintf("Add %v tag", globalConfig.jiraMigrationSuccessTag))
196196
}

0 commit comments

Comments
 (0)