Skip to content

Commit

Permalink
Fixes for linter
Browse files Browse the repository at this point in the history
  • Loading branch information
angrycub committed Dec 1, 2020
1 parent cebed25 commit 4b13b4f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions levant/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func outputDiff(config *structs.DiffOutputConfig, diff *nomad.JobDiff) {
func printDiffAsJSON(diff *nomad.JobDiff, outFun func(string)) {
out, err := json.Marshal(diff)
if err != nil {
log.Error().Msgf("levant/plan: failed to marshall plan to JSON: %s", err.Error)
log.Error().Msgf("levant/plan: failed to marshall plan to JSON: %s", err.Error())
return
}
outFun(string(out))
Expand Down Expand Up @@ -196,7 +196,8 @@ func createJobLine(item string, depth int, oper string) *JSONLine {
}

func createTaskgroupLine(item string, depth int, oper string, updates map[string]uint64) *JSONLine {
var ann []string
ann := make([]string, 0, 5)

for updateType, count := range updates {
ann = append(ann, fmt.Sprintf("%d %s", count, updateType))
}
Expand All @@ -222,7 +223,7 @@ func createFieldLine(item string, depth int, oper string, before string, after s
// parsePlanJSON builds a newline delimited JSON which can
// then be formatted before emitting to the log.
func parsePlanJSON(plan *nomad.JobDiff) []*JSONLine {
var lines []*JSONLine
lines := make([]*JSONLine, 0, 100)
var depth int = 0
lines = append(lines, createJobLine(plan.ID, 0, plan.Type))
depth = depth + 1
Expand All @@ -235,7 +236,7 @@ func parsePlanJSON(plan *nomad.JobDiff) []*JSONLine {
}

func parseTaskGroupDiff(tg *nomad.TaskGroupDiff, depth int) []*JSONLine {
var lines []*JSONLine
lines := make([]*JSONLine, 0, 100)

lines = append(lines, createTaskgroupLine(tg.Name, depth, tg.Type, tg.Updates))
depth = depth + 1
Expand All @@ -248,7 +249,7 @@ func parseTaskGroupDiff(tg *nomad.TaskGroupDiff, depth int) []*JSONLine {
}

func parseTaskDiff(task *nomad.TaskDiff, depth int) []*JSONLine {
var lines []*JSONLine
lines := make([]*JSONLine, 0, 100)
lines = append(lines, createTaskLine(task.Name, depth, task.Type, task.Annotations))
depth = depth + 1
lines = append(lines, parseFieldDiffs(task.Fields, depth)...)
Expand All @@ -257,7 +258,7 @@ func parseTaskDiff(task *nomad.TaskDiff, depth int) []*JSONLine {
}

func parseObjectDiffs(objects []*nomad.ObjectDiff, depth int) []*JSONLine {
var lines []*JSONLine
lines := make([]*JSONLine, 0, 100)

for _, object := range objects {
lines = append(lines, createObjectLine(object.Name, depth, object.Type))
Expand All @@ -271,7 +272,7 @@ func parseObjectDiffs(objects []*nomad.ObjectDiff, depth int) []*JSONLine {
}

func parseFieldDiffs(fields []*nomad.FieldDiff, depth int) []*JSONLine {
var lines []*JSONLine
lines := make([]*JSONLine, 0, 20)

for _, field := range fields {
lines = append(lines, createFieldLine(field.Name, depth, field.Type, field.Old, field.New, field.Annotations))
Expand Down

0 comments on commit 4b13b4f

Please sign in to comment.