Skip to content

Commit 6de8a8f

Browse files
committed
Fix CI for auth service cutover
1 parent 9bfa424 commit 6de8a8f

20 files changed

+755
-55
lines changed

cmd/wl/cmd_accept_upstream.go

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"io"
6+
"strings"
7+
8+
"github.com/gastownhall/wasteland/internal/sdk"
9+
"github.com/spf13/cobra"
10+
)
11+
12+
func newAcceptUpstreamCmd(stdout, stderr io.Writer) *cobra.Command {
13+
var (
14+
quality int
15+
reliability int
16+
severity string
17+
skills string
18+
message string
19+
noPush bool
20+
)
21+
22+
cmd := &cobra.Command{
23+
Use: "accept-upstream <wanted-id> <submitter-handle>",
24+
Short: "Accept a pending upstream submission and issue a stamp",
25+
Long: `Accept a pending upstream submission from the Wasteland PR flow.
26+
27+
This adopts the submitter's upstream PR into the main wanted item, creates a
28+
completion record, and issues a stamp. The submitter must currently have an
29+
in-review upstream submission for the wanted item.
30+
31+
Examples:
32+
wl accept-upstream w-abc123 charlie --quality 4
33+
wl accept-upstream w-abc123 charlie --quality 5 --reliability 4 --severity branch
34+
wl accept-upstream w-abc123 charlie --quality 3 --skills "go,federation" --message "solid work"`,
35+
Args: cobra.ExactArgs(2),
36+
RunE: func(cmd *cobra.Command, args []string) error {
37+
return runAcceptUpstream(cmd, stdout, stderr, args[0], args[1], quality, reliability, severity, skills, message, noPush)
38+
},
39+
}
40+
41+
cmd.Flags().IntVar(&quality, "quality", 0, "Quality rating 1-5 (required)")
42+
cmd.Flags().IntVar(&reliability, "reliability", 0, "Reliability rating 1-5 (defaults to quality)")
43+
cmd.Flags().StringVar(&severity, "severity", "leaf", "Severity: leaf, branch, root")
44+
cmd.Flags().StringVar(&skills, "skills", "", "Comma-separated skill tags")
45+
cmd.Flags().StringVar(&message, "message", "", "Freeform message")
46+
cmd.Flags().BoolVar(&noPush, "no-push", false, "Skip pushing to remotes (offline work)")
47+
_ = cmd.MarkFlagRequired("quality")
48+
cmd.ValidArgsFunction = completeUpstreamActionArgs()
49+
_ = cmd.RegisterFlagCompletionFunc("severity", func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
50+
return []string{"leaf", "branch", "root"}, cobra.ShellCompDirectiveNoFileComp
51+
})
52+
53+
return cmd
54+
}
55+
56+
func runAcceptUpstream(cmd *cobra.Command, stdout, _ io.Writer, wantedID, submitterHandle string, quality, reliability int, severity, skills, message string, noPush bool) error {
57+
if reliability == 0 {
58+
reliability = quality
59+
}
60+
if err := validateAcceptInputs(quality, reliability, severity); err != nil {
61+
return err
62+
}
63+
64+
var skillTags []string
65+
if skills != "" {
66+
for _, s := range strings.Split(skills, ",") {
67+
s = strings.TrimSpace(s)
68+
if s != "" {
69+
skillTags = append(skillTags, s)
70+
}
71+
}
72+
}
73+
74+
wlCfg, err := resolveWasteland(cmd)
75+
if err != nil {
76+
return hintWrap(err)
77+
}
78+
wantedID, err = resolveWantedArg(wlCfg, wantedID)
79+
if err != nil {
80+
return err
81+
}
82+
83+
client, err := newCommandClient(wlCfg, noPush)
84+
if err != nil {
85+
return err
86+
}
87+
88+
result, err := client.AcceptUpstream(wantedID, submitterHandle, sdk.AcceptInput{
89+
Quality: quality,
90+
Reliability: reliability,
91+
Severity: severity,
92+
SkillTags: skillTags,
93+
Message: message,
94+
})
95+
if err != nil {
96+
return err
97+
}
98+
99+
extras := []string{
100+
"Submitter: " + submitterHandle,
101+
fmt.Sprintf("Quality: %d, Reliability: %d", quality, reliability),
102+
"Severity: " + severity,
103+
}
104+
if len(skillTags) > 0 {
105+
extras = append(extras, "Skills: "+strings.Join(skillTags, ", "))
106+
}
107+
if message != "" {
108+
extras = append(extras, "Message: "+message)
109+
}
110+
111+
renderMutationResult(stdout, "Accepted upstream submission for", wantedID, result, extras...)
112+
printNextHint(stdout, "Next: view the adopted item: wl status "+wantedID)
113+
114+
return nil
115+
}

cmd/wl/cmd_close_upstream.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"io"
6+
7+
"github.com/spf13/cobra"
8+
)
9+
10+
func newCloseUpstreamCmd(stdout, stderr io.Writer) *cobra.Command {
11+
var noPush bool
12+
13+
cmd := &cobra.Command{
14+
Use: "close-upstream <wanted-id> <submitter-handle>",
15+
Short: "Adopt a pending upstream submission without issuing a stamp",
16+
Long: `Close a pending upstream submission by adopting its completion without
17+
issuing a stamp, then best-effort closing the upstream PR.
18+
19+
Examples:
20+
wl close-upstream w-abc123 charlie
21+
wl close-upstream w-abc123 charlie --no-push`,
22+
Args: cobra.ExactArgs(2),
23+
RunE: func(cmd *cobra.Command, args []string) error {
24+
return runCloseUpstream(cmd, stdout, stderr, args[0], args[1], noPush)
25+
},
26+
}
27+
28+
cmd.Flags().BoolVar(&noPush, "no-push", false, "Skip pushing to remotes (offline work)")
29+
cmd.ValidArgsFunction = completeUpstreamActionArgs()
30+
return cmd
31+
}
32+
33+
func runCloseUpstream(cmd *cobra.Command, stdout, _ io.Writer, wantedID, submitterHandle string, noPush bool) error {
34+
wlCfg, err := resolveWasteland(cmd)
35+
if err != nil {
36+
return hintWrap(err)
37+
}
38+
wantedID, err = resolveWantedArg(wlCfg, wantedID)
39+
if err != nil {
40+
return err
41+
}
42+
43+
client, err := newCommandClient(wlCfg, noPush)
44+
if err != nil {
45+
return err
46+
}
47+
result, err := client.CloseUpstream(wantedID, submitterHandle)
48+
if err != nil {
49+
return err
50+
}
51+
52+
renderMutationResult(stdout, "Closed upstream submission for", wantedID, result, "Submitter: "+submitterHandle)
53+
printNextHint(stdout, fmt.Sprintf("Next: item completed without stamp. View: wl status %s", wantedID))
54+
return nil
55+
}

0 commit comments

Comments
 (0)