feat(pkger): extend tasks with unique constraints
parent
afb1653bff
commit
cee77081b2
|
|
@ -885,17 +885,29 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
printer.Render()
|
||||
}
|
||||
|
||||
tablePrintFn := b.tablePrinterGen()
|
||||
if teles := diff.Telegrafs; len(teles) > 0 {
|
||||
headers := []string{"New", "Name", "Description"}
|
||||
tablePrintFn("TELEGRAF CONFIGS", headers, len(teles), func(i int) []string {
|
||||
t := teles[i]
|
||||
return []string{
|
||||
boolDiff(true),
|
||||
t.Name,
|
||||
green(t.Description),
|
||||
printer := diffPrinterGen("Telegraf Configurations", []string{"Description"})
|
||||
appendValues := func(id pkger.SafeID, pkgName string, v influxdb.TelegrafConfig) []string {
|
||||
return []string{pkgName, id.String(), v.Name, v.Description}
|
||||
}
|
||||
|
||||
for _, e := range teles {
|
||||
var oldRow []string
|
||||
if e.Old != nil {
|
||||
oldRow = appendValues(e.ID, e.PkgName, *e.Old)
|
||||
}
|
||||
})
|
||||
|
||||
newRow := appendValues(e.ID, e.PkgName, e.New)
|
||||
switch {
|
||||
case e.IsNew():
|
||||
printer.AppendDiff(nil, newRow)
|
||||
case e.Remove:
|
||||
printer.AppendDiff(oldRow, nil)
|
||||
default:
|
||||
printer.AppendDiff(oldRow, newRow)
|
||||
}
|
||||
}
|
||||
printer.Render()
|
||||
}
|
||||
|
||||
if tasks := diff.Tasks; len(tasks) > 0 {
|
||||
|
|
@ -905,7 +917,7 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
if v.Cron == "" {
|
||||
timing = fmt.Sprintf("every: %s offset: %s", v.Every, v.Offset)
|
||||
}
|
||||
return []string{pkgName, id.String(), v.Description, timing}
|
||||
return []string{pkgName, id.String(), v.Name, v.Description, timing}
|
||||
}
|
||||
|
||||
for _, e := range tasks {
|
||||
|
|
@ -957,6 +969,7 @@ func (b *cmdPkgBuilder) printPkgDiff(diff pkger.Diff) error {
|
|||
printer.Render()
|
||||
}
|
||||
|
||||
tablePrintFn := b.tablePrinterGen()
|
||||
if len(diff.LabelMappings) > 0 {
|
||||
headers := []string{"New", "Resource Type", "Resource Name", "Resource ID", "Label Name", "Label ID"}
|
||||
tablePrintFn("LABEL MAPPINGS", headers, len(diff.LabelMappings), func(i int) []string {
|
||||
|
|
|
|||
207
http/swagger.yml
207
http/swagger.yml
|
|
@ -7560,14 +7560,34 @@ components:
|
|||
items:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
remove:
|
||||
type: boolean
|
||||
id:
|
||||
type: string
|
||||
description:
|
||||
pkgName:
|
||||
type: string
|
||||
charts:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PkgChart"
|
||||
new:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
charts:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PkgChart"
|
||||
old:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
charts:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/PkgChart"
|
||||
labels:
|
||||
type: array
|
||||
items:
|
||||
|
|
@ -7634,67 +7654,154 @@ components:
|
|||
items:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
endpointName:
|
||||
type: string
|
||||
endpointID:
|
||||
type: string
|
||||
endpointType:
|
||||
type: string
|
||||
every:
|
||||
type: string
|
||||
offset:
|
||||
type: string
|
||||
messageTemplate:
|
||||
type: string
|
||||
status:
|
||||
type: string
|
||||
statusRules:
|
||||
type: array
|
||||
items:
|
||||
remove:
|
||||
type: boolean
|
||||
id:
|
||||
type: string
|
||||
pkgName:
|
||||
type: string
|
||||
new:
|
||||
type: object
|
||||
properties:
|
||||
currentLevel:
|
||||
type: string
|
||||
previousLevel:
|
||||
type: string
|
||||
tagRules:
|
||||
type: array
|
||||
items:
|
||||
name:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
endpointName:
|
||||
type: string
|
||||
endpointID:
|
||||
type: string
|
||||
endpointType:
|
||||
type: string
|
||||
every:
|
||||
type: string
|
||||
offset:
|
||||
type: string
|
||||
messageTemplate:
|
||||
type: string
|
||||
status:
|
||||
type: string
|
||||
statusRules:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
currentLevel:
|
||||
type: string
|
||||
previousLevel:
|
||||
type: string
|
||||
tagRules:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
key:
|
||||
type: string
|
||||
value:
|
||||
type: string
|
||||
operator:
|
||||
type: string
|
||||
old:
|
||||
type: object
|
||||
properties:
|
||||
key:
|
||||
name:
|
||||
type: string
|
||||
value:
|
||||
description:
|
||||
type: string
|
||||
operator:
|
||||
endpointName:
|
||||
type: string
|
||||
endpointID:
|
||||
type: string
|
||||
endpointType:
|
||||
type: string
|
||||
every:
|
||||
type: string
|
||||
offset:
|
||||
type: string
|
||||
messageTemplate:
|
||||
type: string
|
||||
status:
|
||||
type: string
|
||||
statusRules:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
currentLevel:
|
||||
type: string
|
||||
previousLevel:
|
||||
type: string
|
||||
tagRules:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
key:
|
||||
type: string
|
||||
value:
|
||||
type: string
|
||||
operator:
|
||||
type: string
|
||||
tasks:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
remove:
|
||||
type: boolean
|
||||
id:
|
||||
type: string
|
||||
cron:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
every:
|
||||
type: string
|
||||
offset:
|
||||
type: string
|
||||
query:
|
||||
type: string
|
||||
status:
|
||||
pkgName:
|
||||
type: string
|
||||
new:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
cron:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
every:
|
||||
type: string
|
||||
offset:
|
||||
type: string
|
||||
query:
|
||||
type: string
|
||||
status:
|
||||
type: string
|
||||
old:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
cron:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
every:
|
||||
type: string
|
||||
offset:
|
||||
type: string
|
||||
query:
|
||||
type: string
|
||||
status:
|
||||
type: string
|
||||
telegrafConfigs:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/TelegrafRequest"
|
||||
type: object
|
||||
properties:
|
||||
remove:
|
||||
type: boolean
|
||||
id:
|
||||
type: string
|
||||
pkgName:
|
||||
type: string
|
||||
new:
|
||||
$ref: "#/components/schemas/TelegrafRequest"
|
||||
old:
|
||||
$ref: "#/components/schemas/TelegrafRequest"
|
||||
variables:
|
||||
type: array
|
||||
items:
|
||||
|
|
|
|||
|
|
@ -623,12 +623,21 @@ func newDiffTask(t *task) DiffTask {
|
|||
|
||||
// DiffTelegraf is a diff of an individual telegraf. This resource is always new.
|
||||
type DiffTelegraf struct {
|
||||
influxdb.TelegrafConfig
|
||||
DiffIdentifier
|
||||
|
||||
New influxdb.TelegrafConfig
|
||||
Old *influxdb.TelegrafConfig
|
||||
}
|
||||
|
||||
func newDiffTelegraf(t *telegraf) DiffTelegraf {
|
||||
return DiffTelegraf{
|
||||
TelegrafConfig: t.config,
|
||||
DiffIdentifier: DiffIdentifier{
|
||||
ID: SafeID(t.ID()),
|
||||
Remove: t.shouldRemove,
|
||||
PkgName: t.PkgName(),
|
||||
},
|
||||
New: t.config,
|
||||
Old: t.existing,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2194,9 +2203,14 @@ type telegraf struct {
|
|||
config influxdb.TelegrafConfig
|
||||
|
||||
labels sortedLabels
|
||||
|
||||
existing *influxdb.TelegrafConfig
|
||||
}
|
||||
|
||||
func (t *telegraf) ID() influxdb.ID {
|
||||
if t.existing != nil {
|
||||
return t.existing.ID
|
||||
}
|
||||
return t.config.ID
|
||||
}
|
||||
|
||||
|
|
@ -2209,7 +2223,7 @@ func (t *telegraf) ResourceType() influxdb.ResourceType {
|
|||
}
|
||||
|
||||
func (t *telegraf) Exists() bool {
|
||||
return false
|
||||
return t.existing != nil
|
||||
}
|
||||
|
||||
func (t *telegraf) summarize() SummaryTelegraf {
|
||||
|
|
|
|||
Loading…
Reference in New Issue