Documentation ¶
Index ¶
- Constants
- Variables
- func AuthorizerFromEnvironment() (autorest.Authorizer, error)
- func IsNotFound(err error) bool
- func IsTerminalProvisioningState(state ProvisioningState) bool
- func MakeResourceGroupScopeARMID(subscription string, resourceGroup string, provider string, params ...string) string
- func MakeSubscriptionScopeARMID(subscription string, provider string, params ...string) string
- func WithDefaultRetries() func(*ClientConfig) *ClientConfig
- func WithLogger(logger logr.Logger) func(*ClientConfig) *ClientConfig
- func WithRetries(retries *RetryConfig) func(*ClientConfig) *ClientConfig
- type ARMMeta
- type Applier
- type AzureTemplateClient
- func (atc *AzureTemplateClient) BeginDeleteResource(ctx context.Context, id string, apiVersion string, ...) (time.Duration, error)
- func (atc *AzureTemplateClient) CreateDeployment(ctx context.Context, deployment *Deployment) error
- func (atc *AzureTemplateClient) DeleteDeployment(ctx context.Context, deploymentId string) (time.Duration, error)
- func (atc *AzureTemplateClient) GetDeployment(ctx context.Context, deploymentId string) (*Deployment, time.Duration, error)
- func (atc *AzureTemplateClient) GetResource(ctx context.Context, id string, apiVersion string, ...) (time.Duration, error)
- func (atc *AzureTemplateClient) HeadResource(ctx context.Context, id string, apiVersion string) (bool, time.Duration, error)
- func (atc *AzureTemplateClient) NewResourceGroupDeployment(resourceGroup string, deploymentName string, ...) *Deployment
- func (atc *AzureTemplateClient) NewSubscriptionDeployment(location string, deploymentName string, ...) *Deployment
- func (atc *AzureTemplateClient) SubscriptionID() string
- type AzureTemplateClientOption
- type Client
- func (c *Client) DeleteResource(ctx context.Context, resourceID string, resource interface{}) (time.Duration, error)
- func (c *Client) GetResource(ctx context.Context, resourceID string, resource interface{}) (time.Duration, error)
- func (c *Client) PutDeployment(ctx context.Context, deployment *Deployment) error
- func (c *Client) WithExponentialRetries(attempts int, backoff time.Duration, maxBackoff time.Duration) *Client
- type ClientConfig
- type DebugSetting
- type Deployment
- func (d *Deployment) ErrorOrEmpty() string
- func (d *Deployment) GetDeploymentARMID() (string, error)
- func (d *Deployment) GetEntityPath() (string, error)
- func (d *Deployment) IsSuccessful() bool
- func (d *Deployment) IsTerminalProvisioningState() bool
- func (d *Deployment) ProvisioningStateOrUnknown() string
- func (d *Deployment) ResourceID() (string, error)
- func (d *Deployment) Validate() error
- type DeploymentError
- type DeploymentMode
- type DeploymentProperties
- type DeploymentScope
- type DeploymentSpec
- type DeploymentStatus
- type DetailLevel
- type Output
- type OutputResource
- type ProvisioningState
- type RetryConfig
- type Template
- type TemplateOutput
- type TemplateResourceObjectOutput
Constants ¶
const ( ResourceGroupScope DeploymentScope = "resourceGroup" SubscriptionScope DeploymentScope = "subscription" RequestContentDetailLevel DetailLevel = "requestContent" ResponseContentDetailLevel DetailLevel = "responseContent" RequestAndResponseContentDetailLevel DetailLevel = "requestContent,responseContent" IncrementalDeploymentMode DeploymentMode = "Incremental" CompleteDeploymentMode DeploymentMode = "Complete" SucceededProvisioningState ProvisioningState = "Succeeded" FailedProvisioningState ProvisioningState = "Failed" DeletingProvisioningState ProvisioningState = "Deleting" AcceptedProvisioningState ProvisioningState = "Accepted" )
Variables ¶
var UserAgent = "aso-controller/" + version.BuildVersion
Functions ¶
func AuthorizerFromEnvironment ¶
func AuthorizerFromEnvironment() (autorest.Authorizer, error)
func IsNotFound ¶
func IsTerminalProvisioningState ¶
func IsTerminalProvisioningState(state ProvisioningState) bool
func WithDefaultRetries ¶
func WithDefaultRetries() func(*ClientConfig) *ClientConfig
func WithLogger ¶
func WithLogger(logger logr.Logger) func(*ClientConfig) *ClientConfig
func WithRetries ¶
func WithRetries(retries *RetryConfig) func(*ClientConfig) *ClientConfig
Types ¶
type ARMMeta ¶
type ARMMeta struct { Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` ID string `json:"id,omitempty"` // TODO: This is filled out on response to us after PUT Location string `json:"location,omitempty"` ResourceGroup string `json:"-"` // TODO: I feel like these should be being serialized? SubscriptionId string `json:"-"` }
type Applier ¶
type Applier interface { CreateDeployment(ctx context.Context, deployment *Deployment) error DeleteDeployment(ctx context.Context, deploymentId string) (time.Duration, error) GetDeployment(ctx context.Context, deploymentId string) (*Deployment, time.Duration, error) NewResourceGroupDeployment(resourceGroup string, deploymentName string, resourceSpec genruntime.ARMResourceSpec) *Deployment NewSubscriptionDeployment(location string, deploymentName string, resourceSpec genruntime.ARMResourceSpec) *Deployment SubscriptionID() string // TODO: These functions take an empty status and fill it out with the response from Azure (rather than as // TODO: the return type. I don't love that pattern but don't have a better one either. BeginDeleteResource(ctx context.Context, id string, apiVersion string, status genruntime.ARMResourceStatus) (time.Duration, error) GetResource(ctx context.Context, id string, apiVersion string, status genruntime.ARMResourceStatus) (time.Duration, error) HeadResource(ctx context.Context, id string, apiVersion string) (bool, time.Duration, error) }
TODO: Naming?
type AzureTemplateClient ¶
type AzureTemplateClient struct { RawClient *Client Logger logr.Logger // contains filtered or unexported fields }
func NewAzureTemplateClient ¶
func NewAzureTemplateClient(authorizer autorest.Authorizer, subID string, opts ...AzureTemplateClientOption) (*AzureTemplateClient, error)
func (*AzureTemplateClient) BeginDeleteResource ¶
func (atc *AzureTemplateClient) BeginDeleteResource( ctx context.Context, id string, apiVersion string, status genruntime.ARMResourceStatus) (time.Duration, error)
func (*AzureTemplateClient) CreateDeployment ¶
func (atc *AzureTemplateClient) CreateDeployment(ctx context.Context, deployment *Deployment) error
CreateDeployment deploys a resource to Azure via a deployment template, and updates the given Deployment with the current state.
func (*AzureTemplateClient) DeleteDeployment ¶
func (atc *AzureTemplateClient) DeleteDeployment(ctx context.Context, deploymentId string) (time.Duration, error)
DeleteDeployment deletes a deployment. If the deployment doesn't exist it does not return an error
func (*AzureTemplateClient) GetDeployment ¶
func (atc *AzureTemplateClient) GetDeployment(ctx context.Context, deploymentId string) (*Deployment, time.Duration, error)
func (*AzureTemplateClient) GetResource ¶
func (atc *AzureTemplateClient) GetResource( ctx context.Context, id string, apiVersion string, status genruntime.ARMResourceStatus) (time.Duration, error)
func (*AzureTemplateClient) HeadResource ¶
func (atc *AzureTemplateClient) HeadResource(ctx context.Context, id string, apiVersion string) (bool, time.Duration, error)
HeadResource checks to see if the resource exists
Note: this doesn't actually use HTTP HEAD as Azure Resource Manager does not uniformly implement HEAD for all all resources. Also, ARM returns a 400 rather than 405 when requesting HEAD for a resource which the Resource Provider does not implement HEAD. For these reasons, we use an HTTP GET
func (*AzureTemplateClient) NewResourceGroupDeployment ¶
func (atc *AzureTemplateClient) NewResourceGroupDeployment(resourceGroup string, deploymentName string, resourceSpec genruntime.ARMResourceSpec) *Deployment
func (*AzureTemplateClient) NewSubscriptionDeployment ¶
func (atc *AzureTemplateClient) NewSubscriptionDeployment(location string, deploymentName string, resourceSpec genruntime.ARMResourceSpec) *Deployment
func (*AzureTemplateClient) SubscriptionID ¶
func (atc *AzureTemplateClient) SubscriptionID() string
type AzureTemplateClientOption ¶
type AzureTemplateClientOption func(config *ClientConfig) *ClientConfig
type Client ¶
func NewClient ¶
func NewClient(authorizer autorest.Authorizer) *Client
NewClient creates a new raw client
func (*Client) DeleteResource ¶
func (c *Client) DeleteResource(ctx context.Context, resourceID string, resource interface{}) (time.Duration, error)
DeleteResource will make an HTTP DELETE call to the resourceId and attempt to fill the resource with the response. If the body of the response is empty, the resource will be nil.
func (*Client) GetResource ¶
func (*Client) PutDeployment ¶
func (c *Client) PutDeployment(ctx context.Context, deployment *Deployment) error
PutDeployment creates or updates a deployment in Azure, and updates the given Deployment with the current deployment state.
type ClientConfig ¶
type ClientConfig struct { Logger logr.Logger Retries *RetryConfig }
type DebugSetting ¶
type DebugSetting struct {
DetailLevel DetailLevel `json:"detailLevel,omitempty"`
}
type Deployment ¶
type Deployment struct { ARMMeta `json:",inline"` Scope DeploymentScope `json:"-"` Properties *DeploymentProperties }
func NewResourceGroupDeployment ¶
func NewResourceGroupDeployment( subscriptionId string, groupName string, deploymentName string, resources ...interface{}) *Deployment
func NewSubscriptionDeployment ¶
func NewSubscriptionDeployment( subscriptionID string, location string, deploymentName string, resources ...interface{}) *Deployment
func (*Deployment) ErrorOrEmpty ¶
func (d *Deployment) ErrorOrEmpty() string
func (*Deployment) GetDeploymentARMID ¶
func (d *Deployment) GetDeploymentARMID() (string, error)
func (*Deployment) GetEntityPath ¶
func (d *Deployment) GetEntityPath() (string, error)
func (*Deployment) IsSuccessful ¶
func (d *Deployment) IsSuccessful() bool
func (*Deployment) IsTerminalProvisioningState ¶
func (d *Deployment) IsTerminalProvisioningState() bool
func (*Deployment) ProvisioningStateOrUnknown ¶
func (d *Deployment) ProvisioningStateOrUnknown() string
func (*Deployment) ResourceID ¶
func (d *Deployment) ResourceID() (string, error)
func (*Deployment) Validate ¶
func (d *Deployment) Validate() error
type DeploymentError ¶
type DeploymentError struct { Code string `json:"code,omitempty"` Message string `json:"message,omitempty"` Target string `json:"target,omitempty"` Details []DeploymentError `json:"details,omitempty"` }
TODO: Flesh this out more -- https://docs.microsoft.com/en-us/rest/api/resources/deployments/createorupdate#errorresponse
func (*DeploymentError) String ¶
func (deploymentErr *DeploymentError) String() string
TODO: restructure this file to be a bit clearer (functions by their types)
type DeploymentMode ¶
type DeploymentMode string
type DeploymentProperties ¶
type DeploymentProperties struct { DeploymentStatus `json:",inline"` DeploymentSpec `json:",inline"` }
type DeploymentScope ¶
type DeploymentScope string
type DeploymentSpec ¶
type DeploymentSpec struct { DebugSetting *DebugSetting `json:"debugSetting,omitempty"` Mode DeploymentMode `json:"mode,omitempty"` Template *Template `json:"template,omitempty"` }
type DeploymentStatus ¶
type DeploymentStatus struct { ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` Timestamp *date.Time `json:"timestamp,omitempty"` Duration *duration.ISO8601 `json:"duration,omitempty"` CorrelationID string `json:"correlationId,omitempty"` Outputs json.RawMessage `json:"outputs,omitempty"` // TODO: What is this for? Error *DeploymentError OutputResources []OutputResource `json:"outputResources,omitempty"` }
type DetailLevel ¶
type DetailLevel string
type OutputResource ¶
type OutputResource struct {
ID string `json:"id,omitempty"`
}
type ProvisioningState ¶
type ProvisioningState string
type RetryConfig ¶
type Template ¶
type Template struct { Schema string `json:"$schema,omitempty"` ContentVersion string `json:"contentVersion,omitempty"` Parameters interface{} `json:"parameters,omitempty"` Variables interface{} `json:"variables,omitempty"` Resources []interface{} `json:"resources,omitempty"` Outputs map[string]Output `json:"outputs,omitempty"` }
type TemplateOutput ¶
type TemplateOutput struct { Type string `json:"type,omitempty"` Value TemplateResourceObjectOutput `json:"value,omitempty"` }
type TemplateResourceObjectOutput ¶
type TemplateResourceObjectOutput struct { APIVersion string `json:"apiVersion,omitempty"` Location string `json:"location,omitempty"` Properties interface{} `json:"properties,omitempty"` SubscriptionID string `json:"subscriptionId,omitempty"` Scope string `json:"scope,omitempty"` ID string `json:"id,omitempty"` ResourceID string `json:"resourceId,omitempty"` ReferenceAPIVersion string `json:"referenceApiVersion,omitempty"` Condition *bool `json:"condition,omitempty"` IsCondition *bool `json:"isConditionTrue,omitempty"` IsTemplateResource *bool `json:"isTemplateResource,omitempty"` IsAction *bool `json:"isAction,omitempty"` ProvisioningOperation string `json:"provisioningOperation,omitempty"` }
TemplateResourceObjectOutput represents the structure output from a deployment template for a given resource when requesting a 'Full' representation. The structure for a resource group is as follows:
{ "apiVersion": "2018-05-01", "location": "westus2", "properties": { "provisioningState": "Succeeded" }, "subscriptionId": "guid", "scope": "", "resourceId": "Microsoft.Resources/resourceGroups/foo", "referenceApiVersion": "2018-05-01", "condition": true, "isConditionTrue": true, "isTemplateResource": false, "isAction": false, "provisioningOperation": "Read" }