Skip to content

Commit

Permalink
fix: deletion logic for transformed checks (#1143)
Browse files Browse the repository at this point in the history
* fix: deletion logic for transformed checks

* fix: lint error

* fix: nil uuid edge case when persisiting checks

* feat: add transform delete strategy

* chore: update manifests

* chore: fix lint

* chore: use constants and check statuses for transformed

* chore: fix lint
  • Loading branch information
yashmehrotra authored Jul 18, 2023
1 parent 14a043d commit 23a2a70
Show file tree
Hide file tree
Showing 51 changed files with 834 additions and 91 deletions.
1 change: 1 addition & 0 deletions api/external/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Describable interface {
GetIcon() string
GetName() string
GetLabels() map[string]string
GetTransformDeleteStrategy() string
}

type WithType interface {
Expand Down
5 changes: 5 additions & 0 deletions api/v1/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import (
"k8s.io/client-go/kubernetes"
)

const (
OnTransformMarkHealthy = "MarkHealthy"
OnTransformMarkUnhealthy = "MarkUnhealthy"
)

type checkContext interface {
context.Context
HydrateConnectionByURL(connectionName string) (*models.Connection, error)
Expand Down
6 changes: 6 additions & 0 deletions api/v1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ type Description struct {
Icon string `yaml:"icon,omitempty" json:"icon,omitempty" template:"true"`
// Labels for the check
Labels Labels `yaml:"labels,omitempty" json:"labels,omitempty"`
// Transformed checks have a delete strategy on deletion they can either be marked healthy, unhealthy or left as is
TransformDeleteStrategy string `yaml:"transformDeleteStrategy,omitempty" json:"transformDeleteStrategy,omitempty"`
}

func (d Description) String() string {
Expand All @@ -305,6 +307,10 @@ func (d Description) GetLabels() map[string]string {
return d.Labels
}

func (d Description) GetTransformDeleteStrategy() string {
return d.TransformDeleteStrategy
}

type Connection struct {
// Connection name e.g. connection://http/google
Connection string `yaml:"connection,omitempty" json:"connection,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions checks/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func transform(ctx *context.Context, in *pkg.CheckResult) ([]*pkg.CheckResult, e
t.Name = def(t.Name, in.Check.GetName())
t.Type = def(t.Type, in.Check.GetType())
t.Endpoint = def(t.Endpoint, in.Check.GetEndpoint())
t.TransformDeleteStrategy = def(t.TransformDeleteStrategy, in.Check.GetTransformDeleteStrategy())
r := t.ToCheckResult()
r.Canary = in.Canary
r.Canary.Namespace = def(t.Namespace, r.Canary.Namespace)
Expand All @@ -96,6 +97,7 @@ func transform(ctx *context.Context, in *pkg.CheckResult) ([]*pkg.CheckResult, e
// We use this label to set the transformed column to true
// This label is used and then removed in pkg.FromV1 function
r.Canary.Labels["transformed"] = "true" //nolint:goconst
r.Transformed = true
results = append(results, &r)
}

Expand Down
111 changes: 111 additions & 0 deletions config/deploy/crd.yaml

Large diffs are not rendered by default.

111 changes: 111 additions & 0 deletions config/deploy/manifests.yaml

Large diffs are not rendered by default.

Loading

0 comments on commit 23a2a70

Please sign in to comment.