Skip to content
Snippets Groups Projects
Commit 2c4fe935 authored by Johan de Klerk's avatar Johan de Klerk
Browse files

Merge branch 'main' of gitlab.com:uafrica/mage

parents 554258e5 2b3fd4cf
Branches
Tags
No related merge requests found
...@@ -33,7 +33,7 @@ func Clean(path string) error { ...@@ -33,7 +33,7 @@ func Clean(path string) error {
return nil return nil
} }
func Build(dir string, isDebug bool) error { func Build(dir string, module string, isDebug bool) error {
currentDir, _ := os.Getwd() currentDir, _ := os.Getwd()
fullPath := currentDir + "/core/" + dir fullPath := currentDir + "/core/" + dir
...@@ -46,8 +46,8 @@ func Build(dir string, isDebug bool) error { ...@@ -46,8 +46,8 @@ func Build(dir string, isDebug bool) error {
outputDir := fmt.Sprintf(currentDir+`/core/build/handlers/%v`, handler) outputDir := fmt.Sprintf(currentDir+`/core/build/handlers/%v`, handler)
outputFile := fmt.Sprintf(`%v/%v`, outputDir, handler) outputFile := fmt.Sprintf(`%v/%v`, outputDir, handler)
appPath := fmt.Sprintf(`gitlab.com/ship-logic/backends/backend/core/%v`, handler) appPath := fmt.Sprintf(`%v/core/%v`, module, handler)
err := BuildGolangApp(outputFile, appPath, isDebug) err := BuildGolangApp(outputFile, appPath, module, isDebug)
if err != nil { if err != nil {
return err return err
} }
...@@ -75,10 +75,10 @@ func Build(dir string, isDebug bool) error { ...@@ -75,10 +75,10 @@ func Build(dir string, isDebug bool) error {
return nil return nil
} }
func BuildGolangApp(outputDir string, appPath string, isDebug bool) error { func BuildGolangApp(outputDir string, appPath string, module string, isDebug bool) error {
commandArgs := []string{ commandArgs := []string{
`build`, `build`,
fmt.Sprintf(`-ldflags=-X gitlab.com/ship-logic/backends/backend/globals.BuildVersion=%v -X gitlab.com/ship-logic/backends/backend/globals.OSType=%v -X gitlab.com/ship-logic/backends/backend/globals.IsDebugBuild=%v`, CurrentCommit(), runtime.GOOS, isDebug), fmt.Sprintf(`-ldflags=-X %v/globals.BuildVersion=%v -X %v/globals.OSType=%v -X %v/globals.IsDebugBuild=%v`, module, CurrentCommit(), module, runtime.GOOS, module, isDebug),
} }
if isDebug { if isDebug {
... ...
......
...@@ -27,7 +27,7 @@ func CDKCompileTypeScript(cdkDir string) error { ...@@ -27,7 +27,7 @@ func CDKCompileTypeScript(cdkDir string) error {
return nil return nil
} }
func CDKDiff(cdkDir string, env string, stack string, local bool) error { func CDKDiff(cdkDir string, env string, stack string, local bool, profile string) error {
fmt.Println("Getting Diff for: " + stack) fmt.Println("Getting Diff for: " + stack)
commandArgs := []string{ commandArgs := []string{
...@@ -42,7 +42,7 @@ func CDKDiff(cdkDir string, env string, stack string, local bool) error { ...@@ -42,7 +42,7 @@ func CDKDiff(cdkDir string, env string, stack string, local bool) error {
} }
if local { if local {
commandArgs = append(commandArgs, fmt.Sprintf(`--profile=shiplogic-%v`, env)) commandArgs = append(commandArgs, fmt.Sprintf(`--profile=%v`, profile))
} }
commandArgs = append(commandArgs, commandArgs = append(commandArgs,
...@@ -63,7 +63,7 @@ func CDKDiff(cdkDir string, env string, stack string, local bool) error { ...@@ -63,7 +63,7 @@ func CDKDiff(cdkDir string, env string, stack string, local bool) error {
return nil return nil
} }
func CDKDeploy(cdkDir string, env string, stack string, exclusively bool, local bool) error { func CDKDeploy(cdkDir string, env string, stack string, exclusively bool, local bool, profile string) error {
commandArgs := []string{ commandArgs := []string{
`deploy`, `deploy`,
fmt.Sprintf(`"%s"`, stack), fmt.Sprintf(`"%s"`, stack),
...@@ -77,7 +77,7 @@ func CDKDeploy(cdkDir string, env string, stack string, exclusively bool, local ...@@ -77,7 +77,7 @@ func CDKDeploy(cdkDir string, env string, stack string, exclusively bool, local
} }
if local { if local {
commandArgs = append(commandArgs, fmt.Sprintf(`--profile=shiplogic-%v`, env)) commandArgs = append(commandArgs, fmt.Sprintf(`--profile=%v`, profile))
commandArgs = append(commandArgs, `--hotswap`) // make it go fast commandArgs = append(commandArgs, `--hotswap`) // make it go fast
} }
...@@ -103,7 +103,7 @@ func CDKDeploy(cdkDir string, env string, stack string, exclusively bool, local ...@@ -103,7 +103,7 @@ func CDKDeploy(cdkDir string, env string, stack string, exclusively bool, local
return nil return nil
} }
func CDKSynthAll(cdkDir string, env string, local bool) error { func CDKSynthAll(cdkDir string, env string, profile string, local bool) error {
commandArgs := []string{ commandArgs := []string{
`synth`, `synth`,
`"*"`, `"*"`,
...@@ -114,7 +114,7 @@ func CDKSynthAll(cdkDir string, env string, local bool) error { ...@@ -114,7 +114,7 @@ func CDKSynthAll(cdkDir string, env string, local bool) error {
} }
if local { if local {
commandArgs = append(commandArgs, fmt.Sprintf(`--profile=shiplogic-%v`, env)) commandArgs = append(commandArgs, fmt.Sprintf(`--profile=%v`, profile))
} }
commandArgs = append(commandArgs, commandArgs = append(commandArgs,
...@@ -135,7 +135,7 @@ func CDKSynthAll(cdkDir string, env string, local bool) error { ...@@ -135,7 +135,7 @@ func CDKSynthAll(cdkDir string, env string, local bool) error {
return nil return nil
} }
func CDKSynthDebug(cdkDir string, env string, handler string) error { func CDKSynthDebug(cdkDir string, env string, handler string, appName string, profile string) error {
// Check if sandbox environment is active and get the sandbox name from the config file // Check if sandbox environment is active and get the sandbox name from the config file
sandboxFilePath := "cdk/sandbox/config.dev.sandbox.yaml" sandboxFilePath := "cdk/sandbox/config.dev.sandbox.yaml"
sandboxName := "" sandboxName := ""
...@@ -157,9 +157,9 @@ func CDKSynthDebug(cdkDir string, env string, handler string) error { ...@@ -157,9 +157,9 @@ func CDKSynthDebug(cdkDir string, env string, handler string) error {
var stack string var stack string
if len(sandboxName) == 0 { if len(sandboxName) == 0 {
stack = fmt.Sprintf("shiplogic-backend-%v-core", env) stack = fmt.Sprintf("%v-%v-core", appName, env)
} else { } else {
stack = fmt.Sprintf("sl-%v-%v-core", env, sandboxName) stack = fmt.Sprintf("sandbox-%v-%v-core", env, sandboxName)
} }
commandArgs := []string{ commandArgs := []string{
...@@ -167,7 +167,7 @@ func CDKSynthDebug(cdkDir string, env string, handler string) error { ...@@ -167,7 +167,7 @@ func CDKSynthDebug(cdkDir string, env string, handler string) error {
stack, stack,
`-c`, `-c`,
fmt.Sprintf(`config=%v`, env), fmt.Sprintf(`config=%v`, env),
fmt.Sprintf("--profile=shiplogic-%v", env), fmt.Sprintf("--profile=%v", profile),
`--require-approval=never`, `--require-approval=never`,
`--exclusively=true`, `--exclusively=true`,
`--no-staging`, `--no-staging`,
... ...
......
...@@ -14,7 +14,7 @@ import ( ...@@ -14,7 +14,7 @@ import (
"github.com/docker/docker/client" "github.com/docker/docker/client"
) )
func SamStartApi(ctx context.Context, env string, handler string, debug bool) error { func SamStartApi(ctx context.Context, handler string, profile string, debug bool) error {
stopRunningSamDocker() stopRunningSamDocker()
usr, _ := user.Current() usr, _ := user.Current()
...@@ -35,7 +35,7 @@ func SamStartApi(ctx context.Context, env string, handler string, debug bool) er ...@@ -35,7 +35,7 @@ func SamStartApi(ctx context.Context, env string, handler string, debug bool) er
} }
commandArgs = append(commandArgs, commandArgs = append(commandArgs,
fmt.Sprintf(`--profile=shiplogic-%v`, env), fmt.Sprintf(`--profile=%v`, profile),
fmt.Sprintf(`--template=core/%v/template.yml`, handler), fmt.Sprintf(`--template=core/%v/template.yml`, handler),
`--region=af-south-1`) `--region=af-south-1`)
...@@ -47,7 +47,7 @@ func SamStartApi(ctx context.Context, env string, handler string, debug bool) er ...@@ -47,7 +47,7 @@ func SamStartApi(ctx context.Context, env string, handler string, debug bool) er
return nil return nil
} }
func SamInvokeSQS(ctx context.Context, env string, handler string, function string) error { func SamInvokeSQS(ctx context.Context, handler string, function string, profile string) error {
stopRunningSamDocker() stopRunningSamDocker()
usr, _ := user.Current() usr, _ := user.Current()
...@@ -63,7 +63,7 @@ func SamInvokeSQS(ctx context.Context, env string, handler string, function stri ...@@ -63,7 +63,7 @@ func SamInvokeSQS(ctx context.Context, env string, handler string, function stri
`--debug-port=5986`, `--debug-port=5986`,
fmt.Sprintf(`--debugger-path=%s`, delveDir), fmt.Sprintf(`--debugger-path=%s`, delveDir),
`--debug-args=-delveAPI=2`, `--debug-args=-delveAPI=2`,
fmt.Sprintf(`--profile=shiplogic-%v`, env), fmt.Sprintf(`--profile=%v`, profile),
fmt.Sprintf(`--template=core/%v/template.yml`, handler), fmt.Sprintf(`--template=core/%v/template.yml`, handler),
`--region=af-south-1`, `--region=af-south-1`,
} }
... ...
......
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
"github.com/aws/aws-sdk-go/service/s3" "github.com/aws/aws-sdk-go/service/s3"
) )
func UploadToS3(env string, bucket string, filePath string, name string, local bool) error { func UploadToS3(profile string, bucket string, filePath string, name string, local bool) error {
fmt.Println(fmt.Sprintf("Uploading %s to %s", filePath, bucket)) fmt.Println(fmt.Sprintf("Uploading %s to %s", filePath, bucket))
options := session.Options{ options := session.Options{
...@@ -21,7 +21,7 @@ func UploadToS3(env string, bucket string, filePath string, name string, local b ...@@ -21,7 +21,7 @@ func UploadToS3(env string, bucket string, filePath string, name string, local b
} }
if local { if local {
options.Profile = fmt.Sprintf("shiplogic-%s", env) options.Profile = profile
} }
sess, err := session.NewSessionWithOptions(options) sess, err := session.NewSessionWithOptions(options)
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment