You've already forked golang-saas-starter-kit
mirror of
https://github.com/raseels-repos/golang-saas-starter-kit.git
synced 2025-08-10 22:41:25 +02:00
update deploy to check for task def placeholders in env vars.
This commit is contained in:
@@ -29,7 +29,7 @@ cache:
|
|||||||
.build_tmpl: &build_tmpl
|
.build_tmpl: &build_tmpl
|
||||||
<<: *job_tmpl
|
<<: *job_tmpl
|
||||||
script:
|
script:
|
||||||
- 'devops build -service=${SERVICE} -project=${PROJECT_NAME} -env=${TARGET_ENV}'
|
- 'EMAIL_SENDER=$EMAIL_SENDER devops build -service=${SERVICE} -project=${PROJECT_NAME} -env=${TARGET_ENV}'
|
||||||
|
|
||||||
.deploy_tmpl: &deploy_tmpl
|
.deploy_tmpl: &deploy_tmpl
|
||||||
<<: *job_tmpl
|
<<: *job_tmpl
|
||||||
@@ -92,7 +92,7 @@ webapp:deploy:dev:
|
|||||||
STATIC_FILES_S3: 'true'
|
STATIC_FILES_S3: 'true'
|
||||||
STATIC_FILES_IMG_RESIZE: 'true'
|
STATIC_FILES_IMG_RESIZE: 'true'
|
||||||
AWS_USE_ROLE: 'true'
|
AWS_USE_ROLE: 'true'
|
||||||
EMAIL_SENDER: 'lee@geeksinthewoods.com'
|
EMAIL_SENDER: 'lee+saas-starter-kit@geeksinthewoods.com'
|
||||||
|
|
||||||
webapi:build:dev:
|
webapi:build:dev:
|
||||||
<<: *build_tmpl
|
<<: *build_tmpl
|
||||||
@@ -132,7 +132,7 @@ webapi:deploy:dev:
|
|||||||
STATIC_FILES_S3: 'false'
|
STATIC_FILES_S3: 'false'
|
||||||
STATIC_FILES_IMG_RESIZE: 'false'
|
STATIC_FILES_IMG_RESIZE: 'false'
|
||||||
AWS_USE_ROLE: 'true'
|
AWS_USE_ROLE: 'true'
|
||||||
EMAIL_SENDER: 'lee@geeksinthewoods.com'
|
EMAIL_SENDER: 'lee+saas-starter-kit@geeksinthewoods.com'
|
||||||
|
|
||||||
#ddlogscollector:deploy:stage:
|
#ddlogscollector:deploy:stage:
|
||||||
# <<: *deploy_stage_tmpl
|
# <<: *deploy_stage_tmpl
|
||||||
|
@@ -200,7 +200,7 @@ func Migrate(log *log.Logger, req *migrateRequest) error {
|
|||||||
|
|
||||||
// Start Migrations
|
// Start Migrations
|
||||||
log.Printf("\t\tStart migrations.")
|
log.Printf("\t\tStart migrations.")
|
||||||
if err = schema.Migrate(masterDb, log); err != nil {
|
if err = schema.Migrate(masterDb, log, false); err != nil {
|
||||||
return errors.WithStack(err)
|
return errors.WithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1480,7 +1480,7 @@ func ServiceDeploy(log *log.Logger, req *serviceDeployRequest) error {
|
|||||||
|
|
||||||
// Start the database migrations.
|
// Start the database migrations.
|
||||||
log.Printf("\t\tStart migrations.")
|
log.Printf("\t\tStart migrations.")
|
||||||
if err = schema.Migrate(masterDb, log); err != nil {
|
if err = schema.Migrate(masterDb, log, false); err != nil {
|
||||||
return errors.WithStack(err)
|
return errors.WithStack(err)
|
||||||
}
|
}
|
||||||
log.Printf("\t\tFinished migrations.")
|
log.Printf("\t\tFinished migrations.")
|
||||||
@@ -2552,22 +2552,23 @@ func ServiceDeploy(log *log.Logger, req *serviceDeployRequest) error {
|
|||||||
pks = append(pks, k)
|
pks = append(pks, k)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate new regular expression for finding placeholders.
|
|
||||||
expr := "(" + strings.Join(pks, "|") + ")"
|
|
||||||
r, err := regexp.Compile(expr)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read the defined json task definition.
|
// Read the defined json task definition.
|
||||||
dat, err := EcsReadTaskDefinition(req.ServiceDir, req.Env)
|
dat, err := EcsReadTaskDefinition(req.ServiceDir, req.Env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
jsonStr := string(dat)
|
||||||
|
|
||||||
// Replace placeholders used in the JSON task definition.
|
// Replace placeholders used in the JSON task definition.
|
||||||
{
|
{
|
||||||
jsonStr := string(dat)
|
// Generate new regular expression for finding placeholders.
|
||||||
|
expr := "(" + strings.Join(pks, "|") + ")"
|
||||||
|
r, err := regexp.Compile(expr)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
matches := r.FindAllString(jsonStr, -1)
|
matches := r.FindAllString(jsonStr, -1)
|
||||||
|
|
||||||
@@ -2586,11 +2587,37 @@ func ServiceDeploy(log *log.Logger, req *serviceDeployRequest) error {
|
|||||||
jsonStr = strings.Replace(jsonStr, m, newVal, -1)
|
jsonStr = strings.Replace(jsonStr, m, newVal, -1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dat = []byte(jsonStr)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replace placeholders defined in task def but not here from env vars.
|
||||||
|
{
|
||||||
|
r, err := regexp.Compile(`{\b(\w*)\b}`)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
matches := r.FindAllString(jsonStr, -1)
|
||||||
|
if len(matches) > 0 {
|
||||||
|
log.Println("\t\tSearching for placeholders in env variables.")
|
||||||
|
|
||||||
|
replaced := make(map[string]bool)
|
||||||
|
for _, m := range matches {
|
||||||
|
m = strings.Trim(m, "{}")
|
||||||
|
if replaced[m] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
replaced[m] = true
|
||||||
|
|
||||||
|
newVal := os.Getenv(m)
|
||||||
|
log.Printf("\t\t\t%s -> %s", m, newVal)
|
||||||
|
jsonStr = strings.Replace(jsonStr, m, newVal, -1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dat = []byte(jsonStr)
|
||||||
|
|
||||||
log.Println("\t\tParse JSON to task definition.")
|
log.Println("\t\tParse JSON to task definition.")
|
||||||
|
|
||||||
taskDefInput, err := parseTaskDefinitionInput(dat)
|
taskDefInput, err := parseTaskDefinitionInput(dat)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Reference in New Issue
Block a user