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

Commit

Permalink
TER-235: Update app creation: add features expand method
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Caussat authored and Jordan Caussat committed Mar 20, 2018
1 parent 10164bc commit 9978437
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions ghost/resource_ghost_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,6 @@ func resourceGhostApp() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"parameters": {
Type: schema.TypeString,
Optional: true,
},
"provisioner": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -467,8 +463,8 @@ func expandGhostApp(d *schema.ResourceData) ghost.App {
VpcID: d.Get("vpc_id").(string),
InstanceMonitoring: d.Get("instance_monitoring").(bool),

Modules: expandGhostAppModules(d),
// Features:
Modules: expandGhostAppModules(d),
Features: expandGhostAppFeatures(d),
// Autoscale:
BuildInfos: expandGhostAppBuildInfos(d),
EnvironmentInfos: expandGhostAppEnvironmentInfos(d),
Expand All @@ -481,6 +477,26 @@ func expandGhostApp(d *schema.ResourceData) ghost.App {
return app
}

// Get features from TF configuration
func expandGhostAppFeatures(d *schema.ResourceData) *[]ghost.Feature {
configs := d.Get("features").([]interface{})
features := &[]ghost.Feature{}

// Add each module to modules list
for _, config := range configs {
data := config.(map[string]interface{})
feature := ghost.Feature{
Name: data["name"].(string),
Version: data["version"].(string),
Provisioner: data["provisioner"].(string),
}

*features = append(*features, feature)
}

return features
}

// Get modules from TF configuration
func expandGhostAppModules(d *schema.ResourceData) *[]ghost.Module {
configs := d.Get("modules").([]interface{})
Expand Down

0 comments on commit 9978437

Please sign in to comment.