Skip to content

Commit

Permalink
fix(config): make the 'auto update' of the config file consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
rappizs committed Aug 3, 2023
1 parent 986f541 commit 97cdf47
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Configuration arguments are as follows:
| Name | Value Type | Example Value | Required | Default |
| --- | --- | --- | --- | --- |
| log-level | string | "warn" | false | "info" |
| dry-run | bool | false | false | false |
| github-token | string | | true | null |
| jira-user | string | "[email protected]" | false | null |
| jira-pass | string | | false | null |
Expand All @@ -75,6 +76,8 @@ Configuration arguments are as follows:
`log-level` is the minimum level which will be logged; any output below
this value will be discarded.

`dry-run` is for experimenting with the tool, if set to `true`, no changes will be executed in Jira

`github-token` is a personal access token used to access GitHub as a
specific user.

Expand Down
28 changes: 15 additions & 13 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,18 +272,20 @@ func (c *Config) SetJiraToken(token *oauth1.Token) {

// configFile is a serializable representation of the current Viper configuration.
type configFile struct {
LogLevel string `json:"log-level" mapstructure:"log-level"`
GithubToken string `json:"github-token" mapstructure:"github-token"`
JiraUser string `json:"jira-user" mapstructure:"jira-user"`
JiraToken string `json:"jira-token" mapstructure:"jira-token"`
JiraSecret string `json:"jira-secret" mapstructure:"jira-secret"`
JiraKey string `json:"jira-private-key-path" mapstructure:"jira-private-key-path"`
JiraCKey string `json:"jira-consumer-key" mapstructure:"jira-consumer-key"`
RepoName string `json:"repo-name" mapstructure:"repo-name"`
JiraURI string `json:"jira-uri" mapstructure:"jira-uri"`
JiraProject string `json:"jira-project" mapstructure:"jira-project"`
Since string `json:"since" mapstructure:"since"`
Timeout time.Duration `json:"timeout" mapstructure:"timeout"`
LogLevel string `json:"log-level,omitempty" mapstructure:"log-level"`
DryRun string `json:"dry-run,omitempty" mapstructure:"dry-run"`
GithubToken string `json:"github-token,omitempty" mapstructure:"github-token"`
JiraUser string `json:"jira-user,omitempty" mapstructure:"jira-user"`
JiraPass string `json:"jira-pass,omitempty" mapstructure:"jira-pass"`
JiraToken string `json:"jira-token,omitempty" mapstructure:"jira-token"`
JiraSecret string `json:"jira-secret,omitempty" mapstructure:"jira-secret"`
JiraKey string `json:"jira-private-key-path,omitempty" mapstructure:"jira-private-key-path"`
JiraCKey string `json:"jira-consumer-key,omitempty" mapstructure:"jira-consumer-key"`
RepoName string `json:"repo-name,omitempty" mapstructure:"repo-name"`
JiraURI string `json:"jira-uri,omitempty" mapstructure:"jira-uri"`
JiraProject string `json:"jira-project,omitempty" mapstructure:"jira-project"`
Since string `json:"since,omitempty" mapstructure:"since"`
Timeout time.Duration `json:"timeout,omitempty" mapstructure:"timeout"`
}

// SaveConfig updates the `since` parameter to now, then saves the configuration file.
Expand All @@ -298,7 +300,7 @@ func (c *Config) SaveConfig() error {
return fmt.Errorf("unmarshalling config: %w", err)
}

b, err := json.MarshalIndent(cf, "", " ")
b, err := json.MarshalIndent(&cf, "", " ")
if err != nil {
return fmt.Errorf("marshalling config: %w", err)
}
Expand Down

0 comments on commit 97cdf47

Please sign in to comment.