diff --git a/.gitignore b/.gitignore index 8258fdd..945cac3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *DS_Store* .idea +.vscode config.yaml release diff --git a/internal/config/config.go b/internal/config/config.go index 67b035a..0662408 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -46,11 +46,11 @@ func Parse() *Config { } // nolint:exhaustivestruct - c := &Config{} + cfg := &Config{} - if err := yaml.Unmarshal(data, c); err != nil { + if err := yaml.Unmarshal(data, cfg); err != nil { panic("Failed to unmarshal YAML data: " + err.Error()) } - return c + return cfg } diff --git a/internal/tasks/base.go b/internal/tasks/base.go index a1dfcbf..b287b51 100644 --- a/internal/tasks/base.go +++ b/internal/tasks/base.go @@ -11,15 +11,13 @@ import ( // BaseTask is a base task structure. type BaseTask struct { - client *gitlab.Client - - projectID int - title string - body string - tags []string - executionStartTimestamp time.Time + client *gitlab.Client + title string + body string cron string + tags []string + projectID int dueIn time.Duration } diff --git a/internal/tasks/config.go b/internal/tasks/config.go index 8aea701..9c9c832 100644 --- a/internal/tasks/config.go +++ b/internal/tasks/config.go @@ -5,12 +5,12 @@ import "time" // Config is a task's configuration as should be defined in configuration file. // nolint:tagliatelle type Config struct { - ProjectID int `yaml:"project_id"` + ExecutionStart TaskStartTime `yaml:"execution_start"` Title string `yaml:"title"` Body string `yaml:"body"` - Tags []string `yaml:"tags"` - ExecutionStart TaskStartTime `yaml:"execution_start"` Cron string `yaml:"cron"` + Tags []string `yaml:"tags"` + ProjectID int `yaml:"project_id"` DueIn time.Duration `yaml:"due_in"` } @@ -30,14 +30,14 @@ func (tts *TaskStartTime) UnmarshalYAML(unmarshal func(interface{}) error) error return err } - t, err := time.Parse("2006-01-02 15:04:05", timeData) + timeField, err := time.Parse("2006-01-02 15:04:05", timeData) if err != nil { // ToDo: fix it! // nolint:wrapcheck return err } - tts.ts = t + tts.ts = timeField return nil } diff --git a/internal/tasks/tasks.go b/internal/tasks/tasks.go index 2fba897..fb0c71b 100644 --- a/internal/tasks/tasks.go +++ b/internal/tasks/tasks.go @@ -7,7 +7,7 @@ import ( // PrintCreationTSes prints tasks creation timestamps. func PrintCreationTSes(client *gitlab.Client, tasks []Config) { for _, task := range tasks { - t := &BaseTask{ + taskData := &BaseTask{ client: client, projectID: task.ProjectID, title: task.Title, @@ -20,19 +20,19 @@ func PrintCreationTSes(client *gitlab.Client, tasks []Config) { // Get similar tasks. // ToDo: refactor? - issues, err := t.getIssues() + issues, err := taskData.getIssues() if err != nil { panic("Error while getting issues from Gitlab: " + err.Error()) } - t.log(t.getNextCreationTimestamp(t.getLastCreationTimestamp(issues)).String()) + taskData.log(taskData.getNextCreationTimestamp(taskData.getLastCreationTimestamp(issues)).String()) } } // Process processes passed tasks. func Process(client *gitlab.Client, tasks []Config) { for _, task := range tasks { - t := &BaseTask{ + taskData := &BaseTask{ client: client, projectID: task.ProjectID, title: task.Title, @@ -43,6 +43,6 @@ func Process(client *gitlab.Client, tasks []Config) { dueIn: task.DueIn, } - t.Run() + taskData.Run() } } diff --git a/main.go b/main.go index b09fa68..62cd822 100644 --- a/main.go +++ b/main.go @@ -29,12 +29,12 @@ func main() { cfg := config.Parse() - c := gitlab.NewGitlabClient(&cfg.Gitlab) + gitlabClient := gitlab.NewGitlabClient(&cfg.Gitlab) if *showNextCreationTS { - tasks.PrintCreationTSes(c, cfg.Tasks) + tasks.PrintCreationTSes(gitlabClient, cfg.Tasks) os.Exit(0) } - tasks.Process(c, cfg.Tasks) + tasks.Process(gitlabClient, cfg.Tasks) }