/
publicip_client.go
27 lines (24 loc) · 968 Bytes
/
publicip_client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package azureclients
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/feiskyer/mcs/azureclients/auth"
"github.com/feiskyer/mcs/azureclients/publicipclient"
"github.com/feiskyer/mcs/azureclients/retry"
)
// NewPublicIPClient creates a new PublicIP client.
func NewPublicIPClient(config *auth.AzureAuthConfig, env *azure.Environment) (publicipclient.Interface, error) {
servicePrincipalToken, err := auth.GetServicePrincipalToken(config, env)
if err != nil {
return nil, err
}
clientConfig := &retry.ClientConfig{
CloudName: config.Cloud,
SubscriptionID: config.SubscriptionID,
ResourceManagerEndpoint: env.ResourceManagerEndpoint,
Backoff: &retry.Backoff{Steps: 1},
RateLimitConfig: &retry.RateLimitConfig{},
Authorizer: autorest.NewBearerAuthorizer(servicePrincipalToken),
}
return publicipclient.New(clientConfig), nil
}