feat: use SuggestedLabels from runner capabilities
- Add StringUtils.HasSuffix template function - Update runner edit template to use SuggestedLabels from capabilities - Auto-suggest -latest variants for OS-type labels (ios, macos, xcode, etc.) - Falls back to OS-based suggestions if no SuggestedLabels available 🤖 Generated with Claude Code Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -35,6 +35,7 @@ func (su *StringUtils) ToString(v any) string {
|
||||
func (su *StringUtils) HasPrefix(s, prefix string) bool {
|
||||
return strings.HasPrefix(s, prefix)
|
||||
}
|
||||
func (su *StringUtils) HasSuffix(s, suffix string) bool { return strings.HasSuffix(s, suffix)}
|
||||
|
||||
func (su *StringUtils) Contains(s, substr string) bool {
|
||||
return strings.Contains(s, substr)
|
||||
|
||||
@@ -100,37 +100,38 @@
|
||||
<p class="tw-text-sm tw-mb-2" style="opacity: 0.7;">Based on detected capabilities. Click + to add individually.</p>
|
||||
<div class="tw-flex tw-flex-wrap tw-gap-2" id="suggested-labels">
|
||||
{{$labels := .Runner.AgentLabels}}
|
||||
{{if eq .RunnerCapabilities.OS "linux"}}
|
||||
{{if not (SliceUtils.Contains $labels "linux")}}
|
||||
<form method="post" action="{{$.Link}}/add-label" style="display:inline;">{{$.CsrfTokenHtml}}<input type="hidden" name="label" value="linux"><button type="submit" class="ui small teal label" style="cursor:pointer;">{{svg "octicon-plus" 12}} linux</button></form>
|
||||
{{else}}<span class="ui small teal label">linux</span>{{end}}
|
||||
{{if not (SliceUtils.Contains $labels "linux-latest")}}
|
||||
<form method="post" action="{{$.Link}}/add-label" style="display:inline;">{{$.CsrfTokenHtml}}<input type="hidden" name="label" value="linux-latest"><button type="submit" class="ui small teal label" style="cursor:pointer;">{{svg "octicon-plus" 12}} linux-latest</button></form>
|
||||
{{else}}<span class="ui small teal label">linux-latest</span>{{end}}
|
||||
{{else if eq .RunnerCapabilities.OS "windows"}}
|
||||
{{if not (SliceUtils.Contains $labels "windows")}}
|
||||
<form method="post" action="{{$.Link}}/add-label" style="display:inline;">{{$.CsrfTokenHtml}}<input type="hidden" name="label" value="windows"><button type="submit" class="ui small teal label" style="cursor:pointer;">{{svg "octicon-plus" 12}} windows</button></form>
|
||||
{{else}}<span class="ui small teal label">windows</span>{{end}}
|
||||
{{if not (SliceUtils.Contains $labels "windows-latest")}}
|
||||
<form method="post" action="{{$.Link}}/add-label" style="display:inline;">{{$.CsrfTokenHtml}}<input type="hidden" name="label" value="windows-latest"><button type="submit" class="ui small teal label" style="cursor:pointer;">{{svg "octicon-plus" 12}} windows-latest</button></form>
|
||||
{{else}}<span class="ui small teal label">windows-latest</span>{{end}}
|
||||
{{else if eq .RunnerCapabilities.OS "darwin"}}
|
||||
{{if not (SliceUtils.Contains $labels "macos")}}
|
||||
<form method="post" action="{{$.Link}}/add-label" style="display:inline;">{{$.CsrfTokenHtml}}<input type="hidden" name="label" value="macos"><button type="submit" class="ui small teal label" style="cursor:pointer;">{{svg "octicon-plus" 12}} macos</button></form>
|
||||
{{else}}<span class="ui small teal label">macos</span>{{end}}
|
||||
{{if not (SliceUtils.Contains $labels "macos-latest")}}
|
||||
<form method="post" action="{{$.Link}}/add-label" style="display:inline;">{{$.CsrfTokenHtml}}<input type="hidden" name="label" value="macos-latest"><button type="submit" class="ui small teal label" style="cursor:pointer;">{{svg "octicon-plus" 12}} macos-latest</button></form>
|
||||
{{else}}<span class="ui small teal label">macos-latest</span>{{end}}
|
||||
{{end}}
|
||||
{{if and .RunnerCapabilities.Distro .RunnerCapabilities.Distro.ID}}
|
||||
{{$distro := .RunnerCapabilities.Distro.ID}}
|
||||
{{$distroLatest := printf "%s-latest" .RunnerCapabilities.Distro.ID}}
|
||||
{{if not (SliceUtils.Contains $labels $distro)}}
|
||||
<form method="post" action="{{$.Link}}/add-label" style="display:inline;">{{$.CsrfTokenHtml}}<input type="hidden" name="label" value="{{$distro}}"><button type="submit" class="ui small purple label" style="cursor:pointer;">{{svg "octicon-plus" 12}} {{$distro}}</button></form>
|
||||
{{else}}<span class="ui small purple label">{{$distro}}</span>{{end}}
|
||||
{{if not (SliceUtils.Contains $labels $distroLatest)}}
|
||||
<form method="post" action="{{$.Link}}/add-label" style="display:inline;">{{$.CsrfTokenHtml}}<input type="hidden" name="label" value="{{$distroLatest}}"><button type="submit" class="ui small purple label" style="cursor:pointer;">{{svg "octicon-plus" 12}} {{$distroLatest}}</button></form>
|
||||
{{else}}<span class="ui small purple label">{{$distroLatest}}</span>{{end}}
|
||||
{{if .RunnerCapabilities.SuggestedLabels}}
|
||||
{{range .RunnerCapabilities.SuggestedLabels}}
|
||||
{{$label := .}}
|
||||
{{$latestLabel := printf "%s-latest" .}}
|
||||
{{if not (SliceUtils.Contains $labels $label)}}
|
||||
<form method="post" action="{{$.Link}}/add-label" style="display:inline;">
|
||||
{{$.CsrfTokenHtml}}<input type="hidden" name="label" value="{{$label}}">
|
||||
<button type="submit" class="ui small teal label" style="cursor:pointer;">{{svg "octicon-plus" 12}} {{$label}}</button>
|
||||
</form>
|
||||
{{else}}<span class="ui small teal label">{{$label}}</span>{{end}}
|
||||
{{/* Auto-suggest -latest variant for OS-type labels */}}
|
||||
{{if and (not (StringUtils.HasSuffix $label "-latest")) (not (SliceUtils.Contains $labels $latestLabel))}}
|
||||
{{if or (eq $label "linux") (eq $label "macos") (eq $label "windows") (eq $label "ios") (eq $label "xcode") (eq $label "tvos") (eq $label "watchos") (eq $label "visionos") (eq $label "debian") (eq $label "ubuntu") (eq $label "fedora") (eq $label "dotnet") (eq $label "node")}}
|
||||
<form method="post" action="{{$.Link}}/add-label" style="display:inline;">
|
||||
{{$.CsrfTokenHtml}}<input type="hidden" name="label" value="{{$latestLabel}}">
|
||||
<button type="submit" class="ui small purple label" style="cursor:pointer;">{{svg "octicon-plus" 12}} {{$latestLabel}}</button>
|
||||
</form>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{else}}
|
||||
{{/* Fallback to OS-based suggestions if no SuggestedLabels */}}
|
||||
{{if eq .RunnerCapabilities.OS "linux"}}
|
||||
{{if not (SliceUtils.Contains $labels "linux")}}<form method="post" action="{{$.Link}}/add-label" style="display:inline;">{{$.CsrfTokenHtml}}<input type="hidden" name="label" value="linux"><button type="submit" class="ui small teal label" style="cursor:pointer;">{{svg "octicon-plus" 12}} linux</button></form>{{else}}<span class="ui small teal label">linux</span>{{end}}
|
||||
{{if not (SliceUtils.Contains $labels "linux-latest")}}<form method="post" action="{{$.Link}}/add-label" style="display:inline;">{{$.CsrfTokenHtml}}<input type="hidden" name="label" value="linux-latest"><button type="submit" class="ui small teal label" style="cursor:pointer;">{{svg "octicon-plus" 12}} linux-latest</button></form>{{else}}<span class="ui small teal label">linux-latest</span>{{end}}
|
||||
{{else if eq .RunnerCapabilities.OS "windows"}}
|
||||
{{if not (SliceUtils.Contains $labels "windows")}}<form method="post" action="{{$.Link}}/add-label" style="display:inline;">{{$.CsrfTokenHtml}}<input type="hidden" name="label" value="windows"><button type="submit" class="ui small teal label" style="cursor:pointer;">{{svg "octicon-plus" 12}} windows</button></form>{{else}}<span class="ui small teal label">windows</span>{{end}}
|
||||
{{if not (SliceUtils.Contains $labels "windows-latest")}}<form method="post" action="{{$.Link}}/add-label" style="display:inline;">{{$.CsrfTokenHtml}}<input type="hidden" name="label" value="windows-latest"><button type="submit" class="ui small teal label" style="cursor:pointer;">{{svg "octicon-plus" 12}} windows-latest</button></form>{{else}}<span class="ui small teal label">windows-latest</span>{{end}}
|
||||
{{else if eq .RunnerCapabilities.OS "darwin"}}
|
||||
{{if not (SliceUtils.Contains $labels "macos")}}<form method="post" action="{{$.Link}}/add-label" style="display:inline;">{{$.CsrfTokenHtml}}<input type="hidden" name="label" value="macos"><button type="submit" class="ui small teal label" style="cursor:pointer;">{{svg "octicon-plus" 12}} macos</button></form>{{else}}<span class="ui small teal label">macos</span>{{end}}
|
||||
{{if not (SliceUtils.Contains $labels "macos-latest")}}<form method="post" action="{{$.Link}}/add-label" style="display:inline;">{{$.CsrfTokenHtml}}<input type="hidden" name="label" value="macos-latest"><button type="submit" class="ui small teal label" style="cursor:pointer;">{{svg "octicon-plus" 12}} macos-latest</button></form>{{else}}<span class="ui small teal label">macos-latest</span>{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user