From ea48597896906a988260b0e4fd81cc43053c846f Mon Sep 17 00:00:00 2001 From: Jordan Caussat Date: Wed, 14 Mar 2018 11:04:13 +0100 Subject: [PATCH] TER-239: Update app read feature: read build infos and autoscale --- ghost/resource_ghost_app.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ghost/resource_ghost_app.go b/ghost/resource_ghost_app.go index 3d1d7d2..ff3de97 100644 --- a/ghost/resource_ghost_app.go +++ b/ghost/resource_ghost_app.go @@ -537,9 +537,13 @@ func flattenGhostApp(d *schema.ResourceData, app ghost.App) error { d.Set("instance_monitoring", app.InstanceMonitoring) d.Set("modules", flattenGhostAppModules(app.Modules)) + d.Set("build_infos", flattenGhostAppBuildInfos(app.BuildInfos)) if err := d.Set("features", flattenGhostAppFeatures(app.Features)); err != nil { return err } + if err := d.Set("autoscale", flattenGhostAppAutoscale(app.Autoscale)); err != nil { + return err + } return nil } @@ -629,6 +633,19 @@ func expandGhostAppAutoscale(d []interface{}) *ghost.Autoscale { return autoscale } +func flattenGhostAppAutoscale(autoscale *ghost.Autoscale) []interface{} { + values := []interface{}{} + + values = append(values, map[string]interface{}{ + "name": autoscale.Name, + "enable_metrics": autoscale.EnableMetrics, + "min": autoscale.Min, + "max": autoscale.Max, + }) + + return values +} + // Get lifecycle_hooks from TF configuration func expandGhostAppLifecycleHooks(d []interface{}) *ghost.LifecycleHooks { if len(d) == 0 { @@ -694,6 +711,19 @@ func expandGhostAppBuildInfos(d []interface{}) *ghost.BuildInfos { return buildInfos } +func flattenGhostAppBuildInfos(buildInfos *ghost.BuildInfos) []interface{} { + values := []interface{}{} + + values = append(values, map[string]interface{}{ + "ssh_username": buildInfos.SshUsername, + "source_ami": buildInfos.SourceAmi, + "ami_name": buildInfos.AmiName, + "subnet_id": buildInfos.SubnetID, + }) + + return values +} + // Get environment_infos from TF configuration func expandGhostAppEnvironmentInfos(d []interface{}) *ghost.EnvironmentInfos { data := d[0].(map[string]interface{})