diff --git a/_magefile/build.go b/_magefile/build.go index 0eb335d53336892b38eed02dc05235121de74827..4aaaa2e50ad9e9adf3feb96996391208ba0771a9 100644 --- a/_magefile/build.go +++ b/_magefile/build.go @@ -33,7 +33,7 @@ func Clean(path string) error { return nil } -func Build(dir string, isDebug bool) error { +func Build(dir string, module string, isDebug bool) error { currentDir, _ := os.Getwd() fullPath := currentDir + "/core/" + dir @@ -46,8 +46,8 @@ func Build(dir string, isDebug bool) error { outputDir := fmt.Sprintf(currentDir+`/core/build/handlers/%v`, handler) outputFile := fmt.Sprintf(`%v/%v`, outputDir, handler) - appPath := fmt.Sprintf(`gitlab.com/ship-logic/backends/backend/core/%v`, handler) - err := BuildGolangApp(outputFile, appPath, isDebug) + appPath := fmt.Sprintf(`%v/core/%v`, module, handler) + err := BuildGolangApp(outputFile, appPath, module, isDebug) if err != nil { return err } @@ -75,10 +75,10 @@ func Build(dir string, isDebug bool) error { return nil } -func BuildGolangApp(outputDir string, appPath string, isDebug bool) error { +func BuildGolangApp(outputDir string, appPath string, module string, isDebug bool) error { commandArgs := []string{ `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 { diff --git a/_magefile/cdk.go b/_magefile/cdk.go index 3ce59b8c974393923bab1adbc4c33527a6f98f94..7219fe8175d37e790c51e6be74f0bd9c8d8b22fa 100644 --- a/_magefile/cdk.go +++ b/_magefile/cdk.go @@ -27,7 +27,7 @@ func CDKCompileTypeScript(cdkDir string) error { 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) commandArgs := []string{ @@ -42,7 +42,7 @@ func CDKDiff(cdkDir string, env string, stack string, local bool) error { } if local { - commandArgs = append(commandArgs, fmt.Sprintf(`--profile=shiplogic-%v`, env)) + commandArgs = append(commandArgs, fmt.Sprintf(`--profile=%v`, profile)) } commandArgs = append(commandArgs, @@ -63,7 +63,7 @@ func CDKDiff(cdkDir string, env string, stack string, local bool) error { 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{ `deploy`, fmt.Sprintf(`"%s"`, stack), @@ -77,7 +77,7 @@ func CDKDeploy(cdkDir string, env string, stack string, exclusively bool, 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 } @@ -103,7 +103,7 @@ func CDKDeploy(cdkDir string, env string, stack string, exclusively bool, local return nil } -func CDKSynthAll(cdkDir string, env string, local bool) error { +func CDKSynthAll(cdkDir string, env string, profile string, local bool) error { commandArgs := []string{ `synth`, `"*"`, @@ -114,7 +114,7 @@ func CDKSynthAll(cdkDir string, env string, local bool) error { } if local { - commandArgs = append(commandArgs, fmt.Sprintf(`--profile=shiplogic-%v`, env)) + commandArgs = append(commandArgs, fmt.Sprintf(`--profile=%v`, profile)) } commandArgs = append(commandArgs, @@ -135,7 +135,7 @@ func CDKSynthAll(cdkDir string, env string, local bool) error { 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 sandboxFilePath := "cdk/sandbox/config.dev.sandbox.yaml" sandboxName := "" @@ -157,9 +157,9 @@ func CDKSynthDebug(cdkDir string, env string, handler string) error { var stack string if len(sandboxName) == 0 { - stack = fmt.Sprintf("shiplogic-backend-%v-core", env) + stack = fmt.Sprintf("%v-%v-core", appName, env) } else { - stack = fmt.Sprintf("sl-%v-%v-core", env, sandboxName) + stack = fmt.Sprintf("sandbox-%v-%v-core", env, sandboxName) } commandArgs := []string{ @@ -167,7 +167,7 @@ func CDKSynthDebug(cdkDir string, env string, handler string) error { stack, `-c`, fmt.Sprintf(`config=%v`, env), - fmt.Sprintf("--profile=shiplogic-%v", env), + fmt.Sprintf("--profile=%v", profile), `--require-approval=never`, `--exclusively=true`, `--no-staging`, diff --git a/_magefile/debug.go b/_magefile/debug.go index 7ba21068a63353c8175e7e48632e009888e900d6..22aff8c4898e468b04fdffe74436c3c0b079fc0d 100644 --- a/_magefile/debug.go +++ b/_magefile/debug.go @@ -14,7 +14,7 @@ import ( "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() usr, _ := user.Current() @@ -35,7 +35,7 @@ func SamStartApi(ctx context.Context, env string, handler string, debug bool) er } commandArgs = append(commandArgs, - fmt.Sprintf(`--profile=shiplogic-%v`, env), + fmt.Sprintf(`--profile=%v`, profile), fmt.Sprintf(`--template=core/%v/template.yml`, handler), `--region=af-south-1`) @@ -47,7 +47,7 @@ func SamStartApi(ctx context.Context, env string, handler string, debug bool) er 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() usr, _ := user.Current() @@ -63,7 +63,7 @@ func SamInvokeSQS(ctx context.Context, env string, handler string, function stri `--debug-port=5986`, fmt.Sprintf(`--debugger-path=%s`, delveDir), `--debug-args=-delveAPI=2`, - fmt.Sprintf(`--profile=shiplogic-%v`, env), + fmt.Sprintf(`--profile=%v`, profile), fmt.Sprintf(`--template=core/%v/template.yml`, handler), `--region=af-south-1`, } diff --git a/_magefile/s3.go b/_magefile/s3.go index e7e4aaf479058d308e536f11e276e35f93d8d9e3..e4e84493679545dac3f9ab6a21e0fb96b68e5c36 100644 --- a/_magefile/s3.go +++ b/_magefile/s3.go @@ -11,7 +11,7 @@ import ( "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)) options := session.Options{ @@ -21,7 +21,7 @@ func UploadToS3(env string, bucket string, filePath string, name string, local b } if local { - options.Profile = fmt.Sprintf("shiplogic-%s", env) + options.Profile = profile } sess, err := session.NewSessionWithOptions(options)