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

Commit

Permalink
TER-235: Move name generation for testing to the test file
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 d995862 commit 10164bc
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions ghost/resource_ghost_app.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package ghost

import (
"crypto/rand"
"fmt"
"log"

"cloud-deploy.io/go-st"
Expand Down Expand Up @@ -461,35 +459,28 @@ func resourceGhostAppDelete(d *schema.ResourceData, meta interface{}) error {
// Get app from TF configuration
func expandGhostApp(d *schema.ResourceData) ghost.App {
app := ghost.App{
Name: d.Get("name").(string),
Env: d.Get("env").(string),
Role: d.Get("role").(string),
Region: d.Get("region").(string),
InstanceType: d.Get("instance_type").(string),
VpcID: d.Get("vpc_id").(string),

Modules: expandGhostAppModules(d),
Name: d.Get("name").(string),
Env: d.Get("env").(string),
Role: d.Get("role").(string),
Region: d.Get("region").(string),
InstanceType: d.Get("instance_type").(string),
VpcID: d.Get("vpc_id").(string),
InstanceMonitoring: d.Get("instance_monitoring").(bool),

Modules: expandGhostAppModules(d),
// Features:
// Autoscale:
BuildInfos: expandGhostAppBuildInfos(d),
EnvironmentInfos: expandGhostAppEnvironmentInfos(d),

// LifecycleHooks:
// SafeDeployment:
// EnvironmentVariables:
LogNotifications: expandGhostAppStringList(d.Get("log_notifications").([]interface{})),
}
// LogNotifications: d.Get("log_notifications").([]string),

app.Name = "APP_TEST-" + pseudo_uuid()

return app
}

func pseudo_uuid() (uuid string) {
b := make([]byte, 16)
_, err := rand.Read(b)
if err == nil {
uuid = fmt.Sprintf("%X-%X-%X-%X-%X", b[0:4], b[4:6], b[6:8], b[8:10], b[10:])
}
return
}

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

0 comments on commit 10164bc

Please sign in to comment.