コード例 #1
0
ファイル: main.go プロジェクト: jen20/riviera
func createResourceGroup(azureClient *azure.Client) (string, error) {
	name := fmt.Sprintf("riviera_resource_group_%d", rand.Intn(8999)+1000)

	r := azureClient.NewRequest()

	r.Command = azure.CreateResourceGroup{
		Name:     name,
		Location: azure.WestUS,
		Tags: map[string]*string{
			"Key1": azure.String("value1"),
			"Key2": azure.String("value2"),
		},
	}

	response, err := r.Execute()
	if err != nil {
		return "", err
	}

	if !response.IsSuccessful() {
		return "", fmt.Errorf("Error creating resource group %q", name)
	}

	return name, nil
}
コード例 #2
0
ファイル: provider.go プロジェクト: partamonov/terraform
func registerProviderWithSubscription(providerName string, client *riviera.Client) error {
	request := client.NewRequest()
	request.Command = riviera.RegisterResourceProvider{
		Namespace: providerName,
	}

	response, err := request.Execute()
	if err != nil {
		return fmt.Errorf("Cannot request provider registration for Azure Resource Manager: %s.", err)
	}

	if !response.IsSuccessful() {
		return fmt.Errorf("Credentials for accessing the Azure Resource Manager API are likely " +
			"to be incorrect, or\n  the service principal does not have permission to use " +
			"the Azure Service Management\n  API.")
	}

	return nil
}