@@ -78,6 +78,16 @@ func builders() (bt []builderType) {
78
78
return
79
79
}
80
80
81
+ func swarmingBuilders () ([]string , error ) {
82
+ ctx , _ := context .WithTimeout (context .Background (), 5 * time .Second )
83
+ client := gomoteServerClient (ctx )
84
+ resp , err := client .ListSwarmingBuilders (ctx , & protos.ListSwarmingBuildersRequest {})
85
+ if err != nil {
86
+ return nil , fmt .Errorf ("unable to retrieve swarming builders: %s" , err )
87
+ }
88
+ return resp .Builders , nil
89
+ }
90
+
81
91
func create (args []string ) error {
82
92
fs := flag .NewFlagSet ("create" , flag .ContinueOnError )
83
93
@@ -91,18 +101,30 @@ func create(args []string) error {
91
101
fmt .Fprintln (os .Stderr , "added to that group." )
92
102
fs .PrintDefaults ()
93
103
fmt .Fprintln (os .Stderr , "\n Valid types:" )
94
- for _ , bt := range builders () {
95
- var warn string
96
- if bt .IsReverse {
97
- if bt .ExpectNum > 0 {
98
- warn = fmt .Sprintf (" [limited capacity: %d machines]" , bt .ExpectNum )
99
- } else {
100
- warn = " [limited capacity]"
104
+ if luciEnabled () {
105
+ swarmingBuilders , err := swarmingBuilders ()
106
+ if err != nil {
107
+ fmt .Fprintf (os .Stderr , " %s\n " , err )
108
+ } else {
109
+ for _ , builder := range swarmingBuilders {
110
+ fmt .Fprintf (os .Stderr , " * %s\n " , builder )
111
+ }
112
+ }
113
+ os .Exit (1 )
114
+ } else {
115
+ for _ , bt := range builders () {
116
+ var warn string
117
+ if bt .IsReverse {
118
+ if bt .ExpectNum > 0 {
119
+ warn = fmt .Sprintf (" [limited capacity: %d machines]" , bt .ExpectNum )
120
+ } else {
121
+ warn = " [limited capacity]"
122
+ }
101
123
}
124
+ fmt .Fprintf (os .Stderr , " * %s%s\n " , bt .Name , warn )
102
125
}
103
- fmt . Fprintf ( os .Stderr , " * %s%s \n " , bt . Name , warn )
126
+ os .Exit ( 1 )
104
127
}
105
- os .Exit (1 )
106
128
}
107
129
var status bool
108
130
fs .BoolVar (& status , "status" , true , "print regular status updates while waiting" )
0 commit comments