feat(pkger): extend template Summary with discrete kinds for each summary type
references: #18804pull/18818/head
parent
b9e6744807
commit
ffe5d941d3
|
@ -2629,12 +2629,14 @@ spec:
|
||||||
|
|
||||||
labels := sum1.Labels
|
labels := sum1.Labels
|
||||||
require.Len(t, labels, 2)
|
require.Len(t, labels, 2)
|
||||||
|
assert.Equal(t, pkger.KindLabel, labels[0].Kind)
|
||||||
assert.NotZero(t, labels[0].ID)
|
assert.NotZero(t, labels[0].ID)
|
||||||
assert.Equal(t, "label-1", labels[0].Name)
|
assert.Equal(t, "label-1", labels[0].Name)
|
||||||
assert.Equal(t, "the 2nd label", labels[1].Name)
|
assert.Equal(t, "the 2nd label", labels[1].Name)
|
||||||
|
|
||||||
bkts := sum1.Buckets
|
bkts := sum1.Buckets
|
||||||
require.Len(t, bkts, 1)
|
require.Len(t, bkts, 1)
|
||||||
|
assert.Equal(t, pkger.KindBucket, bkts[0].Kind)
|
||||||
assert.NotZero(t, bkts[0].ID)
|
assert.NotZero(t, bkts[0].ID)
|
||||||
assert.NotEmpty(t, bkts[0].MetaName)
|
assert.NotEmpty(t, bkts[0].MetaName)
|
||||||
assert.Equal(t, "rucketeer", bkts[0].Name)
|
assert.Equal(t, "rucketeer", bkts[0].Name)
|
||||||
|
@ -2643,8 +2645,10 @@ spec:
|
||||||
checks := sum1.Checks
|
checks := sum1.Checks
|
||||||
require.Len(t, checks, 2)
|
require.Len(t, checks, 2)
|
||||||
assert.Equal(t, "check 0 name", checks[0].Check.GetName())
|
assert.Equal(t, "check 0 name", checks[0].Check.GetName())
|
||||||
|
assert.Equal(t, pkger.KindCheckThreshold, checks[0].Kind)
|
||||||
hasLabelAssociations(t, checks[0].LabelAssociations, 1, "label-1")
|
hasLabelAssociations(t, checks[0].LabelAssociations, 1, "label-1")
|
||||||
assert.Equal(t, "check-1", checks[1].Check.GetName())
|
assert.Equal(t, "check-1", checks[1].Check.GetName())
|
||||||
|
assert.Equal(t, pkger.KindCheckDeadman, checks[1].Kind)
|
||||||
hasLabelAssociations(t, checks[1].LabelAssociations, 1, "label-1")
|
hasLabelAssociations(t, checks[1].LabelAssociations, 1, "label-1")
|
||||||
for _, ch := range checks {
|
for _, ch := range checks {
|
||||||
assert.NotZero(t, ch.Check.GetID())
|
assert.NotZero(t, ch.Check.GetID())
|
||||||
|
@ -2652,6 +2656,7 @@ spec:
|
||||||
|
|
||||||
dashs := sum1.Dashboards
|
dashs := sum1.Dashboards
|
||||||
require.Len(t, dashs, 1)
|
require.Len(t, dashs, 1)
|
||||||
|
assert.Equal(t, pkger.KindDashboard, dashs[0].Kind)
|
||||||
assert.NotZero(t, dashs[0].ID)
|
assert.NotZero(t, dashs[0].ID)
|
||||||
assert.NotEmpty(t, dashs[0].Name)
|
assert.NotEmpty(t, dashs[0].Name)
|
||||||
assert.Equal(t, "dash_1", dashs[0].Name)
|
assert.Equal(t, "dash_1", dashs[0].Name)
|
||||||
|
@ -2662,6 +2667,7 @@ spec:
|
||||||
|
|
||||||
endpoints := sum1.NotificationEndpoints
|
endpoints := sum1.NotificationEndpoints
|
||||||
require.Len(t, endpoints, 1)
|
require.Len(t, endpoints, 1)
|
||||||
|
assert.Equal(t, pkger.KindNotificationEndpointHTTP, endpoints[0].Kind)
|
||||||
assert.NotZero(t, endpoints[0].NotificationEndpoint.GetID())
|
assert.NotZero(t, endpoints[0].NotificationEndpoint.GetID())
|
||||||
assert.Equal(t, "no auth endpoint", endpoints[0].NotificationEndpoint.GetName())
|
assert.Equal(t, "no auth endpoint", endpoints[0].NotificationEndpoint.GetName())
|
||||||
assert.Equal(t, "http none auth desc", endpoints[0].NotificationEndpoint.GetDescription())
|
assert.Equal(t, "http none auth desc", endpoints[0].NotificationEndpoint.GetDescription())
|
||||||
|
@ -2670,6 +2676,7 @@ spec:
|
||||||
|
|
||||||
require.Len(t, sum1.NotificationRules, 1)
|
require.Len(t, sum1.NotificationRules, 1)
|
||||||
rule := sum1.NotificationRules[0]
|
rule := sum1.NotificationRules[0]
|
||||||
|
assert.Equal(t, pkger.KindNotificationRule, rule.Kind)
|
||||||
assert.NotZero(t, rule.ID)
|
assert.NotZero(t, rule.ID)
|
||||||
assert.Equal(t, "rule_0", rule.Name)
|
assert.Equal(t, "rule_0", rule.Name)
|
||||||
assert.Equal(t, pkger.SafeID(endpoints[0].NotificationEndpoint.GetID()), rule.EndpointID)
|
assert.Equal(t, pkger.SafeID(endpoints[0].NotificationEndpoint.GetID()), rule.EndpointID)
|
||||||
|
@ -2678,12 +2685,14 @@ spec:
|
||||||
|
|
||||||
require.Len(t, sum1.Tasks, 1)
|
require.Len(t, sum1.Tasks, 1)
|
||||||
task := sum1.Tasks[0]
|
task := sum1.Tasks[0]
|
||||||
|
assert.Equal(t, pkger.KindTask, task.Kind)
|
||||||
assert.NotZero(t, task.ID)
|
assert.NotZero(t, task.ID)
|
||||||
assert.Equal(t, "task_1", task.Name)
|
assert.Equal(t, "task_1", task.Name)
|
||||||
assert.Equal(t, "desc_1", task.Description)
|
assert.Equal(t, "desc_1", task.Description)
|
||||||
|
|
||||||
teles := sum1.TelegrafConfigs
|
teles := sum1.TelegrafConfigs
|
||||||
require.Len(t, teles, 1)
|
require.Len(t, teles, 1)
|
||||||
|
assert.Equal(t, pkger.KindTelegraf, teles[0].Kind)
|
||||||
assert.NotZero(t, teles[0].TelegrafConfig.ID)
|
assert.NotZero(t, teles[0].TelegrafConfig.ID)
|
||||||
assert.Equal(t, l.Org.ID, teles[0].TelegrafConfig.OrgID)
|
assert.Equal(t, l.Org.ID, teles[0].TelegrafConfig.OrgID)
|
||||||
assert.Equal(t, "first tele config", teles[0].TelegrafConfig.Name)
|
assert.Equal(t, "first tele config", teles[0].TelegrafConfig.Name)
|
||||||
|
@ -2692,6 +2701,7 @@ spec:
|
||||||
|
|
||||||
vars := sum1.Variables
|
vars := sum1.Variables
|
||||||
require.Len(t, vars, 1)
|
require.Len(t, vars, 1)
|
||||||
|
assert.Equal(t, pkger.KindVariable, vars[0].Kind)
|
||||||
assert.NotZero(t, vars[0].ID)
|
assert.NotZero(t, vars[0].ID)
|
||||||
assert.Equal(t, "query var", vars[0].Name)
|
assert.Equal(t, "query var", vars[0].Name)
|
||||||
assert.Equal(t, []string{"rucketeer"}, vars[0].Selected)
|
assert.Equal(t, []string{"rucketeer"}, vars[0].Selected)
|
||||||
|
|
|
@ -7801,6 +7801,8 @@ components:
|
||||||
type: string
|
type: string
|
||||||
orgID:
|
orgID:
|
||||||
type: string
|
type: string
|
||||||
|
kind:
|
||||||
|
$ref: "#/components/schemas/TemplateKind"
|
||||||
templateMetaName:
|
templateMetaName:
|
||||||
type: string
|
type: string
|
||||||
name:
|
name:
|
||||||
|
@ -7822,6 +7824,8 @@ components:
|
||||||
- $ref: "#/components/schemas/CheckDiscriminator"
|
- $ref: "#/components/schemas/CheckDiscriminator"
|
||||||
- type: object
|
- type: object
|
||||||
properties:
|
properties:
|
||||||
|
kind:
|
||||||
|
$ref: "#/components/schemas/TemplateKind"
|
||||||
templateMetaName:
|
templateMetaName:
|
||||||
type: string
|
type: string
|
||||||
labelAssociations:
|
labelAssociations:
|
||||||
|
@ -7830,10 +7834,6 @@ components:
|
||||||
$ref: "#/components/schemas/TemplateSummaryLabel"
|
$ref: "#/components/schemas/TemplateSummaryLabel"
|
||||||
envReferences:
|
envReferences:
|
||||||
$ref: "#/components/schemas/TemplateEnvReferences"
|
$ref: "#/components/schemas/TemplateEnvReferences"
|
||||||
labels:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: "#/components/schemas/TemplateSummaryLabel"
|
|
||||||
dashboards:
|
dashboards:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
|
@ -7843,6 +7843,8 @@ components:
|
||||||
type: "string"
|
type: "string"
|
||||||
orgID:
|
orgID:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
kind:
|
||||||
|
$ref: "#/components/schemas/TemplateKind"
|
||||||
templateMetaName:
|
templateMetaName:
|
||||||
type: string
|
type: string
|
||||||
name:
|
name:
|
||||||
|
@ -7859,6 +7861,10 @@ components:
|
||||||
$ref: "#/components/schemas/TemplateChart"
|
$ref: "#/components/schemas/TemplateChart"
|
||||||
envReferences:
|
envReferences:
|
||||||
$ref: "#/components/schemas/TemplateEnvReferences"
|
$ref: "#/components/schemas/TemplateEnvReferences"
|
||||||
|
labels:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/TemplateSummaryLabel"
|
||||||
labelMappings:
|
labelMappings:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
|
@ -7895,6 +7901,8 @@ components:
|
||||||
- $ref: "#/components/schemas/NotificationEndpointDiscrimator"
|
- $ref: "#/components/schemas/NotificationEndpointDiscrimator"
|
||||||
- type: object
|
- type: object
|
||||||
properties:
|
properties:
|
||||||
|
kind:
|
||||||
|
$ref: "#/components/schemas/TemplateKind"
|
||||||
templateMetaName:
|
templateMetaName:
|
||||||
type: string
|
type: string
|
||||||
labelAssociations:
|
labelAssociations:
|
||||||
|
@ -7908,6 +7916,8 @@ components:
|
||||||
items:
|
items:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
kind:
|
||||||
|
$ref: "#/components/schemas/TemplateKind"
|
||||||
templateMetaName:
|
templateMetaName:
|
||||||
type: string
|
type: string
|
||||||
name:
|
name:
|
||||||
|
@ -7959,6 +7969,8 @@ components:
|
||||||
items:
|
items:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
kind:
|
||||||
|
$ref: "#/components/schemas/TemplateKind"
|
||||||
templateMetaName:
|
templateMetaName:
|
||||||
type: string
|
type: string
|
||||||
id:
|
id:
|
||||||
|
@ -7986,6 +7998,8 @@ components:
|
||||||
- $ref: "#/components/schemas/TelegrafRequest"
|
- $ref: "#/components/schemas/TelegrafRequest"
|
||||||
- type: object
|
- type: object
|
||||||
properties:
|
properties:
|
||||||
|
kind:
|
||||||
|
$ref: "#/components/schemas/TemplateKind"
|
||||||
templateMetaName:
|
templateMetaName:
|
||||||
type: string
|
type: string
|
||||||
labelAssociations:
|
labelAssociations:
|
||||||
|
@ -7999,6 +8013,8 @@ components:
|
||||||
items:
|
items:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
kind:
|
||||||
|
$ref: "#/components/schemas/TemplateKind"
|
||||||
templateMetaName:
|
templateMetaName:
|
||||||
type: string
|
type: string
|
||||||
id:
|
id:
|
||||||
|
@ -8368,6 +8384,8 @@ components:
|
||||||
type: string
|
type: string
|
||||||
orgID:
|
orgID:
|
||||||
type: string
|
type: string
|
||||||
|
kind:
|
||||||
|
$ref: "#/components/schemas/TemplateKind"
|
||||||
templateMetaName:
|
templateMetaName:
|
||||||
type: string
|
type: string
|
||||||
name:
|
name:
|
||||||
|
|
|
@ -447,33 +447,39 @@ type Summary struct {
|
||||||
Variables []SummaryVariable `json:"variables"`
|
Variables []SummaryVariable `json:"variables"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SummaryIdentifier establishes the shared identifiers for a given resource
|
||||||
|
// within a template.
|
||||||
|
type SummaryIdentifier struct {
|
||||||
|
Kind Kind `json:"kind"`
|
||||||
|
MetaName string `json:"templateMetaName"`
|
||||||
|
EnvReferences []SummaryReference `json:"envReferences"`
|
||||||
|
}
|
||||||
|
|
||||||
// SummaryBucket provides a summary of a pkg bucket.
|
// SummaryBucket provides a summary of a pkg bucket.
|
||||||
type SummaryBucket struct {
|
type SummaryBucket struct {
|
||||||
|
SummaryIdentifier
|
||||||
ID SafeID `json:"id,omitempty"`
|
ID SafeID `json:"id,omitempty"`
|
||||||
OrgID SafeID `json:"orgID,omitempty"`
|
OrgID SafeID `json:"orgID,omitempty"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
MetaName string `json:"templateMetaName"`
|
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
// TODO: return retention rules?
|
// TODO: return retention rules?
|
||||||
RetentionPeriod time.Duration `json:"retentionPeriod"`
|
RetentionPeriod time.Duration `json:"retentionPeriod"`
|
||||||
|
|
||||||
EnvReferences []SummaryReference `json:"envReferences"`
|
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
||||||
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SummaryCheck provides a summary of a pkg check.
|
// SummaryCheck provides a summary of a pkg check.
|
||||||
type SummaryCheck struct {
|
type SummaryCheck struct {
|
||||||
MetaName string `json:"templateMetaName"`
|
SummaryIdentifier
|
||||||
Check influxdb.Check `json:"check"`
|
Check influxdb.Check `json:"check"`
|
||||||
Status influxdb.Status `json:"status"`
|
Status influxdb.Status `json:"status"`
|
||||||
|
|
||||||
EnvReferences []SummaryReference `json:"envReferences"`
|
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
||||||
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SummaryCheck) UnmarshalJSON(b []byte) error {
|
func (s *SummaryCheck) UnmarshalJSON(b []byte) error {
|
||||||
var out struct {
|
var out struct {
|
||||||
MetaName string `json:"templateMetaName"`
|
SummaryIdentifier
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
||||||
Check json.RawMessage `json:"check"`
|
Check json.RawMessage `json:"check"`
|
||||||
|
@ -481,7 +487,7 @@ func (s *SummaryCheck) UnmarshalJSON(b []byte) error {
|
||||||
if err := json.Unmarshal(b, &out); err != nil {
|
if err := json.Unmarshal(b, &out); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
s.MetaName = out.MetaName
|
s.SummaryIdentifier = out.SummaryIdentifier
|
||||||
s.Status = influxdb.Status(out.Status)
|
s.Status = influxdb.Status(out.Status)
|
||||||
s.LabelAssociations = out.LabelAssociations
|
s.LabelAssociations = out.LabelAssociations
|
||||||
|
|
||||||
|
@ -492,15 +498,14 @@ func (s *SummaryCheck) UnmarshalJSON(b []byte) error {
|
||||||
|
|
||||||
// SummaryDashboard provides a summary of a pkg dashboard.
|
// SummaryDashboard provides a summary of a pkg dashboard.
|
||||||
type SummaryDashboard struct {
|
type SummaryDashboard struct {
|
||||||
|
SummaryIdentifier
|
||||||
ID SafeID `json:"id"`
|
ID SafeID `json:"id"`
|
||||||
OrgID SafeID `json:"orgID"`
|
OrgID SafeID `json:"orgID"`
|
||||||
MetaName string `json:"templateMetaName"`
|
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Charts []SummaryChart `json:"charts"`
|
Charts []SummaryChart `json:"charts"`
|
||||||
|
|
||||||
EnvReferences []SummaryReference `json:"envReferences"`
|
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
||||||
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SummaryChart provides a summary of a pkg dashboard's chart.
|
// SummaryChart provides a summary of a pkg dashboard's chart.
|
||||||
|
@ -554,25 +559,24 @@ func (s *SummaryChart) UnmarshalJSON(b []byte) error {
|
||||||
|
|
||||||
// SummaryNotificationEndpoint provides a summary of a pkg notification endpoint.
|
// SummaryNotificationEndpoint provides a summary of a pkg notification endpoint.
|
||||||
type SummaryNotificationEndpoint struct {
|
type SummaryNotificationEndpoint struct {
|
||||||
MetaName string `json:"templateMetaName"`
|
SummaryIdentifier
|
||||||
NotificationEndpoint influxdb.NotificationEndpoint `json:"notificationEndpoint"`
|
NotificationEndpoint influxdb.NotificationEndpoint `json:"notificationEndpoint"`
|
||||||
|
|
||||||
EnvReferences []SummaryReference `json:"envReferences"`
|
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
||||||
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON unmarshals the notificatio endpoint. This is necessary b/c of
|
// UnmarshalJSON unmarshals the notificatio endpoint. This is necessary b/c of
|
||||||
// the notification endpoint does not have a means ot unmarshal itself.
|
// the notification endpoint does not have a means ot unmarshal itself.
|
||||||
func (s *SummaryNotificationEndpoint) UnmarshalJSON(b []byte) error {
|
func (s *SummaryNotificationEndpoint) UnmarshalJSON(b []byte) error {
|
||||||
var a struct {
|
var a struct {
|
||||||
PkgName string `json:"templateMetaName"`
|
SummaryIdentifier
|
||||||
NotificationEndpoint json.RawMessage `json:"notificationEndpoint"`
|
NotificationEndpoint json.RawMessage `json:"notificationEndpoint"`
|
||||||
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal(b, &a); err != nil {
|
if err := json.Unmarshal(b, &a); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
s.MetaName = a.PkgName
|
s.SummaryIdentifier = a.SummaryIdentifier
|
||||||
s.LabelAssociations = a.LabelAssociations
|
s.LabelAssociations = a.LabelAssociations
|
||||||
|
|
||||||
e, err := endpoint.UnmarshalJSON(a.NotificationEndpoint)
|
e, err := endpoint.UnmarshalJSON(a.NotificationEndpoint)
|
||||||
|
@ -583,8 +587,8 @@ func (s *SummaryNotificationEndpoint) UnmarshalJSON(b []byte) error {
|
||||||
// Summary types for NotificationRules which provide a summary of a pkg notification rule.
|
// Summary types for NotificationRules which provide a summary of a pkg notification rule.
|
||||||
type (
|
type (
|
||||||
SummaryNotificationRule struct {
|
SummaryNotificationRule struct {
|
||||||
|
SummaryIdentifier
|
||||||
ID SafeID `json:"id"`
|
ID SafeID `json:"id"`
|
||||||
MetaName string `json:"templateMetaName"`
|
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
|
||||||
|
@ -600,8 +604,7 @@ type (
|
||||||
StatusRules []SummaryStatusRule `json:"statusRules"`
|
StatusRules []SummaryStatusRule `json:"statusRules"`
|
||||||
TagRules []SummaryTagRule `json:"tagRules"`
|
TagRules []SummaryTagRule `json:"tagRules"`
|
||||||
|
|
||||||
EnvReferences []SummaryReference `json:"envReferences"`
|
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
||||||
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SummaryStatusRule struct {
|
SummaryStatusRule struct {
|
||||||
|
@ -618,16 +621,14 @@ type (
|
||||||
|
|
||||||
// SummaryLabel provides a summary of a pkg label.
|
// SummaryLabel provides a summary of a pkg label.
|
||||||
type SummaryLabel struct {
|
type SummaryLabel struct {
|
||||||
|
SummaryIdentifier
|
||||||
ID SafeID `json:"id"`
|
ID SafeID `json:"id"`
|
||||||
OrgID SafeID `json:"orgID"`
|
OrgID SafeID `json:"orgID"`
|
||||||
MetaName string `json:"templateMetaName"`
|
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Properties struct {
|
Properties struct {
|
||||||
Color string `json:"color"`
|
Color string `json:"color"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
} `json:"properties"`
|
} `json:"properties"`
|
||||||
|
|
||||||
EnvReferences []SummaryReference `json:"envReferences"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SummaryLabelMapping provides a summary of a label mapped with a single resource.
|
// SummaryLabelMapping provides a summary of a label mapped with a single resource.
|
||||||
|
@ -654,8 +655,8 @@ type SummaryReference struct {
|
||||||
|
|
||||||
// SummaryTask provides a summary of a task.
|
// SummaryTask provides a summary of a task.
|
||||||
type SummaryTask struct {
|
type SummaryTask struct {
|
||||||
|
SummaryIdentifier
|
||||||
ID SafeID `json:"id"`
|
ID SafeID `json:"id"`
|
||||||
MetaName string `json:"templateMetaName"`
|
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Cron string `json:"cron"`
|
Cron string `json:"cron"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
@ -664,29 +665,26 @@ type SummaryTask struct {
|
||||||
Query string `json:"query"`
|
Query string `json:"query"`
|
||||||
Status influxdb.Status `json:"status"`
|
Status influxdb.Status `json:"status"`
|
||||||
|
|
||||||
EnvReferences []SummaryReference `json:"envReferences"`
|
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
||||||
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SummaryTelegraf provides a summary of a pkg telegraf config.
|
// SummaryTelegraf provides a summary of a pkg telegraf config.
|
||||||
type SummaryTelegraf struct {
|
type SummaryTelegraf struct {
|
||||||
MetaName string `json:"templateMetaName"`
|
SummaryIdentifier
|
||||||
TelegrafConfig influxdb.TelegrafConfig `json:"telegrafConfig"`
|
TelegrafConfig influxdb.TelegrafConfig `json:"telegrafConfig"`
|
||||||
|
|
||||||
EnvReferences []SummaryReference `json:"envReferences"`
|
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
||||||
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SummaryVariable provides a summary of a pkg variable.
|
// SummaryVariable provides a summary of a pkg variable.
|
||||||
type SummaryVariable struct {
|
type SummaryVariable struct {
|
||||||
|
SummaryIdentifier
|
||||||
ID SafeID `json:"id,omitempty"`
|
ID SafeID `json:"id,omitempty"`
|
||||||
MetaName string `json:"templateMetaName"`
|
|
||||||
OrgID SafeID `json:"orgID,omitempty"`
|
OrgID SafeID `json:"orgID,omitempty"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Selected []string `json:"variables"`
|
Selected []string `json:"variables"`
|
||||||
Arguments *influxdb.VariableArguments `json:"arguments"`
|
Arguments *influxdb.VariableArguments `json:"arguments"`
|
||||||
|
|
||||||
EnvReferences []SummaryReference `json:"envReferences"`
|
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
||||||
LabelAssociations []SummaryLabel `json:"labelAssociations"`
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,12 +89,15 @@ type bucket struct {
|
||||||
|
|
||||||
func (b *bucket) summarize() SummaryBucket {
|
func (b *bucket) summarize() SummaryBucket {
|
||||||
return SummaryBucket{
|
return SummaryBucket{
|
||||||
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindBucket,
|
||||||
|
MetaName: b.MetaName(),
|
||||||
|
EnvReferences: summarizeCommonReferences(b.identity, b.labels),
|
||||||
|
},
|
||||||
Name: b.Name(),
|
Name: b.Name(),
|
||||||
MetaName: b.MetaName(),
|
|
||||||
Description: b.Description,
|
Description: b.Description,
|
||||||
RetentionPeriod: b.RetentionRules.RP(),
|
RetentionPeriod: b.RetentionRules.RP(),
|
||||||
LabelAssociations: toSummaryLabels(b.labels...),
|
LabelAssociations: toSummaryLabels(b.labels...),
|
||||||
EnvReferences: summarizeCommonReferences(b.identity, b.labels),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,18 +251,22 @@ func (c *check) summarize() SummaryCheck {
|
||||||
}
|
}
|
||||||
|
|
||||||
sum := SummaryCheck{
|
sum := SummaryCheck{
|
||||||
MetaName: c.MetaName(),
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
MetaName: c.MetaName(),
|
||||||
|
EnvReferences: summarizeCommonReferences(c.identity, c.labels),
|
||||||
|
},
|
||||||
Status: c.Status(),
|
Status: c.Status(),
|
||||||
LabelAssociations: toSummaryLabels(c.labels...),
|
LabelAssociations: toSummaryLabels(c.labels...),
|
||||||
EnvReferences: summarizeCommonReferences(c.identity, c.labels),
|
|
||||||
}
|
}
|
||||||
switch c.kind {
|
switch c.kind {
|
||||||
case checkKindThreshold:
|
case checkKindThreshold:
|
||||||
|
sum.Kind = KindCheckThreshold
|
||||||
sum.Check = &icheck.Threshold{
|
sum.Check = &icheck.Threshold{
|
||||||
Base: base,
|
Base: base,
|
||||||
Thresholds: toInfluxThresholds(c.thresholds...),
|
Thresholds: toInfluxThresholds(c.thresholds...),
|
||||||
}
|
}
|
||||||
case checkKindDeadman:
|
case checkKindDeadman:
|
||||||
|
sum.Kind = KindCheckDeadman
|
||||||
sum.Check = &icheck.Deadman{
|
sum.Check = &icheck.Deadman{
|
||||||
Base: base,
|
Base: base,
|
||||||
Level: notification.ParseCheckLevel(strings.ToUpper(c.level)),
|
Level: notification.ParseCheckLevel(strings.ToUpper(c.level)),
|
||||||
|
@ -463,11 +470,14 @@ func (d *dashboard) ResourceType() influxdb.ResourceType {
|
||||||
|
|
||||||
func (d *dashboard) summarize() SummaryDashboard {
|
func (d *dashboard) summarize() SummaryDashboard {
|
||||||
iDash := SummaryDashboard{
|
iDash := SummaryDashboard{
|
||||||
MetaName: d.MetaName(),
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindDashboard,
|
||||||
|
MetaName: d.MetaName(),
|
||||||
|
EnvReferences: summarizeCommonReferences(d.identity, d.labels),
|
||||||
|
},
|
||||||
Name: d.Name(),
|
Name: d.Name(),
|
||||||
Description: d.Description,
|
Description: d.Description,
|
||||||
LabelAssociations: toSummaryLabels(d.labels...),
|
LabelAssociations: toSummaryLabels(d.labels...),
|
||||||
EnvReferences: summarizeCommonReferences(d.identity, d.labels),
|
|
||||||
}
|
}
|
||||||
for _, c := range d.Charts {
|
for _, c := range d.Charts {
|
||||||
iDash.Charts = append(iDash.Charts, SummaryChart{
|
iDash.Charts = append(iDash.Charts, SummaryChart{
|
||||||
|
@ -1131,8 +1141,12 @@ type label struct {
|
||||||
|
|
||||||
func (l *label) summarize() SummaryLabel {
|
func (l *label) summarize() SummaryLabel {
|
||||||
return SummaryLabel{
|
return SummaryLabel{
|
||||||
MetaName: l.MetaName(),
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
Name: l.Name(),
|
Kind: KindLabel,
|
||||||
|
MetaName: l.MetaName(),
|
||||||
|
EnvReferences: l.identity.summarizeReferences(),
|
||||||
|
},
|
||||||
|
Name: l.Name(),
|
||||||
Properties: struct {
|
Properties: struct {
|
||||||
Color string `json:"color"`
|
Color string `json:"color"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
@ -1140,7 +1154,6 @@ func (l *label) summarize() SummaryLabel {
|
||||||
Color: l.Color,
|
Color: l.Color,
|
||||||
Description: l.Description,
|
Description: l.Description,
|
||||||
},
|
},
|
||||||
EnvReferences: l.identity.summarizeReferences(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1284,13 +1297,16 @@ func (n *notificationEndpoint) base() endpoint.Base {
|
||||||
func (n *notificationEndpoint) summarize() SummaryNotificationEndpoint {
|
func (n *notificationEndpoint) summarize() SummaryNotificationEndpoint {
|
||||||
base := n.base()
|
base := n.base()
|
||||||
sum := SummaryNotificationEndpoint{
|
sum := SummaryNotificationEndpoint{
|
||||||
MetaName: n.MetaName(),
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
MetaName: n.MetaName(),
|
||||||
|
EnvReferences: summarizeCommonReferences(n.identity, n.labels),
|
||||||
|
},
|
||||||
LabelAssociations: toSummaryLabels(n.labels...),
|
LabelAssociations: toSummaryLabels(n.labels...),
|
||||||
EnvReferences: summarizeCommonReferences(n.identity, n.labels),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch n.kind {
|
switch n.kind {
|
||||||
case notificationKindHTTP:
|
case notificationKindHTTP:
|
||||||
|
sum.Kind = KindNotificationEndpointHTTP
|
||||||
e := &endpoint.HTTP{
|
e := &endpoint.HTTP{
|
||||||
Base: base,
|
Base: base,
|
||||||
URL: n.url,
|
URL: n.url,
|
||||||
|
@ -1309,12 +1325,14 @@ func (n *notificationEndpoint) summarize() SummaryNotificationEndpoint {
|
||||||
}
|
}
|
||||||
sum.NotificationEndpoint = e
|
sum.NotificationEndpoint = e
|
||||||
case notificationKindPagerDuty:
|
case notificationKindPagerDuty:
|
||||||
|
sum.Kind = KindNotificationEndpointPagerDuty
|
||||||
sum.NotificationEndpoint = &endpoint.PagerDuty{
|
sum.NotificationEndpoint = &endpoint.PagerDuty{
|
||||||
Base: base,
|
Base: base,
|
||||||
ClientURL: n.url,
|
ClientURL: n.url,
|
||||||
RoutingKey: n.routingKey.SecretField(),
|
RoutingKey: n.routingKey.SecretField(),
|
||||||
}
|
}
|
||||||
case notificationKindSlack:
|
case notificationKindSlack:
|
||||||
|
sum.Kind = KindNotificationEndpointSlack
|
||||||
sum.NotificationEndpoint = &endpoint.Slack{
|
sum.NotificationEndpoint = &endpoint.Slack{
|
||||||
Base: base,
|
Base: base,
|
||||||
URL: n.url,
|
URL: n.url,
|
||||||
|
@ -1487,14 +1505,17 @@ func (r *notificationRule) summarize() SummaryNotificationRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
return SummaryNotificationRule{
|
return SummaryNotificationRule{
|
||||||
MetaName: r.MetaName(),
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindNotificationRule,
|
||||||
|
MetaName: r.MetaName(),
|
||||||
|
EnvReferences: envRefs,
|
||||||
|
},
|
||||||
Name: r.Name(),
|
Name: r.Name(),
|
||||||
EndpointMetaName: endpointPkgName,
|
EndpointMetaName: endpointPkgName,
|
||||||
EndpointType: endpointType,
|
EndpointType: endpointType,
|
||||||
Description: r.description,
|
Description: r.description,
|
||||||
Every: r.every.String(),
|
Every: r.every.String(),
|
||||||
LabelAssociations: toSummaryLabels(r.labels...),
|
LabelAssociations: toSummaryLabels(r.labels...),
|
||||||
EnvReferences: envRefs,
|
|
||||||
Offset: r.offset.String(),
|
Offset: r.offset.String(),
|
||||||
MessageTemplate: r.msgTemplate,
|
MessageTemplate: r.msgTemplate,
|
||||||
Status: r.Status(),
|
Status: r.Status(),
|
||||||
|
@ -1721,7 +1742,11 @@ func (t *task) flux() string {
|
||||||
|
|
||||||
func (t *task) summarize() SummaryTask {
|
func (t *task) summarize() SummaryTask {
|
||||||
return SummaryTask{
|
return SummaryTask{
|
||||||
MetaName: t.MetaName(),
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindTask,
|
||||||
|
MetaName: t.MetaName(),
|
||||||
|
EnvReferences: summarizeCommonReferences(t.identity, t.labels),
|
||||||
|
},
|
||||||
Name: t.Name(),
|
Name: t.Name(),
|
||||||
Cron: t.cron,
|
Cron: t.cron,
|
||||||
Description: t.description,
|
Description: t.description,
|
||||||
|
@ -1730,7 +1755,6 @@ func (t *task) summarize() SummaryTask {
|
||||||
Query: t.query,
|
Query: t.query,
|
||||||
Status: t.Status(),
|
Status: t.Status(),
|
||||||
|
|
||||||
EnvReferences: summarizeCommonReferences(t.identity, t.labels),
|
|
||||||
LabelAssociations: toSummaryLabels(t.labels...),
|
LabelAssociations: toSummaryLabels(t.labels...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1856,10 +1880,13 @@ func (t *telegraf) summarize() SummaryTelegraf {
|
||||||
cfg := t.config
|
cfg := t.config
|
||||||
cfg.Name = t.Name()
|
cfg.Name = t.Name()
|
||||||
return SummaryTelegraf{
|
return SummaryTelegraf{
|
||||||
MetaName: t.MetaName(),
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindTelegraf,
|
||||||
|
MetaName: t.MetaName(),
|
||||||
|
EnvReferences: summarizeCommonReferences(t.identity, t.labels),
|
||||||
|
},
|
||||||
TelegrafConfig: cfg,
|
TelegrafConfig: cfg,
|
||||||
LabelAssociations: toSummaryLabels(t.labels...),
|
LabelAssociations: toSummaryLabels(t.labels...),
|
||||||
EnvReferences: summarizeCommonReferences(t.identity, t.labels),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1935,13 +1962,16 @@ func (v *variable) summarize() SummaryVariable {
|
||||||
}
|
}
|
||||||
|
|
||||||
return SummaryVariable{
|
return SummaryVariable{
|
||||||
MetaName: v.MetaName(),
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindVariable,
|
||||||
|
MetaName: v.MetaName(),
|
||||||
|
EnvReferences: envRefs,
|
||||||
|
},
|
||||||
Name: v.Name(),
|
Name: v.Name(),
|
||||||
Description: v.Description,
|
Description: v.Description,
|
||||||
Selected: v.Selected(),
|
Selected: v.Selected(),
|
||||||
Arguments: v.influxVarArgs(),
|
Arguments: v.influxVarArgs(),
|
||||||
LabelAssociations: toSummaryLabels(v.labels...),
|
LabelAssociations: toSummaryLabels(v.labels...),
|
||||||
EnvReferences: envRefs,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,22 +30,28 @@ func TestParse(t *testing.T) {
|
||||||
|
|
||||||
actual := buckets[0]
|
actual := buckets[0]
|
||||||
expectedBucket := SummaryBucket{
|
expectedBucket := SummaryBucket{
|
||||||
MetaName: "rucket-11",
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindBucket,
|
||||||
|
MetaName: "rucket-11",
|
||||||
|
EnvReferences: []SummaryReference{},
|
||||||
|
},
|
||||||
Name: "rucket-11",
|
Name: "rucket-11",
|
||||||
Description: "bucket 1 description",
|
Description: "bucket 1 description",
|
||||||
RetentionPeriod: time.Hour,
|
RetentionPeriod: time.Hour,
|
||||||
LabelAssociations: []SummaryLabel{},
|
LabelAssociations: []SummaryLabel{},
|
||||||
EnvReferences: []SummaryReference{},
|
|
||||||
}
|
}
|
||||||
assert.Equal(t, expectedBucket, actual)
|
assert.Equal(t, expectedBucket, actual)
|
||||||
|
|
||||||
actual = buckets[1]
|
actual = buckets[1]
|
||||||
expectedBucket = SummaryBucket{
|
expectedBucket = SummaryBucket{
|
||||||
MetaName: "rucket-22",
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindBucket,
|
||||||
|
MetaName: "rucket-22",
|
||||||
|
EnvReferences: []SummaryReference{},
|
||||||
|
},
|
||||||
Name: "display name",
|
Name: "display name",
|
||||||
Description: "bucket 2 description",
|
Description: "bucket 2 description",
|
||||||
LabelAssociations: []SummaryLabel{},
|
LabelAssociations: []SummaryLabel{},
|
||||||
EnvReferences: []SummaryReference{},
|
|
||||||
}
|
}
|
||||||
assert.Equal(t, expectedBucket, actual)
|
assert.Equal(t, expectedBucket, actual)
|
||||||
})
|
})
|
||||||
|
@ -483,6 +489,7 @@ spec:
|
||||||
require.Len(t, sum.Checks, 2)
|
require.Len(t, sum.Checks, 2)
|
||||||
|
|
||||||
check1 := sum.Checks[0]
|
check1 := sum.Checks[0]
|
||||||
|
assert.Equal(t, KindCheckThreshold, check1.Kind)
|
||||||
thresholdCheck, ok := check1.Check.(*icheck.Threshold)
|
thresholdCheck, ok := check1.Check.(*icheck.Threshold)
|
||||||
require.Truef(t, ok, "got: %#v", check1)
|
require.Truef(t, ok, "got: %#v", check1)
|
||||||
|
|
||||||
|
@ -529,6 +536,7 @@ spec:
|
||||||
assert.Len(t, check1.LabelAssociations, 1)
|
assert.Len(t, check1.LabelAssociations, 1)
|
||||||
|
|
||||||
check2 := sum.Checks[1]
|
check2 := sum.Checks[1]
|
||||||
|
assert.Equal(t, KindCheckDeadman, check2.Kind)
|
||||||
deadmanCheck, ok := check2.Check.(*icheck.Deadman)
|
deadmanCheck, ok := check2.Check.(*icheck.Deadman)
|
||||||
require.Truef(t, ok, "got: %#v", check2)
|
require.Truef(t, ok, "got: %#v", check2)
|
||||||
|
|
||||||
|
@ -951,6 +959,7 @@ spec:
|
||||||
require.Len(t, sum.Dashboards, 1)
|
require.Len(t, sum.Dashboards, 1)
|
||||||
|
|
||||||
actual := sum.Dashboards[0]
|
actual := sum.Dashboards[0]
|
||||||
|
assert.Equal(t, KindDashboard, actual.Kind)
|
||||||
assert.Equal(t, "dash-1", actual.Name)
|
assert.Equal(t, "dash-1", actual.Name)
|
||||||
assert.Equal(t, "desc1", actual.Description)
|
assert.Equal(t, "desc1", actual.Description)
|
||||||
|
|
||||||
|
@ -1035,6 +1044,7 @@ spec:
|
||||||
require.Len(t, sum.Dashboards, 1)
|
require.Len(t, sum.Dashboards, 1)
|
||||||
|
|
||||||
actual := sum.Dashboards[0]
|
actual := sum.Dashboards[0]
|
||||||
|
assert.Equal(t, KindDashboard, actual.Kind)
|
||||||
assert.Equal(t, "dash-0", actual.Name)
|
assert.Equal(t, "dash-0", actual.Name)
|
||||||
assert.Equal(t, "a dashboard w/ heatmap chart", actual.Description)
|
assert.Equal(t, "a dashboard w/ heatmap chart", actual.Description)
|
||||||
|
|
||||||
|
@ -1153,6 +1163,7 @@ spec:
|
||||||
require.Len(t, sum.Dashboards, 1)
|
require.Len(t, sum.Dashboards, 1)
|
||||||
|
|
||||||
actual := sum.Dashboards[0]
|
actual := sum.Dashboards[0]
|
||||||
|
assert.Equal(t, KindDashboard, actual.Kind)
|
||||||
assert.Equal(t, "dash-0", actual.Name)
|
assert.Equal(t, "dash-0", actual.Name)
|
||||||
assert.Equal(t, "a dashboard w/ single histogram chart", actual.Description)
|
assert.Equal(t, "a dashboard w/ single histogram chart", actual.Description)
|
||||||
|
|
||||||
|
@ -1227,6 +1238,7 @@ spec:
|
||||||
require.Len(t, sum.Dashboards, 1)
|
require.Len(t, sum.Dashboards, 1)
|
||||||
|
|
||||||
actual := sum.Dashboards[0]
|
actual := sum.Dashboards[0]
|
||||||
|
assert.Equal(t, KindDashboard, actual.Kind)
|
||||||
assert.Equal(t, "dash-0", actual.Name)
|
assert.Equal(t, "dash-0", actual.Name)
|
||||||
assert.Equal(t, "a dashboard w/ single markdown chart", actual.Description)
|
assert.Equal(t, "a dashboard w/ single markdown chart", actual.Description)
|
||||||
|
|
||||||
|
@ -1248,6 +1260,7 @@ spec:
|
||||||
require.Len(t, sum.Dashboards, 1)
|
require.Len(t, sum.Dashboards, 1)
|
||||||
|
|
||||||
actual := sum.Dashboards[0]
|
actual := sum.Dashboards[0]
|
||||||
|
assert.Equal(t, KindDashboard, actual.Kind)
|
||||||
assert.Equal(t, "dash-0", actual.Name)
|
assert.Equal(t, "dash-0", actual.Name)
|
||||||
assert.Equal(t, "a dashboard w/ single scatter chart", actual.Description)
|
assert.Equal(t, "a dashboard w/ single scatter chart", actual.Description)
|
||||||
|
|
||||||
|
@ -1525,6 +1538,7 @@ spec:
|
||||||
require.Len(t, sum.Dashboards, 2)
|
require.Len(t, sum.Dashboards, 2)
|
||||||
|
|
||||||
actual := sum.Dashboards[0]
|
actual := sum.Dashboards[0]
|
||||||
|
assert.Equal(t, KindDashboard, actual.Kind)
|
||||||
assert.Equal(t, "dash-1", actual.MetaName)
|
assert.Equal(t, "dash-1", actual.MetaName)
|
||||||
assert.Equal(t, "display name", actual.Name)
|
assert.Equal(t, "display name", actual.Name)
|
||||||
assert.Equal(t, "desc1", actual.Description)
|
assert.Equal(t, "desc1", actual.Description)
|
||||||
|
@ -1692,6 +1706,7 @@ spec:
|
||||||
require.Len(t, sum.Dashboards, 1)
|
require.Len(t, sum.Dashboards, 1)
|
||||||
|
|
||||||
actual := sum.Dashboards[0]
|
actual := sum.Dashboards[0]
|
||||||
|
assert.Equal(t, KindDashboard, actual.Kind)
|
||||||
assert.Equal(t, "dash-1", actual.Name)
|
assert.Equal(t, "dash-1", actual.Name)
|
||||||
assert.Equal(t, "desc1", actual.Description)
|
assert.Equal(t, "desc1", actual.Description)
|
||||||
|
|
||||||
|
@ -1970,6 +1985,7 @@ spec:
|
||||||
require.Len(t, sum.Dashboards, 1)
|
require.Len(t, sum.Dashboards, 1)
|
||||||
|
|
||||||
actual := sum.Dashboards[0]
|
actual := sum.Dashboards[0]
|
||||||
|
assert.Equal(t, KindDashboard, actual.Kind)
|
||||||
assert.Equal(t, "dash-1", actual.Name)
|
assert.Equal(t, "dash-1", actual.Name)
|
||||||
assert.Equal(t, "desc1", actual.Description)
|
assert.Equal(t, "desc1", actual.Description)
|
||||||
|
|
||||||
|
@ -2147,6 +2163,7 @@ spec:
|
||||||
require.Len(t, sum.Dashboards, 1)
|
require.Len(t, sum.Dashboards, 1)
|
||||||
|
|
||||||
actual := sum.Dashboards[0]
|
actual := sum.Dashboards[0]
|
||||||
|
assert.Equal(t, KindDashboard, actual.Kind)
|
||||||
assert.Equal(t, "dash-1", actual.Name)
|
assert.Equal(t, "dash-1", actual.Name)
|
||||||
assert.Equal(t, "desc1", actual.Description)
|
assert.Equal(t, "desc1", actual.Description)
|
||||||
|
|
||||||
|
@ -2432,7 +2449,10 @@ spec:
|
||||||
testfileRunner(t, "testdata/notification_endpoint", func(t *testing.T, template *Template) {
|
testfileRunner(t, "testdata/notification_endpoint", func(t *testing.T, template *Template) {
|
||||||
expectedEndpoints := []SummaryNotificationEndpoint{
|
expectedEndpoints := []SummaryNotificationEndpoint{
|
||||||
{
|
{
|
||||||
MetaName: "http-basic-auth-notification-endpoint",
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindNotificationEndpointHTTP,
|
||||||
|
MetaName: "http-basic-auth-notification-endpoint",
|
||||||
|
},
|
||||||
NotificationEndpoint: &endpoint.HTTP{
|
NotificationEndpoint: &endpoint.HTTP{
|
||||||
Base: endpoint.Base{
|
Base: endpoint.Base{
|
||||||
Name: "basic endpoint name",
|
Name: "basic endpoint name",
|
||||||
|
@ -2447,7 +2467,10 @@ spec:
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MetaName: "http-bearer-auth-notification-endpoint",
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindNotificationEndpointHTTP,
|
||||||
|
MetaName: "http-bearer-auth-notification-endpoint",
|
||||||
|
},
|
||||||
NotificationEndpoint: &endpoint.HTTP{
|
NotificationEndpoint: &endpoint.HTTP{
|
||||||
Base: endpoint.Base{
|
Base: endpoint.Base{
|
||||||
Name: "http-bearer-auth-notification-endpoint",
|
Name: "http-bearer-auth-notification-endpoint",
|
||||||
|
@ -2461,7 +2484,10 @@ spec:
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MetaName: "http-none-auth-notification-endpoint",
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindNotificationEndpointHTTP,
|
||||||
|
MetaName: "http-none-auth-notification-endpoint",
|
||||||
|
},
|
||||||
NotificationEndpoint: &endpoint.HTTP{
|
NotificationEndpoint: &endpoint.HTTP{
|
||||||
Base: endpoint.Base{
|
Base: endpoint.Base{
|
||||||
Name: "http-none-auth-notification-endpoint",
|
Name: "http-none-auth-notification-endpoint",
|
||||||
|
@ -2474,7 +2500,10 @@ spec:
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MetaName: "pager-duty-notification-endpoint",
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindNotificationEndpointPagerDuty,
|
||||||
|
MetaName: "pager-duty-notification-endpoint",
|
||||||
|
},
|
||||||
NotificationEndpoint: &endpoint.PagerDuty{
|
NotificationEndpoint: &endpoint.PagerDuty{
|
||||||
Base: endpoint.Base{
|
Base: endpoint.Base{
|
||||||
Name: "pager duty name",
|
Name: "pager duty name",
|
||||||
|
@ -2486,7 +2515,10 @@ spec:
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MetaName: "slack-notification-endpoint",
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindNotificationEndpointHTTP,
|
||||||
|
MetaName: "slack-notification-endpoint",
|
||||||
|
},
|
||||||
NotificationEndpoint: &endpoint.Slack{
|
NotificationEndpoint: &endpoint.Slack{
|
||||||
Base: endpoint.Base{
|
Base: endpoint.Base{
|
||||||
Name: "slack name",
|
Name: "slack name",
|
||||||
|
@ -2818,6 +2850,7 @@ spec:
|
||||||
require.Len(t, rules, 1)
|
require.Len(t, rules, 1)
|
||||||
|
|
||||||
rule := rules[0]
|
rule := rules[0]
|
||||||
|
assert.Equal(t, KindNotificationRule, rule.Kind)
|
||||||
assert.Equal(t, "rule_0", rule.Name)
|
assert.Equal(t, "rule_0", rule.Name)
|
||||||
assert.Equal(t, "endpoint-0", rule.EndpointMetaName)
|
assert.Equal(t, "endpoint-0", rule.EndpointMetaName)
|
||||||
assert.Equal(t, "desc_0", rule.Description)
|
assert.Equal(t, "desc_0", rule.Description)
|
||||||
|
@ -3152,6 +3185,11 @@ spec:
|
||||||
sum := template.Summary()
|
sum := template.Summary()
|
||||||
tasks := sum.Tasks
|
tasks := sum.Tasks
|
||||||
require.Len(t, tasks, 2)
|
require.Len(t, tasks, 2)
|
||||||
|
|
||||||
|
for _, ta := range tasks {
|
||||||
|
assert.Equal(t, KindTask, ta.Kind)
|
||||||
|
}
|
||||||
|
|
||||||
sort.Slice(tasks, func(i, j int) bool {
|
sort.Slice(tasks, func(i, j int) bool {
|
||||||
return tasks[i].MetaName < tasks[j].MetaName
|
return tasks[i].MetaName < tasks[j].MetaName
|
||||||
})
|
})
|
||||||
|
@ -3374,6 +3412,7 @@ spec:
|
||||||
require.Len(t, sum.TelegrafConfigs, 2)
|
require.Len(t, sum.TelegrafConfigs, 2)
|
||||||
|
|
||||||
actual := sum.TelegrafConfigs[0]
|
actual := sum.TelegrafConfigs[0]
|
||||||
|
assert.Equal(t, KindTelegraf, actual.Kind)
|
||||||
assert.Equal(t, "display name", actual.TelegrafConfig.Name)
|
assert.Equal(t, "display name", actual.TelegrafConfig.Name)
|
||||||
assert.Equal(t, "desc", actual.TelegrafConfig.Description)
|
assert.Equal(t, "desc", actual.TelegrafConfig.Description)
|
||||||
|
|
||||||
|
@ -3473,6 +3512,9 @@ spec:
|
||||||
sum := template.Summary()
|
sum := template.Summary()
|
||||||
|
|
||||||
require.Len(t, sum.Variables, 4)
|
require.Len(t, sum.Variables, 4)
|
||||||
|
for _, v := range sum.Variables {
|
||||||
|
assert.Equal(t, KindVariable, v.Kind)
|
||||||
|
}
|
||||||
|
|
||||||
varEquals := func(t *testing.T, name, vType string, vals interface{}, selected []string, v SummaryVariable) {
|
varEquals := func(t *testing.T, name, vType string, vals interface{}, selected []string, v SummaryVariable) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
@ -3869,28 +3911,37 @@ spec:
|
||||||
|
|
||||||
bkts := []SummaryBucket{
|
bkts := []SummaryBucket{
|
||||||
{
|
{
|
||||||
MetaName: "rucket-1",
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindBucket,
|
||||||
|
MetaName: "rucket-1",
|
||||||
|
EnvReferences: []SummaryReference{},
|
||||||
|
},
|
||||||
Name: "rucket-1",
|
Name: "rucket-1",
|
||||||
Description: "desc_1",
|
Description: "desc_1",
|
||||||
RetentionPeriod: 10000 * time.Second,
|
RetentionPeriod: 10000 * time.Second,
|
||||||
LabelAssociations: labels,
|
LabelAssociations: labels,
|
||||||
EnvReferences: []SummaryReference{},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MetaName: "rucket-2",
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindBucket,
|
||||||
|
MetaName: "rucket-2",
|
||||||
|
EnvReferences: []SummaryReference{},
|
||||||
|
},
|
||||||
Name: "rucket-2",
|
Name: "rucket-2",
|
||||||
Description: "desc-2",
|
Description: "desc-2",
|
||||||
RetentionPeriod: 20000 * time.Second,
|
RetentionPeriod: 20000 * time.Second,
|
||||||
LabelAssociations: labels,
|
LabelAssociations: labels,
|
||||||
EnvReferences: []SummaryReference{},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MetaName: "rucket-3",
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindBucket,
|
||||||
|
MetaName: "rucket-3",
|
||||||
|
EnvReferences: []SummaryReference{},
|
||||||
|
},
|
||||||
Name: "rucket-3",
|
Name: "rucket-3",
|
||||||
Description: "desc_3",
|
Description: "desc_3",
|
||||||
RetentionPeriod: 30000 * time.Second,
|
RetentionPeriod: 30000 * time.Second,
|
||||||
LabelAssociations: labels,
|
LabelAssociations: labels,
|
||||||
EnvReferences: []SummaryReference{},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
assert.Equal(t, bkts, sum.Buckets)
|
assert.Equal(t, bkts, sum.Buckets)
|
||||||
|
@ -4424,8 +4475,12 @@ func sumLabelGen(metaName, name, color, desc string, envRefs ...SummaryReference
|
||||||
envRefs = make([]SummaryReference, 0)
|
envRefs = make([]SummaryReference, 0)
|
||||||
}
|
}
|
||||||
return SummaryLabel{
|
return SummaryLabel{
|
||||||
MetaName: metaName,
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
Name: name,
|
Kind: KindLabel,
|
||||||
|
MetaName: metaName,
|
||||||
|
EnvReferences: envRefs,
|
||||||
|
},
|
||||||
|
Name: name,
|
||||||
Properties: struct {
|
Properties: struct {
|
||||||
Color string `json:"color"`
|
Color string `json:"color"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
|
@ -4433,7 +4488,6 @@ func sumLabelGen(metaName, name, color, desc string, envRefs ...SummaryReference
|
||||||
Color: color,
|
Color: color,
|
||||||
Description: desc,
|
Description: desc,
|
||||||
},
|
},
|
||||||
EnvReferences: envRefs,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -785,14 +785,17 @@ func TestService(t *testing.T) {
|
||||||
require.Len(t, sum.Buckets, 2)
|
require.Len(t, sum.Buckets, 2)
|
||||||
|
|
||||||
expected := SummaryBucket{
|
expected := SummaryBucket{
|
||||||
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindBucket,
|
||||||
|
MetaName: "rucket-11",
|
||||||
|
EnvReferences: []SummaryReference{},
|
||||||
|
},
|
||||||
ID: SafeID(time.Hour),
|
ID: SafeID(time.Hour),
|
||||||
OrgID: SafeID(orgID),
|
OrgID: SafeID(orgID),
|
||||||
MetaName: "rucket-11",
|
|
||||||
Name: "rucket-11",
|
Name: "rucket-11",
|
||||||
Description: "bucket 1 description",
|
Description: "bucket 1 description",
|
||||||
RetentionPeriod: time.Hour,
|
RetentionPeriod: time.Hour,
|
||||||
LabelAssociations: []SummaryLabel{},
|
LabelAssociations: []SummaryLabel{},
|
||||||
EnvReferences: []SummaryReference{},
|
|
||||||
}
|
}
|
||||||
assert.Contains(t, sum.Buckets, expected)
|
assert.Contains(t, sum.Buckets, expected)
|
||||||
})
|
})
|
||||||
|
@ -837,14 +840,17 @@ func TestService(t *testing.T) {
|
||||||
require.Len(t, sum.Buckets, 2)
|
require.Len(t, sum.Buckets, 2)
|
||||||
|
|
||||||
expected := SummaryBucket{
|
expected := SummaryBucket{
|
||||||
|
SummaryIdentifier: SummaryIdentifier{
|
||||||
|
Kind: KindBucket,
|
||||||
|
MetaName: "rucket-11",
|
||||||
|
EnvReferences: []SummaryReference{},
|
||||||
|
},
|
||||||
ID: SafeID(3),
|
ID: SafeID(3),
|
||||||
OrgID: SafeID(orgID),
|
OrgID: SafeID(orgID),
|
||||||
MetaName: "rucket-11",
|
|
||||||
Name: "rucket-11",
|
Name: "rucket-11",
|
||||||
Description: "bucket 1 description",
|
Description: "bucket 1 description",
|
||||||
RetentionPeriod: time.Hour,
|
RetentionPeriod: time.Hour,
|
||||||
LabelAssociations: []SummaryLabel{},
|
LabelAssociations: []SummaryLabel{},
|
||||||
EnvReferences: []SummaryReference{},
|
|
||||||
}
|
}
|
||||||
assert.Contains(t, sum.Buckets, expected)
|
assert.Contains(t, sum.Buckets, expected)
|
||||||
assert.Zero(t, fakeBktSVC.CreateBucketCalls.Count())
|
assert.Zero(t, fakeBktSVC.CreateBucketCalls.Count())
|
||||||
|
|
Loading…
Reference in New Issue