diff --git a/api/v1/canary_types.go b/api/v1/canary_types.go index 957102fcf..ded0bae2a 100644 --- a/api/v1/canary_types.go +++ b/api/v1/canary_types.go @@ -24,6 +24,8 @@ import ( "github.com/flanksource/canary-checker/api/external" "github.com/flanksource/commons/logger" + "github.com/flanksource/duty/models" + "github.com/flanksource/duty/types" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -312,6 +314,52 @@ type Canary struct { Status CanaryStatus `json:"status,omitempty"` } +func (c Canary) ToModel() (models.Canary, error) { + spec, err := json.Marshal(c.Spec) + if err != nil { + return models.Canary{}, err + } + var checks = make(map[string]string) + if c.Status.Checks != nil { + checks = c.Status.Checks + } + + return models.Canary{ + Spec: spec, + Labels: types.JSONStringMap(c.Labels), + Name: c.Name, + Namespace: c.Namespace, + Source: c.Annotations["source"], + Checks: types.JSONStringMap(checks), + }, nil +} + +func CanaryFromModel(c *models.Canary) (*Canary, error) { + canary := Canary{ + ObjectMeta: metav1.ObjectMeta{ + Name: c.Name, + Namespace: c.Namespace, + Annotations: map[string]string{ + "source": c.Source, + }, + Labels: c.Labels, + }, + } + var deletionTimestamp metav1.Time + if c.DeletedAt != nil && !c.DeletedAt.IsZero() { + deletionTimestamp = metav1.NewTime(*c.DeletedAt) + canary.ObjectMeta.DeletionTimestamp = &deletionTimestamp + } + if err := json.Unmarshal(c.Spec, &canary.Spec); err != nil { + return nil, fmt.Errorf("failed to unmarshal spec: %w", err) + } + + id := c.ID.String() + canary.Status.PersistedID = &id + canary.Status.Checks = c.Checks + return &canary, nil +} + func NewCanaryFromSpec(name string, spec CanarySpec) Canary { return Canary{ ObjectMeta: metav1.ObjectMeta{ diff --git a/api/v1/checks.go b/api/v1/checks.go index 629547ac4..08e8ba129 100644 --- a/api/v1/checks.go +++ b/api/v1/checks.go @@ -891,17 +891,11 @@ func (c ConfigDBCheck) GetEndpoint() string { return c.Query } -type ResourceSelector struct { - Name string `yaml:"name,omitempty" json:"name,omitempty"` - LabelSelector string `json:"labelSelector,omitempty" yaml:"labelSelector,omitempty"` - FieldSelector string `json:"fieldSelector,omitempty" yaml:"fieldSelector,omitempty"` -} - type KubernetesCheck struct { Description `yaml:",inline" json:",inline"` Templatable `yaml:",inline" json:",inline"` - Namespace ResourceSelector `yaml:"namespace,omitempty" json:"namespace,omitempty"` - Resource ResourceSelector `yaml:"resource,omitempty" json:"resource,omitempty"` + Namespace types.ResourceSelector `yaml:"namespace,omitempty" json:"namespace,omitempty"` + Resource types.ResourceSelector `yaml:"resource,omitempty" json:"resource,omitempty"` // Ignore the specified resources from the fetched resources. Can be a glob pattern. Ignore []string `yaml:"ignore,omitempty" json:"ignore,omitempty"` Kind string `yaml:"kind" json:"kind"` diff --git a/api/v1/component_types.go b/api/v1/component_types.go index 2b1c5caf3..ab7bf7982 100644 --- a/api/v1/component_types.go +++ b/api/v1/component_types.go @@ -2,8 +2,8 @@ package v1 import ( "fmt" - "strings" + "github.com/flanksource/duty/models" "github.com/flanksource/duty/types" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -39,12 +39,12 @@ type ComponentSpec struct { // Create new child components Components []ComponentSpecObject `json:"components,omitempty"` // Lookup and associcate other components with this component - Selectors ResourceSelectors `json:"selectors,omitempty"` - ComponentChecks ComponentChecks `json:"checks,omitempty"` + Selectors types.ResourceSelectors `json:"selectors,omitempty"` + ComponentChecks ComponentChecks `json:"checks,omitempty"` // Lookup and associate config items with this component - Configs []Config `json:"configs,omitempty"` + Configs Configs `json:"configs,omitempty"` // - Summary *Summary `json:"summary,omitempty"` + Summary *types.Summary `json:"summary,omitempty"` // Only applies when using lookup, when specified the components and properties // specified under ForEach will be templated using the components returned by the lookup // ${.properties} can be used to reference the properties of the component @@ -70,11 +70,11 @@ type ForEach struct { // Properties are created once the full component tree is created, property lookup functions // can return a map of coomponent name => properties to allow for bulk property lookups // being applied to multiple components in the tree - Properties Properties `json:"properties,omitempty"` - Configs []Config `json:"configs,omitempty"` - Selectors ResourceSelectors `json:"selectors,omitempty"` - Relationships []RelationshipSpec `json:"relationships,omitempty"` - ComponentChecks ComponentChecks `json:"checks,omitempty"` + Properties Properties `json:"properties,omitempty"` + Configs []Config `json:"configs,omitempty"` + Selectors types.ResourceSelectors `json:"selectors,omitempty"` + Relationships []RelationshipSpec `json:"relationships,omitempty"` + ComponentChecks ComponentChecks `json:"checks,omitempty"` } func (f *ForEach) IsEmpty() bool { @@ -85,57 +85,6 @@ func (f *ForEach) String() string { return fmt.Sprintf("ForEach(components=%d, properties=%d)", len(f.Components), len(f.Properties)) } -type Summary struct { - Healthy int `json:"healthy,omitempty"` - Unhealthy int `json:"unhealthy,omitempty"` - Warning int `json:"warning,omitempty"` - Info int `json:"info,omitempty"` - Incidents map[string]map[string]int `json:"incidents,omitempty"` - Insights map[string]map[string]int `json:"insights,omitempty"` -} - -func (s Summary) String() string { - str := "" - if s.Unhealthy > 0 { - str += fmt.Sprintf("unhealthy=%d ", s.Unhealthy) - } - if s.Warning > 0 { - str += fmt.Sprintf("warning=%d ", s.Warning) - } - if s.Healthy > 0 { - str += fmt.Sprintf("healthy=%d ", s.Healthy) - } - return strings.TrimSpace(str) -} - -func (s Summary) GetStatus() ComponentPropertyStatus { - if s.Unhealthy > 0 { - return ComponentPropertyStatusUnhealthy - } else if s.Warning > 0 { - return ComponentPropertyStatusWarning - } else if s.Healthy > 0 { - return ComponentPropertyStatusHealthy - } - return "unknown" -} - -func (s Summary) Add(b Summary) Summary { - if b.Healthy > 0 && b.Unhealthy > 0 { - s.Warning += 1 - } else if b.Unhealthy > 0 { - s.Unhealthy += 1 - } else if b.Healthy > 0 { - s.Healthy += 1 - } - if b.Warning > 0 { - s.Warning += b.Warning - } - if b.Info > 0 { - s.Info += b.Info - } - return s -} - type ComponentStatus struct { Status ComponentPropertyStatus `json:"status,omitempty"` } @@ -165,13 +114,6 @@ type Text struct { Label string `json:"label,omitempty"` } -type Link struct { - // e.g. documentation, support, playbook - Type string `json:"type,omitempty"` - URL string `json:"url,omitempty"` - Text `json:",inline"` -} - type Properties []Property type Property struct { @@ -185,19 +127,40 @@ type Property struct { Type string `json:"type,omitempty"` Color string `json:"color,omitempty"` // e.g. milliseconds, bytes, millicores, epoch etc. - Unit string `json:"unit,omitempty"` - Value int64 `json:"value,omitempty"` - Max *int64 `json:"max,omitempty"` - Min int64 `json:"min,omitempty"` - Status string `json:"status,omitempty"` - LastTransition string `json:"lastTransition,omitempty"` - Links []Link `json:"links,omitempty"` + Unit string `json:"unit,omitempty"` + Value int64 `json:"value,omitempty"` + Max *int64 `json:"max,omitempty"` + Min int64 `json:"min,omitempty"` + Status string `json:"status,omitempty"` + LastTransition string `json:"lastTransition,omitempty"` + Links []models.Link `json:"links,omitempty"` // +kubebuilder:validation:XPreserveUnknownFields Lookup *CanarySpec `json:"lookup,omitempty"` ConfigLookup *ConfigLookup `json:"configLookup,omitempty"` Summary *Template `json:"summary,omitempty"` } +func (p Property) ToModel() *models.Property { + return &models.Property{ + Label: p.Label, + Name: p.Name, + Tooltip: p.Tooltip, + Icon: p.Icon, + Order: p.Order, + Text: p.Text, + Value: p.Value, + Unit: p.Unit, + Max: p.Max, + Min: p.Min, + Status: p.Status, + LastTransition: p.LastTransition, + Links: p.Links, + Headline: p.Headline, + Type: p.Type, + Color: p.Color, + } +} + func (p *Property) String() string { if p.Label != "" { return p.Label diff --git a/api/v1/db_types.go b/api/v1/db_types.go index 305ad9513..8b90db154 100644 --- a/api/v1/db_types.go +++ b/api/v1/db_types.go @@ -16,61 +16,13 @@ const ( SQLServerType = "sqlserver" PostgresType = "postgres" SqliteType = "sqlite" - text = "TEXT" jsonType = "json" jsonbType = "JSONB" nvarcharType = "NVARCHAR(MAX)" ) -type ResourceSelectors []ResourceSelector - type ComponentChecks []ComponentCheck -func (rs ResourceSelectors) Value() (driver.Value, error) { - if len(rs) == 0 { - return []byte("[]"), nil - } - return json.Marshal(rs) -} - -func (rs *ResourceSelectors) Scan(val interface{}) error { - if val == nil { - *rs = ResourceSelectors{} - return nil - } - var ba []byte - switch v := val.(type) { - case []byte: - ba = v - default: - return errors.New(fmt.Sprint("Failed to unmarshal ResourceSelectors value:", val)) - } - return json.Unmarshal(ba, rs) -} - -// GormDataType gorm common data type -func (rs ResourceSelectors) GormDataType() string { - return "resourceSelectors" -} - -// GormDBDataType gorm db data type -func (ResourceSelectors) GormDBDataType(db *gorm.DB, field *schema.Field) string { - switch db.Dialector.Name() { - case SqliteType: - return jsonType - case PostgresType: - return jsonbType - case SQLServerType: - return nvarcharType - } - return "" -} - -func (rs ResourceSelectors) GormValue(ctx context.Context, db *gorm.DB) clause.Expr { - data, _ := json.Marshal(rs) - return gorm.Expr("?", string(data)) -} - func (cs ComponentChecks) Value() (driver.Value, error) { if len(cs) == 0 { return []byte("[]"), nil @@ -115,47 +67,3 @@ func (cs ComponentChecks) GormValue(ctx context.Context, db *gorm.DB) clause.Exp data, _ := json.Marshal(cs) return gorm.Expr("?", string(data)) } - -// Scan scan value into Jsonb, implements sql.Scanner interface -func (s Summary) Value() (driver.Value, error) { - return json.Marshal(s) -} - -// Scan scan value into Jsonb, implements sql.Scanner interface -func (s *Summary) Scan(val interface{}) error { - if val == nil { - *s = Summary{} - return nil - } - var ba []byte - switch v := val.(type) { - case []byte: - ba = v - default: - return errors.New(fmt.Sprint("Failed to unmarshal properties value:", val)) - } - err := json.Unmarshal(ba, s) - return err -} - -// GormDataType gorm common data type -func (Summary) GormDataType() string { - return "summary" -} - -func (Summary) GormDBDataType(db *gorm.DB, field *schema.Field) string { - switch db.Dialector.Name() { - case SqliteType: - return text - case PostgresType: - return jsonbType - case SQLServerType: - return nvarcharType - } - return "" -} - -func (s Summary) GormValue(ctx context.Context, db *gorm.DB) clause.Expr { - data, _ := json.Marshal(s) - return gorm.Expr("?", data) -} diff --git a/api/v1/system_types.go b/api/v1/system_types.go index cef978895..c9fd2233f 100644 --- a/api/v1/system_types.go +++ b/api/v1/system_types.go @@ -1,9 +1,14 @@ package v1 import ( + "encoding/json" "fmt" + "github.com/flanksource/commons/logger" + "github.com/flanksource/duty/models" + "github.com/flanksource/duty/types" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + k8sTypes "k8s.io/apimachinery/pkg/types" ) // +kubebuilder:object:root=true @@ -15,6 +20,46 @@ type Topology struct { Spec TopologySpec `json:"spec,omitempty"` Status TopologyStatus `json:"status,omitempty"` } + +func (t *Topology) ToModel() *models.Topology { + spec, _ := json.Marshal(t.Spec) + return &models.Topology{ + Name: t.GetName(), + Namespace: t.GetNamespace(), + Labels: types.JSONStringMap(t.GetLabels()), + Spec: spec, + } +} + +func (t Topology) IsEmpty() bool { + return len(t.Spec.Properties) == 0 && len(t.Spec.Components) == 0 && t.Name == "" +} + +func (t Topology) GetPersistedID() string { + return string(t.GetUID()) +} + +func TopologyFromModels(t models.Topology) Topology { + var topologySpec TopologySpec + id := t.ID.String() + if err := json.Unmarshal(t.Spec, &topologySpec); err != nil { + logger.Errorf("error unmarshalling topology spec %s", err) + } + return Topology{ + TypeMeta: metav1.TypeMeta{ + Kind: "Topology", + APIVersion: "canaries.flanksource.com/v1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: t.Name, + Namespace: t.Namespace, + Labels: t.Labels, + UID: k8sTypes.UID(id), + }, + Spec: topologySpec, + } +} + type TopologySpec struct { Type string `json:"type,omitempty"` Id *Template `json:"id,omitempty"` //nolint @@ -33,10 +78,6 @@ type TopologySpec struct { Configs []Config `json:"configs,omitempty"` } -func (s Topology) IsEmpty() bool { - return len(s.Spec.Properties) == 0 && len(s.Spec.Components) == 0 && s.Name == "" -} - func (spec TopologySpec) GetSchedule() string { return spec.Schedule } @@ -48,10 +89,6 @@ type TopologyStatus struct { Status string `json:"status,omitempty"` } -func (s Topology) GetPersistedID() string { - return string(s.GetUID()) -} - type Selector struct { Name string `json:"name,omitempty"` Labels map[string]string `json:"labels,omitempty"` @@ -62,7 +99,7 @@ type NamespaceSelector struct { } type ComponentCheck struct { - Selector ResourceSelector `json:"selector,omitempty"` + Selector types.ResourceSelector `json:"selector,omitempty"` // +kubebuilder:validation:XPreserveUnknownFields Inline *CanarySpec `json:"inline,omitempty"` } @@ -75,6 +112,16 @@ type Config struct { Tags map[string]string `json:"tags,omitempty"` } +func (c Config) ToModel() *types.ConfigQuery { + return &types.ConfigQuery{ + ID: c.ID, + Type: c.Type, + Name: c.Name, + Namespace: c.Namespace, + Tags: c.Tags, + } +} + func (c Config) String() string { s := c.Type if c.Namespace != "" { @@ -90,6 +137,17 @@ func (c Config) String() string { return s } +type Configs []*Config + +func (c Configs) ToModel() types.ConfigQueries { + queries := make(types.ConfigQueries, len(c)) + for i, c := range c { + queries[i] = c.ToModel() + } + + return queries +} + // +kubebuilder:object:root=true // TopologyList contains a list of Topology diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index dd81818e0..d45b0df46 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -23,6 +23,7 @@ package v1 import ( "encoding/json" + "github.com/flanksource/duty/models" "github.com/flanksource/duty/types" "github.com/flanksource/kommons" corev1 "k8s.io/api/core/v1" @@ -921,7 +922,7 @@ func (in *ComponentSpec) DeepCopyInto(out *ComponentSpec) { } if in.Selectors != nil { in, out := &in.Selectors, &out.Selectors - *out = make(ResourceSelectors, len(*in)) + *out = make(types.ResourceSelectors, len(*in)) copy(*out, *in) } if in.ComponentChecks != nil { @@ -933,14 +934,18 @@ func (in *ComponentSpec) DeepCopyInto(out *ComponentSpec) { } if in.Configs != nil { in, out := &in.Configs, &out.Configs - *out = make([]Config, len(*in)) + *out = make(Configs, len(*in)) for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(Config) + (*in).DeepCopyInto(*out) + } } } if in.Summary != nil { in, out := &in.Summary, &out.Summary - *out = new(Summary) + *out = new(types.Summary) (*in).DeepCopyInto(*out) } if in.ForEach != nil { @@ -1005,7 +1010,7 @@ func (in *ComponentSpecObject) DeepCopyInto(out *ComponentSpecObject) { } if in.Selectors != nil { in, out := &in.Selectors, &out.Selectors - *out = make(ResourceSelectors, len(*in)) + *out = make(types.ResourceSelectors, len(*in)) copy(*out, *in) } if in.ComponentChecks != nil { @@ -1017,14 +1022,18 @@ func (in *ComponentSpecObject) DeepCopyInto(out *ComponentSpecObject) { } if in.Configs != nil { in, out := &in.Configs, &out.Configs - *out = make([]Config, len(*in)) + *out = make(Configs, len(*in)) for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(Config) + (*in).DeepCopyInto(*out) + } } } if in.Summary != nil { in, out := &in.Summary, &out.Summary - *out = new(Summary) + *out = new(types.Summary) (*in).DeepCopyInto(*out) } if in.ForEach != nil { @@ -1163,6 +1172,31 @@ func (in *ConfigLookup) DeepCopy() *ConfigLookup { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in Configs) DeepCopyInto(out *Configs) { + { + in := &in + *out = make(Configs, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(Config) + (*in).DeepCopyInto(*out) + } + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Configs. +func (in Configs) DeepCopy() Configs { + if in == nil { + return nil + } + out := new(Configs) + in.DeepCopyInto(out) + return *out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Connection) DeepCopyInto(out *Connection) { *out = *in @@ -1684,7 +1718,7 @@ func (in *ForEach) DeepCopyInto(out *ForEach) { } if in.Selectors != nil { in, out := &in.Selectors, &out.Selectors - *out = make(ResourceSelectors, len(*in)) + *out = make(types.ResourceSelectors, len(*in)) copy(*out, *in) } if in.Relationships != nil { @@ -2108,22 +2142,6 @@ func (in Labels) DeepCopy() Labels { return *out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Link) DeepCopyInto(out *Link) { - *out = *in - out.Text = in.Text -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Link. -func (in *Link) DeepCopy() *Link { - if in == nil { - return nil - } - out := new(Link) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Mongo) DeepCopyInto(out *Mongo) { *out = *in @@ -2405,7 +2423,7 @@ func (in *Property) DeepCopyInto(out *Property) { } if in.Links != nil { in, out := &in.Links, &out.Links - *out = make([]Link, len(*in)) + *out = make([]models.Link, len(*in)) copy(*out, *in) } if in.Lookup != nil { @@ -2487,40 +2505,6 @@ func (in *RelationshipSpec) DeepCopy() *RelationshipSpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResourceSelector) DeepCopyInto(out *ResourceSelector) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceSelector. -func (in *ResourceSelector) DeepCopy() *ResourceSelector { - if in == nil { - return nil - } - out := new(ResourceSelector) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in ResourceSelectors) DeepCopyInto(out *ResourceSelectors) { - { - in := &in - *out = make(ResourceSelectors, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceSelectors. -func (in ResourceSelectors) DeepCopy() ResourceSelectors { - if in == nil { - return nil - } - out := new(ResourceSelectors) - in.DeepCopyInto(out) - return *out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Restic) DeepCopyInto(out *Restic) { *out = *in @@ -2696,55 +2680,6 @@ func (in *SrvReply) DeepCopy() *SrvReply { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Summary) DeepCopyInto(out *Summary) { - *out = *in - if in.Incidents != nil { - in, out := &in.Incidents, &out.Incidents - *out = make(map[string]map[string]int, len(*in)) - for key, val := range *in { - var outVal map[string]int - if val == nil { - (*out)[key] = nil - } else { - in, out := &val, &outVal - *out = make(map[string]int, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - (*out)[key] = outVal - } - } - if in.Insights != nil { - in, out := &in.Insights, &out.Insights - *out = make(map[string]map[string]int, len(*in)) - for key, val := range *in { - var outVal map[string]int - if val == nil { - (*out)[key] = nil - } else { - in, out := &val, &outVal - *out = make(map[string]int, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - (*out)[key] = outVal - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Summary. -func (in *Summary) DeepCopy() *Summary { - if in == nil { - return nil - } - out := new(Summary) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TCP) DeepCopyInto(out *TCP) { *out = *in diff --git a/cmd/topology.go b/cmd/topology.go index 416bbf1b6..77fedf558 100644 --- a/cmd/topology.go +++ b/cmd/topology.go @@ -9,6 +9,7 @@ import ( "github.com/flanksource/commons/timer" "github.com/flanksource/duty" + "github.com/flanksource/duty/models" "github.com/spf13/cobra" @@ -97,7 +98,7 @@ var RunTopology = &cobra.Command{ opts := getTopologyRunOptions(10) - var results = []*pkg.Component{} + var results = []*models.Component{} wg := sync.WaitGroup{} diff --git a/go.mod b/go.mod index 9a3b9bf10..ef277d728 100644 --- a/go.mod +++ b/go.mod @@ -8,14 +8,14 @@ require ( github.com/allegro/bigcache v1.2.1 github.com/antonmedv/expr v1.12.5 github.com/asecurityteam/rolling v2.0.4+incompatible - github.com/aws/aws-sdk-go v1.44.256 + github.com/aws/aws-sdk-go v1.44.260 github.com/aws/aws-sdk-go-v2 v1.18.0 - github.com/aws/aws-sdk-go-v2/config v1.18.22 - github.com/aws/aws-sdk-go-v2/credentials v1.13.21 + github.com/aws/aws-sdk-go-v2/config v1.18.25 + github.com/aws/aws-sdk-go-v2/credentials v1.13.24 github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.8.1 github.com/aws/aws-sdk-go-v2/service/configservice v1.31.3 github.com/aws/aws-sdk-go-v2/service/ec2 v1.12.0 - github.com/aws/aws-sdk-go-v2/service/s3 v1.33.0 + github.com/aws/aws-sdk-go-v2/service/s3 v1.33.1 github.com/aws/aws-sdk-go-v2/service/ssm v1.35.2 github.com/c2h5oh/datasize v0.0.0-20200825124411-48ed595a09d2 github.com/dynatrace-ace/dynatrace-go-api-client/api/v2/environment/dynatrace v0.0.0-20210816162345-de2eacc8ac9a @@ -40,7 +40,6 @@ require ( github.com/joshdk/go-junit v0.0.0-20210226021600-6145f504ca0d github.com/jszwec/csvutil v1.8.0 github.com/labstack/echo/v4 v4.9.1 - github.com/liamylian/jsontime/v2 v2.0.0 github.com/lib/pq v1.10.9 github.com/microsoft/azure-devops-go-api/azuredevops/v7 v7.1.0 github.com/microsoft/go-mssqldb v0.21.0 @@ -62,12 +61,12 @@ require ( github.com/vadimi/go-http-ntlm/v2 v2.4.1 go.mongodb.org/mongo-driver v1.11.6 golang.org/x/crypto v0.8.0 - golang.org/x/net v0.9.0 - golang.org/x/sync v0.1.0 + golang.org/x/net v0.10.0 + golang.org/x/sync v0.2.0 google.golang.org/api v0.121.0 google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 gopkg.in/flanksource/yaml.v3 v3.2.2 - gorm.io/gorm v1.25.0 + gorm.io/gorm v1.25.1 gorm.io/plugin/prometheus v0.0.0-20220517015831-ca6bfaf20bf4 k8s.io/api v0.26.4 k8s.io/apimachinery v0.26.4 @@ -77,11 +76,11 @@ require ( ) require ( - ariga.io/atlas v0.10.1 // indirect - cloud.google.com/go v0.110.1 // indirect - cloud.google.com/go/compute v1.19.1 // indirect + ariga.io/atlas v0.11.0 // indirect + cloud.google.com/go v0.110.2 // indirect + cloud.google.com/go/compute v1.19.2 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect - cloud.google.com/go/iam v1.0.0 // indirect + cloud.google.com/go/iam v1.0.1 // indirect github.com/AlekSi/pointer v1.1.0 // indirect github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c // indirect github.com/Masterminds/goutils v1.1.1 // indirect @@ -100,7 +99,7 @@ require ( github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3 // indirect - github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.64 // indirect + github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.67 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33 // indirect github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.3.34 // indirect @@ -109,9 +108,9 @@ require ( github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.28 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.27 // indirect github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.2 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.12.9 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.9 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.18.10 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.12.10 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.10 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.19.0 // indirect github.com/aws/smithy-go v1.13.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect @@ -199,6 +198,7 @@ require ( github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/labstack/gommon v0.4.0 // indirect + github.com/liamylian/jsontime/v2 v2.0.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.18 // indirect @@ -258,16 +258,16 @@ require ( go.uber.org/zap v1.24.0 // indirect gocloud.dev v0.29.0 // indirect golang.org/x/mod v0.10.0 // indirect - golang.org/x/oauth2 v0.7.0 // indirect - golang.org/x/sys v0.7.0 // indirect - golang.org/x/term v0.7.0 // indirect + golang.org/x/oauth2 v0.8.0 // indirect + golang.org/x/sys v0.8.0 // indirect + golang.org/x/term v0.8.0 // indirect golang.org/x/text v0.9.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.8.0 // indirect + golang.org/x/tools v0.9.1 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/grpc v1.54.0 // indirect + google.golang.org/grpc v1.55.0 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect @@ -283,7 +283,7 @@ require ( k8s.io/component-base v0.26.0 // indirect k8s.io/klog/v2 v2.100.1 // indirect k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect - k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect + k8s.io/utils v0.0.0-20230505201702-9f6742963106 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/kustomize v2.0.3+incompatible // indirect sigs.k8s.io/kustomize/api v0.12.1 // indirect diff --git a/go.sum b/go.sum index deecce3bf..bd4514e89 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -ariga.io/atlas v0.10.1 h1:zub8+r1P4OqUYoDl6AgUxqPRwl8A9oeI5q3LucfsnUE= -ariga.io/atlas v0.10.1/go.mod h1:+TR129FJZ5Lvzms6dvCeGWh1yR6hMvmXBhug4hrNIGk= +ariga.io/atlas v0.11.0 h1:aGR7MzsUfmdlDYCpRErQeY2NSuRlPE0/q6drNE/5buM= +ariga.io/atlas v0.11.0/go.mod h1:+TR129FJZ5Lvzms6dvCeGWh1yR6hMvmXBhug4hrNIGk= bazil.org/fuse v0.0.0-20160811212531-371fbbdaa898/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8= bazil.org/fuse v0.0.0-20200407214033-5883e5a4b512/go.mod h1:FbcW6z/2VytnFDhZfumh8Ss8zxHE6qpMP5sHTRe0EaM= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= @@ -41,8 +41,8 @@ cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRY cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM= cloud.google.com/go v0.107.0/go.mod h1:wpc2eNrD7hXUTy8EKS10jkxpZBjASrORK7goS+3YX2I= cloud.google.com/go v0.109.0/go.mod h1:2sYycXt75t/CSB5R9M2wPU1tJmire7AQZTPtITcGBVE= -cloud.google.com/go v0.110.1 h1:oDJ19Fu9TX9Xs06iyCw4yifSqZ7JQ8BeuVHcTmWQlOA= -cloud.google.com/go v0.110.1/go.mod h1:uc+V/WjzxQ7vpkxfJhgW4Q4axWXyfAerpQOuSNDZyFw= +cloud.google.com/go v0.110.2 h1:sdFPBr6xG9/wkBbfhmUz/JmZC7X6LavQgcrVINrKiVA= +cloud.google.com/go v0.110.2/go.mod h1:k04UEeEtb6ZBRTv3dZz4CeJC3jKGxyhl0sAiVVquxiw= cloud.google.com/go/accessapproval v1.4.0/go.mod h1:zybIuC3KpDOvotz59lFe5qxRZx6C75OtwbisN56xYB4= cloud.google.com/go/accessapproval v1.5.0/go.mod h1:HFy3tuiGvMdcd/u+Cu5b9NkO1pEICJ46IR82PoUdplw= cloud.google.com/go/accesscontextmanager v1.3.0/go.mod h1:TgCBehyr5gNMz7ZaH9xubp+CE8dkrszb4oK9CWyvD4o= @@ -127,8 +127,8 @@ cloud.google.com/go/compute v1.13.0/go.mod h1:5aPTS0cUNMIc1CE546K+Th6weJUNQErARy cloud.google.com/go/compute v1.14.0/go.mod h1:YfLtxrj9sU4Yxv+sXzZkyPjEyPBZfXHUvjxega5vAdo= cloud.google.com/go/compute v1.15.1/go.mod h1:bjjoF/NtFUrkD/urWfdHaKuOPDR5nWIs63rR+SXhcpA= cloud.google.com/go/compute v1.18.0/go.mod h1:1X7yHxec2Ga+Ss6jPyjxRxpu2uu7PLgsOVXvgU0yacs= -cloud.google.com/go/compute v1.19.1 h1:am86mquDUgjGNWxiGn+5PGLbmgiWXlE/yNWpIpNvuXY= -cloud.google.com/go/compute v1.19.1/go.mod h1:6ylj3a05WF8leseCdIf77NK0g1ey+nj5IKd5/kvShxE= +cloud.google.com/go/compute v1.19.2 h1:GbJtPo8OKVHbVep8jvM57KidbYHxeE68LOVqouNLrDY= +cloud.google.com/go/compute v1.19.2/go.mod h1:5f5a+iC1IriXYauaQ0EyQmEAEq9CGRnV5xJSQSlTV08= cloud.google.com/go/compute/metadata v0.1.0/go.mod h1:Z1VN+bulIf6bt4P/C37K4DyZYZEXYonfTBHHFPO/4UU= cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM= @@ -223,8 +223,8 @@ cloud.google.com/go/iam v0.6.0/go.mod h1:+1AH33ueBne5MzYccyMHtEKqLE4/kJOibtffMHD cloud.google.com/go/iam v0.7.0/go.mod h1:H5Br8wRaDGNc8XP3keLc4unfUUZeyH3Sfl9XpQEYOeg= cloud.google.com/go/iam v0.8.0/go.mod h1:lga0/y3iH6CX7sYqypWJ33hf7kkfXJag67naqGESjkE= cloud.google.com/go/iam v0.10.0/go.mod h1:nXAECrMt2qHpF6RZUZseteD6QyanL68reN4OXPw0UWM= -cloud.google.com/go/iam v1.0.0 h1:hlQJMovyJJwYjZcTohUH4o1L8Z8kYz+E+W/zktiLCBc= -cloud.google.com/go/iam v1.0.0/go.mod h1:ikbQ4f1r91wTmBmmOtBCOtuEOei6taatNXytzB7Cxew= +cloud.google.com/go/iam v1.0.1 h1:lyeCAU6jpnVNrE9zGQkTl3WgNgK/X+uWwaw0kynZJMU= +cloud.google.com/go/iam v1.0.1/go.mod h1:yR3tmSL8BcZB4bxByRv2jkSIahVmCtfKZwLYGBalRE8= cloud.google.com/go/iap v1.4.0/go.mod h1:RGFwRJdihTINIe4wZ2iCP0zF/qu18ZwyKxrhMhygBEc= cloud.google.com/go/iap v1.5.0/go.mod h1:UH/CGgKd4KyohZL5Pt0jSKE4m3FR51qg6FKQ/z/Ix9A= cloud.google.com/go/ids v1.1.0/go.mod h1:WIuwCaYVOzHIj2OhN9HAwvW+DBdmUAdcWlFxRl+KubM= @@ -635,8 +635,8 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX github.com/aws/aws-sdk-go v1.44.156/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go v1.44.187/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go v1.44.200/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.44.256 h1:O8VH+bJqgLDguqkH/xQBFz5o/YheeZqgcOYIgsTVWY4= -github.com/aws/aws-sdk-go v1.44.256/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.260 h1:78IJkDpDPXvLXvIkNAKDP/i3z8Vj+3sTAtQYw/v/2o8= +github.com/aws/aws-sdk-go v1.44.260/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/aws/aws-sdk-go-v2 v1.7.1/go.mod h1:L5LuPC1ZgDr2xQS7AmIec/Jlc7O/Y1u2KxJyNVab250= github.com/aws/aws-sdk-go-v2 v1.9.1/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= @@ -652,13 +652,13 @@ github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10/go.mod h1:VeTZetY5 github.com/aws/aws-sdk-go-v2/config v1.15.3/go.mod h1:9YL3v07Xc/ohTsxFXzan9ZpFpdTOFl4X65BAKYaz8jg= github.com/aws/aws-sdk-go-v2/config v1.17.7/go.mod h1:dN2gja/QXxFF15hQreyrqYhLBaQo1d9ZKe/v/uplQoI= github.com/aws/aws-sdk-go-v2/config v1.18.12/go.mod h1:J36fOhj1LQBr+O4hJCiT8FwVvieeoSGOtPuvhKlsNu8= -github.com/aws/aws-sdk-go-v2/config v1.18.22 h1:7vkUEmjjv+giht4wIROqLs+49VWmiQMMHSduxmoNKLU= -github.com/aws/aws-sdk-go-v2/config v1.18.22/go.mod h1:mN7Li1wxaPxSSy4Xkr6stFuinJGf3VZW3ZSNvO0q6sI= +github.com/aws/aws-sdk-go-v2/config v1.18.25 h1:JuYyZcnMPBiFqn87L2cRppo+rNwgah6YwD3VuyvaW6Q= +github.com/aws/aws-sdk-go-v2/config v1.18.25/go.mod h1:dZnYpD5wTW/dQF0rRNLVypB396zWCcPiBIvdvSWHEg4= github.com/aws/aws-sdk-go-v2/credentials v1.11.2/go.mod h1:j8YsY9TXTm31k4eFhspiQicfXPLZ0gYXA50i4gxPE8g= github.com/aws/aws-sdk-go-v2/credentials v1.12.20/go.mod h1:UKY5HyIux08bbNA7Blv4PcXQ8cTkGh7ghHMFklaviR4= github.com/aws/aws-sdk-go-v2/credentials v1.13.12/go.mod h1:37HG2MBroXK3jXfxVGtbM2J48ra2+Ltu+tmwr/jO0KA= -github.com/aws/aws-sdk-go-v2/credentials v1.13.21 h1:VRiXnPEaaPeGeoFcXvMZOB5K/yfIXOYE3q97Kgb0zbU= -github.com/aws/aws-sdk-go-v2/credentials v1.13.21/go.mod h1:90Dk1lJoMyspa/EDUrldTxsPns0wn6+KpRKpdAWc0uA= +github.com/aws/aws-sdk-go-v2/credentials v1.13.24 h1:PjiYyls3QdCrzqUN35jMWtUK1vqVZ+zLfdOa/UPFDp0= +github.com/aws/aws-sdk-go-v2/credentials v1.13.24/go.mod h1:jYPYi99wUOPIFi0rhiOvXeSEReVOzBqFNOX5bXYoG2o= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.3/go.mod h1:uk1vhHHERfSVCUnqSqz8O48LBYDSC+k6brng09jcMOk= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.17/go.mod h1:yIkQcCDYNsZfXpd5UX2Cy+sWA1jPgIhGTw9cOBzfVnQ= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.22/go.mod h1:YGSIJyQ6D6FjKMQh16hVFSIUD54L4F7zTGePqYMYYJU= @@ -667,8 +667,8 @@ github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3/go.mod h1:4Q0UFP0YJf0NrsEu github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.3/go.mod h1:0dHuD2HZZSiwfJSy1FO5bX1hQ1TxVV1QXXjpn3XUE44= github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.33/go.mod h1:84XgODVR8uRhmOnUkKGUZKqIMxmjmLOR8Uyp7G/TPwc= github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.51/go.mod h1:7Grl2gV+dx9SWrUIgwwlUvU40t7+lOSbx34XwfmsTkY= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.64 h1:9QJQs36z61YB8nxGwRDfWXEDYbU6H7jdI6zFiAX1vag= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.64/go.mod h1:4Q7R9MFpXRdjO3YnAfUTdnuENs32WzBkASt6VxSYDYQ= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.67 h1:fI9/5BDEaAv/pv1VO1X1n3jfP9it+IGqWsCuuBQI8wM= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.67/go.mod h1:zQClPRIwQZfJlZq6WZve+s4Tb4JW+3V6eS+4+KrYeP8= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.9/go.mod h1:AnVH5pvai0pAF4lXRq0bmhbes1u9R8wTE+g+183bZNM= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.23/go.mod h1:2DFxAQ9pfIRy0imBCJv+vZ2X6RKxves6fbnEuSry6b4= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.28/go.mod h1:3lwChorpIM/BhImY/hy+Z6jekmN92cXGPI1QJasVPYY= @@ -719,8 +719,8 @@ github.com/aws/aws-sdk-go-v2/service/kms v1.20.2/go.mod h1:vdqtUOdVuf5ooy+hJ2Gnz github.com/aws/aws-sdk-go-v2/service/s3 v1.26.3/go.mod h1:g1qvDuRsJY+XghsV6zg00Z4KJ7DtFFCx8fJD2a491Ak= github.com/aws/aws-sdk-go-v2/service/s3 v1.27.11/go.mod h1:fmgDANqTUCxciViKl9hb/zD5LFbvPINFRgWhDbR+vZo= github.com/aws/aws-sdk-go-v2/service/s3 v1.30.2/go.mod h1:SXDHd6fI2RhqB7vmAzyYQCTQnpZrIprVJvYxpzW3JAM= -github.com/aws/aws-sdk-go-v2/service/s3 v1.33.0 h1:L5h2fymEdVJYvn6hYO8Jx48YmC6xVmjmgHJV3oGKgmc= -github.com/aws/aws-sdk-go-v2/service/s3 v1.33.0/go.mod h1:J9kLNzEiHSeGMyN7238EjJmBpCniVzFda75Gxl/NqB8= +github.com/aws/aws-sdk-go-v2/service/s3 v1.33.1 h1:O+9nAy9Bb6bJFTpeNFtd9UfHbgxO1o4ZDAM9rQp5NsY= +github.com/aws/aws-sdk-go-v2/service/s3 v1.33.1/go.mod h1:J9kLNzEiHSeGMyN7238EjJmBpCniVzFda75Gxl/NqB8= github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.15.4/go.mod h1:PJc8s+lxyU8rrre0/4a0pn2wgwiDvOEzoOjcJUBr67o= github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.18.3/go.mod h1:hqPcyOuLU6yWIbLy3qMnQnmidgKuIEwqIlW6+chYnog= github.com/aws/aws-sdk-go-v2/service/sns v1.17.4/go.mod h1:kElt+uCcXxcqFyc+bQqZPFD9DME/eC6oHBXvFzQ9Bcw= @@ -733,17 +733,17 @@ github.com/aws/aws-sdk-go-v2/service/ssm v1.35.2/go.mod h1:VLSz2SHUKYFSOlXB/GlXo github.com/aws/aws-sdk-go-v2/service/sso v1.11.3/go.mod h1:7UQ/e69kU7LDPtY40OyoHYgRmgfGM4mgsLYtcObdveU= github.com/aws/aws-sdk-go-v2/service/sso v1.11.23/go.mod h1:/w0eg9IhFGjGyyncHIQrXtU8wvNsTJOP0R6PPj0wf80= github.com/aws/aws-sdk-go-v2/service/sso v1.12.1/go.mod h1:IgV8l3sj22nQDd5qcAGY0WenwCzCphqdbFOpfktZPrI= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.9 h1:GAiaQWuQhQQui76KjuXeShmyXqECwQ0mGRMc/rwsL+c= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.9/go.mod h1:ouy2P4z6sJN70fR3ka3wD3Ro3KezSxU6eKGQI2+2fjI= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.10 h1:UBQjaMTCKwyUYwiVnUt6toEJwGXsLBI6al083tpjJzY= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.10/go.mod h1:ouy2P4z6sJN70fR3ka3wD3Ro3KezSxU6eKGQI2+2fjI= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.5/go.mod h1:csZuQY65DAdFBt1oIjO5hhBR49kQqop4+lcuCjf2arA= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.1/go.mod h1:O1YSOg3aekZibh2SngvCRRG+cRHKKlYgxf/JBF/Kr/k= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.9 h1:TraLwncRJkWqtIBVKI/UqBymq4+hL+3MzUOtUATuzkA= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.9/go.mod h1:AFvkxc8xfBe8XA+5St5XIHHrQQtkxqrRincx4hmMHOk= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.10 h1:PkHIIJs8qvq0e5QybnZoG1K/9QTrLr9OsqCIo59jOBA= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.10/go.mod h1:AFvkxc8xfBe8XA+5St5XIHHrQQtkxqrRincx4hmMHOk= github.com/aws/aws-sdk-go-v2/service/sts v1.16.3/go.mod h1:bfBj0iVmsUyUg4weDB4NxktD9rDGeKSVWnjTnwbx9b8= github.com/aws/aws-sdk-go-v2/service/sts v1.16.19/go.mod h1:h4J3oPZQbxLhzGnk+j9dfYHi5qIOVJ5kczZd658/ydM= github.com/aws/aws-sdk-go-v2/service/sts v1.18.3/go.mod h1:b+psTJn33Q4qGoDaM7ZiOVVG8uVjGI6HaZ8WBHdgDgU= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.10 h1:6UbNM/KJhMBfOI5+lpVcJ/8OA7cBSz0O6OX37SRKlSw= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.10/go.mod h1:BgQOMsg8av8jset59jelyPW7NoZcZXLVpDsXunGDrk8= +github.com/aws/aws-sdk-go-v2/service/sts v1.19.0 h1:2DQLAKDteoEDI8zpCzqBMaZlJuoE9iTYD0gFmXVax9E= +github.com/aws/aws-sdk-go-v2/service/sts v1.19.0/go.mod h1:BgQOMsg8av8jset59jelyPW7NoZcZXLVpDsXunGDrk8= github.com/aws/smithy-go v1.6.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= github.com/aws/smithy-go v1.11.2/go.mod h1:3xHYmszWVx2c0kIwQeEVf9uSm4fYZt67FBJnwub1bgM= @@ -2727,8 +2727,8 @@ golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= -golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -2762,8 +2762,8 @@ golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A golang.org/x/oauth2 v0.3.0/go.mod h1:rQrIauxkUhJ6CuwEXwymO2/eh4xz2ZWF1nBkcxS+tGk= golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= -golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g= -golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= +golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= +golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -2780,8 +2780,9 @@ golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -2949,8 +2950,8 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -2963,8 +2964,8 @@ golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ= -golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= +golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -3088,8 +3089,8 @@ golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= -golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= +golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= +golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -3383,8 +3384,8 @@ google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCD google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= google.golang.org/grpc v1.52.1/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= -google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag= -google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= +google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= +google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -3467,8 +3468,8 @@ gorm.io/driver/postgres v1.5.0 h1:u2FXTy14l45qc3UeCJ7QaAXZmZfDDv0YrthvmRq1l0U= gorm.io/driver/postgres v1.5.0/go.mod h1:FUZXzO+5Uqg5zzwzv4KK49R8lvGIyscBOqYrtI1Ce9A= gorm.io/gorm v1.23.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= gorm.io/gorm v1.24.7-0.20230306060331-85eaf9eeda11/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= -gorm.io/gorm v1.25.0 h1:+KtYtb2roDz14EQe4bla8CbQlmb9dN3VejSai3lprfU= -gorm.io/gorm v1.25.0/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= +gorm.io/gorm v1.25.1 h1:nsSALe5Pr+cM3V1qwwQ7rOkw+6UeLrX5O4v3llhHa64= +gorm.io/gorm v1.25.1/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= gorm.io/plugin/prometheus v0.0.0-20220517015831-ca6bfaf20bf4 h1:x9BE/BCIAJMYfa9VTMOf2Ixt8FERRmrMoyO6RWcxka0= gorm.io/plugin/prometheus v0.0.0-20220517015831-ca6bfaf20bf4/go.mod h1:vHBV5B47gI5tSom29xVjJHUfHA3wdKn8wEoXTsjxRFs= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= @@ -3572,8 +3573,8 @@ k8s.io/utils v0.0.0-20211116205334-6203023598ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/ k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20221107191617-1a15be271d1d/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/utils v0.0.0-20230505201702-9f6742963106 h1:EObNQ3TW2D+WptiYXlApGNLVy0zm/JIBVY9i+M4wpAU= +k8s.io/utils v0.0.0-20230505201702-9f6742963106/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/hack/generate-schemas/go.mod b/hack/generate-schemas/go.mod index e03e48ff7..513ccc7ea 100644 --- a/hack/generate-schemas/go.mod +++ b/hack/generate-schemas/go.mod @@ -10,18 +10,18 @@ require ( ) require ( - cloud.google.com/go/compute v1.19.1 // indirect - cloud.google.com/go/iam v1.0.0 // indirect + cloud.google.com/go/compute v1.19.2 // indirect + cloud.google.com/go/iam v1.0.1 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/ProtonMail/go-crypto v0.0.0-20230426101702-58e86b294756 // indirect github.com/acomagu/bufpipe v1.0.4 // indirect github.com/apparentlymart/go-cidr v1.1.0 // indirect github.com/aws/aws-sdk-go-v2 v1.18.0 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect - github.com/aws/aws-sdk-go-v2/config v1.18.22 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.13.21 // indirect + github.com/aws/aws-sdk-go-v2/config v1.18.25 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.13.24 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3 // indirect - github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.64 // indirect + github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.67 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33 // indirect github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.3.34 // indirect @@ -30,10 +30,10 @@ require ( github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.28 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.27 // indirect github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.2 // indirect - github.com/aws/aws-sdk-go-v2/service/s3 v1.33.0 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.12.9 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.9 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.18.10 // indirect + github.com/aws/aws-sdk-go-v2/service/s3 v1.33.1 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.12.10 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.10 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.19.0 // indirect github.com/aws/smithy-go v1.13.5 // indirect github.com/cloudflare/circl v1.3.3 // indirect github.com/emicklei/go-restful/v3 v3.10.2 // indirect @@ -63,7 +63,7 @@ require ( ) require ( - cloud.google.com/go v0.110.1 // indirect + cloud.google.com/go v0.110.2 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/storage v1.30.1 // indirect github.com/AlekSi/pointer v1.1.0 // indirect @@ -72,7 +72,7 @@ require ( github.com/Masterminds/sprig v2.22.0+incompatible // indirect github.com/Shopify/ejson v1.4.0 // indirect github.com/TomOnTime/utfutil v0.0.0-20210710122150-437f72b26edf // indirect - github.com/aws/aws-sdk-go v1.44.256 // indirect + github.com/aws/aws-sdk-go v1.44.260 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/c2h5oh/datasize v0.0.0-20200825124411-48ed595a09d2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect @@ -147,27 +147,27 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.24.0 // indirect gocloud.dev v0.29.0 // indirect - golang.org/x/crypto v0.8.0 // indirect + golang.org/x/crypto v0.9.0 // indirect golang.org/x/mod v0.10.0 // indirect - golang.org/x/net v0.9.0 // indirect - golang.org/x/oauth2 v0.7.0 // indirect - golang.org/x/sys v0.7.0 // indirect - golang.org/x/term v0.7.0 // indirect + golang.org/x/net v0.10.0 // indirect + golang.org/x/oauth2 v0.8.0 // indirect + golang.org/x/sys v0.8.0 // indirect + golang.org/x/term v0.8.0 // indirect golang.org/x/text v0.9.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.8.0 // indirect + golang.org/x/tools v0.9.1 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect - google.golang.org/api v0.121.0 // indirect + google.golang.org/api v0.122.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect - google.golang.org/grpc v1.54.0 // indirect + google.golang.org/grpc v1.55.0 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/flanksource/yaml.v3 v3.2.2 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - gorm.io/gorm v1.25.0 // indirect + gorm.io/gorm v1.25.1 // indirect k8s.io/api v0.26.4 // indirect k8s.io/apiextensions-apiserver v0.26.0 // indirect k8s.io/apimachinery v0.26.4 // indirect @@ -175,7 +175,7 @@ require ( k8s.io/client-go v11.0.0+incompatible // indirect k8s.io/klog/v2 v2.100.1 // indirect k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect - k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect + k8s.io/utils v0.0.0-20230505201702-9f6742963106 // indirect sigs.k8s.io/controller-runtime v0.14.1 // indirect sigs.k8s.io/kustomize v2.0.3+incompatible // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect @@ -189,4 +189,4 @@ replace ( helm.sh/helm/v3 => helm.sh/helm/v3 v3.5.1 ) -replace k8s.io/client-go => k8s.io/client-go v0.26.4 +replace k8s.io/client-go => k8s.io/client-go v0.26.1 diff --git a/hack/generate-schemas/go.sum b/hack/generate-schemas/go.sum index 61640ae61..4b7a3eb6c 100644 --- a/hack/generate-schemas/go.sum +++ b/hack/generate-schemas/go.sum @@ -37,8 +37,8 @@ cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRY cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM= cloud.google.com/go v0.107.0/go.mod h1:wpc2eNrD7hXUTy8EKS10jkxpZBjASrORK7goS+3YX2I= cloud.google.com/go v0.109.0/go.mod h1:2sYycXt75t/CSB5R9M2wPU1tJmire7AQZTPtITcGBVE= -cloud.google.com/go v0.110.1 h1:oDJ19Fu9TX9Xs06iyCw4yifSqZ7JQ8BeuVHcTmWQlOA= -cloud.google.com/go v0.110.1/go.mod h1:uc+V/WjzxQ7vpkxfJhgW4Q4axWXyfAerpQOuSNDZyFw= +cloud.google.com/go v0.110.2 h1:sdFPBr6xG9/wkBbfhmUz/JmZC7X6LavQgcrVINrKiVA= +cloud.google.com/go v0.110.2/go.mod h1:k04UEeEtb6ZBRTv3dZz4CeJC3jKGxyhl0sAiVVquxiw= cloud.google.com/go/accessapproval v1.4.0/go.mod h1:zybIuC3KpDOvotz59lFe5qxRZx6C75OtwbisN56xYB4= cloud.google.com/go/accessapproval v1.5.0/go.mod h1:HFy3tuiGvMdcd/u+Cu5b9NkO1pEICJ46IR82PoUdplw= cloud.google.com/go/accesscontextmanager v1.3.0/go.mod h1:TgCBehyr5gNMz7ZaH9xubp+CE8dkrszb4oK9CWyvD4o= @@ -123,8 +123,8 @@ cloud.google.com/go/compute v1.13.0/go.mod h1:5aPTS0cUNMIc1CE546K+Th6weJUNQErARy cloud.google.com/go/compute v1.14.0/go.mod h1:YfLtxrj9sU4Yxv+sXzZkyPjEyPBZfXHUvjxega5vAdo= cloud.google.com/go/compute v1.15.1/go.mod h1:bjjoF/NtFUrkD/urWfdHaKuOPDR5nWIs63rR+SXhcpA= cloud.google.com/go/compute v1.18.0/go.mod h1:1X7yHxec2Ga+Ss6jPyjxRxpu2uu7PLgsOVXvgU0yacs= -cloud.google.com/go/compute v1.19.1 h1:am86mquDUgjGNWxiGn+5PGLbmgiWXlE/yNWpIpNvuXY= -cloud.google.com/go/compute v1.19.1/go.mod h1:6ylj3a05WF8leseCdIf77NK0g1ey+nj5IKd5/kvShxE= +cloud.google.com/go/compute v1.19.2 h1:GbJtPo8OKVHbVep8jvM57KidbYHxeE68LOVqouNLrDY= +cloud.google.com/go/compute v1.19.2/go.mod h1:5f5a+iC1IriXYauaQ0EyQmEAEq9CGRnV5xJSQSlTV08= cloud.google.com/go/compute/metadata v0.1.0/go.mod h1:Z1VN+bulIf6bt4P/C37K4DyZYZEXYonfTBHHFPO/4UU= cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM= @@ -219,8 +219,8 @@ cloud.google.com/go/iam v0.6.0/go.mod h1:+1AH33ueBne5MzYccyMHtEKqLE4/kJOibtffMHD cloud.google.com/go/iam v0.7.0/go.mod h1:H5Br8wRaDGNc8XP3keLc4unfUUZeyH3Sfl9XpQEYOeg= cloud.google.com/go/iam v0.8.0/go.mod h1:lga0/y3iH6CX7sYqypWJ33hf7kkfXJag67naqGESjkE= cloud.google.com/go/iam v0.10.0/go.mod h1:nXAECrMt2qHpF6RZUZseteD6QyanL68reN4OXPw0UWM= -cloud.google.com/go/iam v1.0.0 h1:hlQJMovyJJwYjZcTohUH4o1L8Z8kYz+E+W/zktiLCBc= -cloud.google.com/go/iam v1.0.0/go.mod h1:ikbQ4f1r91wTmBmmOtBCOtuEOei6taatNXytzB7Cxew= +cloud.google.com/go/iam v1.0.1 h1:lyeCAU6jpnVNrE9zGQkTl3WgNgK/X+uWwaw0kynZJMU= +cloud.google.com/go/iam v1.0.1/go.mod h1:yR3tmSL8BcZB4bxByRv2jkSIahVmCtfKZwLYGBalRE8= cloud.google.com/go/iap v1.4.0/go.mod h1:RGFwRJdihTINIe4wZ2iCP0zF/qu18ZwyKxrhMhygBEc= cloud.google.com/go/iap v1.5.0/go.mod h1:UH/CGgKd4KyohZL5Pt0jSKE4m3FR51qg6FKQ/z/Ix9A= cloud.google.com/go/ids v1.1.0/go.mod h1:WIuwCaYVOzHIj2OhN9HAwvW+DBdmUAdcWlFxRl+KubM= @@ -568,8 +568,8 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX github.com/aws/aws-sdk-go v1.44.156/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go v1.44.187/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go v1.44.200/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.44.256 h1:O8VH+bJqgLDguqkH/xQBFz5o/YheeZqgcOYIgsTVWY4= -github.com/aws/aws-sdk-go v1.44.256/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.260 h1:78IJkDpDPXvLXvIkNAKDP/i3z8Vj+3sTAtQYw/v/2o8= +github.com/aws/aws-sdk-go v1.44.260/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.9.1/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= github.com/aws/aws-sdk-go-v2 v1.16.2/go.mod h1:ytwTPBG6fXTZLxxeeCCWj2/EMYp/xDUgX+OET6TLNNU= github.com/aws/aws-sdk-go-v2 v1.16.16/go.mod h1:SwiyXi/1zTUZ6KIAmLK5V5ll8SiURNUYOqTerZPaF9k= @@ -583,13 +583,13 @@ github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10/go.mod h1:VeTZetY5 github.com/aws/aws-sdk-go-v2/config v1.15.3/go.mod h1:9YL3v07Xc/ohTsxFXzan9ZpFpdTOFl4X65BAKYaz8jg= github.com/aws/aws-sdk-go-v2/config v1.17.7/go.mod h1:dN2gja/QXxFF15hQreyrqYhLBaQo1d9ZKe/v/uplQoI= github.com/aws/aws-sdk-go-v2/config v1.18.12/go.mod h1:J36fOhj1LQBr+O4hJCiT8FwVvieeoSGOtPuvhKlsNu8= -github.com/aws/aws-sdk-go-v2/config v1.18.22 h1:7vkUEmjjv+giht4wIROqLs+49VWmiQMMHSduxmoNKLU= -github.com/aws/aws-sdk-go-v2/config v1.18.22/go.mod h1:mN7Li1wxaPxSSy4Xkr6stFuinJGf3VZW3ZSNvO0q6sI= +github.com/aws/aws-sdk-go-v2/config v1.18.25 h1:JuYyZcnMPBiFqn87L2cRppo+rNwgah6YwD3VuyvaW6Q= +github.com/aws/aws-sdk-go-v2/config v1.18.25/go.mod h1:dZnYpD5wTW/dQF0rRNLVypB396zWCcPiBIvdvSWHEg4= github.com/aws/aws-sdk-go-v2/credentials v1.11.2/go.mod h1:j8YsY9TXTm31k4eFhspiQicfXPLZ0gYXA50i4gxPE8g= github.com/aws/aws-sdk-go-v2/credentials v1.12.20/go.mod h1:UKY5HyIux08bbNA7Blv4PcXQ8cTkGh7ghHMFklaviR4= github.com/aws/aws-sdk-go-v2/credentials v1.13.12/go.mod h1:37HG2MBroXK3jXfxVGtbM2J48ra2+Ltu+tmwr/jO0KA= -github.com/aws/aws-sdk-go-v2/credentials v1.13.21 h1:VRiXnPEaaPeGeoFcXvMZOB5K/yfIXOYE3q97Kgb0zbU= -github.com/aws/aws-sdk-go-v2/credentials v1.13.21/go.mod h1:90Dk1lJoMyspa/EDUrldTxsPns0wn6+KpRKpdAWc0uA= +github.com/aws/aws-sdk-go-v2/credentials v1.13.24 h1:PjiYyls3QdCrzqUN35jMWtUK1vqVZ+zLfdOa/UPFDp0= +github.com/aws/aws-sdk-go-v2/credentials v1.13.24/go.mod h1:jYPYi99wUOPIFi0rhiOvXeSEReVOzBqFNOX5bXYoG2o= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.3/go.mod h1:uk1vhHHERfSVCUnqSqz8O48LBYDSC+k6brng09jcMOk= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.17/go.mod h1:yIkQcCDYNsZfXpd5UX2Cy+sWA1jPgIhGTw9cOBzfVnQ= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.22/go.mod h1:YGSIJyQ6D6FjKMQh16hVFSIUD54L4F7zTGePqYMYYJU= @@ -598,8 +598,8 @@ github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3/go.mod h1:4Q0UFP0YJf0NrsEu github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.3/go.mod h1:0dHuD2HZZSiwfJSy1FO5bX1hQ1TxVV1QXXjpn3XUE44= github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.33/go.mod h1:84XgODVR8uRhmOnUkKGUZKqIMxmjmLOR8Uyp7G/TPwc= github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.51/go.mod h1:7Grl2gV+dx9SWrUIgwwlUvU40t7+lOSbx34XwfmsTkY= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.64 h1:9QJQs36z61YB8nxGwRDfWXEDYbU6H7jdI6zFiAX1vag= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.64/go.mod h1:4Q7R9MFpXRdjO3YnAfUTdnuENs32WzBkASt6VxSYDYQ= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.67 h1:fI9/5BDEaAv/pv1VO1X1n3jfP9it+IGqWsCuuBQI8wM= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.67/go.mod h1:zQClPRIwQZfJlZq6WZve+s4Tb4JW+3V6eS+4+KrYeP8= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.9/go.mod h1:AnVH5pvai0pAF4lXRq0bmhbes1u9R8wTE+g+183bZNM= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.23/go.mod h1:2DFxAQ9pfIRy0imBCJv+vZ2X6RKxves6fbnEuSry6b4= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.28/go.mod h1:3lwChorpIM/BhImY/hy+Z6jekmN92cXGPI1QJasVPYY= @@ -644,8 +644,8 @@ github.com/aws/aws-sdk-go-v2/service/kms v1.20.2/go.mod h1:vdqtUOdVuf5ooy+hJ2Gnz github.com/aws/aws-sdk-go-v2/service/s3 v1.26.3/go.mod h1:g1qvDuRsJY+XghsV6zg00Z4KJ7DtFFCx8fJD2a491Ak= github.com/aws/aws-sdk-go-v2/service/s3 v1.27.11/go.mod h1:fmgDANqTUCxciViKl9hb/zD5LFbvPINFRgWhDbR+vZo= github.com/aws/aws-sdk-go-v2/service/s3 v1.30.2/go.mod h1:SXDHd6fI2RhqB7vmAzyYQCTQnpZrIprVJvYxpzW3JAM= -github.com/aws/aws-sdk-go-v2/service/s3 v1.33.0 h1:L5h2fymEdVJYvn6hYO8Jx48YmC6xVmjmgHJV3oGKgmc= -github.com/aws/aws-sdk-go-v2/service/s3 v1.33.0/go.mod h1:J9kLNzEiHSeGMyN7238EjJmBpCniVzFda75Gxl/NqB8= +github.com/aws/aws-sdk-go-v2/service/s3 v1.33.1 h1:O+9nAy9Bb6bJFTpeNFtd9UfHbgxO1o4ZDAM9rQp5NsY= +github.com/aws/aws-sdk-go-v2/service/s3 v1.33.1/go.mod h1:J9kLNzEiHSeGMyN7238EjJmBpCniVzFda75Gxl/NqB8= github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.15.4/go.mod h1:PJc8s+lxyU8rrre0/4a0pn2wgwiDvOEzoOjcJUBr67o= github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.18.3/go.mod h1:hqPcyOuLU6yWIbLy3qMnQnmidgKuIEwqIlW6+chYnog= github.com/aws/aws-sdk-go-v2/service/sns v1.17.4/go.mod h1:kElt+uCcXxcqFyc+bQqZPFD9DME/eC6oHBXvFzQ9Bcw= @@ -657,17 +657,17 @@ github.com/aws/aws-sdk-go-v2/service/ssm v1.35.2/go.mod h1:VLSz2SHUKYFSOlXB/GlXo github.com/aws/aws-sdk-go-v2/service/sso v1.11.3/go.mod h1:7UQ/e69kU7LDPtY40OyoHYgRmgfGM4mgsLYtcObdveU= github.com/aws/aws-sdk-go-v2/service/sso v1.11.23/go.mod h1:/w0eg9IhFGjGyyncHIQrXtU8wvNsTJOP0R6PPj0wf80= github.com/aws/aws-sdk-go-v2/service/sso v1.12.1/go.mod h1:IgV8l3sj22nQDd5qcAGY0WenwCzCphqdbFOpfktZPrI= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.9 h1:GAiaQWuQhQQui76KjuXeShmyXqECwQ0mGRMc/rwsL+c= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.9/go.mod h1:ouy2P4z6sJN70fR3ka3wD3Ro3KezSxU6eKGQI2+2fjI= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.10 h1:UBQjaMTCKwyUYwiVnUt6toEJwGXsLBI6al083tpjJzY= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.10/go.mod h1:ouy2P4z6sJN70fR3ka3wD3Ro3KezSxU6eKGQI2+2fjI= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.5/go.mod h1:csZuQY65DAdFBt1oIjO5hhBR49kQqop4+lcuCjf2arA= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.1/go.mod h1:O1YSOg3aekZibh2SngvCRRG+cRHKKlYgxf/JBF/Kr/k= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.9 h1:TraLwncRJkWqtIBVKI/UqBymq4+hL+3MzUOtUATuzkA= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.9/go.mod h1:AFvkxc8xfBe8XA+5St5XIHHrQQtkxqrRincx4hmMHOk= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.10 h1:PkHIIJs8qvq0e5QybnZoG1K/9QTrLr9OsqCIo59jOBA= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.10/go.mod h1:AFvkxc8xfBe8XA+5St5XIHHrQQtkxqrRincx4hmMHOk= github.com/aws/aws-sdk-go-v2/service/sts v1.16.3/go.mod h1:bfBj0iVmsUyUg4weDB4NxktD9rDGeKSVWnjTnwbx9b8= github.com/aws/aws-sdk-go-v2/service/sts v1.16.19/go.mod h1:h4J3oPZQbxLhzGnk+j9dfYHi5qIOVJ5kczZd658/ydM= github.com/aws/aws-sdk-go-v2/service/sts v1.18.3/go.mod h1:b+psTJn33Q4qGoDaM7ZiOVVG8uVjGI6HaZ8WBHdgDgU= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.10 h1:6UbNM/KJhMBfOI5+lpVcJ/8OA7cBSz0O6OX37SRKlSw= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.10/go.mod h1:BgQOMsg8av8jset59jelyPW7NoZcZXLVpDsXunGDrk8= +github.com/aws/aws-sdk-go-v2/service/sts v1.19.0 h1:2DQLAKDteoEDI8zpCzqBMaZlJuoE9iTYD0gFmXVax9E= +github.com/aws/aws-sdk-go-v2/service/sts v1.19.0/go.mod h1:BgQOMsg8av8jset59jelyPW7NoZcZXLVpDsXunGDrk8= github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= github.com/aws/smithy-go v1.11.2/go.mod h1:3xHYmszWVx2c0kIwQeEVf9uSm4fYZt67FBJnwub1bgM= github.com/aws/smithy-go v1.13.3/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= @@ -1851,8 +1851,8 @@ golang.org/x/crypto v0.0.0-20221012134737-56aed061732a/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ= -golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= +golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= +golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1994,8 +1994,8 @@ golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= -golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -2029,8 +2029,8 @@ golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A golang.org/x/oauth2 v0.3.0/go.mod h1:rQrIauxkUhJ6CuwEXwymO2/eh4xz2ZWF1nBkcxS+tGk= golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= -golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g= -golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= +golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= +golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -2047,8 +2047,8 @@ golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -2179,8 +2179,8 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -2191,8 +2191,8 @@ golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ= -golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= +golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -2303,8 +2303,8 @@ golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= -golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= +golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= +golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -2386,8 +2386,8 @@ google.golang.org/api v0.106.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/ google.golang.org/api v0.107.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= google.golang.org/api v0.108.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= google.golang.org/api v0.110.0/go.mod h1:7FC4Vvx1Mooxh8C5HWjzZHcavuS2f6pmJpZx60ca7iI= -google.golang.org/api v0.121.0 h1:8Oopoo8Vavxx6gt+sgs8s8/X60WBAtKQq6JqnkF+xow= -google.golang.org/api v0.121.0/go.mod h1:gcitW0lvnyWjSp9nKxAbdHKIZ6vF4aajGueeslZOyms= +google.golang.org/api v0.122.0 h1:zDobeejm3E7pEG1mNHvdxvjs5XJoCMzyNH+CmwL94Es= +google.golang.org/api v0.122.0/go.mod h1:gcitW0lvnyWjSp9nKxAbdHKIZ6vF4aajGueeslZOyms= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -2578,8 +2578,8 @@ google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCD google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= google.golang.org/grpc v1.52.1/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= -google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag= -google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= +google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= +google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -2640,8 +2640,8 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/gorm v1.25.0 h1:+KtYtb2roDz14EQe4bla8CbQlmb9dN3VejSai3lprfU= -gorm.io/gorm v1.25.0/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= +gorm.io/gorm v1.25.1 h1:nsSALe5Pr+cM3V1qwwQ7rOkw+6UeLrX5O4v3llhHa64= +gorm.io/gorm v1.25.1/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A= @@ -2668,8 +2668,8 @@ k8s.io/apimachinery v0.26.4 h1:rZccKdBLg9vP6J09JD+z8Yr99Ce8gk3Lbi9TCx05Jzs= k8s.io/apimachinery v0.26.4/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I= k8s.io/cli-runtime v0.24.4 h1:YCSf0dZp+pYXVR/8aZQ6MEBSiicv8rLyVsGBEbRnwfY= k8s.io/cli-runtime v0.24.4/go.mod h1:RF+cSLYXkPV3WyvPrX2qeRLEUJY38INWx6jLKVLFCxM= -k8s.io/client-go v0.26.4 h1:/7P/IbGBuT73A+G97trf44NTPSNqvuBREpOfdLbHvD4= -k8s.io/client-go v0.26.4/go.mod h1:6qOItWm3EwxJdl/8p5t7FWtWUOwyMdA8N9ekbW4idpI= +k8s.io/client-go v0.26.1 h1:87CXzYJnAMGaa/IDDfRdhTzxk/wzGZ+/HUQpqgVSZXU= +k8s.io/client-go v0.26.1/go.mod h1:IWNSglg+rQ3OcvDkhY6+QLeasV4OYHDjdqeWkDQZwGE= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= @@ -2693,8 +2693,8 @@ k8s.io/utils v0.0.0-20211116205334-6203023598ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/ k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20221107191617-1a15be271d1d/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/utils v0.0.0-20230505201702-9f6742963106 h1:EObNQ3TW2D+WptiYXlApGNLVy0zm/JIBVY9i+M4wpAU= +k8s.io/utils v0.0.0-20230505201702-9f6742963106/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/pkg/api.go b/pkg/api.go index b63ace268..a6d61c306 100644 --- a/pkg/api.go +++ b/pkg/api.go @@ -7,14 +7,13 @@ import ( "github.com/flanksource/canary-checker/api/external" v1 "github.com/flanksource/canary-checker/api/v1" - "github.com/flanksource/canary-checker/pkg/db/types" "github.com/flanksource/canary-checker/pkg/labels" "github.com/flanksource/canary-checker/pkg/utils" "github.com/flanksource/commons/console" "github.com/flanksource/commons/logger" + "github.com/flanksource/duty/models" + "github.com/flanksource/duty/types" "github.com/google/uuid" - "github.com/lib/pq" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) type Endpoint struct { @@ -112,68 +111,6 @@ type Timeseries struct { Count int `json:"count,omitempty"` } -type Canary struct { - ID uuid.UUID `gorm:"default:generate_ulid()"` - Spec types.JSON - Labels types.JSONStringMap - Source string - Name string - Namespace string - Checks types.JSONStringMap `gorm:"-"` - CreatedAt time.Time - UpdatedAt time.Time - DeletedAt *time.Time `json:"deleted_at,omitempty" time_format:"postgres_timestamp"` -} - -func (c Canary) GetCheckID(checkName string) string { - return c.Checks[checkName] -} - -func (c Canary) ToV1() (*v1.Canary, error) { - canary := v1.Canary{ - ObjectMeta: metav1.ObjectMeta{ - Name: c.Name, - Namespace: c.Namespace, - Annotations: map[string]string{ - "source": c.Source, - }, - Labels: c.Labels, - }, - } - var deletionTimestamp metav1.Time - if c.DeletedAt != nil && !c.DeletedAt.IsZero() { - deletionTimestamp = metav1.NewTime(*c.DeletedAt) - canary.ObjectMeta.DeletionTimestamp = &deletionTimestamp - } - if err := json.Unmarshal(c.Spec, &canary.Spec); err != nil { - logger.Debugf("Failed to unmarshal canary spec: %s", err) - return nil, err - } - id := c.ID.String() - canary.Status.PersistedID = &id - canary.Status.Checks = c.Checks - return &canary, nil -} - -func CanaryFromV1(canary v1.Canary) (Canary, error) { - spec, err := json.Marshal(canary.Spec) - if err != nil { - return Canary{}, err - } - var checks = make(map[string]string) - if canary.Status.Checks != nil { - checks = canary.Status.Checks - } - return Canary{ - Spec: spec, - Labels: types.JSONStringMap(canary.Labels), - Name: canary.Name, - Namespace: canary.Namespace, - Source: canary.Annotations["source"], - Checks: types.JSONStringMap(checks), - }, nil -} - type Check struct { ID uuid.UUID `json:"id" gorm:"default:generate_ulid()"` CanaryID uuid.UUID `json:"canary_id"` @@ -203,7 +140,7 @@ type Check struct { Canary *v1.Canary `json:"-" gorm:"-"` } -func FromExternalCheck(canary Canary, check external.Check) Check { +func FromExternalCheck(canary models.Canary, check external.Check) Check { return Check{ CanaryID: canary.ID, Type: check.GetType(), @@ -296,78 +233,15 @@ type Checker interface { CheckArgs(args map[string]interface{}) *CheckResult } -type Config struct { - ID *uuid.UUID `json:"id,omitempty"` - ConfigClass string `json:"config_class,omitempty"` - Name string `json:"name,omitempty"` - Namespace string `json:"namespace,omitempty"` - Spec *types.JSONMap `json:"spec,omitempty" gorm:"column:config"` - Tags types.JSONStringMap `json:"tags,omitempty" gorm:"type:jsonstringmap"` - ExternalID pq.StringArray `json:"external_id,omitempty" gorm:"type:text[]"` - Type string `json:"type,omitempty"` -} - -func (c Config) String() string { - s := c.ConfigClass - if c.Namespace != "" { - s += "/" + c.Namespace - } - - if c.Name != "" { - s += "/" + c.Name - } - if len(c.Tags) > 0 { - s += " " + fmt.Sprintf("%v", c.Tags) - } - return s -} - -func NewConfigs(configs []v1.Config) Configs { - var pkgConfigs Configs - for _, config := range configs { - pkgConfigs = append(pkgConfigs, NewConfig(config)) - } - return pkgConfigs -} - -func NewConfig(config v1.Config) *Config { - return &Config{ - Name: config.Name, - Namespace: config.Namespace, - Tags: types.JSONStringMap(config.Tags), - ExternalID: pq.StringArray(config.ID), - Type: config.Type, - } -} - -func ToV1Config(config Config) v1.Config { +func ToV1Config(config models.ConfigItem) v1.Config { return v1.Config{ - Name: config.Name, - Namespace: config.Namespace, + Name: deref(config.Name), + Namespace: deref(config.Namespace), ID: config.ExternalID, - Type: config.Type, - } -} - -func (c Config) GetSelectorID() string { - selectorID, err := utils.GenerateJSONMD5Hash(ToV1Config(c)) - if err != nil { - return "" + Type: deref(config.Type), } - return selectorID } -// ToJSONMap converts the struct to map[string]interface{} to -// be compatible with otto vm -func (c Config) ToJSONMap() map[string]interface{} { - m := make(map[string]interface{}) - b, _ := json.Marshal(&c) - _ = json.Unmarshal(b, &m) - return m -} - -type Configs []*Config - // URL information type URL struct { IP string @@ -511,3 +385,11 @@ func (m Metric) String() string { func (e Endpoint) GetEndpoint() string { return e.String } + +func deref(v *string) string { + if v == nil { + return "" + } + + return *v +} diff --git a/pkg/api/push.go b/pkg/api/push.go index 6402a5c87..f2ee2f38d 100644 --- a/pkg/api/push.go +++ b/pkg/api/push.go @@ -11,6 +11,7 @@ import ( "github.com/flanksource/canary-checker/pkg" "github.com/flanksource/canary-checker/pkg/cache" "github.com/flanksource/canary-checker/pkg/db" + "github.com/flanksource/duty/models" "github.com/google/uuid" "github.com/labstack/echo/v4" @@ -55,7 +56,7 @@ func PushHandler(c echo.Context) error { if canary != nil { data.Check.CanaryID = canary.ID } else { - canary = &pkg.Canary{ + canary = &models.Canary{ Name: data.Check.Name, Namespace: data.Check.Namespace, } diff --git a/pkg/api/run_now.go b/pkg/api/run_now.go index 0fad21655..852ec947a 100644 --- a/pkg/api/run_now.go +++ b/pkg/api/run_now.go @@ -7,6 +7,7 @@ import ( "strconv" "github.com/flanksource/canary-checker/api/context" + v1 "github.com/flanksource/canary-checker/api/v1" "github.com/flanksource/canary-checker/checks" "github.com/flanksource/canary-checker/pkg" "github.com/flanksource/canary-checker/pkg/db" @@ -59,7 +60,7 @@ func RunCanaryHandler(c echo.Context) error { return errorResonse(c, fmt.Errorf("canary with id=%s was not found", id), http.StatusNotFound) } - canary, err := canaryModel.ToV1() + canary, err := v1.CanaryFromModel(canaryModel) if err != nil { return errorResonse(c, err, http.StatusInternalServerError) } diff --git a/pkg/db/canary.go b/pkg/db/canary.go index 2b3d1e77c..0ba6c56f5 100644 --- a/pkg/db/canary.go +++ b/pkg/db/canary.go @@ -9,19 +9,19 @@ import ( v1 "github.com/flanksource/canary-checker/api/v1" "github.com/flanksource/canary-checker/pkg" - "github.com/flanksource/canary-checker/pkg/db/types" "github.com/flanksource/canary-checker/pkg/metrics" "github.com/flanksource/canary-checker/pkg/utils" "github.com/flanksource/commons/logger" "github.com/flanksource/duty" "github.com/flanksource/duty/models" + dutyTypes "github.com/flanksource/duty/types" "github.com/google/uuid" "gorm.io/gorm" "gorm.io/gorm/clause" ) -func GetAllCanaries() ([]pkg.Canary, error) { - var _canaries []pkg.Canary +func GetAllCanaries() ([]models.Canary, error) { + var _canaries []models.Canary var rawCanaries interface{} query := fmt.Sprintf("SELECT json_agg(jsonb_set_lax(to_jsonb(canaries),'{checks}', %s)) :: jsonb as canaries from canaries where deleted_at is null", getChecksForCanaries()) @@ -115,7 +115,7 @@ func UpdateChecksStatus(ids []string, status models.CheckHealthStatus) error { func DeleteCanary(canary v1.Canary) error { logger.Infof("deleting canary %s/%s", canary.Namespace, canary.Name) - model, err := pkg.CanaryFromV1(canary) + model, err := canary.ToModel() if err != nil { return err } @@ -154,8 +154,8 @@ func DeleteChecks(id []string) error { return Gorm.Table("checks").Where("id IN (?)", id).UpdateColumn("deleted_at", time.Now()).Error } -func GetCanary(id string) (*pkg.Canary, error) { - var model *pkg.Canary +func GetCanary(id string) (*models.Canary, error) { + var model *models.Canary if err := Gorm.Where("id = ?", id).First(&model).Error; err != nil { return nil, err } @@ -163,8 +163,8 @@ func GetCanary(id string) (*pkg.Canary, error) { return model, nil } -func FindCanaryByID(id string) (*pkg.Canary, error) { - var model *pkg.Canary +func FindCanaryByID(id string) (*models.Canary, error) { + var model *models.Canary if err := Gorm.Where("id = ?", id).First(&model).Error; err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { return nil, nil @@ -187,8 +187,8 @@ func GetCheck(id string) (*pkg.Check, error) { return model, nil } -func FindCanary(namespace, name string) (*pkg.Canary, error) { - var model pkg.Canary +func FindCanary(namespace, name string) (*models.Canary, error) { + var model models.Canary if err := Gorm.Where("namespace = ? AND name = ?", namespace, name).First(&model).Error; err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { return nil, nil @@ -199,7 +199,7 @@ func FindCanary(namespace, name string) (*pkg.Canary, error) { return &model, nil } -func FindCheck(canary pkg.Canary, name string) (*pkg.Check, error) { +func FindCheck(canary models.Canary, name string) (*pkg.Check, error) { var model pkg.Check if err := Gorm.Where("canary_id = ? AND name = ?", canary.ID.String(), name).First(&model).Error; err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { @@ -210,22 +210,22 @@ func FindCheck(canary pkg.Canary, name string) (*pkg.Check, error) { return &model, nil } -func CreateCanary(canary *pkg.Canary) error { +func CreateCanary(canary *models.Canary) error { if canary.Spec == nil || len(canary.Spec) == 0 { empty := []byte("{}") - canary.Spec = types.JSON(empty) + canary.Spec = dutyTypes.JSON(empty) } return Gorm.Create(canary).Error } -func CreateCheck(canary pkg.Canary, check *pkg.Check) error { +func CreateCheck(canary models.Canary, check *pkg.Check) error { return Gorm.Create(&check).Error } -func PersistCanary(canary v1.Canary, source string) (*pkg.Canary, map[string]string, bool, error) { +func PersistCanary(canary v1.Canary, source string) (*models.Canary, map[string]string, bool, error) { changed := false - model, err := pkg.CanaryFromV1(canary) + model, err := canary.ToModel() if err != nil { return nil, nil, changed, err } diff --git a/pkg/db/canary_selector.go b/pkg/db/canary_selector.go index 92f3b9c61..ebdc3734a 100644 --- a/pkg/db/canary_selector.go +++ b/pkg/db/canary_selector.go @@ -5,8 +5,9 @@ import ( v1 "github.com/flanksource/canary-checker/api/v1" "github.com/flanksource/canary-checker/pkg" - "github.com/flanksource/canary-checker/pkg/db/types" "github.com/flanksource/commons/logger" + "github.com/flanksource/duty/models" + "github.com/flanksource/duty/types" "github.com/google/uuid" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -64,7 +65,7 @@ func GetAllActiveChecksForCanary(canaryID uuid.UUID) (checks pkg.Checks, err err return checks, nil } -func CreateComponentCanaryFromInline(id, name, namespace, schedule, owner string, spec *v1.CanarySpec) (*pkg.Canary, error) { +func CreateComponentCanaryFromInline(id, name, namespace, schedule, owner string, spec *v1.CanarySpec) (*models.Canary, error) { if spec.GetSchedule() == "@never" { spec.Schedule = schedule } diff --git a/pkg/db/component_selector.go b/pkg/db/component_selector.go index 9b9086345..d8d54ed26 100644 --- a/pkg/db/component_selector.go +++ b/pkg/db/component_selector.go @@ -3,8 +3,8 @@ package db import ( "strings" - "github.com/flanksource/canary-checker/pkg" - "github.com/flanksource/canary-checker/pkg/db/types" + "github.com/flanksource/duty/models" + "github.com/flanksource/duty/types" ) func GetLabelsFromSelector(selector string) (matchLabels map[string]string) { @@ -23,11 +23,11 @@ func GetLabelsFromSelector(selector string) (matchLabels map[string]string) { return } -func GetComponentsWithLabelSelector(labelSelector string) (components pkg.Components, err error) { +func GetComponentsWithLabelSelector(labelSelector string) (components models.Components, err error) { if labelSelector == "" { return nil, nil } - var uninqueComponents = make(map[string]*pkg.Component) + var uniqueComponents = make(map[string]*models.Component) matchLabels := GetLabelsFromSelector(labelSelector) var labels = make(map[string]string) var onlyKeys []string @@ -38,43 +38,45 @@ func GetComponentsWithLabelSelector(labelSelector string) (components pkg.Compon onlyKeys = append(onlyKeys, k) } } - var comps pkg.Components + var comps models.Components if err := Gorm.Table("components").Where("labels @> ? and deleted_at is null", types.JSONStringMap(labels)).Find(&comps).Error; err != nil { return nil, err } for _, c := range comps { - uninqueComponents[c.ID.String()] = c + uniqueComponents[c.ID.String()] = c } for _, k := range onlyKeys { - var comps pkg.Components + var comps models.Components if err := Gorm.Table("components").Where("labels ?? ? and deleted_at is null", k).Find(&comps).Error; err != nil { continue } for _, c := range comps { - uninqueComponents[c.ID.String()] = c + uniqueComponents[c.ID.String()] = c } } - for _, c := range uninqueComponents { + for _, c := range uniqueComponents { components = append(components, c) } return components, nil } -func GetComponentsWithFieldSelector(fieldSelector string) (components pkg.Components, err error) { +func GetComponentsWithFieldSelector(fieldSelector string) (components models.Components, err error) { if fieldSelector == "" { return nil, nil } - var uninqueComponents = make(map[string]*pkg.Component) + var uninqueComponents = make(map[string]*models.Component) matchLabels := GetLabelsFromSelector(fieldSelector) for k, v := range matchLabels { - var comp pkg.Components + var comp models.Components Gorm.Raw("select * from lookup_component_by_property(?, ?)", k, v).Scan(&comp) for _, c := range comp { uninqueComponents[c.ID.String()] = c } } + for _, c := range uninqueComponents { components = append(components, c) } + return } diff --git a/pkg/db/config_db.go b/pkg/db/config_db.go index 96becd7a4..46e92381e 100644 --- a/pkg/db/config_db.go +++ b/pkg/db/config_db.go @@ -8,7 +8,9 @@ import ( "gorm.io/gorm" "gorm.io/gorm/clause" - "github.com/flanksource/canary-checker/pkg" + "github.com/flanksource/duty/models" + "github.com/flanksource/duty/types" + //"github.com/flanksource/canary-checker/pkg/db/types" "github.com/flanksource/commons/logger" ) @@ -21,19 +23,21 @@ type ConfigComponentRelationship struct { DeletedAt *time.Time } -func configQuery(config pkg.Config) *gorm.DB { +func configQuery(config *types.ConfigQuery) *gorm.DB { query := Gorm.Table("config_items") - if config.ConfigClass != "" { - query = query.Where("config_class = ?", config.ConfigClass) + if config.Class != "" { + query = query.Where("config_class = ?", config.Class) } + if config.Name != "" { query = query.Where("name = ?", config.Name) } + if config.Namespace != "" { query = query.Where("namespace = ?", config.Namespace) } - if config.Tags != nil && len(config.Tags) > 0 { + if len(config.Tags) > 0 { query = query.Where("tags @> ?", config.Tags) } @@ -42,18 +46,21 @@ func configQuery(config pkg.Config) *gorm.DB { if config.Type != "" { query = query.Where("type = @config_type OR config_class = @config_type", sql.Named("config_type", config.Type)) } + if len(config.ExternalID) > 0 { query = query.Where("external_id @> ?", config.ExternalID) } + return query } -func FindConfig(config pkg.Config) (*pkg.Config, error) { +func FindConfig(config *types.ConfigQuery) (*models.ConfigItem, error) { if Gorm == nil { logger.Debugf("Config lookup on %v will be ignored, db not initialized", config) return nil, gorm.ErrRecordNotFound } - var dbConfigObject pkg.Config + + var dbConfigObject models.ConfigItem query := configQuery(config) tx := query.Limit(1).Find(&dbConfigObject) if tx.Error != nil { @@ -65,8 +72,8 @@ func FindConfig(config pkg.Config) (*pkg.Config, error) { return &dbConfigObject, nil } -func FindConfigForComponent(componentID, configType string) ([]pkg.Config, error) { - var dbConfigObjects []pkg.Config +func FindConfigForComponent(componentID, configType string) ([]models.ConfigItem, error) { + var dbConfigObjects []models.ConfigItem relationshipQuery := Gorm.Table("config_component_relationships").Select("config_id").Where("component_id = ? AND deleted_at IS NULL", componentID) query := Gorm.Table("config_items").Where("id IN (?)", relationshipQuery) if configType != "" { diff --git a/pkg/db/topology.go b/pkg/db/topology.go index ef2c2cdce..5a754014f 100644 --- a/pkg/db/topology.go +++ b/pkg/db/topology.go @@ -21,7 +21,7 @@ func PersistTopology(t *v1.Topology) (bool, error) { var err error var changed bool - model := pkg.TopologyFromV1(t) + model := t.ToModel() model.ID, err = uuid.Parse(t.GetPersistedID()) if err != nil { return changed, err @@ -39,7 +39,7 @@ func PersistTopology(t *v1.Topology) (bool, error) { return changed, nil } -func PersistComponents(results []*pkg.Component) error { +func PersistComponents(results []*models.Component) error { for _, component := range results { _, err := PersistComponent(component) if err != nil { @@ -51,29 +51,29 @@ func PersistComponents(results []*pkg.Component) error { } func GetTopology(ctx context.Context, id string) (*v1.Topology, error) { - var t pkg.Topology + var t models.Topology if err := Gorm.WithContext(ctx).Table("topologies").Where("id = ? AND deleted_at is NULL", id).First(&t).Error; err != nil { return nil, err } - tv1 := t.ToV1() + tv1 := v1.TopologyFromModels(t) return &tv1, nil } func GetAllTopologies() ([]v1.Topology, error) { var v1topologies []v1.Topology - var topologies []pkg.Topology + var topologies []models.Topology if err := Gorm.Table("topologies").Find(&topologies).Where("deleted_at is NULL").Error; err != nil { return nil, err } for _, t := range topologies { - v1topologies = append(v1topologies, t.ToV1()) + v1topologies = append(v1topologies, v1.TopologyFromModels(t)) } return v1topologies, nil } // Get all the components from table which has not null selectors -func GetAllComponentsWithSelectors() (components pkg.Components, err error) { +func GetAllComponentsWithSelectors() (components models.Components, err error) { if err := Gorm.Table("components").Where("deleted_at is NULL and selectors != 'null'").Find(&components).Error; err != nil { return nil, err } @@ -123,8 +123,8 @@ func UpdateComponentCosts() error { `).Error } -func GetComponentsWithSelectors(resourceSelectors v1.ResourceSelectors) (components pkg.Components, err error) { - var uniqueComponents = make(map[string]*pkg.Component) +func GetComponentsWithSelectors(resourceSelectors types.ResourceSelectors) (components models.Components, err error) { + var uniqueComponents = make(map[string]*models.Component) for _, resourceSelector := range resourceSelectors { var selectorID string selectorID, err = utils.GenerateJSONMD5Hash(resourceSelector) @@ -160,21 +160,21 @@ func GetComponentsWithSelectors(resourceSelectors v1.ResourceSelectors) (compone return components, nil } -func GetAllComponentsWithConfigs() (components pkg.Components, err error) { +func GetAllComponentsWithConfigs() (components models.Components, err error) { if err := Gorm.Table("components").Where("deleted_at is NULL and configs != 'null'").Find(&components).Error; err != nil { return nil, err } return } -func GetAllComponentWithCanaries() (components pkg.Components, err error) { +func GetAllComponentWithCanaries() (components models.Components, err error) { if err := Gorm.Table("components").Where("deleted_at is NULL and component_checks != 'null'").Find(&components).Error; err != nil { return nil, err } return } -func NewComponentRelationships(relationshipID uuid.UUID, path string, components pkg.Components) (relationships []*pkg.ComponentRelationship, err error) { +func NewComponentRelationships(relationshipID uuid.UUID, path string, components models.Components) (relationships []*pkg.ComponentRelationship, err error) { for _, component := range components { relationships = append(relationships, &pkg.ComponentRelationship{ RelationshipID: relationshipID, @@ -219,8 +219,8 @@ func PersistCheckComponentRelationship(relationship *pkg.CheckComponentRelations } // TODO: Simplify logic and improve readability -func PersistComponent(component *pkg.Component) ([]uuid.UUID, error) { - existing := &pkg.Component{} +func PersistComponent(component *models.Component) ([]uuid.UUID, error) { + existing := &models.Component{} var persisted []uuid.UUID var tx *gorm.DB if component.TopologyID == nil { @@ -290,7 +290,7 @@ func UpdateStatusAndSummaryForComponent(id uuid.UUID, status types.ComponentStat func DeleteTopology(t *v1.Topology) error { logger.Infof("Deleting topology %s/%s", t.Namespace, t.Name) - model := pkg.TopologyFromV1(t) + model := t.ToModel() deleteTime := time.Now() tx := Gorm.Table("topologies").Find(model, "id = ?", t.GetPersistedID()).UpdateColumn("deleted_at", deleteTime) @@ -303,7 +303,7 @@ func DeleteTopology(t *v1.Topology) error { // DeleteComponents deletes all components associated with a topology func DeleteComponentsOfTopology(topologyID string, deleteTime time.Time) error { logger.Infof("Deleting all components associated with topology: %s", topologyID) - componentsModel := &[]pkg.Component{} + componentsModel := &[]models.Component{} if err := Gorm.Where("topology_id = ?", topologyID).Find(componentsModel).UpdateColumn("deleted_at", deleteTime).Error; err != nil { return err } @@ -367,7 +367,7 @@ func DeleteComponentChildren(componentID string, deleteTime time.Time) error { } func DeleteInlineCanariesForComponent(componentID string, deleteTime time.Time) error { - var canaries = []*pkg.Canary{} + var canaries = []*models.Canary{} source := "component/" + componentID if err := Gorm.Where("source = ?", source).Find(&canaries).UpdateColumn("deleted_at", deleteTime).Error; err != nil { return err diff --git a/pkg/db/types/types.go b/pkg/db/types/types.go deleted file mode 100644 index 246ed27da..000000000 --- a/pkg/db/types/types.go +++ /dev/null @@ -1,345 +0,0 @@ -// nolint -package types - -import ( - "context" - "database/sql/driver" - "encoding/json" - "errors" - "fmt" - "strings" - - "gorm.io/gorm" - "gorm.io/gorm/clause" - "gorm.io/gorm/schema" -) - -// JSON defined JSON data type, need to implements driver.Valuer, sql.Scanner interface -type JSON json.RawMessage - -// Value return json value, implement driver.Valuer interface -func (j JSON) Value() (driver.Value, error) { - if len(j) == 0 { - return nil, nil - } - bytes, err := json.RawMessage(j).MarshalJSON() - return string(bytes), err -} - -// Scan scan value into Jsonb, implements sql.Scanner interface -func (j *JSON) Scan(value interface{}) error { - if value == nil { - *j = JSON("null") - return nil - } - var bytes []byte - switch v := value.(type) { - case []byte: - bytes = v - case string: - bytes = []byte(v) - default: - return errors.New(fmt.Sprint("Failed to unmarshal JSONB value:", value)) - } - - result := json.RawMessage{} - err := json.Unmarshal(bytes, &result) - *j = JSON(result) - return err -} - -// MarshalJSON to output non base64 encoded []byte -func (j JSON) MarshalJSON() ([]byte, error) { - return json.RawMessage(j).MarshalJSON() -} - -// UnmarshalJSON to deserialize []byte -func (j *JSON) UnmarshalJSON(b []byte) error { - result := json.RawMessage{} - err := result.UnmarshalJSON(b) - *j = JSON(result) - return err -} - -func (j JSON) String() string { - return string(j) -} - -// GormDataType gorm common data type -func (JSON) GormDataType() string { - return "json" -} - -// GormDBDataType gorm db data type -func (JSON) GormDBDataType(db *gorm.DB, field *schema.Field) string { - switch db.Dialector.Name() { - case "sqlite": - return "JSON" - case "mysql": - return "JSON" - case "postgres": - return "JSONB" - } - return "" -} - -func (js JSON) GormValue(ctx context.Context, db *gorm.DB) clause.Expr { - if len(js) == 0 { - return gorm.Expr("NULL") - } - - data, _ := js.MarshalJSON() - return gorm.Expr("?", string(data)) -} - -// JSONQueryExpression json query expression, implements clause.Expression interface to use as querier -type JSONQueryExpression struct { - column string - keys []string - hasKeys bool - equals bool - equalsValue interface{} -} - -// JSONQuery query column as json -func JSONQuery(column string) *JSONQueryExpression { - return &JSONQueryExpression{column: column} -} - -// HasKey returns clause.Expression -func (jsonQuery *JSONQueryExpression) HasKey(keys ...string) *JSONQueryExpression { - jsonQuery.keys = keys - jsonQuery.hasKeys = true - return jsonQuery -} - -// Keys returns clause.Expression -func (jsonQuery *JSONQueryExpression) Equals(value interface{}, keys ...string) *JSONQueryExpression { - jsonQuery.keys = keys - jsonQuery.equals = true - jsonQuery.equalsValue = value - return jsonQuery -} - -// Build implements clause.Expression -func (jsonQuery *JSONQueryExpression) Build(builder clause.Builder) { - if stmt, ok := builder.(*gorm.Statement); ok { - switch stmt.Dialector.Name() { - case "mysql", "sqlite": - switch { - case jsonQuery.hasKeys: - if len(jsonQuery.keys) > 0 { - builder.WriteString("JSON_EXTRACT(" + stmt.Quote(jsonQuery.column) + ",") - builder.AddVar(stmt, "$."+strings.Join(jsonQuery.keys, ".")) - builder.WriteString(") IS NOT NULL") - } - case jsonQuery.equals: - if len(jsonQuery.keys) > 0 { - builder.WriteString("JSON_EXTRACT(" + stmt.Quote(jsonQuery.column) + ",") - builder.AddVar(stmt, "$."+strings.Join(jsonQuery.keys, ".")) - builder.WriteString(") = ") - if _, ok := jsonQuery.equalsValue.(bool); ok { - builder.WriteString(fmt.Sprint(jsonQuery.equalsValue)) - } else { - stmt.AddVar(builder, jsonQuery.equalsValue) - } - } - } - case "postgres": - switch { - case jsonQuery.hasKeys: - if len(jsonQuery.keys) > 0 { - stmt.WriteQuoted(jsonQuery.column) - stmt.WriteString("::jsonb") - for _, key := range jsonQuery.keys[0 : len(jsonQuery.keys)-1] { - stmt.WriteString(" -> ") - stmt.AddVar(builder, key) - } - - stmt.WriteString(" ? ") - stmt.AddVar(builder, jsonQuery.keys[len(jsonQuery.keys)-1]) - } - case jsonQuery.equals: - if len(jsonQuery.keys) > 0 { - builder.WriteString(fmt.Sprintf("json_extract_path_text(%v::json,", stmt.Quote(jsonQuery.column))) - - for idx, key := range jsonQuery.keys { - if idx > 0 { - builder.WriteByte(',') - } - stmt.AddVar(builder, key) - } - builder.WriteString(") = ") - - if _, ok := jsonQuery.equalsValue.(string); ok { - stmt.AddVar(builder, jsonQuery.equalsValue) - } else { - stmt.AddVar(builder, fmt.Sprint(jsonQuery.equalsValue)) - } - } - } - } - } -} - -// JSONMap defiend JSON data type, need to implements driver.Valuer, sql.Scanner interface -type JSONMap map[string]interface{} - -func (m JSONMap) ToMapStringAny() map[string]any { - r := make(map[string]any) - for k, v := range m { - r[k] = v - } - return r -} - -// Value return json value, implement driver.Valuer interface -func (m JSONMap) Value() (driver.Value, error) { - if m == nil { - return nil, nil - } - ba, err := m.MarshalJSON() - return string(ba), err -} - -// Scan scan value into Jsonb, implements sql.Scanner interface -func (m *JSONMap) Scan(val interface{}) error { - if val == nil { - *m = make(JSONMap) - return nil - } - var ba []byte - switch v := val.(type) { - case []byte: - ba = v - case string: - ba = []byte(v) - default: - return errors.New(fmt.Sprint("Failed to unmarshal JSONB value:", val)) - } - t := map[string]interface{}{} - err := json.Unmarshal(ba, &t) - *m = t - return err -} - -// MarshalJSON to output non base64 encoded []byte -func (m JSONMap) MarshalJSON() ([]byte, error) { - if m == nil { - return []byte("{}"), nil - } - t := (map[string]interface{})(m) - return json.Marshal(t) -} - -// UnmarshalJSON to deserialize []byte -func (m *JSONMap) UnmarshalJSON(b []byte) error { - t := map[string]interface{}{} - err := json.Unmarshal(b, &t) - *m = JSONMap(t) - return err -} - -// GormDataType gorm common data type -func (m JSONMap) GormDataType() string { - return "jsonmap" -} - -// GormDBDataType gorm db data type -func (JSONMap) GormDBDataType(db *gorm.DB, field *schema.Field) string { - switch db.Dialector.Name() { - case "sqlite": - return "JSON" - case "postgres": - return "JSONB" - case "sqlserver": - return "NVARCHAR(MAX)" - } - return "" -} - -func (jm JSONMap) GormValue(ctx context.Context, db *gorm.DB) clause.Expr { - data, _ := jm.MarshalJSON() - return gorm.Expr("?", string(data)) -} - -// JSONStringMap defiend JSON data type, need to implements driver.Valuer, sql.Scanner interface -type JSONStringMap map[string]string - -func (m JSONStringMap) ToMapStringAny() map[string]any { - r := make(map[string]any) - for k, v := range m { - r[k] = v - } - return r -} - -// Value return json value, implement driver.Valuer interface -func (m JSONStringMap) Value() (driver.Value, error) { - if m == nil { - return nil, nil - } - ba, err := m.MarshalJSON() - return string(ba), err -} - -// Scan scan value into Jsonb, implements sql.Scanner interface -func (m *JSONStringMap) Scan(val interface{}) error { - if val == nil { - *m = make(JSONStringMap) - return nil - } - var ba []byte - switch v := val.(type) { - case []byte: - ba = v - case string: - ba = []byte(v) - default: - return errors.New(fmt.Sprint("Failed to unmarshal JSONB value:", val)) - } - t := map[string]string{} - err := json.Unmarshal(ba, &t) - *m = t - return err -} - -// MarshalJSON to output non base64 encoded []byte -func (m JSONStringMap) MarshalJSON() ([]byte, error) { - if m == nil { - return []byte("{}"), nil - } - t := (map[string]string)(m) - return json.Marshal(t) -} - -// UnmarshalJSON to deserialize []byte -func (m *JSONStringMap) UnmarshalJSON(b []byte) error { - t := map[string]string{} - err := json.Unmarshal(b, &t) - *m = JSONStringMap(t) - return err -} - -// GormDataType gorm common data type -func (m JSONStringMap) GormDataType() string { - return "jsonstringmap" -} - -// GormDBDataType gorm db data type -func (JSONStringMap) GormDBDataType(db *gorm.DB, field *schema.Field) string { - switch db.Dialector.Name() { - case "sqlite": - return "JSON" - case "postgres": - return "JSONB" - case "sqlserver": - return "NVARCHAR(MAX)" - } - return "" -} - -func (jm JSONStringMap) GormValue(ctx context.Context, db *gorm.DB) clause.Expr { - data, _ := jm.MarshalJSON() - return gorm.Expr("?", string(data)) -} diff --git a/pkg/jobs/canary/canary_jobs.go b/pkg/jobs/canary/canary_jobs.go index 36a9bc26f..04b9f3781 100644 --- a/pkg/jobs/canary/canary_jobs.go +++ b/pkg/jobs/canary/canary_jobs.go @@ -286,7 +286,7 @@ func SyncCanaryJobs() { } for _, _c := range canaries { - canary, err := _c.ToV1() + canary, err := v1.CanaryFromModel(&_c) if err != nil { logger.Errorf("Error parsing canary[%s]: %v", _c.ID, err) jobHistory.AddError(err.Error()) @@ -294,14 +294,14 @@ func SyncCanaryJobs() { } if len(canary.Status.Checks) == 0 && len(canary.Spec.GetAllChecks()) > 0 { logger.Infof("Persisting %s as it has no checks", canary.Name) - pkgCanary, _, _, err := db.PersistCanary(*canary, canary.Annotations["source"]) + canaryModel, _, _, err := db.PersistCanary(*canary, canary.Annotations["source"]) if err != nil { logger.Errorf("Failed to persist canary %s: %v", canary.Name, err) jobHistory.AddError(err.Error()) continue } - v1canary, err := pkgCanary.ToV1() + v1canary, err := v1.CanaryFromModel(canaryModel) if err != nil { logger.Errorf("Failed to convert canary to V1 %s: %v", canary.Name, err) jobHistory.AddError(err.Error()) diff --git a/pkg/jobs/system/system_jobs.go b/pkg/jobs/system/system_jobs.go index 60b12f36a..e369a60df 100644 --- a/pkg/jobs/system/system_jobs.go +++ b/pkg/jobs/system/system_jobs.go @@ -56,6 +56,7 @@ func SyncTopologyJobs() { logger.Errorf("Failed to get topology: %v", err) return } + logger.Debugf("Found %d topologies", len(topologies)) for _, topology := range topologies { jobHistory := models.NewJobHistory("TopologySync", "topology", topology.GetPersistedID()).Start() diff --git a/pkg/system_api.go b/pkg/system_api.go index e819d8020..75d2cae3a 100644 --- a/pkg/system_api.go +++ b/pkg/system_api.go @@ -1,29 +1,14 @@ package pkg import ( - "context" - "database/sql/driver" - "fmt" - "strings" "time" v1 "github.com/flanksource/canary-checker/api/v1" - "github.com/flanksource/canary-checker/pkg/db/types" - "github.com/flanksource/commons/console" - "github.com/flanksource/commons/logger" - dutyTypes "github.com/flanksource/duty/types" + "github.com/flanksource/duty/models" + "github.com/flanksource/duty/types" "github.com/google/uuid" - jsontime "github.com/liamylian/jsontime/v2/v2" - "github.com/pkg/errors" - "gorm.io/gorm" - "gorm.io/gorm/clause" - "gorm.io/gorm/schema" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - k8sTypes "k8s.io/apimachinery/pkg/types" ) -var json = jsontime.ConfigWithCustomTimeFormat - type ComponentStatus string var ( @@ -54,134 +39,12 @@ func (status ComponentStatus) Compare(other ComponentStatus) int { const ComponentType = "component" -type Topology struct { - ID uuid.UUID `gorm:"default:generate_ulid()"` - Name string - Namespace string - Labels types.JSONStringMap - Spec types.JSON - Schedule string - CreatedAt time.Time `json:"created_at,omitempty" time_format:"postgres_timestamp"` - UpdatedAt time.Time `json:"updated_at,omitempty" time_format:"postgres_timestamp"` - DeletedAt *time.Time `json:"deleted_at,omitempty" time_format:"postgres_timestamp"` -} - -func TopologyFromV1(topology *v1.Topology) *Topology { - spec, _ := json.Marshal(topology.Spec) - return &Topology{ - Name: topology.GetName(), - Namespace: topology.GetNamespace(), - Labels: types.JSONStringMap(topology.GetLabels()), - Spec: spec, - } -} - -func (s *Topology) ToV1() v1.Topology { - var topologySpec v1.TopologySpec - id := s.ID.String() - if err := json.Unmarshal(s.Spec, &topologySpec); err != nil { - logger.Errorf("error unmarshalling topology spec %s", err) - } - return v1.Topology{ - TypeMeta: metav1.TypeMeta{ - Kind: "Topology", - APIVersion: "canaries.flanksource.com/v1", - }, - ObjectMeta: metav1.ObjectMeta{ - Name: s.Name, - Namespace: s.Namespace, - Labels: s.Labels, - UID: k8sTypes.UID(id), - }, - Spec: topologySpec, - } -} - type Object struct { Name string `json:"name,omitempty"` Namespace string `json:"namespace,omitempty"` Labels types.JSONStringMap `json:"labels,omitempty"` } -func (component *Component) UnmarshalJSON(b []byte) error { - type UpstreamUnmarshal Component - var c UpstreamUnmarshal - if err := json.Unmarshal(b, &c); err != nil { - return err - } - c.TopologyType = ComponentType - *component = Component(c) - return nil -} - -func (components *Components) UnmarshalJSON(b []byte) error { - var flat []Component - if err := json.Unmarshal(b, &flat); err != nil { - return err - } - for _, _c := range flat { - c := _c - c.TopologyType = ComponentType - *components = append(*components, &c) - } - return nil -} - -func (components Components) Walk() Components { - var comps Components - for _, _c := range components { - c := _c - comps = append(comps, c) - if c.Components != nil { - comps = append(comps, c.Components.Walk()...) - } - } - return comps -} - -type Component struct { - Name string `json:"name,omitempty"` - ID uuid.UUID `json:"id,omitempty" gorm:"default:generate_ulid()"` //nolint - Text string `json:"text,omitempty"` - Schedule string `json:"schedule,omitempty"` - TopologyType string `json:"topology_type,omitempty"` - Namespace string `json:"namespace,omitempty"` - Labels types.JSONStringMap `json:"labels,omitempty"` - Tooltip string `json:"tooltip,omitempty"` - Icon string `json:"icon,omitempty"` - Owner string `json:"owner,omitempty"` - Status ComponentStatus `json:"status,omitempty"` - StatusReason string `json:"statusReason,omitempty"` - Path string `json:"path,omitempty"` - Order int `json:"order,omitempty" gorm:"-"` - // The type of component, e.g. service, API, website, library, database, etc. - Type string `json:"type,omitempty"` - Summary v1.Summary `json:"summary,omitempty" gorm:"type:summary"` - // The lifecycle state of the component e.g. production, staging, dev, etc. - Lifecycle string `json:"lifecycle,omitempty"` - Properties Properties `json:"properties,omitempty" gorm:"type:properties"` - Components Components `json:"components,omitempty" gorm:"-"` - ParentId *uuid.UUID `json:"parent_id,omitempty"` //nolint - Selectors v1.ResourceSelectors `json:"selectors,omitempty" gorm:"resourceSelectors" swaggerignore:"true"` - ComponentChecks v1.ComponentChecks `json:"-" gorm:"componentChecks" swaggerignore:"true"` - Checks Checks `json:"checks,omitempty" gorm:"-"` - Configs Configs `json:"configs,omitempty" gorm:"type:configs"` - TopologyID *uuid.UUID `json:"topology_id,omitempty"` //nolint - CreatedAt time.Time `json:"created_at,omitempty" time_format:"postgres_timestamp"` - UpdatedAt time.Time `json:"updated_at,omitempty" time_format:"postgres_timestamp"` - DeletedAt *time.Time `json:"deleted_at,omitempty" time_format:"postgres_timestamp" swaggerignore:"true"` - ExternalId string `json:"external_id,omitempty"` //nolint - IsLeaf bool `json:"is_leaf"` - SelectorID string `json:"-" gorm:"-"` - Incidents []Incident `json:"incidents,omitempty" gorm:"-"` - ConfigInsights []map[string]interface{} `json:"insights,omitempty" gorm:"-"` - CostPerMinute float64 `json:"cost_per_minute,omitempty" gorm:"column:cost_per_minute"` - CostTotal1d float64 `json:"cost_total_1d,omitempty" gorm:"column:cost_total_1d"` - CostTotal7d float64 `json:"cost_total_7d,omitempty" gorm:"column:cost_total_7d"` - CostTotal30d float64 `json:"cost_total_30d,omitempty" gorm:"column:cost_total_30d"` - LogSelectors dutyTypes.LogSelectors `json:"logs,omitempty" gorm:"column:log_selectors"` -} - type ComponentRelationship struct { ComponentID uuid.UUID `json:"component_id,omitempty"` RelationshipID uuid.UUID `json:"relationship_id,omitempty"` @@ -202,116 +65,25 @@ type CheckComponentRelationship struct { DeletedAt *time.Time `json:"deleted_at,omitempty"` } -func (component Component) Clone() Component { - clone := Component{ - Name: component.Name, - TopologyType: component.TopologyType, - Order: component.Order, - ID: component.ID, - Text: component.Text, - Namespace: component.Namespace, - Labels: component.Labels, - Tooltip: component.Tooltip, - Icon: component.Icon, - Owner: component.Owner, - Status: component.Status, - StatusReason: component.StatusReason, - Type: component.Type, - Lifecycle: component.Lifecycle, - Checks: component.Checks, - Configs: component.Configs, - ComponentChecks: component.ComponentChecks, - Properties: component.Properties, - ExternalId: component.ExternalId, - Schedule: component.Schedule, +func NewComponent(c v1.ComponentSpec) *models.Component { + _c := models.Component{ + Name: c.Name, + Owner: c.Owner, + Type: c.Type, + Order: c.Order, + Lifecycle: c.Lifecycle, + Tooltip: c.Tooltip, + Icon: c.Icon, + Selectors: c.Selectors, + Configs: c.Configs.ToModel(), + LogSelectors: c.LogSelectors, } - copy(clone.LogSelectors, component.LogSelectors) - return clone -} - -func (component Component) String() string { - s := "" - if component.Type != "" { - s += component.Type + "/" - } - if component.Namespace != "" { - s += component.Namespace + "/" - } - if component.Text != "" { - s += component.Text - } else if component.Name != "" { - s += component.Name - } else { - s += component.ExternalId - } - return s -} - -func (component Component) GetAsEnvironment() map[string]interface{} { - return map[string]interface{}{ - "self": component, - "properties": component.Properties.AsMap(), - } -} - -func NewComponent(c v1.ComponentSpec) *Component { - configs := NewConfigs(c.Configs) - _c := Component{ - Name: c.Name, - Owner: c.Owner, - Type: c.Type, - Order: c.Order, - Lifecycle: c.Lifecycle, - Tooltip: c.Tooltip, - Icon: c.Icon, - Selectors: c.Selectors, - ComponentChecks: c.ComponentChecks, - Configs: configs, - LogSelectors: c.LogSelectors, - } if c.Summary != nil { _c.Summary = *c.Summary } - return &_c -} - -func (component Component) GetID() string { - if component.ID != uuid.Nil { - return component.ID.String() - } - if component.Text != "" { - return component.Text - } - return component.Name -} -func (components Components) Debug(prefix string) string { - s := "" - for _, component := range components { - status := component.Status - - if component.IsHealthy() { - status = ComponentStatus(console.Greenf(string(status))) - } else { - status = ComponentStatus(console.Redf(string(status))) - } - - s += fmt.Sprintf("%s%s (%s) => %s\n", prefix, component, component.GetID(), status) - s += component.Components.Debug(prefix + "\t") - } - return s -} - -type Components []*Component - -func (components Components) Find(name string) *Component { - for _, component := range components { - if component.Name == name { - return component - } - } - return nil + return &_c } type Text struct { @@ -335,305 +107,3 @@ type Incident struct { Severity int `json:"severity"` Description string `json:"description"` } - -// Property is a realized v1.Property without the lookup definition -type Property struct { - Label string `json:"label,omitempty"` - Name string `json:"name,omitempty"` - Tooltip string `json:"tooltip,omitempty"` - Icon string `json:"icon,omitempty"` - Type string `json:"type,omitempty"` - Color string `json:"color,omitempty"` - Order int `json:"order,omitempty"` - Headline bool `json:"headline,omitempty"` - - // Either text or value is required, but not both. - Text string `json:"text,omitempty"` - Value int64 `json:"value,omitempty"` - - // e.g. milliseconds, bytes, millicores, epoch etc. - Unit string `json:"unit,omitempty"` - Max *int64 `json:"max,omitempty"` - Min int64 `json:"min,omitempty"` - - Status string `json:"status,omitempty"` - LastTransition string `json:"lastTransition,omitempty"` - Links []v1.Link `json:"links,omitempty"` -} - -type Properties []*Property - -func (p Properties) AsJSON() []byte { - if len(p) == 0 { - return []byte("[]") - } - data, err := json.Marshal(p) - if err != nil { - logger.Errorf("Error marshalling properties: %v", err) - } - return data -} - -func (p Properties) AsMap() map[string]interface{} { - result := make(map[string]interface{}) - for _, property := range p { - result[property.Name] = property.GetValue() - } - return result -} - -func (p Properties) Find(name string) *Property { - for _, prop := range p { - if prop.Name == name { - return prop - } - } - return nil -} - -func (p Property) GetValue() interface{} { - if p.Text != "" { - return p.Text - } - if p.Value != 0 { - return p.Value - } - return nil -} - -func (p *Property) String() string { - s := fmt.Sprintf("%s[", p.Name) - if p.Text != "" { - s += fmt.Sprintf("text=%s ", p.Text) - } - if p.Value != 0 { - s += fmt.Sprintf("value=%d ", p.Value) - } - if p.Unit != "" { - s += fmt.Sprintf("unit=%s ", p.Unit) - } - if p.Max != nil { - s += fmt.Sprintf("max=%d ", *p.Max) - } - if p.Min != 0 { - s += fmt.Sprintf("min=%d ", p.Min) - } - if p.Status != "" { - s += fmt.Sprintf("status=%s ", p.Status) - } - if p.LastTransition != "" { - s += fmt.Sprintf("lastTransition=%s ", p.LastTransition) - } - - return strings.TrimRight(s, " ") + "]" -} - -func (p *Property) Merge(other *Property) { - if other.Text != "" { - p.Text = other.Text - } - if other.Value != 0 { - p.Value = other.Value - } - if other.Unit != "" { - p.Unit = other.Unit - } - if other.Max != nil { - p.Max = other.Max - } - if other.Min != 0 { - p.Min = other.Min - } - if other.Order > 0 { - p.Order = other.Order - } - if other.Status != "" { - p.Status = other.Status - } - if other.LastTransition != "" { - p.LastTransition = other.LastTransition - } - if other.Links != nil { - p.Links = other.Links - } - if other.Type != "" { - p.Type = other.Type - } - if other.Color != "" { - p.Color = other.Color - } -} - -func NewProperty(property v1.Property) *Property { - return &Property{ - Label: property.Label, - Name: property.Name, - Tooltip: property.Tooltip, - Icon: property.Icon, - Order: property.Order, - Text: property.Text, - Value: property.Value, - Unit: property.Unit, - Max: property.Max, - Min: property.Min, - Status: property.Status, - LastTransition: property.LastTransition, - Links: property.Links, - Headline: property.Headline, - Type: property.Type, - Color: property.Color, - } -} - -func (component Component) IsHealthy() bool { - s := component.Summarize() - return s.Healthy > 0 && s.Unhealthy == 0 && s.Warning == 0 -} - -func (component Component) Summarize() v1.Summary { - s := v1.Summary{ - Incidents: component.Summary.Incidents, - Insights: component.Summary.Insights, - } - if component.Checks != nil && component.Components == nil { - for _, check := range component.Checks { - if ComponentStatus(check.Status) == ComponentPropertyStatusHealthy { - s.Healthy++ - } else { - s.Unhealthy++ - } - } - return s - } - if len(component.Components) == 0 { - switch component.Status { - case ComponentPropertyStatusHealthy: - s.Healthy++ - case ComponentPropertyStatusUnhealthy: - s.Unhealthy++ - case ComponentPropertyStatusWarning: - s.Warning++ - case ComponentPropertyStatusInfo: - s.Info++ - } - return s - } - for _, child := range component.Components { - s = s.Add(child.Summarize()) - child.Summary = child.Summarize() - } - return s -} - -func (components Components) Summarize() v1.Summary { - s := v1.Summary{} - for _, component := range components { - s = s.Add(component.Summarize()) - } - return s -} - -func (component Component) GetStatus() ComponentStatus { - if component.Summary.Healthy > 0 && component.Summary.Unhealthy > 0 { - return ComponentPropertyStatusWarning - } else if component.Summary.Unhealthy > 0 { - return ComponentPropertyStatusUnhealthy - } else if component.Summary.Warning > 0 { - return ComponentPropertyStatusWarning - } else if component.Summary.Healthy > 0 { - return ComponentPropertyStatusHealthy - } else { - return ComponentPropertyStatusInfo - } -} - -// Scan scan value into Jsonb, implements sql.Scanner interface -func (p Properties) Value() (driver.Value, error) { - if len(p) == 0 { - return nil, nil - } - return p.AsJSON(), nil -} - -// Scan scan value into Jsonb, implements sql.Scanner interface -func (p *Properties) Scan(val interface{}) error { - if val == nil { - *p = make(Properties, 0) - return nil - } - var ba []byte - switch v := val.(type) { - case []byte: - ba = v - default: - return errors.New(fmt.Sprint("Failed to unmarshal properties value:", val)) - } - err := json.Unmarshal(ba, p) - return err -} - -// GormDataType gorm common data type -func (Properties) GormDataType() string { - return "properties" -} - -func (Properties) GormDBDataType(db *gorm.DB, field *schema.Field) string { - switch db.Dialector.Name() { - case "sqlite": - return "TEXT" - case "postgres": - return "JSONB" - case "sqlserver": - return "NVARCHAR(MAX)" - } - return "" -} - -func (p Properties) GormValue(ctx context.Context, db *gorm.DB) clause.Expr { - data, _ := json.Marshal(p) - return gorm.Expr("?", data) -} - -func (c Configs) GormValue(ctx context.Context, db *gorm.DB) clause.Expr { - data, _ := json.Marshal(c) - return gorm.Expr("?", data) -} - -// Scan scan value into Jsonb, implements sql.Scanner interface -func (c Configs) Value() (driver.Value, error) { - return json.Marshal(c) -} - -// Scan scan value into Jsonb, implements sql.Scanner interface -func (c *Configs) Scan(val interface{}) error { - if val == nil { - *c = Configs{} - return nil - } - var ba []byte - switch v := val.(type) { - case []byte: - ba = v - default: - return errors.New(fmt.Sprint("Failed to unmarshal properties value:", val)) - } - err := json.Unmarshal(ba, c) - return err -} - -// GormDataType gorm common data type -func (Configs) GormDataType() string { - return "configs" -} - -func (Configs) GormDBDataType(db *gorm.DB, field *schema.Field) string { - switch db.Dialector.Name() { - case "sqlite": - return "TEXT" - case "postgres": - return "JSONB" - case "sqlserver": - return "NVARCHAR(MAX)" - } - return "" -} diff --git a/pkg/topology/checks/component_check.go b/pkg/topology/checks/component_check.go index 0e63fddf3..f6d0db097 100644 --- a/pkg/topology/checks/component_check.go +++ b/pkg/topology/checks/component_check.go @@ -1,8 +1,10 @@ package checks import ( + "encoding/json" "time" + v1 "github.com/flanksource/canary-checker/api/v1" "github.com/flanksource/canary-checker/pkg" "github.com/flanksource/canary-checker/pkg/db" canaryJobs "github.com/flanksource/canary-checker/pkg/jobs/canary" @@ -18,9 +20,10 @@ func ComponentCheckRun() { logger.Debugf("Syncing Check Relationships") components, err := db.GetAllComponentWithCanaries() if err != nil { - logger.Errorf("error getting components: %v", err) + logger.Errorf("error getting components with canaries: %v", err) return } + jobHistory := models.NewJobHistory("ComponentCheckRelationshipSync", "", "").Start() _ = db.PersistJobHistory(jobHistory) for _, component := range components { @@ -36,7 +39,7 @@ func ComponentCheckRun() { _ = db.PersistJobHistory(jobHistory.End()) } -func GetCheckComponentRelationshipsForComponent(component *pkg.Component) (relationships []*pkg.CheckComponentRelationship) { +func GetCheckComponentRelationshipsForComponent(component *models.Component) (relationships []*pkg.CheckComponentRelationship) { for _, componentCheck := range component.ComponentChecks { if componentCheck.Selector.LabelSelector != "" { labelChecks, err := db.GetChecksWithLabelSelector(componentCheck.Selector.LabelSelector) @@ -57,20 +60,27 @@ func GetCheckComponentRelationshipsForComponent(component *pkg.Component) (relat }) } } + if componentCheck.Inline != nil { + var canarySpec v1.CanarySpec + if err := json.Unmarshal([]byte(*componentCheck.Inline), &canarySpec); err != nil { + logger.Debugf("error unmarshalling inline: %v", err) + continue + } + inlineSchedule := component.Schedule - if componentCheck.Inline.Schedule != "" { - inlineSchedule = componentCheck.Inline.Schedule + if canarySpec.Schedule != "" { + inlineSchedule = canarySpec.Schedule } canary, err := db.CreateComponentCanaryFromInline( component.ID.String(), component.Name, component.Namespace, - inlineSchedule, component.Owner, componentCheck.Inline, + inlineSchedule, component.Owner, &canarySpec, ) if err != nil { logger.Debugf("error creating canary from inline: %v", err) } - if v1canary, err := canary.ToV1(); err == nil { + if v1canary, err := v1.CanaryFromModel(canary); err == nil { if err := canaryJobs.SyncCanaryJob(*v1canary); err != nil { logger.Debugf("error creating canary job: %v", err) } @@ -95,6 +105,7 @@ func GetCheckComponentRelationshipsForComponent(component *pkg.Component) (relat } } } + return relationships } diff --git a/pkg/topology/configs/component_config.go b/pkg/topology/configs/component_config.go index c40385e0b..aa27b8f55 100644 --- a/pkg/topology/configs/component_config.go +++ b/pkg/topology/configs/component_config.go @@ -6,11 +6,11 @@ import ( "github.com/flanksource/commons/collections" "github.com/flanksource/commons/logger" "github.com/flanksource/duty/models" + "github.com/flanksource/duty/types" "github.com/google/uuid" "github.com/pkg/errors" "gorm.io/gorm" - "github.com/flanksource/canary-checker/pkg" "github.com/flanksource/canary-checker/pkg/db" "github.com/flanksource/canary-checker/pkg/utils" ) @@ -19,7 +19,7 @@ func ComponentConfigRun() { logger.Debugf("Syncing Component Config Relationships") components, err := db.GetAllComponentsWithConfigs() if err != nil { - logger.Errorf("error getting components: %v", err) + logger.Errorf("error getting components with configs: %v", err) return } @@ -36,7 +36,7 @@ func ComponentConfigRun() { _ = db.PersistJobHistory(jobHistory.End()) } -func SyncComponentConfigRelationship(componentID uuid.UUID, configs pkg.Configs) error { +func SyncComponentConfigRelationship(componentID uuid.UUID, configs types.ConfigQueries) error { if len(configs) == 0 { return nil } @@ -55,7 +55,7 @@ func SyncComponentConfigRelationship(componentID uuid.UUID, configs pkg.Configs) var newConfigsIDs []string for _, config := range configs { - dbConfig, err := db.FindConfig(*config) + dbConfig, err := db.FindConfig(config) if dbConfig == nil || errors.Is(err, gorm.ErrRecordNotFound) { logger.Tracef("no config found for %s", *config) continue @@ -72,7 +72,7 @@ func SyncComponentConfigRelationship(componentID uuid.UUID, configs pkg.Configs) // If configID does not exist, create a new relationship if !collections.Contains(existingConfigIDs, dbConfig.ID.String()) { - if err := db.PersistConfigComponentRelationship(*dbConfig.ID, componentID, selectorID); err != nil { + if err := db.PersistConfigComponentRelationship(dbConfig.ID, componentID, selectorID); err != nil { return errors.Wrap(err, "error persisting config relationships") } continue @@ -83,7 +83,7 @@ func SyncComponentConfigRelationship(componentID uuid.UUID, configs pkg.Configs) Update("deleted_at", time.Now()).Error; err != nil { return errors.Wrap(err, "error updating config relationships") } - if err := db.PersistConfigComponentRelationship(*dbConfig.ID, componentID, selectorID); err != nil { + if err := db.PersistConfigComponentRelationship(dbConfig.ID, componentID, selectorID); err != nil { return errors.Wrap(err, "error persisting config relationships") } } diff --git a/pkg/topology/context.go b/pkg/topology/context.go index ec0853c0b..f6b390a97 100644 --- a/pkg/topology/context.go +++ b/pkg/topology/context.go @@ -3,7 +3,7 @@ package topology import ( "github.com/flanksource/canary-checker/api/context" v1 "github.com/flanksource/canary-checker/api/v1" - "github.com/flanksource/canary-checker/pkg" + "github.com/flanksource/duty/models" "github.com/flanksource/kommons" "github.com/flanksource/kommons/ktemplate" "github.com/pkg/errors" @@ -16,9 +16,9 @@ type ComponentContext struct { // Components keep track of the components that properties can apply to, // properties can return a map of component names to properties to facilitate // queries that are more efficient to perform for all components rather than a component at a time - Components *pkg.Components + Components *models.Components // Properties can either be looked up on an individual component, or act as a summary across all components - CurrentComponent *pkg.Component + CurrentComponent *models.Component templater *ktemplate.StructTemplater } @@ -46,7 +46,7 @@ func (c *ComponentContext) GetTemplater() ktemplate.StructTemplater { return *c.templater } -func (c *ComponentContext) SetCurrentComponent(component *pkg.Component) { +func (c *ComponentContext) SetCurrentComponent(component *models.Component) { c.CurrentComponent = component if c.templater != nil { c.templater.Values = map[string]interface{}{ @@ -102,7 +102,7 @@ func (c *ComponentContext) Clone() *ComponentContext { Components: c.Components, } } -func (c *ComponentContext) WithComponents(components *pkg.Components, current *pkg.Component) *ComponentContext { +func (c *ComponentContext) WithComponents(components *models.Components, current *models.Component) *ComponentContext { cloned := c.Clone() cloned.Components = components cloned.CurrentComponent = current diff --git a/pkg/topology/run.go b/pkg/topology/run.go index 68cac3aaf..3b5c3ab31 100644 --- a/pkg/topology/run.go +++ b/pkg/topology/run.go @@ -9,11 +9,11 @@ import ( "github.com/flanksource/canary-checker/checks" "github.com/flanksource/canary-checker/pkg" "github.com/flanksource/canary-checker/pkg/db" - "github.com/flanksource/canary-checker/pkg/db/types" "github.com/flanksource/canary-checker/pkg/utils" "github.com/flanksource/canary-checker/templating" "github.com/flanksource/commons/logger" "github.com/flanksource/duty/models" + dutyTypes "github.com/flanksource/duty/types" "github.com/flanksource/kommons" "github.com/google/uuid" jsontime "github.com/liamylian/jsontime/v2/v2" @@ -22,9 +22,9 @@ import ( var json = jsontime.ConfigWithCustomTimeFormat -func mergeComponentLookup(ctx *ComponentContext, component *v1.ComponentSpec, spec *v1.CanarySpec) (pkg.Components, error) { +func mergeComponentLookup(ctx *ComponentContext, component *v1.ComponentSpec, spec *v1.CanarySpec) (models.Components, error) { name := component.Name - components := pkg.Components{} + components := models.Components{} results, err := lookup(ctx, name, *spec) if err != nil { return nil, errors.Wrapf(err, "component lookup failed: %s", component) @@ -36,7 +36,7 @@ func mergeComponentLookup(ctx *ComponentContext, component *v1.ComponentSpec, sp } else { // the property returned a list of new properties for _, result := range results { - var p pkg.Component + var p models.Component data, err := json.Marshal(result) if err != nil { return nil, err @@ -56,7 +56,7 @@ func mergeComponentLookup(ctx *ComponentContext, component *v1.ComponentSpec, sp return components, nil } -func forEachComponent(ctx *ComponentContext, spec *v1.ComponentSpec, component *pkg.Component) error { +func forEachComponent(ctx *ComponentContext, spec *v1.ComponentSpec, component *models.Component) error { logger.Debugf("[%s] %s", component.Name, spec.ForEach) if spec.ForEach == nil { return nil @@ -95,7 +95,7 @@ func forEachComponent(ctx *ComponentContext, spec *v1.ComponentSpec, component * if err := ctx.TemplateConfig(&child); err != nil { logger.Errorf("Failed to lookup configs %s: %v", child, err) } else { - component.Configs = append(component.Configs, pkg.NewConfig(child)) + component.Configs = append(component.Configs, child.ToModel()) } } @@ -111,19 +111,19 @@ func forEachComponent(ctx *ComponentContext, spec *v1.ComponentSpec, component * return nil } -func lookupComponents(ctx *ComponentContext, component v1.ComponentSpec) (components pkg.Components, err error) { +func lookupComponents(ctx *ComponentContext, component v1.ComponentSpec) (components models.Components, err error) { // A component can have either a lookup or child components // A lookup will translates flatly into a list of components if component.Lookup != nil { - var lookedUpComponents pkg.Components + var lookedUpComponents models.Components logger.Debugf("Looking up components for %s => %s", component, component.ForEach) if lookedUpComponents, err = mergeComponentLookup(ctx, &component, component.Lookup); err != nil { return nil, err } components = append(components, lookedUpComponents...) } else { - var childComponents pkg.Components + var childComponents models.Components for _, child := range component.Components { children, err := lookupComponents(ctx, v1.ComponentSpec(child)) if err != nil { @@ -200,8 +200,9 @@ func lookup(ctx *ComponentContext, name string, spec v1.CanarySpec) ([]interface return results, nil } -func lookupConfig(ctx *ComponentContext, property *v1.Property) (*pkg.Property, error) { - prop := pkg.NewProperty(*property) +func lookupConfig(ctx *ComponentContext, property *v1.Property) (*models.Property, error) { + prop := property.ToModel() + logger.Debugf("Looking up config for %s => %s", property.Name, property.ConfigLookup.Config) if property.ConfigLookup.Config == nil { return nil, fmt.Errorf("empty config in configLookup") @@ -227,36 +228,45 @@ func lookupConfig(ctx *ComponentContext, property *v1.Property) (*pkg.Property, if err := ctx.TemplateConfig(config); err != nil { return nil, err } - pkgConfig := pkg.NewConfig(*config) - pkgConfig.Name = configName - _config, err := db.FindConfig(*pkgConfig) + + configQuery := config.ToModel() + configQuery.Name = configName + _config, err := db.FindConfig(configQuery) if err != nil { return prop, err - } - if _config == nil { + } else if _config == nil { return prop, nil } + configMap, err := _config.ConfigJSONStringMap() + if err != nil { + return prop, fmt.Errorf("failed to marshal config: %w", err) + } + templateEnv := map[string]any{ - "config": _config.Spec.ToMapStringAny(), + "config": configMap, "tags": _config.Tags.ToMapStringAny(), } prop.Text, err = templating.Template(templateEnv, property.ConfigLookup.Display.Template) return prop, err } -func lookupProperty(ctx *ComponentContext, property *v1.Property) (pkg.Properties, error) { - prop := pkg.NewProperty(*property) +func lookupProperty(ctx *ComponentContext, property *v1.Property) (models.Properties, error) { + if property == nil { + return nil, nil + } + + prop := property.ToModel() if property.ConfigLookup != nil { prop, err := lookupConfig(ctx, property) if err != nil { return nil, errors.Wrapf(err, "property config lookup failed: %s", property) } - return pkg.Properties{prop}, nil + return models.Properties{prop}, nil } if property.Lookup == nil { - return pkg.Properties{prop}, nil + return models.Properties{prop}, nil } results, err := lookup(ctx, property.Name, *property.Lookup) @@ -276,7 +286,7 @@ func lookupProperty(ctx *ComponentContext, property *v1.Property) (pkg.Propertie if isComponentList(data) { // the result is map of components to properties, find the existing component // and then merge the property into it - components := pkg.Components{} + components := models.Components{} err = json.Unmarshal([]byte(results[0].(string)), &components) if err != nil { return nil, err @@ -296,12 +306,12 @@ func lookupProperty(ctx *ComponentContext, property *v1.Property) (pkg.Propertie } return nil, nil } else if isPropertyList(data) { - properties := pkg.Properties{} + properties := models.Properties{} err = json.Unmarshal([]byte(results[0].(string)), &properties) return properties, err } else { prop.Text = string(data) - return pkg.Properties{prop}, nil + return models.Properties{prop}, nil } } @@ -311,14 +321,14 @@ type TopologyRunOptions struct { Namespace string } -func Run(opts TopologyRunOptions, s v1.Topology) []*pkg.Component { +func Run(opts TopologyRunOptions, s v1.Topology) []*models.Component { if s.Namespace == "" { s.Namespace = opts.Namespace } logger.Debugf("Running topology %s/%s depth=%d", s.Namespace, s.Name, opts.Depth) ctx := NewComponentContext(opts.Client, s) - var results pkg.Components - component := &pkg.Component{ + var results models.Components + component := &models.Component{ Name: ctx.Topology.Spec.Text, Namespace: ctx.Topology.GetNamespace(), Labels: ctx.Topology.Labels, @@ -343,7 +353,7 @@ func Run(opts TopologyRunOptions, s v1.Topology) []*pkg.Component { // add topology labels to the components for _, component := range components { if component.Labels == nil { - component.Labels = make(types.JSONStringMap) + component.Labels = make(dutyTypes.JSONStringMap) } for key, value := range ctx.Topology.Labels { // don't overwrite the component labels @@ -397,10 +407,9 @@ func Run(opts TopologyRunOptions, s v1.Topology) []*pkg.Component { component.ExternalId = component.Name } - component.Status = pkg.ComponentStatus(component.Summary.GetStatus()) - // if logger.IsTraceEnabled() { + component.Status = component.Summary.GetStatus() + logger.Debugf(component.Components.Debug("")) - // } results = append(results, component) logger.Infof("%s id=%s external_id=%s status=%s", component.Name, component.ID, component.ExternalId, component.Status) for _, c := range results.Walk() { diff --git a/pkg/topology/sync.go b/pkg/topology/sync.go index 8fb8fe5a7..385af0dae 100644 --- a/pkg/topology/sync.go +++ b/pkg/topology/sync.go @@ -20,7 +20,7 @@ func ComponentRun() { components, err := db.GetAllComponentsWithSelectors() if err != nil { - logger.Errorf("error getting components: %v", err) + logger.Errorf("error getting components with selectors: %v", err) return } @@ -54,9 +54,10 @@ func ComponentStatusSummarySync() { logger.Debugf("Syncing Status and Summary for components") topology, err := Query(duty.TopologyOptions{Depth: 3}) if err != nil { - logger.Errorf("error getting components: %v", err) + logger.Errorf("error querying topology: %v", err) return } + jobHistory := models.NewJobHistory("ComponentStatusSummarySync", "", "").Start() _ = db.PersistJobHistory(jobHistory) topology.Components.Map(func(c *models.Component) { diff --git a/templating/template.go b/templating/template.go index b8180fe4b..228d520a1 100644 --- a/templating/template.go +++ b/templating/template.go @@ -14,11 +14,11 @@ import ( "github.com/robertkrimen/otto" v1 "github.com/flanksource/canary-checker/api/v1" - "github.com/flanksource/canary-checker/pkg" "github.com/flanksource/canary-checker/pkg/db" _ "github.com/flanksource/canary-checker/templating/js" "github.com/flanksource/commons/logger" "github.com/flanksource/commons/text" + "github.com/flanksource/duty/types" "github.com/robertkrimen/otto/registry" _ "github.com/robertkrimen/otto/underscore" ) @@ -48,21 +48,25 @@ func Template(environment map[string]interface{}, template v1.Template) (string, err := vm.Set("findConfigItem", func(call otto.FunctionCall) otto.Value { configType, _ := call.Argument(0).ToString() configName, _ := call.Argument(1).ToString() - configItemParams := pkg.Config{ - Type: configType, - Name: configName, - } - configItem, err := db.FindConfig(configItemParams) + configItem, err := db.FindConfig(&types.ConfigQuery{Type: configType, Name: configName}) if err != nil { logger.Errorf("Error fetching config item for js: %v", err) emptyObj, _ := vm.ToValue(map[string]string{}) return emptyObj } + if configItem == nil { emptyObj, _ := vm.ToValue(map[string]string{}) return emptyObj } - result, _ := vm.ToValue(configItem.ToJSONMap()) + + jsonMap, err := configItem.ConfigJSONStringMap() + if err != nil { + logger.Errorf("failed to convert config item to json: %v", err) + emptyObj, _ := vm.ToValue(map[string]string{}) + return emptyObj + } + result, _ := vm.ToValue(jsonMap) return result }) if err != nil { @@ -80,7 +84,8 @@ func Template(environment map[string]interface{}, template v1.Template) (string, } var ciJSON []map[string]interface{} for _, i := range configItems { - ciJSON = append(ciJSON, i.ToJSONMap()) + configJSON, _ := i.ConfigJSONStringMap() + ciJSON = append(ciJSON, configJSON) } result, _ := vm.ToValue(ciJSON) return result