You've already forked golang-saas-starter-kit
mirror of
https://github.com/raseels-repos/golang-saas-starter-kit.git
synced 2025-06-17 00:17:59 +02:00
fixing deploy script
This commit is contained in:
@ -12,15 +12,15 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"geeks-accelerator/oss/saas-starter-kit/internal/platform/docker"
|
||||
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/webcontext"
|
||||
"geeks-accelerator/oss/saas-starter-kit/internal/schema"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
"github.com/aws/aws-sdk-go/aws/ec2metadata"
|
||||
"github.com/kelseyhightower/envconfig"
|
||||
"geeks-accelerator/oss/saas-starter-kit/internal/platform/docker"
|
||||
"geeks-accelerator/oss/saas-starter-kit/internal/schema"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/kelseyhightower/envconfig"
|
||||
)
|
||||
|
||||
// Success and failure markers.
|
||||
@ -48,7 +48,6 @@ func New() *Test {
|
||||
|
||||
log := log.New(os.Stdout, "TEST : ", log.LstdFlags|log.Lmicroseconds|log.Lshortfile)
|
||||
|
||||
|
||||
// =========================================================================
|
||||
// Configuration
|
||||
var cfg struct {
|
||||
@ -65,7 +64,6 @@ func New() *Test {
|
||||
log.Fatalf("startup : Parsing Config : %+v", err)
|
||||
}
|
||||
|
||||
|
||||
// AWS access keys are required, if roles are enabled, remove any placeholders.
|
||||
if cfg.Aws.UseRole {
|
||||
cfg.Aws.AccessKeyID = ""
|
||||
@ -97,7 +95,6 @@ func New() *Test {
|
||||
log.Printf("startup : Config : %v\n", string(cfgJSON))
|
||||
}
|
||||
|
||||
|
||||
// ============================================================
|
||||
// Init AWS Session
|
||||
var awsSession *session.Session
|
||||
@ -118,7 +115,6 @@ func New() *Test {
|
||||
log.Printf("startup : AWS : Using static credentials\n")
|
||||
}
|
||||
|
||||
|
||||
// ============================================================
|
||||
// Startup Postgres container
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cicd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"path/filepath"
|
||||
@ -144,7 +145,7 @@ func NewMigrateRequest(log *log.Logger, flags MigrateFlags) (*migrateRequest, er
|
||||
}
|
||||
|
||||
// Run is the main entrypoint for migration of database schema for a given target environment.
|
||||
func Migrate(log *log.Logger, req *migrateRequest) error {
|
||||
func Migrate(log *log.Logger, ctx context.Context, req *migrateRequest) error {
|
||||
|
||||
// Load the database details.
|
||||
var db DB
|
||||
@ -200,7 +201,7 @@ func Migrate(log *log.Logger, req *migrateRequest) error {
|
||||
|
||||
// Start Migrations
|
||||
log.Printf("\t\tStart migrations.")
|
||||
if err = schema.Migrate(masterDb, log, false); err != nil {
|
||||
if err = schema.Migrate(ctx, masterDb, log, false); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
|
@ -571,12 +571,12 @@ func NewServiceDeployRequest(log *log.Logger, flags ServiceDeployFlags) (*servic
|
||||
if req.S3BucketPublicName != "" || req.S3BucketPrivateName != "" {
|
||||
var bpr []string
|
||||
if req.S3BucketPublicName != "" {
|
||||
bpr = append(bpr, "arn:aws:s3:::"+req.S3BucketPublicName )
|
||||
bpr = append(bpr, "arn:aws:s3:::"+req.S3BucketPublicName + "/*" )
|
||||
bpr = append(bpr, "arn:aws:s3:::"+req.S3BucketPublicName)
|
||||
bpr = append(bpr, "arn:aws:s3:::"+req.S3BucketPublicName+"/*")
|
||||
}
|
||||
if req.S3BucketPrivateName != "" {
|
||||
bpr = append(bpr, "arn:aws:s3:::"+req.S3BucketPrivateName )
|
||||
bpr = append(bpr, "arn:aws:s3:::"+req.S3BucketPrivateName + "/*" )
|
||||
bpr = append(bpr, "arn:aws:s3:::"+req.S3BucketPrivateName)
|
||||
bpr = append(bpr, "arn:aws:s3:::"+req.S3BucketPrivateName+"/*")
|
||||
}
|
||||
|
||||
bp := IamStatementEntry{
|
||||
@ -918,7 +918,7 @@ func NewServiceDeployRequest(log *log.Logger, flags ServiceDeployFlags) (*servic
|
||||
}
|
||||
|
||||
// Run is the main entrypoint for deploying a service for a given target environment.
|
||||
func ServiceDeploy(log *log.Logger, req *serviceDeployRequest) error {
|
||||
func ServiceDeploy(log *log.Logger, ctx context.Context, req *serviceDeployRequest) error {
|
||||
|
||||
startTime := time.Now()
|
||||
|
||||
@ -1533,7 +1533,7 @@ func ServiceDeploy(log *log.Logger, req *serviceDeployRequest) error {
|
||||
|
||||
// Start the database migrations.
|
||||
log.Printf("\t\tStart migrations.")
|
||||
if err = schema.Migrate(masterDb, log, false); err != nil {
|
||||
if err = schema.Migrate(ctx, masterDb, log, false); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
log.Printf("\t\tFinished migrations.")
|
||||
|
@ -1,10 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"expvar"
|
||||
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web/webcontext"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"geeks-accelerator/oss/saas-starter-kit/tools/devops/cmd/cicd"
|
||||
_ "github.com/lib/pq"
|
||||
@ -111,7 +114,16 @@ func main() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cicd.ServiceDeploy(log, req)
|
||||
|
||||
// Set the context with the required values to
|
||||
// process the request.
|
||||
v := webcontext.Values{
|
||||
Now: time.Now(),
|
||||
Env: req.Env,
|
||||
}
|
||||
ctx := context.WithValue(context.Background(), webcontext.KeyValues, &v)
|
||||
|
||||
return cicd.ServiceDeploy(log, ctx, req)
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -127,7 +139,16 @@ func main() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cicd.Migrate(log, req)
|
||||
|
||||
// Set the context with the required values to
|
||||
// process the request.
|
||||
v := webcontext.Values{
|
||||
Now: time.Now(),
|
||||
Env: req.Env,
|
||||
}
|
||||
ctx := context.WithValue(context.Background(), webcontext.KeyValues, &v)
|
||||
|
||||
return cicd.Migrate(log, ctx, req)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user