(ctx context.Context, method, uriPath string, body io.Reader)
| 24 | ) |
| 25 | |
| 26 | func (s *ScaleSetClient) newActionsRequest(ctx context.Context, method, uriPath string, body io.Reader) (*http.Request, error) { |
| 27 | if err := s.ensureAdminInfo(ctx); err != nil { |
| 28 | return nil, fmt.Errorf("failed to update token: %w", err) |
| 29 | } |
| 30 | |
| 31 | actionsURI, err := s.actionsServiceInfo.GetURL() |
| 32 | if err != nil { |
| 33 | return nil, fmt.Errorf("failed to get pipeline URL: %w", err) |
| 34 | } |
| 35 | |
| 36 | pathURI, err := url.Parse(uriPath) |
| 37 | if err != nil { |
| 38 | return nil, fmt.Errorf("failed to parse path: %w", err) |
| 39 | } |
| 40 | pathQuery := pathURI.Query() |
| 41 | baseQuery := actionsURI.Query() |
| 42 | for k, values := range pathQuery { |
| 43 | if baseQuery.Get(k) == "" { |
| 44 | for _, val := range values { |
| 45 | baseQuery.Add(k, val) |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | if baseQuery.Get("api-version") == "" { |
| 50 | baseQuery.Set("api-version", "6.0-preview") |
| 51 | } |
| 52 | |
| 53 | actionsURI.Path = path.Join(actionsURI.Path, pathURI.Path) |
| 54 | actionsURI.RawQuery = baseQuery.Encode() |
| 55 | |
| 56 | req, err := http.NewRequestWithContext(ctx, method, actionsURI.String(), body) |
| 57 | if err != nil { |
| 58 | return nil, err |
| 59 | } |
| 60 | |
| 61 | req.Header.Set("Content-Type", "application/json") |
| 62 | req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", s.actionsServiceInfo.Token)) |
| 63 | |
| 64 | return req, nil |
| 65 | } |
no test coverage detected