Linting fixes.
This commit is contained in:
parent
e315c37bb6
commit
91f4676118
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
*DS_Store*
|
*DS_Store*
|
||||||
.idea
|
.idea
|
||||||
|
.vscode
|
||||||
config.yaml
|
config.yaml
|
||||||
release
|
release
|
||||||
|
@ -46,11 +46,11 @@ func Parse() *Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// nolint:exhaustivestruct
|
// 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())
|
panic("Failed to unmarshal YAML data: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return c
|
return cfg
|
||||||
}
|
}
|
||||||
|
@ -11,15 +11,13 @@ import (
|
|||||||
|
|
||||||
// BaseTask is a base task structure.
|
// BaseTask is a base task structure.
|
||||||
type BaseTask struct {
|
type BaseTask struct {
|
||||||
client *gitlab.Client
|
|
||||||
|
|
||||||
projectID int
|
|
||||||
title string
|
|
||||||
body string
|
|
||||||
tags []string
|
|
||||||
|
|
||||||
executionStartTimestamp time.Time
|
executionStartTimestamp time.Time
|
||||||
|
client *gitlab.Client
|
||||||
|
title string
|
||||||
|
body string
|
||||||
cron string
|
cron string
|
||||||
|
tags []string
|
||||||
|
projectID int
|
||||||
dueIn time.Duration
|
dueIn time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,12 +5,12 @@ import "time"
|
|||||||
// Config is a task's configuration as should be defined in configuration file.
|
// Config is a task's configuration as should be defined in configuration file.
|
||||||
// nolint:tagliatelle
|
// nolint:tagliatelle
|
||||||
type Config struct {
|
type Config struct {
|
||||||
ProjectID int `yaml:"project_id"`
|
ExecutionStart TaskStartTime `yaml:"execution_start"`
|
||||||
Title string `yaml:"title"`
|
Title string `yaml:"title"`
|
||||||
Body string `yaml:"body"`
|
Body string `yaml:"body"`
|
||||||
Tags []string `yaml:"tags"`
|
|
||||||
ExecutionStart TaskStartTime `yaml:"execution_start"`
|
|
||||||
Cron string `yaml:"cron"`
|
Cron string `yaml:"cron"`
|
||||||
|
Tags []string `yaml:"tags"`
|
||||||
|
ProjectID int `yaml:"project_id"`
|
||||||
DueIn time.Duration `yaml:"due_in"`
|
DueIn time.Duration `yaml:"due_in"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,14 +30,14 @@ func (tts *TaskStartTime) UnmarshalYAML(unmarshal func(interface{}) error) error
|
|||||||
return err
|
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 {
|
if err != nil {
|
||||||
// ToDo: fix it!
|
// ToDo: fix it!
|
||||||
// nolint:wrapcheck
|
// nolint:wrapcheck
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
tts.ts = t
|
tts.ts = timeField
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
// PrintCreationTSes prints tasks creation timestamps.
|
// PrintCreationTSes prints tasks creation timestamps.
|
||||||
func PrintCreationTSes(client *gitlab.Client, tasks []Config) {
|
func PrintCreationTSes(client *gitlab.Client, tasks []Config) {
|
||||||
for _, task := range tasks {
|
for _, task := range tasks {
|
||||||
t := &BaseTask{
|
taskData := &BaseTask{
|
||||||
client: client,
|
client: client,
|
||||||
projectID: task.ProjectID,
|
projectID: task.ProjectID,
|
||||||
title: task.Title,
|
title: task.Title,
|
||||||
@ -20,19 +20,19 @@ func PrintCreationTSes(client *gitlab.Client, tasks []Config) {
|
|||||||
|
|
||||||
// Get similar tasks.
|
// Get similar tasks.
|
||||||
// ToDo: refactor?
|
// ToDo: refactor?
|
||||||
issues, err := t.getIssues()
|
issues, err := taskData.getIssues()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("Error while getting issues from Gitlab: " + err.Error())
|
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.
|
// Process processes passed tasks.
|
||||||
func Process(client *gitlab.Client, tasks []Config) {
|
func Process(client *gitlab.Client, tasks []Config) {
|
||||||
for _, task := range tasks {
|
for _, task := range tasks {
|
||||||
t := &BaseTask{
|
taskData := &BaseTask{
|
||||||
client: client,
|
client: client,
|
||||||
projectID: task.ProjectID,
|
projectID: task.ProjectID,
|
||||||
title: task.Title,
|
title: task.Title,
|
||||||
@ -43,6 +43,6 @@ func Process(client *gitlab.Client, tasks []Config) {
|
|||||||
dueIn: task.DueIn,
|
dueIn: task.DueIn,
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run()
|
taskData.Run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
6
main.go
6
main.go
@ -29,12 +29,12 @@ func main() {
|
|||||||
|
|
||||||
cfg := config.Parse()
|
cfg := config.Parse()
|
||||||
|
|
||||||
c := gitlab.NewGitlabClient(&cfg.Gitlab)
|
gitlabClient := gitlab.NewGitlabClient(&cfg.Gitlab)
|
||||||
|
|
||||||
if *showNextCreationTS {
|
if *showNextCreationTS {
|
||||||
tasks.PrintCreationTSes(c, cfg.Tasks)
|
tasks.PrintCreationTSes(gitlabClient, cfg.Tasks)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.Process(c, cfg.Tasks)
|
tasks.Process(gitlabClient, cfg.Tasks)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user