Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing Riviera SDK [Part 1 of 2] #289

Merged
merged 21 commits into from
Aug 30, 2017
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f0fe74f
Refactoring SQL Database over to Riviera
tombuildsstuff Aug 30, 2017
b2deb95
Added validation covering RFC3339 dates
tombuildsstuff Aug 30, 2017
8de7b95
Adding validation
tombuildsstuff Aug 30, 2017
89ac422
Adding import support
tombuildsstuff Aug 30, 2017
eee9a66
Documenting import + extra test specs
tombuildsstuff Aug 30, 2017
c78518a
Removing Riviera from the test helpers
tombuildsstuff Aug 30, 2017
f694591
Updating to parse the values out of the state
tombuildsstuff Aug 30, 2017
94586d2
Switching firewall rules over to the go sdk
tombuildsstuff Aug 30, 2017
528d7b0
Switching the tests over to the Go SDK
tombuildsstuff Aug 30, 2017
2f66762
Linting
tombuildsstuff Aug 30, 2017
54a7858
Adding a debug statement to the 404 checking
tombuildsstuff Aug 30, 2017
11a400c
Verifying that deleted SQL Servers + DB's are detected.
tombuildsstuff Aug 30, 2017
98a71e9
Tests to ensure deleted ElasticPool + FW Rules are detected
tombuildsstuff Aug 30, 2017
cd0b0a3
Adding tests for the validation for the Resource Group Name
tombuildsstuff Aug 30, 2017
b0fc940
Removing Riviera from Resource Groups. Fixes #49
tombuildsstuff Aug 30, 2017
413c5b9
Removing the Riviera Client
tombuildsstuff Aug 30, 2017
47b1bcd
Removing the Riviera SQL package
tombuildsstuff Aug 30, 2017
56d2236
Removing the Riviera split in the Provider list
tombuildsstuff Aug 30, 2017
4ae97ab
Exposing the encryption status of the database
tombuildsstuff Aug 30, 2017
9a6deb8
Adding Sweepers for SQL Server
tombuildsstuff Aug 30, 2017
0069f6f
Updating the ElasticPool docs
tombuildsstuff Aug 30, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Removing the Riviera Client
  • Loading branch information
tombuildsstuff committed Aug 30, 2017
commit 413c5b994541ba4f95eaa335425a4a62e65c64d8
16 changes: 0 additions & 16 deletions azurerm/config.go
Original file line number Diff line number Diff line change
@@ -35,7 +35,6 @@ import (
"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/hashicorp/terraform/terraform"
riviera "github.com/jen20/riviera/azure"
)

// ArmClient contains the handles to all the specific Azure Resource Manager
@@ -48,8 +47,6 @@ type ArmClient struct {

StopContext context.Context

rivieraClient *riviera.Client

availSetClient compute.AvailabilitySetsClient
usageOpsClient compute.UsageClient
vmExtensionImageClient compute.VirtualMachineExtensionImagesClient
@@ -188,19 +185,6 @@ func (c *Config) getArmClient() (*ArmClient, error) {
environment: env,
}

rivieraClient, err := riviera.NewClient(&riviera.AzureResourceManagerCredentials{
ClientID: c.ClientID,
ClientSecret: c.ClientSecret,
TenantID: c.TenantID,
SubscriptionID: c.SubscriptionID,
ResourceManagerEndpoint: env.ResourceManagerEndpoint,
ActiveDirectoryEndpoint: env.ActiveDirectoryEndpoint,
})
if err != nil {
return nil, fmt.Errorf("Error creating Riviera client: %s", err)
}
client.rivieraClient = rivieraClient

oauthConfig, err := adal.NewOAuthConfig(env.ActiveDirectoryEndpoint, c.TenantID)
if err != nil {
return nil, err
32 changes: 0 additions & 32 deletions azurerm/provider.go
Original file line number Diff line number Diff line change
@@ -6,17 +6,14 @@ import (
"encoding/hex"
"fmt"
"log"
"reflect"
"strings"
"sync"

"github.com/Azure/azure-sdk-for-go/arm/resources/resources"
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/terraform/helper/mutexkv"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
riviera "github.com/jen20/riviera/azure"
)

// Provider returns a terraform.ResourceProvider.
@@ -316,35 +313,6 @@ func registerAzureResourceProvidersWithSubscription(providerList []resources.Pro
// armMutexKV is the instance of MutexKV for ARM resources
var armMutexKV = mutexkv.NewMutexKV()

func azureStateRefreshFunc(resourceURI string, client *ArmClient, command riviera.APICall) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
req := client.rivieraClient.NewRequestForURI(resourceURI)
req.Command = command

res, err := req.Execute()
if err != nil {
return nil, "", fmt.Errorf("Error executing %T command in azureStateRefreshFunc", req.Command)
}

var value reflect.Value
if reflect.ValueOf(res.Parsed).Kind() == reflect.Ptr {
value = reflect.ValueOf(res.Parsed).Elem()
} else {
value = reflect.ValueOf(res.Parsed)
}

for i := 0; i < value.NumField(); i++ { // iterates through every struct type field
tag := value.Type().Field(i).Tag // returns the tag string
tagValue := tag.Get("mapstructure")
if tagValue == "provisioningState" {
return res.Parsed, value.Field(i).Elem().String(), nil
}
}

panic(fmt.Errorf("azureStateRefreshFunc called on structure %T with no mapstructure:provisioningState tag. This is a bug", res.Parsed))
}
}

// Resource group names can be capitalised, but we store them in lowercase.
// Use a custom diff function to avoid creation of new resources.
func resourceAzurermResourceGroupNameDiffSuppress(k, old, new string, d *schema.ResourceData) bool {