-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into lg-akscreds
- Loading branch information
Showing
576 changed files
with
70,472 additions
and
27,768 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.