Skip to content

Commit 79c8fa1

Browse files
authored
Add deleteWhenDone option to insights (#927)
* Insights were automatically deleted, add option to keep insight created during validation
1 parent dd50ea0 commit 79c8fa1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

internal/validate/install/install.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ type GitHub struct {
5656
}
5757

5858
type Insight struct {
59-
Title string `yaml:"title"`
60-
DataSeries []map[string]any `yaml:"dataSeries"`
59+
Title string `yaml:"title"`
60+
DataSeries []map[string]any `yaml:"dataSeries"`
61+
DeleteWhenDone bool `yaml:"deleteWhenDone"`
6162
}
6263

6364
type ValidationSpec struct {
@@ -114,6 +115,7 @@ func DefaultConfig() *ValidationSpec {
114115
"timeScopeValue": 1,
115116
},
116117
},
118+
DeleteWhenDone: true,
117119
},
118120
}
119121
}
@@ -171,7 +173,7 @@ func Validate(ctx context.Context, client api.Client, config *ValidationSpec) er
171173

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

209211
defer func() {
210-
if insightId != "" {
212+
if insightId != "" && config.Insight.DeleteWhenDone {
211213
_ = removeInsight(ctx, client, insightId)
212214
log.Printf("%s insight %s has been removed", validate.SuccessEmoji, config.Insight.Title)
213215

0 commit comments

Comments
 (0)