Linting fixes.
This commit is contained in:
parent
e315c37bb6
commit
91f4676118
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
*DS_Store*
|
||||
.idea
|
||||
.vscode
|
||||
config.yaml
|
||||
release
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -11,15 +11,13 @@ import (
|
||||
|
||||
// BaseTask is a base task structure.
|
||||
type BaseTask struct {
|
||||
executionStartTimestamp time.Time
|
||||
client *gitlab.Client
|
||||
|
||||
projectID int
|
||||
title string
|
||||
body string
|
||||
tags []string
|
||||
|
||||
executionStartTimestamp time.Time
|
||||
cron string
|
||||
tags []string
|
||||
projectID int
|
||||
dueIn time.Duration
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
6
main.go
6
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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user