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

provider: Migrate to standalone plugin SDK v1.1.0 #154

Merged
merged 3 commits into from
Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ linters:

linters-settings:
errcheck:
ignore: github.com/hashicorp/terraform/helper/schema:ForceNew|Set,fmt:.*,io:Close
ignore: github.com/hashicorp/terraform-plugin-sdk/helper/schema:ForceNew|Set,fmt:.*,io:Close
misspell:
locale: UK
43 changes: 22 additions & 21 deletions azuread/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ import (
"github.com/Azure/go-autorest/autorest/azure"
"github.com/hashicorp/go-azure-helpers/authentication"
"github.com/hashicorp/go-azure-helpers/sender"
"github.com/hashicorp/terraform/httpclient"
"github.com/hashicorp/terraform-plugin-sdk/httpclient"
"github.com/terraform-providers/terraform-provider-azuread/version"
)

// ArmClient contains the handles to all the specific Azure ADger resource classes' respective clients.
type ArmClient struct {
subscriptionID string
clientID string
tenantID string
environment azure.Environment
subscriptionID string
clientID string
tenantID string
terraformVersion string
environment azure.Environment

StopContext context.Context

Expand All @@ -35,18 +36,19 @@ type ArmClient struct {
}

// getArmClient is a helper method which returns a fully instantiated *ArmClient based on the auth Config's current settings.
func getArmClient(authCfg *authentication.Config) (*ArmClient, error) {
func getArmClient(authCfg *authentication.Config, tfVersion string) (*ArmClient, error) {
env, err := authentication.DetermineEnvironment(authCfg.Environment)
if err != nil {
return nil, err
}

// client declarations:
client := ArmClient{
subscriptionID: authCfg.SubscriptionID,
clientID: authCfg.ClientID,
tenantID: authCfg.TenantID,
environment: *env,
subscriptionID: authCfg.SubscriptionID,
clientID: authCfg.ClientID,
tenantID: authCfg.TenantID,
terraformVersion: tfVersion,
environment: *env,
}

sender := sender.BuildSender("AzureAD")
Expand All @@ -70,33 +72,32 @@ func getArmClient(authCfg *authentication.Config) (*ArmClient, error) {

func (c *ArmClient) registerGraphRBACClients(endpoint, tenantID string, authorizer autorest.Authorizer) {
c.applicationsClient = graphrbac.NewApplicationsClientWithBaseURI(endpoint, tenantID)
configureClient(&c.applicationsClient.Client, authorizer)
configureClient(&c.applicationsClient.Client, authorizer, c.terraformVersion)

c.domainsClient = graphrbac.NewDomainsClientWithBaseURI(endpoint, tenantID)
configureClient(&c.domainsClient.Client, authorizer)
configureClient(&c.domainsClient.Client, authorizer, c.terraformVersion)

c.groupsClient = graphrbac.NewGroupsClientWithBaseURI(endpoint, tenantID)
configureClient(&c.groupsClient.Client, authorizer)
configureClient(&c.groupsClient.Client, authorizer, c.terraformVersion)

c.servicePrincipalsClient = graphrbac.NewServicePrincipalsClientWithBaseURI(endpoint, tenantID)
configureClient(&c.servicePrincipalsClient.Client, authorizer)
configureClient(&c.servicePrincipalsClient.Client, authorizer, c.terraformVersion)

c.usersClient = graphrbac.NewUsersClientWithBaseURI(endpoint, tenantID)
configureClient(&c.usersClient.Client, authorizer)
configureClient(&c.usersClient.Client, authorizer, c.terraformVersion)
}

func configureClient(client *autorest.Client, auth autorest.Authorizer) {
setUserAgent(client)
func configureClient(client *autorest.Client, auth autorest.Authorizer, tfVersion string) {
setUserAgent(client, tfVersion)
client.Authorizer = auth
client.Sender = sender.BuildSender("AzureAD")
client.SkipResourceProviderRegistration = false
client.PollingDuration = 60 * time.Minute
}

//could be moved to helpers
func setUserAgent(client *autorest.Client) {
// TODO: This is the SDK version not the CLI version, once we are on 0.12, should revisit
tfUserAgent := httpclient.UserAgentString()
// Could be moved to helpers
func setUserAgent(client *autorest.Client, tfVersion string) {
tfUserAgent := httpclient.TerraformUserAgent(tfVersion)

pv := version.ProviderVersion
providerUserAgent := fmt.Sprintf("%s terraform-provider-azuread/%s", tfUserAgent, pv)
Expand Down
2 changes: 1 addition & 1 deletion azuread/data_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/ar"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/graph"
Expand Down
2 changes: 1 addition & 1 deletion azuread/data_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

"github.com/google/uuid"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccAzureADApplicationDataSource_byObjectId(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion azuread/data_domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"

"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func dataDomains() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion azuread/data_domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package azuread
import (
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccDataSourceAzureADDomains_basic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion azuread/data_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/graph"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/ar"
Expand Down
4 changes: 2 additions & 2 deletions azuread/data_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/tf"
)

Expand Down
2 changes: 1 addition & 1 deletion azuread/data_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"

"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/graph"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/validate"
Expand Down
2 changes: 1 addition & 1 deletion azuread/data_groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/tf"
)

Expand Down
2 changes: 1 addition & 1 deletion azuread/data_service_principal.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/ar"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/graph"
Expand Down
2 changes: 1 addition & 1 deletion azuread/data_service_principal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

"github.com/google/uuid"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccAzureADServicePrincipalDataSource_byApplicationId(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion azuread/data_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/graph"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/validate"
Expand Down
4 changes: 2 additions & 2 deletions azuread/data_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/tf"
)
Expand Down
2 changes: 1 addition & 1 deletion azuread/data_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"

"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/graph"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/validate"
Expand Down
4 changes: 2 additions & 2 deletions azuread/data_users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/tf"
)
Expand Down
2 changes: 1 addition & 1 deletion azuread/helpers/graph/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package graph

import (
"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func SchemaAppRoles() *schema.Schema {
Expand Down
6 changes: 3 additions & 3 deletions azuread/helpers/graph/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/Azure/go-autorest/autorest/date"
"github.com/hashicorp/go-uuid"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/ar"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/p"
Expand Down
2 changes: 1 addition & 1 deletion azuread/helpers/graph/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/Azure/go-autorest/autorest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/ar"
)
Expand Down
2 changes: 1 addition & 1 deletion azuread/helpers/tf/acctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"
"time"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
)

func AccRandTimeInt() int {
Expand Down
2 changes: 1 addition & 1 deletion azuread/helpers/tf/locks.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package tf

import "github.com/hashicorp/terraform/helper/mutexkv"
import "github.com/hashicorp/terraform-plugin-sdk/helper/mutexkv"

// mutex is the instance of MutexKV for ARM resources
var mutex = mutexkv.NewMutexKV()
Expand Down
2 changes: 1 addition & 1 deletion azuread/helpers/validate/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/url"
"strings"

"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func URLIsHTTPS(i interface{}, k string) (_ []string, errors []error) {
Expand Down
6 changes: 3 additions & 3 deletions azuread/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"

"github.com/hashicorp/go-azure-helpers/authentication"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

// Provider returns a terraform.ResourceProvider.
Expand Down Expand Up @@ -120,7 +120,7 @@ func providerConfigure(p *schema.Provider) schema.ConfigureFunc {
return nil, fmt.Errorf("Error building AzureAD Client: %s", err)
}

client, err := getArmClient(config)
client, err := getArmClient(config, p.TerraformVersion)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions azuread/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"regexp"
"testing"

"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

var testAccProviders map[string]terraform.ResourceProvider
Expand Down
4 changes: 2 additions & 2 deletions azuread/resource_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/google/uuid"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/ar"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/graph"
Expand Down
4 changes: 2 additions & 2 deletions azuread/resource_application_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"time"

"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/ar"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/graph"
Expand Down
4 changes: 2 additions & 2 deletions azuread/resource_application_password_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"

"github.com/google/uuid"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/ar"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/graph"
Expand Down
4 changes: 2 additions & 2 deletions azuread/resource_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"testing"

"github.com/google/uuid"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/ar"
)
Expand Down
4 changes: 2 additions & 2 deletions azuread/resource_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/google/uuid"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/ar"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/graph"
Expand Down
2 changes: 1 addition & 1 deletion azuread/resource_group_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package azuread
import (
"fmt"

"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/ar"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/graph"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/tf"
Expand Down
6 changes: 3 additions & 3 deletions azuread/resource_group_member_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/ar"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/graph"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/tf"
Expand Down
Loading