Skip to content

Commit a84a232

Browse files
committed
Improve UI handling of recommendtns
Signed-off-by: Adolfo García Veytia (Puerco) <puerco@carabiner.dev>
1 parent 023ee0f commit a84a232

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

sourcetool/internal/cmd/setup.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ sourcetool is about to perform the following actions on your behalf:
151151
- %s.
152152
153153
`,
154-
srctool.ControlConfigurationDescr(opts.GetBranch(), models.CONFIG_POLICY),
154+
srctool.ControlConfigurationDescr(opts.GetBranch(), models.CONFIG_TAG_RULES),
155155
srctool.ControlConfigurationDescr(opts.GetBranch(), models.CONFIG_GEN_PROVENANCE),
156156
srctool.ControlConfigurationDescr(opts.GetBranch(), models.CONFIG_BRANCH_RULES),
157157
)
@@ -322,6 +322,11 @@ a fork of the repository you want to protect.
322322
opts.GetBranch().Repository, []*models.Branch{opts.GetBranch()}, cs,
323323
)
324324
if err != nil {
325+
// if strings.Contains(err.Error(), models.ErrProtectionAlreadyInPlace.Error()) {
326+
if errors.Is(err, models.ErrProtectionAlreadyInPlace) {
327+
fmt.Printf("\n ℹ️ Controls already enabled on %s\n\n", opts.GetRepository().Path)
328+
return nil
329+
}
325330
return fmt.Errorf("configuring controls: %w", err)
326331
}
327332

sourcetool/internal/cmd/status.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,22 @@ sourcetool status myorg/myrepo@mybranch
165165

166166
fmt.Println(w("Current SLSA Source level: " + toplevel))
167167
fmt.Println("")
168-
169-
fmt.Println("Recommended actions:")
170-
168+
titled := false
171169
for _, status := range controls.Controls {
172170
if status.RecommendedAction == nil {
173171
continue
174172
}
173+
174+
// Suggest creating the policy but only on the higher levels
175+
if status.Name == slsa.PolicyAvailable && toplevel == slsa.SlsaSourceLevel1 {
176+
continue
177+
}
178+
179+
if !titled {
180+
fmt.Println(w2("✨ Recommended actions:"))
181+
titled = true
182+
}
183+
175184
fmt.Printf(" - %s\n", status.RecommendedAction.Message)
176185
if status.RecommendedAction.Command != "" {
177186
fmt.Printf(" > %s\n", status.RecommendedAction.Command)

sourcetool/pkg/sourcetool/tool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
)
2121

2222
var ControlConfigurations = []models.ControlConfiguration{
23-
models.CONFIG_POLICY, models.CONFIG_GEN_PROVENANCE, models.CONFIG_BRANCH_RULES,
23+
models.CONFIG_POLICY, models.CONFIG_GEN_PROVENANCE, models.CONFIG_BRANCH_RULES, models.CONFIG_TAG_RULES,
2424
}
2525

2626
// New initializes a new source tool instance.

0 commit comments

Comments
 (0)