Skip to content

Commit

Permalink
Merge branch 'master' into automationresources
Browse files Browse the repository at this point in the history
  • Loading branch information
bgelens committed Sep 9, 2018
2 parents 872517e + c165188 commit 11926b1
Show file tree
Hide file tree
Showing 293 changed files with 23,076 additions and 10,914 deletions.
526 changes: 109 additions & 417 deletions CHANGELOG.md

Large diffs are not rendered by default.

176 changes: 77 additions & 99 deletions azurerm/config.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions azurerm/data_source_app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/hashicorp/terraform/helper/schema"
azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

Expand All @@ -28,7 +28,7 @@ func dataSourceArmAppService() *schema.Resource {
Computed: true,
},

"site_config": azSchema.AppServiceSiteConfigSchema(),
"site_config": azure.SchemaAppServiceSiteConfig(),

"client_affinity_enabled": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -192,7 +192,7 @@ func dataSourceArmAppServiceRead(d *schema.ResourceData, meta interface{}) error
return err
}

siteConfig := azSchema.FlattenAppServiceSiteConfig(configResp.SiteConfig)
siteConfig := azure.FlattenAppServiceSiteConfig(configResp.SiteConfig)
if err := d.Set("site_config", siteConfig); err != nil {
return err
}
Expand Down
15 changes: 11 additions & 4 deletions azurerm/data_source_azuread_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package azurerm

import (
"fmt"

"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
"log"
)

func dataSourceArmAzureADApplication() *schema.Resource {
Expand Down Expand Up @@ -73,6 +73,8 @@ func dataSourceArmAzureADApplicationRead(d *schema.ResourceData, meta interface{
var application graphrbac.Application

if oId, ok := d.GetOk("object_id"); ok {

// use the object_id to find the Azure AD application
objectId := oId.(string)
resp, err := client.Get(ctx, objectId)
if err != nil {
Expand All @@ -85,13 +87,18 @@ func dataSourceArmAzureADApplicationRead(d *schema.ResourceData, meta interface{

application = resp
} else {
resp, err := client.ListComplete(ctx, "")

// use the name to find the Azure AD application
name := d.Get("name").(string)
filter := fmt.Sprintf("displayName eq '%s'", name)
log.Printf("[DEBUG] [data_source_azuread_application] Using filter %q", filter)

resp, err := client.ListComplete(ctx, filter)

if err != nil {
return fmt.Errorf("Error listing Azure AD Applications: %+v", err)
}

name := d.Get("name").(string)

var app *graphrbac.Application
for _, v := range *resp.Response().Value {
if v.DisplayName != nil {
Expand Down
78 changes: 47 additions & 31 deletions azurerm/data_source_azuread_service_principal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package azurerm

import (
"fmt"

"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
"log"
)

func dataSourceArmActiveDirectoryServicePrincipal() *schema.Resource {
Expand Down Expand Up @@ -44,6 +44,8 @@ func dataSourceArmActiveDirectoryServicePrincipalRead(d *schema.ResourceData, me
var servicePrincipal *graphrbac.ServicePrincipal

if v, ok := d.GetOk("object_id"); ok {

//use the object_id to find the Azure AD service principal
objectId := v.(string)
app, err := client.Get(ctx, objectId)
if err != nil {
Expand All @@ -55,47 +57,61 @@ func dataSourceArmActiveDirectoryServicePrincipalRead(d *schema.ResourceData, me
}

servicePrincipal = &app
} else {
apps, err := client.ListComplete(ctx, "")

} else if _, ok := d.GetOk("display_name"); ok {

// use the display_name to find the Azure AD service principal
displayName := d.Get("display_name").(string)
filter := fmt.Sprintf("displayName eq '%s'", displayName)
log.Printf("[DEBUG] [data_source_azuread_service_principal] Using filter %q", filter)

apps, err := client.ListComplete(ctx, filter)
if err != nil {
return fmt.Errorf("Error listing Service Principals: %+v", err)
}

if v, ok := d.GetOk("display_name"); ok {
displayName := v.(string)

for _, app := range *apps.Response().Value {
if app.DisplayName == nil {
continue
}

if *app.DisplayName == displayName {
servicePrincipal = &app
break
}
for _, app := range *apps.Response().Value {
if app.DisplayName == nil {
continue
}

if servicePrincipal == nil {
return fmt.Errorf("A Service Principal with the Display Name %q was not found", displayName)
if *app.DisplayName == displayName {
servicePrincipal = &app
break
}
} else {
applicationId := d.Get("application_id").(string)

for _, app := range *apps.Response().Value {
if app.AppID == nil {
continue
}

if *app.AppID == applicationId {
servicePrincipal = &app
break
}
}

if servicePrincipal == nil {
return fmt.Errorf("A Service Principal with the Display Name %q was not found", displayName)
}

} else {

// use the application_id to find the Azure AD service principal
applicationId := d.Get("application_id").(string)
filter := fmt.Sprintf("appId eq '%s'", applicationId)
log.Printf("[DEBUG] [data_source_azuread_service_principal] Using filter %q", filter)

apps, err := client.ListComplete(ctx, filter)
if err != nil {
return fmt.Errorf("Error listing Service Principals: %+v", err)
}

for _, app := range *apps.Response().Value {
if app.AppID == nil {
continue
}

if servicePrincipal == nil {
return fmt.Errorf("A Service Principal for Application ID %q was not found", applicationId)
if *app.AppID == applicationId {
servicePrincipal = &app
break
}
}

if servicePrincipal == nil {
return fmt.Errorf("A Service Principal for Application ID %q was not found", applicationId)
}

}

d.SetId(*servicePrincipal.ObjectID)
Expand Down
2 changes: 1 addition & 1 deletion azurerm/data_source_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"regexp"
"sort"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2017-12-01/compute"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
Expand Down
8 changes: 4 additions & 4 deletions azurerm/data_source_key_vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2016-10-01/keyvault"
"github.com/hashicorp/terraform/helper/schema"
kvschema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

Expand Down Expand Up @@ -139,12 +139,12 @@ func dataSourceArmKeyVaultRead(d *schema.ResourceData, meta interface{}) error {
d.Set("enabled_for_disk_encryption", props.EnabledForDiskEncryption)
d.Set("enabled_for_template_deployment", props.EnabledForTemplateDeployment)
if err := d.Set("sku", flattenKeyVaultDataSourceSku(props.Sku)); err != nil {
return fmt.Errorf("Error flattening `sku` for KeyVault %q: %+v", resp.Name, err)
return fmt.Errorf("Error flattening `sku` for KeyVault %q: %+v", *resp.Name, err)
}

flattenedPolicies := kvschema.FlattenKeyVaultAccessPolicies(props.AccessPolicies)
flattenedPolicies := azure.FlattenKeyVaultAccessPolicies(props.AccessPolicies)
if err := d.Set("access_policy", flattenedPolicies); err != nil {
return fmt.Errorf("Error flattening `access_policy` for KeyVault %q: %+v", resp.Name, err)
return fmt.Errorf("Error flattening `access_policy` for KeyVault %q: %+v", *resp.Name, err)
}
d.Set("vault_uri", props.VaultURI)
}
Expand Down
Loading

0 comments on commit 11926b1

Please sign in to comment.