Skip to content

Commit

Permalink
Merge branch 'master' into lg-akscreds
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed Apr 10, 2018
2 parents 7244cdc + 4661399 commit a71a92f
Show file tree
Hide file tree
Showing 576 changed files with 70,472 additions and 27,768 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ website/vendor
# Test exclusions
!command/test-fixtures/**/*.tfstate
!command/test-fixtures/**/.terraform/

.env.sh
391 changes: 84 additions & 307 deletions CHANGELOG.md

Large diffs are not rendered by default.

122 changes: 95 additions & 27 deletions azurerm/config.go

Large diffs are not rendered by default.

297 changes: 297 additions & 0 deletions azurerm/data_source_app_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
package azurerm

import (
"fmt"
"log"

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

func dataSourceArmAppService() *schema.Resource {
return &schema.Resource{
Read: dataSourceArmAppServiceRead,

Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},

"resource_group_name": resourceGroupNameDiffSuppressSchema(),

"location": locationForDataSourceSchema(),

"app_service_plan_id": {
Type: schema.TypeString,
Computed: true,
},

"site_config": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"always_on": {
Type: schema.TypeBool,
Computed: true,
},

"default_documents": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},

"dotnet_framework_version": {
Type: schema.TypeString,
Computed: true,
},

"java_version": {
Type: schema.TypeString,
Computed: true,
},

"java_container": {
Type: schema.TypeString,
Computed: true,
},

"java_container_version": {
Type: schema.TypeString,
Computed: true,
},

"local_mysql_enabled": {
Type: schema.TypeBool,
Computed: true,
},

"managed_pipeline_mode": {
Type: schema.TypeString,
Computed: true,
},

"php_version": {
Type: schema.TypeString,
Computed: true,
},

"python_version": {
Type: schema.TypeString,
Computed: true,
},

"remote_debugging_enabled": {
Type: schema.TypeBool,
Computed: true,
},

"remote_debugging_version": {
Type: schema.TypeString,
Computed: true,
},

"scm_type": {
Type: schema.TypeString,
Computed: true,
},

"use_32_bit_worker_process": {
Type: schema.TypeBool,
Computed: true,
},

"websockets_enabled": {
Type: schema.TypeBool,
Computed: true,
},
},
},
},

"client_affinity_enabled": {
Type: schema.TypeBool,
Computed: true,
},

"https_only": {
Type: schema.TypeBool,
Computed: true,
},

"enabled": {
Type: schema.TypeBool,
Computed: true,
},

"app_settings": {
Type: schema.TypeMap,
Computed: true,
},

"connection_string": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Computed: true,
},
"value": {
Type: schema.TypeString,
Computed: true,
},
"type": {
Type: schema.TypeString,
Computed: true,
},
},
},
},

"tags": tagsForDataSourceSchema(),

"site_credential": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"username": {
Type: schema.TypeString,
Computed: true,
},
"password": {
Type: schema.TypeString,
Computed: true,
Sensitive: true,
},
},
},
},

"default_site_hostname": {
Type: schema.TypeString,
Computed: true,
},

"outbound_ip_addresses": {
Type: schema.TypeString,
Computed: true,
},
"source_control": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"repo_url": {
Type: schema.TypeString,
Computed: true,
},
"branch": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
},
}
}
func dataSourceArmAppServiceRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).appServicesClient

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

ctx := meta.(*ArmClient).StopContext
resp, err := client.Get(ctx, resourceGroup, name)
if err != nil {
if utils.ResponseWasNotFound(resp.Response) {
log.Printf("[DEBUG] App Service %q (resource group %q) was not found - removing from state", name, resourceGroup)
d.SetId("")
return nil
}
return fmt.Errorf("Error making Read request on AzureRM App Service %q: %+v", name, err)
}

configResp, err := client.GetConfiguration(ctx, resourceGroup, name)
if err != nil {
return fmt.Errorf("Error making Read request on AzureRM App Service Configuration %q: %+v", name, err)
}

appSettingsResp, err := client.ListApplicationSettings(ctx, resourceGroup, name)
if err != nil {
return fmt.Errorf("Error making Read request on AzureRM App Service AppSettings %q: %+v", name, err)
}

connectionStringsResp, err := client.ListConnectionStrings(ctx, resourceGroup, name)
if err != nil {
return fmt.Errorf("Error making Read request on AzureRM App Service ConnectionStrings %q: %+v", name, err)
}

scmResp, err := client.GetSourceControl(ctx, resourceGroup, name)
if err != nil {
return fmt.Errorf("Error making Read request on AzureRM App Service Source Control %q: %+v", name, err)
}

siteCredFuture, err := client.ListPublishingCredentials(ctx, resourceGroup, name)
if err != nil {
return err
}
err = siteCredFuture.WaitForCompletion(ctx, client.Client)
if err != nil {
return err
}
siteCredResp, err := siteCredFuture.Result(client)
if err != nil {
return fmt.Errorf("Error making Read request on AzureRM App Service Site Credential %q: %+v", name, err)
}

d.SetId(*resp.ID)

d.Set("name", name)
d.Set("resource_group_name", resourceGroup)
if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

if props := resp.SiteProperties; props != nil {
d.Set("app_service_plan_id", props.ServerFarmID)
d.Set("client_affinity_enabled", props.ClientAffinityEnabled)
d.Set("enabled", props.Enabled)
d.Set("https_only", props.HTTPSOnly)
d.Set("default_site_hostname", props.DefaultHostName)
d.Set("outbound_ip_addresses", props.OutboundIPAddresses)
}

if err := d.Set("app_settings", flattenAppServiceAppSettings(appSettingsResp.Properties)); err != nil {
return err
}
if err := d.Set("connection_string", flattenAppServiceConnectionStrings(connectionStringsResp.Properties)); err != nil {
return err
}

siteConfig := flattenAppServiceSiteConfig(configResp.SiteConfig)
if err := d.Set("site_config", siteConfig); err != nil {
return err
}

scm := flattenAppServiceSourceControl(scmResp.SiteSourceControlProperties)
if err := d.Set("source_control", scm); err != nil {
return err
}

siteCred := flattenAppServiceSiteCredential(siteCredResp.UserProperties)
if err := d.Set("site_credential", siteCred); err != nil {
return err
}

flattenAndSetTags(d, resp.Tags)

return nil
}
Loading

0 comments on commit a71a92f

Please sign in to comment.