-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove rancher machine module support
Add FindTenantID and NewSubscriptionsClient functions. FindTenantID function is used to find the tenant ID for the subscription ID. It will send an unauthenticated request to the Azure Resource Manager endpoint to get the tenant ID from the WWW-Authenticate header. Signed-off-by: Michal Jura <[email protected]>
- Loading branch information
Showing
4 changed files
with
88 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package utils | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/Azure/go-autorest/autorest" | ||
"github.com/Azure/go-autorest/autorest/azure" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
// RequestWithInspection logs the request URL and method before sending the request to Azure API server for processing. | ||
func RequestWithInspection() autorest.PrepareDecorator { | ||
return func(p autorest.Preparer) autorest.Preparer { | ||
return autorest.PreparerFunc(func(r *http.Request) (*http.Request, error) { | ||
logrus.Info("Azure request", logrus.Fields{ | ||
"method": r.Method, | ||
"request": r.URL.String(), | ||
}) | ||
return p.Prepare(r) | ||
}) | ||
} | ||
} | ||
|
||
// ResponseWithInspection logs the response status, request URL, and request ID after receiving the response from Azure API server. | ||
func ResponseWithInspection() autorest.RespondDecorator { | ||
return func(r autorest.Responder) autorest.Responder { | ||
return autorest.ResponderFunc(func(resp *http.Response) error { | ||
logrus.Info("Azure response", logrus.Fields{ | ||
"status": resp.Status, | ||
"method": resp.Request.Method, | ||
"request": resp.Request.URL.String(), | ||
"x-ms-request-id": azure.ExtractRequestID(resp), | ||
}) | ||
return r.Respond(resp) | ||
}) | ||
} | ||
} |