chore(pkger): refactor diffs to use reuable identifier type
parent
85e31e8194
commit
afb1653bff
|
@ -161,7 +161,9 @@ func TestPkgerHTTPServer(t *testing.T) {
|
||||||
var diff pkger.Diff
|
var diff pkger.Diff
|
||||||
for _, b := range sum.Buckets {
|
for _, b := range sum.Buckets {
|
||||||
diff.Buckets = append(diff.Buckets, pkger.DiffBucket{
|
diff.Buckets = append(diff.Buckets, pkger.DiffBucket{
|
||||||
|
DiffIdentifier: pkger.DiffIdentifier{
|
||||||
PkgName: b.Name,
|
PkgName: b.Name,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return sum, diff, nil
|
return sum, diff, nil
|
||||||
|
@ -215,7 +217,9 @@ func TestPkgerHTTPServer(t *testing.T) {
|
||||||
var diff pkger.Diff
|
var diff pkger.Diff
|
||||||
for _, b := range sum.Buckets {
|
for _, b := range sum.Buckets {
|
||||||
diff.Buckets = append(diff.Buckets, pkger.DiffBucket{
|
diff.Buckets = append(diff.Buckets, pkger.DiffBucket{
|
||||||
|
DiffIdentifier: pkger.DiffIdentifier{
|
||||||
PkgName: b.Name,
|
PkgName: b.Name,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return sum, diff, nil
|
return sum, diff, nil
|
||||||
|
@ -317,7 +321,9 @@ func TestPkgerHTTPServer(t *testing.T) {
|
||||||
var diff pkger.Diff
|
var diff pkger.Diff
|
||||||
for _, b := range sum.Buckets {
|
for _, b := range sum.Buckets {
|
||||||
diff.Buckets = append(diff.Buckets, pkger.DiffBucket{
|
diff.Buckets = append(diff.Buckets, pkger.DiffBucket{
|
||||||
|
DiffIdentifier: pkger.DiffIdentifier{
|
||||||
PkgName: b.Name,
|
PkgName: b.Name,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return sum, diff, nil
|
return sum, diff, nil
|
||||||
|
@ -409,7 +415,9 @@ func TestPkgerHTTPServer(t *testing.T) {
|
||||||
var diff pkger.Diff
|
var diff pkger.Diff
|
||||||
for _, b := range sum.Buckets {
|
for _, b := range sum.Buckets {
|
||||||
diff.Buckets = append(diff.Buckets, pkger.DiffBucket{
|
diff.Buckets = append(diff.Buckets, pkger.DiffBucket{
|
||||||
|
DiffIdentifier: pkger.DiffIdentifier{
|
||||||
PkgName: b.Name,
|
PkgName: b.Name,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return sum, diff, nil
|
return sum, diff, nil
|
||||||
|
|
125
pkger/models.go
125
pkger/models.go
|
@ -135,6 +135,19 @@ func (s SafeID) String() string {
|
||||||
return influxdb.ID(s).String()
|
return influxdb.ID(s).String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DiffIdentifier are the identifying fields for any given resource. Each resource
|
||||||
|
// dictates if the resource is new, to be removed, or will remain.
|
||||||
|
type DiffIdentifier struct {
|
||||||
|
ID SafeID `json:"id"`
|
||||||
|
Remove bool `json:"bool"`
|
||||||
|
PkgName string `json:"pkgName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsNew indicates the resource is new to the platform.
|
||||||
|
func (d DiffIdentifier) IsNew() bool {
|
||||||
|
return d.ID == 0
|
||||||
|
}
|
||||||
|
|
||||||
// Diff is the result of a service DryRun call. The diff outlines
|
// Diff is the result of a service DryRun call. The diff outlines
|
||||||
// what is new and or updated from the current state of the platform.
|
// what is new and or updated from the current state of the platform.
|
||||||
type Diff struct {
|
type Diff struct {
|
||||||
|
@ -177,9 +190,8 @@ func (d Diff) HasConflicts() bool {
|
||||||
type (
|
type (
|
||||||
// DiffBucket is a diff of an individual bucket.
|
// DiffBucket is a diff of an individual bucket.
|
||||||
DiffBucket struct {
|
DiffBucket struct {
|
||||||
Remove bool `json:"remove"`
|
DiffIdentifier
|
||||||
ID SafeID `json:"id"`
|
|
||||||
PkgName string `json:"pkgName"`
|
|
||||||
New DiffBucketValues `json:"new"`
|
New DiffBucketValues `json:"new"`
|
||||||
Old *DiffBucketValues `json:"old,omitempty"` // using omitempty here to signal there was no prev state with a nil
|
Old *DiffBucketValues `json:"old,omitempty"` // using omitempty here to signal there was no prev state with a nil
|
||||||
}
|
}
|
||||||
|
@ -194,8 +206,11 @@ type (
|
||||||
|
|
||||||
func newDiffBucket(b *bucket, i *influxdb.Bucket) DiffBucket {
|
func newDiffBucket(b *bucket, i *influxdb.Bucket) DiffBucket {
|
||||||
diff := DiffBucket{
|
diff := DiffBucket{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
|
ID: SafeID(b.ID()),
|
||||||
Remove: b.shouldRemove,
|
Remove: b.shouldRemove,
|
||||||
PkgName: b.PkgName(),
|
PkgName: b.PkgName(),
|
||||||
|
},
|
||||||
New: DiffBucketValues{
|
New: DiffBucketValues{
|
||||||
Name: b.Name(),
|
Name: b.Name(),
|
||||||
Description: b.Description,
|
Description: b.Description,
|
||||||
|
@ -215,11 +230,6 @@ func newDiffBucket(b *bucket, i *influxdb.Bucket) DiffBucket {
|
||||||
return diff
|
return diff
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNew indicates whether a pkg bucket is going to be new to the platform.
|
|
||||||
func (d DiffBucket) IsNew() bool {
|
|
||||||
return d.ID == SafeID(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d DiffBucket) hasConflict() bool {
|
func (d DiffBucket) hasConflict() bool {
|
||||||
return !d.IsNew() && d.Old != nil && !reflect.DeepEqual(*d.Old, d.New)
|
return !d.IsNew() && d.Old != nil && !reflect.DeepEqual(*d.Old, d.New)
|
||||||
}
|
}
|
||||||
|
@ -248,17 +258,19 @@ func (d *DiffCheckValues) UnmarshalJSON(b []byte) (err error) {
|
||||||
|
|
||||||
// DiffCheck is a diff of an individual check.
|
// DiffCheck is a diff of an individual check.
|
||||||
type DiffCheck struct {
|
type DiffCheck struct {
|
||||||
Remove bool `json:"remove"`
|
DiffIdentifier
|
||||||
ID SafeID `json:"id"`
|
|
||||||
PkgName string `json:"pkgName"`
|
|
||||||
New DiffCheckValues `json:"new"`
|
New DiffCheckValues `json:"new"`
|
||||||
Old *DiffCheckValues `json:"old"`
|
Old *DiffCheckValues `json:"old"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDiffCheck(c *check, iCheck influxdb.Check) DiffCheck {
|
func newDiffCheck(c *check, iCheck influxdb.Check) DiffCheck {
|
||||||
diff := DiffCheck{
|
diff := DiffCheck{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
|
ID: SafeID(c.ID()),
|
||||||
Remove: c.shouldRemove,
|
Remove: c.shouldRemove,
|
||||||
PkgName: c.PkgName(),
|
PkgName: c.PkgName(),
|
||||||
|
},
|
||||||
New: DiffCheckValues{
|
New: DiffCheckValues{
|
||||||
Check: c.summarize().Check,
|
Check: c.summarize().Check,
|
||||||
},
|
},
|
||||||
|
@ -272,17 +284,11 @@ func newDiffCheck(c *check, iCheck influxdb.Check) DiffCheck {
|
||||||
return diff
|
return diff
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNew determines if the check in the pkg is new to the platform.
|
|
||||||
func (d DiffCheck) IsNew() bool {
|
|
||||||
return d.Old == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// DiffDashboard is a diff of an individual dashboard.
|
// DiffDashboard is a diff of an individual dashboard.
|
||||||
DiffDashboard struct {
|
DiffDashboard struct {
|
||||||
ID SafeID `json:"id"`
|
DiffIdentifier
|
||||||
Remove bool `json:"remove"`
|
|
||||||
PkgName string `json:"pkgName"`
|
|
||||||
New DiffDashboardValues `json:"new"`
|
New DiffDashboardValues `json:"new"`
|
||||||
Old *DiffDashboardValues `json:"old"`
|
Old *DiffDashboardValues `json:"old"`
|
||||||
}
|
}
|
||||||
|
@ -297,8 +303,11 @@ type (
|
||||||
|
|
||||||
func newDiffDashboard(d *dashboard) DiffDashboard {
|
func newDiffDashboard(d *dashboard) DiffDashboard {
|
||||||
diff := DiffDashboard{
|
diff := DiffDashboard{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: SafeID(d.ID()),
|
ID: SafeID(d.ID()),
|
||||||
|
Remove: d.shouldRemove,
|
||||||
PkgName: d.PkgName(),
|
PkgName: d.PkgName(),
|
||||||
|
},
|
||||||
New: DiffDashboardValues{
|
New: DiffDashboardValues{
|
||||||
Name: d.Name(),
|
Name: d.Name(),
|
||||||
Desc: d.Description,
|
Desc: d.Description,
|
||||||
|
@ -344,11 +353,6 @@ func newDiffDashboard(d *dashboard) DiffDashboard {
|
||||||
return diff
|
return diff
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNew indicates whether the pkg dashboard is new to the platform.
|
|
||||||
func (d DiffDashboard) IsNew() bool {
|
|
||||||
return d.ID == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiffChart is a diff of oa chart. Since all charts are new right now.
|
// DiffChart is a diff of oa chart. Since all charts are new right now.
|
||||||
// the SummaryChart is reused here.
|
// the SummaryChart is reused here.
|
||||||
type DiffChart SummaryChart
|
type DiffChart SummaryChart
|
||||||
|
@ -356,9 +360,8 @@ type DiffChart SummaryChart
|
||||||
type (
|
type (
|
||||||
// DiffLabel is a diff of an individual label.
|
// DiffLabel is a diff of an individual label.
|
||||||
DiffLabel struct {
|
DiffLabel struct {
|
||||||
Remove bool `json:"remove"`
|
DiffIdentifier
|
||||||
ID SafeID `json:"id"`
|
|
||||||
PkgName string `json:"pkgName"`
|
|
||||||
New DiffLabelValues `json:"new"`
|
New DiffLabelValues `json:"new"`
|
||||||
Old *DiffLabelValues `json:"old,omitempty"` // using omitempty here to signal there was no prev state with a nil
|
Old *DiffLabelValues `json:"old,omitempty"` // using omitempty here to signal there was no prev state with a nil
|
||||||
}
|
}
|
||||||
|
@ -371,19 +374,13 @@ type (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// IsNew indicates whether a pkg label is going to be new to the platform.
|
|
||||||
func (d DiffLabel) IsNew() bool {
|
|
||||||
return d.ID == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d DiffLabel) hasConflict() bool {
|
|
||||||
return !d.IsNew() && d.Old != nil && *d.Old != d.New
|
|
||||||
}
|
|
||||||
|
|
||||||
func newDiffLabel(l *label, i *influxdb.Label) DiffLabel {
|
func newDiffLabel(l *label, i *influxdb.Label) DiffLabel {
|
||||||
diff := DiffLabel{
|
diff := DiffLabel{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
|
ID: SafeID(l.ID()),
|
||||||
Remove: l.shouldRemove,
|
Remove: l.shouldRemove,
|
||||||
PkgName: l.PkgName(),
|
PkgName: l.PkgName(),
|
||||||
|
},
|
||||||
New: DiffLabelValues{
|
New: DiffLabelValues{
|
||||||
Name: l.Name(),
|
Name: l.Name(),
|
||||||
Color: l.Color,
|
Color: l.Color,
|
||||||
|
@ -401,6 +398,10 @@ func newDiffLabel(l *label, i *influxdb.Label) DiffLabel {
|
||||||
return diff
|
return diff
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d DiffLabel) hasConflict() bool {
|
||||||
|
return !d.IsNew() && d.Old != nil && *d.Old != d.New
|
||||||
|
}
|
||||||
|
|
||||||
// DiffLabelMapping is a diff of an individual label mapping. A
|
// DiffLabelMapping is a diff of an individual label mapping. A
|
||||||
// single resource may have multiple mappings to multiple labels.
|
// single resource may have multiple mappings to multiple labels.
|
||||||
// A label can have many mappings to other resources.
|
// A label can have many mappings to other resources.
|
||||||
|
@ -439,17 +440,19 @@ func (d *DiffNotificationEndpointValues) UnmarshalJSON(b []byte) (err error) {
|
||||||
|
|
||||||
// DiffNotificationEndpoint is a diff of an individual notification endpoint.
|
// DiffNotificationEndpoint is a diff of an individual notification endpoint.
|
||||||
type DiffNotificationEndpoint struct {
|
type DiffNotificationEndpoint struct {
|
||||||
ID SafeID `json:"id"`
|
DiffIdentifier
|
||||||
Remove bool `json:"remove"`
|
|
||||||
PkgName string `json:"pkgName"`
|
|
||||||
New DiffNotificationEndpointValues `json:"new"`
|
New DiffNotificationEndpointValues `json:"new"`
|
||||||
Old *DiffNotificationEndpointValues `json:"old"`
|
Old *DiffNotificationEndpointValues `json:"old"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDiffNotificationEndpoint(ne *notificationEndpoint, i influxdb.NotificationEndpoint) DiffNotificationEndpoint {
|
func newDiffNotificationEndpoint(ne *notificationEndpoint, i influxdb.NotificationEndpoint) DiffNotificationEndpoint {
|
||||||
diff := DiffNotificationEndpoint{
|
diff := DiffNotificationEndpoint{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
|
ID: SafeID(ne.ID()),
|
||||||
Remove: ne.shouldRemove,
|
Remove: ne.shouldRemove,
|
||||||
PkgName: ne.PkgName(),
|
PkgName: ne.PkgName(),
|
||||||
|
},
|
||||||
New: DiffNotificationEndpointValues{
|
New: DiffNotificationEndpointValues{
|
||||||
NotificationEndpoint: ne.summarize().NotificationEndpoint,
|
NotificationEndpoint: ne.summarize().NotificationEndpoint,
|
||||||
},
|
},
|
||||||
|
@ -463,18 +466,10 @@ func newDiffNotificationEndpoint(ne *notificationEndpoint, i influxdb.Notificati
|
||||||
return diff
|
return diff
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNew indicates if the resource will be new to the platform or if it edits
|
|
||||||
// an existing resource.
|
|
||||||
func (d DiffNotificationEndpoint) IsNew() bool {
|
|
||||||
return d.ID == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// DiffNotificationRule is a diff of an individual notification rule.
|
// DiffNotificationRule is a diff of an individual notification rule.
|
||||||
DiffNotificationRule struct {
|
DiffNotificationRule struct {
|
||||||
ID SafeID `json:"id"`
|
DiffIdentifier
|
||||||
Remove bool `json:"bool"`
|
|
||||||
PkgName string `json:"pkgName"`
|
|
||||||
|
|
||||||
New DiffNotificationRuleValues `json:"new"`
|
New DiffNotificationRuleValues `json:"new"`
|
||||||
Old *DiffNotificationRuleValues `json:"old"`
|
Old *DiffNotificationRuleValues `json:"old"`
|
||||||
|
@ -500,9 +495,11 @@ type (
|
||||||
|
|
||||||
func newDiffNotificationRule(r *notificationRule, iEndpoint influxdb.NotificationEndpoint) DiffNotificationRule {
|
func newDiffNotificationRule(r *notificationRule, iEndpoint influxdb.NotificationEndpoint) DiffNotificationRule {
|
||||||
sum := DiffNotificationRule{
|
sum := DiffNotificationRule{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: SafeID(r.ID()),
|
ID: SafeID(r.ID()),
|
||||||
Remove: r.shouldRemove,
|
Remove: r.shouldRemove,
|
||||||
PkgName: r.PkgName(),
|
PkgName: r.PkgName(),
|
||||||
|
},
|
||||||
New: DiffNotificationRuleValues{
|
New: DiffNotificationRuleValues{
|
||||||
Name: r.Name(),
|
Name: r.Name(),
|
||||||
Description: r.description,
|
Description: r.description,
|
||||||
|
@ -568,18 +565,11 @@ func newDiffNotificationRule(r *notificationRule, iEndpoint influxdb.Notificatio
|
||||||
return sum
|
return sum
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNew indicates if the resource will be new to the platform or if it edits
|
|
||||||
// an existing resource.
|
|
||||||
func (d DiffNotificationRule) IsNew() bool {
|
|
||||||
return d.ID == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// DiffTask is a diff of an individual task.
|
// DiffTask is a diff of an individual task.
|
||||||
DiffTask struct {
|
DiffTask struct {
|
||||||
ID SafeID `json:"id"`
|
DiffIdentifier
|
||||||
Remove bool `json:"remove"`
|
|
||||||
PkgName string `json:"pkgName"`
|
|
||||||
New DiffTaskValues `json:"new"`
|
New DiffTaskValues `json:"new"`
|
||||||
Old *DiffTaskValues `json:"old"`
|
Old *DiffTaskValues `json:"old"`
|
||||||
}
|
}
|
||||||
|
@ -598,8 +588,11 @@ type (
|
||||||
|
|
||||||
func newDiffTask(t *task) DiffTask {
|
func newDiffTask(t *task) DiffTask {
|
||||||
diff := DiffTask{
|
diff := DiffTask{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: SafeID(t.ID()),
|
ID: SafeID(t.ID()),
|
||||||
|
Remove: t.shouldRemove,
|
||||||
PkgName: t.PkgName(),
|
PkgName: t.PkgName(),
|
||||||
|
},
|
||||||
New: DiffTaskValues{
|
New: DiffTaskValues{
|
||||||
Name: t.Name(),
|
Name: t.Name(),
|
||||||
Cron: t.cron,
|
Cron: t.cron,
|
||||||
|
@ -628,11 +621,6 @@ func newDiffTask(t *task) DiffTask {
|
||||||
return diff
|
return diff
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNew indicates whether a pkg task is going to be new to the platform.
|
|
||||||
func (d DiffTask) IsNew() bool {
|
|
||||||
return d.ID == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiffTelegraf is a diff of an individual telegraf. This resource is always new.
|
// DiffTelegraf is a diff of an individual telegraf. This resource is always new.
|
||||||
type DiffTelegraf struct {
|
type DiffTelegraf struct {
|
||||||
influxdb.TelegrafConfig
|
influxdb.TelegrafConfig
|
||||||
|
@ -647,9 +635,8 @@ func newDiffTelegraf(t *telegraf) DiffTelegraf {
|
||||||
type (
|
type (
|
||||||
// DiffVariable is a diff of an individual variable.
|
// DiffVariable is a diff of an individual variable.
|
||||||
DiffVariable struct {
|
DiffVariable struct {
|
||||||
ID SafeID `json:"id"`
|
DiffIdentifier
|
||||||
Remove bool `json:"remove"`
|
|
||||||
PkgName string `json:"pkgName"`
|
|
||||||
New DiffVariableValues `json:"new"`
|
New DiffVariableValues `json:"new"`
|
||||||
Old *DiffVariableValues `json:"old,omitempty"` // using omitempty here to signal there was no prev state with a nil
|
Old *DiffVariableValues `json:"old,omitempty"` // using omitempty here to signal there was no prev state with a nil
|
||||||
}
|
}
|
||||||
|
@ -664,8 +651,11 @@ type (
|
||||||
|
|
||||||
func newDiffVariable(v *variable, iv *influxdb.Variable) DiffVariable {
|
func newDiffVariable(v *variable, iv *influxdb.Variable) DiffVariable {
|
||||||
diff := DiffVariable{
|
diff := DiffVariable{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
|
ID: SafeID(v.ID()),
|
||||||
Remove: v.shouldRemove,
|
Remove: v.shouldRemove,
|
||||||
PkgName: v.PkgName(),
|
PkgName: v.PkgName(),
|
||||||
|
},
|
||||||
New: DiffVariableValues{
|
New: DiffVariableValues{
|
||||||
Name: v.Name(),
|
Name: v.Name(),
|
||||||
Description: v.Description,
|
Description: v.Description,
|
||||||
|
@ -684,11 +674,6 @@ func newDiffVariable(v *variable, iv *influxdb.Variable) DiffVariable {
|
||||||
return diff
|
return diff
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNew indicates whether a pkg variable is going to be new to the platform.
|
|
||||||
func (d DiffVariable) IsNew() bool {
|
|
||||||
return d.ID == SafeID(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d DiffVariable) hasConflict() bool {
|
func (d DiffVariable) hasConflict() bool {
|
||||||
return !d.IsNew() && d.Old != nil && !reflect.DeepEqual(*d.Old, d.New)
|
return !d.IsNew() && d.Old != nil && !reflect.DeepEqual(*d.Old, d.New)
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,9 @@ func TestPkg(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "new bucket",
|
name: "new bucket",
|
||||||
resource: DiffBucket{
|
resource: DiffBucket{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
PkgName: "new bucket",
|
PkgName: "new bucket",
|
||||||
|
},
|
||||||
New: DiffBucketValues{
|
New: DiffBucketValues{
|
||||||
Description: "new desc",
|
Description: "new desc",
|
||||||
},
|
},
|
||||||
|
@ -146,8 +148,10 @@ func TestPkg(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "existing bucket with no changes",
|
name: "existing bucket with no changes",
|
||||||
resource: DiffBucket{
|
resource: DiffBucket{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: 3,
|
ID: 3,
|
||||||
PkgName: "new bucket",
|
PkgName: "new bucket",
|
||||||
|
},
|
||||||
New: DiffBucketValues{
|
New: DiffBucketValues{
|
||||||
Description: "new desc",
|
Description: "new desc",
|
||||||
RetentionRules: retentionRules{{
|
RetentionRules: retentionRules{{
|
||||||
|
@ -168,8 +172,10 @@ func TestPkg(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "existing bucket with desc changes",
|
name: "existing bucket with desc changes",
|
||||||
resource: DiffBucket{
|
resource: DiffBucket{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: 3,
|
ID: 3,
|
||||||
PkgName: "existing bucket",
|
PkgName: "existing bucket",
|
||||||
|
},
|
||||||
New: DiffBucketValues{
|
New: DiffBucketValues{
|
||||||
Description: "new desc",
|
Description: "new desc",
|
||||||
RetentionRules: retentionRules{{
|
RetentionRules: retentionRules{{
|
||||||
|
@ -190,8 +196,10 @@ func TestPkg(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "existing bucket with retention changes",
|
name: "existing bucket with retention changes",
|
||||||
resource: DiffBucket{
|
resource: DiffBucket{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: 3,
|
ID: 3,
|
||||||
PkgName: "existing bucket",
|
PkgName: "existing bucket",
|
||||||
|
},
|
||||||
New: DiffBucketValues{
|
New: DiffBucketValues{
|
||||||
Description: "new desc",
|
Description: "new desc",
|
||||||
RetentionRules: retentionRules{{
|
RetentionRules: retentionRules{{
|
||||||
|
@ -208,8 +216,10 @@ func TestPkg(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "existing bucket with retention changes",
|
name: "existing bucket with retention changes",
|
||||||
resource: DiffBucket{
|
resource: DiffBucket{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: 3,
|
ID: 3,
|
||||||
PkgName: "existing bucket",
|
PkgName: "existing bucket",
|
||||||
|
},
|
||||||
New: DiffBucketValues{
|
New: DiffBucketValues{
|
||||||
Description: "new desc",
|
Description: "new desc",
|
||||||
RetentionRules: retentionRules{{
|
RetentionRules: retentionRules{{
|
||||||
|
@ -230,8 +240,10 @@ func TestPkg(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "existing bucket with retention changes",
|
name: "existing bucket with retention changes",
|
||||||
resource: DiffBucket{
|
resource: DiffBucket{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: 3,
|
ID: 3,
|
||||||
PkgName: "existing bucket",
|
PkgName: "existing bucket",
|
||||||
|
},
|
||||||
New: DiffBucketValues{
|
New: DiffBucketValues{
|
||||||
Description: "new desc",
|
Description: "new desc",
|
||||||
RetentionRules: retentionRules{{
|
RetentionRules: retentionRules{{
|
||||||
|
@ -258,7 +270,9 @@ func TestPkg(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "new label",
|
name: "new label",
|
||||||
resource: DiffLabel{
|
resource: DiffLabel{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
PkgName: "new label",
|
PkgName: "new label",
|
||||||
|
},
|
||||||
New: DiffLabelValues{
|
New: DiffLabelValues{
|
||||||
Name: "new label",
|
Name: "new label",
|
||||||
Color: "new color",
|
Color: "new color",
|
||||||
|
@ -270,8 +284,10 @@ func TestPkg(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "existing label with no changes",
|
name: "existing label with no changes",
|
||||||
resource: DiffLabel{
|
resource: DiffLabel{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
PkgName: "existing label",
|
PkgName: "existing label",
|
||||||
|
},
|
||||||
New: DiffLabelValues{
|
New: DiffLabelValues{
|
||||||
Name: "existing label",
|
Name: "existing label",
|
||||||
Color: "color",
|
Color: "color",
|
||||||
|
@ -288,8 +304,10 @@ func TestPkg(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "existing label with changes",
|
name: "existing label with changes",
|
||||||
resource: DiffLabel{
|
resource: DiffLabel{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
PkgName: "existing label",
|
PkgName: "existing label",
|
||||||
|
},
|
||||||
New: DiffLabelValues{
|
New: DiffLabelValues{
|
||||||
Name: "existing label",
|
Name: "existing label",
|
||||||
Color: "color",
|
Color: "color",
|
||||||
|
@ -306,7 +324,9 @@ func TestPkg(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "new variable",
|
name: "new variable",
|
||||||
resource: DiffVariable{
|
resource: DiffVariable{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
PkgName: "new var",
|
PkgName: "new var",
|
||||||
|
},
|
||||||
New: DiffVariableValues{
|
New: DiffVariableValues{
|
||||||
Name: "new var",
|
Name: "new var",
|
||||||
Description: "new desc",
|
Description: "new desc",
|
||||||
|
@ -321,8 +341,10 @@ func TestPkg(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "existing variable no changes",
|
name: "existing variable no changes",
|
||||||
resource: DiffVariable{
|
resource: DiffVariable{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: 2,
|
ID: 2,
|
||||||
PkgName: "new var",
|
PkgName: "new var",
|
||||||
|
},
|
||||||
New: DiffVariableValues{
|
New: DiffVariableValues{
|
||||||
Name: "new var",
|
Name: "new var",
|
||||||
Description: "new desc",
|
Description: "new desc",
|
||||||
|
@ -345,8 +367,10 @@ func TestPkg(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "existing variable with desc changes",
|
name: "existing variable with desc changes",
|
||||||
resource: DiffVariable{
|
resource: DiffVariable{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: 3,
|
ID: 3,
|
||||||
PkgName: "new var",
|
PkgName: "new var",
|
||||||
|
},
|
||||||
New: DiffVariableValues{
|
New: DiffVariableValues{
|
||||||
Name: "new var",
|
Name: "new var",
|
||||||
Description: "new desc",
|
Description: "new desc",
|
||||||
|
@ -368,8 +392,10 @@ func TestPkg(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "existing variable with constant arg changes",
|
name: "existing variable with constant arg changes",
|
||||||
resource: DiffVariable{
|
resource: DiffVariable{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: 3,
|
ID: 3,
|
||||||
PkgName: "new var",
|
PkgName: "new var",
|
||||||
|
},
|
||||||
New: DiffVariableValues{
|
New: DiffVariableValues{
|
||||||
Name: "new var",
|
Name: "new var",
|
||||||
Description: "new desc",
|
Description: "new desc",
|
||||||
|
@ -391,8 +417,10 @@ func TestPkg(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "existing variable with map arg changes",
|
name: "existing variable with map arg changes",
|
||||||
resource: DiffVariable{
|
resource: DiffVariable{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: 3,
|
ID: 3,
|
||||||
PkgName: "new var",
|
PkgName: "new var",
|
||||||
|
},
|
||||||
New: DiffVariableValues{
|
New: DiffVariableValues{
|
||||||
Name: "new var",
|
Name: "new var",
|
||||||
Description: "new desc",
|
Description: "new desc",
|
||||||
|
@ -414,8 +442,10 @@ func TestPkg(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "existing variable with query arg changes",
|
name: "existing variable with query arg changes",
|
||||||
resource: DiffVariable{
|
resource: DiffVariable{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: 3,
|
ID: 3,
|
||||||
PkgName: "new var",
|
PkgName: "new var",
|
||||||
|
},
|
||||||
New: DiffVariableValues{
|
New: DiffVariableValues{
|
||||||
Name: "new var",
|
Name: "new var",
|
||||||
Description: "new desc",
|
Description: "new desc",
|
||||||
|
|
|
@ -83,8 +83,11 @@ func TestService(t *testing.T) {
|
||||||
require.Len(t, diff.Buckets, 2)
|
require.Len(t, diff.Buckets, 2)
|
||||||
|
|
||||||
expected := DiffBucket{
|
expected := DiffBucket{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: SafeID(1),
|
ID: SafeID(1),
|
||||||
PkgName: "rucket_11",
|
PkgName: "rucket_11",
|
||||||
|
},
|
||||||
|
|
||||||
Old: &DiffBucketValues{
|
Old: &DiffBucketValues{
|
||||||
Name: "rucket_11",
|
Name: "rucket_11",
|
||||||
Description: "old desc",
|
Description: "old desc",
|
||||||
|
@ -114,7 +117,9 @@ func TestService(t *testing.T) {
|
||||||
require.Len(t, diff.Buckets, 2)
|
require.Len(t, diff.Buckets, 2)
|
||||||
|
|
||||||
expected := DiffBucket{
|
expected := DiffBucket{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
PkgName: "rucket_11",
|
PkgName: "rucket_11",
|
||||||
|
},
|
||||||
New: DiffBucketValues{
|
New: DiffBucketValues{
|
||||||
Name: "rucket_11",
|
Name: "rucket_11",
|
||||||
Description: "bucket 1 description",
|
Description: "bucket 1 description",
|
||||||
|
@ -190,8 +195,10 @@ func TestService(t *testing.T) {
|
||||||
require.Len(t, diff.Labels, 3)
|
require.Len(t, diff.Labels, 3)
|
||||||
|
|
||||||
expected := DiffLabel{
|
expected := DiffLabel{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
ID: SafeID(1),
|
ID: SafeID(1),
|
||||||
PkgName: "label_1",
|
PkgName: "label_1",
|
||||||
|
},
|
||||||
Old: &DiffLabelValues{
|
Old: &DiffLabelValues{
|
||||||
Name: "label_1",
|
Name: "label_1",
|
||||||
Color: "old color",
|
Color: "old color",
|
||||||
|
@ -228,7 +235,9 @@ func TestService(t *testing.T) {
|
||||||
require.Len(t, diff.Labels, 3)
|
require.Len(t, diff.Labels, 3)
|
||||||
|
|
||||||
expected := DiffLabel{
|
expected := DiffLabel{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
PkgName: "label_1",
|
PkgName: "label_1",
|
||||||
|
},
|
||||||
New: DiffLabelValues{
|
New: DiffLabelValues{
|
||||||
Name: "label_1",
|
Name: "label_1",
|
||||||
Color: "#FFFFFF",
|
Color: "#FFFFFF",
|
||||||
|
@ -287,8 +296,10 @@ func TestService(t *testing.T) {
|
||||||
require.Len(t, existingEndpoints, 1)
|
require.Len(t, existingEndpoints, 1)
|
||||||
|
|
||||||
expected := DiffNotificationEndpoint{
|
expected := DiffNotificationEndpoint{
|
||||||
ID: SafeID(1),
|
DiffIdentifier: DiffIdentifier{
|
||||||
|
ID: 1,
|
||||||
PkgName: "http_none_auth_notification_endpoint",
|
PkgName: "http_none_auth_notification_endpoint",
|
||||||
|
},
|
||||||
Old: &DiffNotificationEndpointValues{
|
Old: &DiffNotificationEndpointValues{
|
||||||
NotificationEndpoint: existing,
|
NotificationEndpoint: existing,
|
||||||
},
|
},
|
||||||
|
@ -404,8 +415,10 @@ func TestService(t *testing.T) {
|
||||||
require.Len(t, diff.Variables, 4)
|
require.Len(t, diff.Variables, 4)
|
||||||
|
|
||||||
expected := DiffVariable{
|
expected := DiffVariable{
|
||||||
ID: SafeID(1),
|
DiffIdentifier: DiffIdentifier{
|
||||||
|
ID: 1,
|
||||||
PkgName: "var_const_3",
|
PkgName: "var_const_3",
|
||||||
|
},
|
||||||
Old: &DiffVariableValues{
|
Old: &DiffVariableValues{
|
||||||
Name: "var_const_3",
|
Name: "var_const_3",
|
||||||
Description: "old desc",
|
Description: "old desc",
|
||||||
|
@ -422,8 +435,10 @@ func TestService(t *testing.T) {
|
||||||
assert.Equal(t, expected, diff.Variables[0])
|
assert.Equal(t, expected, diff.Variables[0])
|
||||||
|
|
||||||
expected = DiffVariable{
|
expected = DiffVariable{
|
||||||
|
DiffIdentifier: DiffIdentifier{
|
||||||
// no ID here since this one would be new
|
// no ID here since this one would be new
|
||||||
PkgName: "var_map_4",
|
PkgName: "var_map_4",
|
||||||
|
},
|
||||||
New: DiffVariableValues{
|
New: DiffVariableValues{
|
||||||
Name: "var_map_4",
|
Name: "var_map_4",
|
||||||
Description: "var_map_4 desc",
|
Description: "var_map_4 desc",
|
||||||
|
|
Loading…
Reference in New Issue