MCPcopy Create free account
hub / github.com/cloudbase/garm / GetRunnerByName

Method GetRunnerByName

util/github/scalesets/runners.go:130–165  ·  view source on GitHub ↗
(ctx context.Context, runnerName string)

Source from the content-addressed store, hash-verified

128}
129
130func (s *ScaleSetClient) GetRunnerByName(ctx context.Context, runnerName string) (_ params.RunnerReference, err error) {
131 s.recordOperation("GetRunnerByName")
132 defer func() {
133 if err != nil {
134 s.recordFailedOperation("GetRunnerByName")
135 }
136 }()
137
138 path := fmt.Sprintf("%s?agentName=%s", runnerEndpoint, runnerName)
139
140 req, err := s.newActionsRequest(ctx, http.MethodGet, path, nil)
141 if err != nil {
142 return params.RunnerReference{}, fmt.Errorf("failed to construct request: %w", err)
143 }
144
145 resp, err := s.Do(req)
146 if err != nil {
147 return params.RunnerReference{}, fmt.Errorf("request failed for %s: %w", req.URL.String(), err)
148 }
149 defer resp.Body.Close()
150
151 var runnerList params.RunnerReferenceList
152 if err := json.NewDecoder(resp.Body).Decode(&runnerList); err != nil {
153 return params.RunnerReference{}, fmt.Errorf("failed to decode response: %w", err)
154 }
155
156 if runnerList.Count == 0 {
157 return params.RunnerReference{}, fmt.Errorf("could not find runner with name %q: %w", runnerName, runnerErrors.ErrNotFound)
158 }
159
160 if runnerList.Count > 1 {
161 return params.RunnerReference{}, fmt.Errorf("failed to decode response: %w", err)
162 }
163
164 return runnerList.RunnerReferences[0], nil
165}
166
167func (s *ScaleSetClient) RemoveRunner(ctx context.Context, runnerID int64) (err error) {
168 s.recordOperation("RemoveRunner")

Callers

nothing calls this directly

Calls 6

recordOperationMethod · 0.95
recordFailedOperationMethod · 0.95
newActionsRequestMethod · 0.95
DoMethod · 0.95
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected