-
Notifications
You must be signed in to change notification settings - Fork 101
feat(#5187): provision pipeline labels during enrollment #5564
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -258,7 +258,22 @@ func Install(ctx context.Context, cfg InstallConfig, | |
| } | ||
| progress(repoFullName, "scaffold", "Scaffold files committed") | ||
|
|
||
| // Step 6: Write repository variables. | ||
| // Step 6: Provision labels declared by harness files. | ||
| progress(repoFullName, "labels", "Provisioning pipeline labels") | ||
| harnessLabels, labelCollectErr := scaffold.CollectHarnessLabels() | ||
| if labelCollectErr != nil { | ||
| return result, fmt.Errorf("collecting harness labels: %w", labelCollectErr) | ||
| } | ||
| for _, l := range harnessLabels { | ||
| if err := client.CreateLabel(ctx, cfg.Owner, cfg.Repo, l.Name, l.Color, l.Description); err != nil { | ||
| return result, fmt.Errorf("creating label %q: %w", l.Name, err) | ||
| } | ||
| } | ||
| if len(harnessLabels) > 0 { | ||
| progress(repoFullName, "labels", fmt.Sprintf("Provisioned %d pipeline labels", len(harnessLabels))) | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] stale-reference Duplicate step number after insertion. The PR inserts a new Step 6 (labels) and renumbers the old Step 6 (vars) to Step 7, but does not renumber the existing Step 7 (secrets) to Step 8. After merge there will be two comments reading '// Step 7'. Suggested fix: Renumber '// Step 7: Write repository secrets.' to '// Step 8: Write repository secrets.' |
||
| // Step 7: Write repository variables. | ||
| progress(repoFullName, "vars", "Configuring repository variables") | ||
| repoVars := map[string]string{ | ||
| "FULLSEND_MINT_URL": mintURL, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package scaffold | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
|
|
||
| "gopkg.in/yaml.v3" | ||
| ) | ||
|
|
||
| // LabelDef describes a label that must exist in the target repo for | ||
| // agent post-scripts to function correctly. It mirrors harness.LabelDef | ||
| // but lives here to avoid an import cycle (harness test files import | ||
| // scaffold). | ||
| type LabelDef struct { | ||
| Name string `yaml:"name"` | ||
| Color string `yaml:"color"` | ||
| Description string `yaml:"description,omitempty"` | ||
| } | ||
|
|
||
| // CollectHarnessLabels reads embedded harness YAML files and returns | ||
| // the deduplicated set of labels declared across all harnesses. | ||
| // When the same label name appears in multiple harnesses, the first | ||
| // definition wins (stable because embed.FS walks alphabetically). | ||
| func CollectHarnessLabels() ([]LabelDef, error) { | ||
| seen := make(map[string]struct{}) | ||
| var labels []LabelDef | ||
|
|
||
| err := WalkFullsendRepoAll(func(path string, data []byte) error { | ||
| if !strings.HasPrefix(path, "harness/") || !isYAML(path) { | ||
| return nil | ||
| } | ||
| var h struct { | ||
| Labels []LabelDef `yaml:"labels"` | ||
| } | ||
| if err := yaml.Unmarshal(data, &h); err != nil { | ||
| return fmt.Errorf("parsing %s: %w", path, err) | ||
| } | ||
| for _, l := range h.Labels { | ||
| if _, ok := seen[l.Name]; ok { | ||
| continue | ||
| } | ||
| seen[l.Name] = struct{}{} | ||
| labels = append(labels, l) | ||
| } | ||
| return nil | ||
| }) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return labels, nil | ||
| } | ||
|
|
||
| func isYAML(path string) bool { | ||
| return strings.HasSuffix(path, ".yaml") || strings.HasSuffix(path, ".yml") | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[low] field-ordering-and-comments
CreatedLabels field is positioned before the '// Call recorders' section but logically belongs within it (all other Created*/Deleted*/Updated* fields appear after that comment). Additionally, the field has a misleading two-line comment: the first line describes the type rather than the field, duplicating the type's own godoc.
Suggested fix: Move CreatedLabels into the '// Call recorders' block alongside other Created* fields. Remove the duplicate type-description comment.