@@ -19,9 +19,11 @@ import (
1919 "fmt"
2020 "io"
2121 "net/http"
22+ "net/url"
23+ "path"
2224)
2325
24- func (s * ScaleSetClient ) newActionsRequest (ctx context.Context , method , path string , body io.Reader ) (* http.Request , error ) {
26+ func (s * ScaleSetClient ) newActionsRequest (ctx context.Context , method , uriPath string , body io.Reader ) (* http.Request , error ) {
2527 if err := s .ensureAdminInfo (ctx ); err != nil {
2628 return nil , fmt .Errorf ("failed to update token: %w" , err )
2729 }
@@ -31,14 +33,27 @@ func (s *ScaleSetClient) newActionsRequest(ctx context.Context, method, path str
3133 return nil , fmt .Errorf ("failed to get pipeline URL: %w" , err )
3234 }
3335
34- uri := actionsURI .JoinPath (path )
35- q := uri .Query ()
36- if q .Get ("api-version" ) == "" {
37- q .Set ("api-version" , "6.0-preview" )
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+ }
3848 }
39- uri .RawQuery = q .Encode ()
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 ()
4055
41- req , err := http .NewRequestWithContext (ctx , method , uri .String (), body )
56+ req , err := http .NewRequestWithContext (ctx , method , actionsURI .String (), body )
4257 if err != nil {
4358 return nil , err
4459 }
0 commit comments