Skip to content

Commit

Permalink
Add deleteWhenDone option to insights (#927)
Browse files Browse the repository at this point in the history
* Insights were automatically deleted, add option to keep insight created during validation
  • Loading branch information
jdpleiness authored Jan 24, 2023
1 parent dd50ea0 commit 79c8fa1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/validate/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ type GitHub struct {
}

type Insight struct {
Title string `yaml:"title"`
DataSeries []map[string]any `yaml:"dataSeries"`
Title string `yaml:"title"`
DataSeries []map[string]any `yaml:"dataSeries"`
DeleteWhenDone bool `yaml:"deleteWhenDone"`
}

type ValidationSpec struct {
Expand Down Expand Up @@ -114,6 +115,7 @@ func DefaultConfig() *ValidationSpec {
"timeScopeValue": 1,
},
},
DeleteWhenDone: true,
},
}
}
Expand Down Expand Up @@ -171,7 +173,7 @@ func Validate(ctx context.Context, client api.Client, config *ValidationSpec) er

cloned, err := repoCloneTimeout(ctx, client, config.ExternalService)
if err != nil {
return err //TODO make sure errors are wrapped once
return err
}
if !cloned {
return errors.Newf("%s validate failed, repo did not clone\n", validate.FailureEmoji)
Expand Down Expand Up @@ -207,7 +209,7 @@ func Validate(ctx context.Context, client api.Client, config *ValidationSpec) er
log.Printf("%s insight successfully added", validate.SuccessEmoji)

defer func() {
if insightId != "" {
if insightId != "" && config.Insight.DeleteWhenDone {
_ = removeInsight(ctx, client, insightId)
log.Printf("%s insight %s has been removed", validate.SuccessEmoji, config.Insight.Title)

Expand Down

0 comments on commit 79c8fa1

Please sign in to comment.