Skip to content
This repository has been archived by the owner on Apr 9, 2021. It is now read-only.

Commit

Permalink
TER-239: Update app read feature: read build infos and autoscale
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Caussat committed Mar 26, 2018
1 parent 81e648a commit ea48597
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions ghost/resource_ghost_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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{})
Expand Down

0 comments on commit ea48597

Please sign in to comment.