Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate: add deleteWhenDone option to insights #927

Merged
merged 1 commit into from
Jan 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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