This repository has been archived by the owner on Jun 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
deploy_config.go
66 lines (55 loc) · 2.12 KB
/
deploy_config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package deploy
import (
"fmt"
"io"
"path"
"github.com/Originate/exosphere/src/aws"
"github.com/Originate/exosphere/src/docker/composebuilder"
"github.com/Originate/exosphere/src/types"
"github.com/Originate/exosphere/src/types/context"
)
// Config contains information needed for deployment
type Config struct {
AppContext *context.AppContext
AutoApprove bool
AwsProfile string
RemoteEnvironmentID string
Writer io.Writer
}
// GetDockerComposeProjectName returns the docker compose project name
func (c Config) GetDockerComposeProjectName() string {
return composebuilder.GetDockerComposeProjectName(c.AppContext.Config.Name)
}
// GetTerraformDir returns the path of the main terraform directory
func (c Config) GetTerraformDir() string {
return path.Join(c.AppContext.Location, "terraform")
}
// GetInfrastructureTerraformDir returns the path of the infra structure terraform directory
func (c Config) GetInfrastructureTerraformDir() string {
return path.Join(c.GetTerraformDir(), "infrastructure")
}
// GetServicesTerraformDir returns the path of the services terraform directory
func (c Config) GetServicesTerraformDir() string {
return path.Join(c.GetTerraformDir(), "services")
}
// GetAwsBucketName returns the aws bucket name to use for storage
func (c Config) GetAwsBucketName() string {
return fmt.Sprintf("%s-%s-%s-terraform", c.GetRemoteEnvironment().AccountID, c.AppContext.Config.Name, c.RemoteEnvironmentID)
}
// GetAwsTerraformLockTable returns the dynamodb table name for storing terraform locks
func (c Config) GetAwsTerraformLockTable() string {
return "TerraformLocks"
}
// GetRemoteEnvironment returns the app remote environment
func (c Config) GetRemoteEnvironment() types.AppRemoteEnvironment {
return c.AppContext.Config.Remote.Environments[c.RemoteEnvironmentID]
}
// GetAwsOptions returns options to aws functions
func (c Config) GetAwsOptions() aws.Options {
return aws.Options{
Profile: c.AwsProfile,
Region: c.GetRemoteEnvironment().Region,
TerraformLockTable: c.GetAwsTerraformLockTable(),
BucketName: c.GetAwsBucketName(),
}
}