Skip to content

Commit

Permalink
Enable command processing for dronePtr as well. (#1126)
Browse files Browse the repository at this point in the history
* Enable command processing for dronePtr as well.
* Remove potential versioning in env
  • Loading branch information
joel-rieke authored Jun 28, 2024
1 parent 18e7951 commit 288257e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
31 changes: 20 additions & 11 deletions atrium/vestibulum/trcshbase/trcsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func deployerInterrupted(featherCtx *cap.FeatherContext) error {
}

// EnableDeploy - initializes and starts running deployer for provided deployment and environment.
func EnableDeployer(env string, region string, token string, trcPath string, secretId *string, approleId *string, outputMemCache bool, deployment string) {
func EnableDeployer(env string, region string, token string, trcPath string, secretId *string, approleId *string, outputMemCache bool, deployment string, dronePtr *bool) {
trcshDriverConfig, err := TrcshInitConfig(env, region, "", outputMemCache)
if err != nil {
fmt.Printf("Initialization setup error: %s\n", err.Error())
Expand Down Expand Up @@ -206,7 +206,7 @@ func EnableDeployer(env string, region string, token string, trcPath string, sec

go captiplib.FeatherCtlEmitter(trcshDriverConfig.FeatherCtx, trcshDriverConfig.DriverConfig.DeploymentCtlMessageChan, deployerEmote, nil)

go ProcessDeploy(trcshDriverConfig.FeatherCtx, trcshDriverConfig, "", deployment, trcPath, "", secretId, approleId, false)
go ProcessDeploy(trcshDriverConfig.FeatherCtx, trcshDriverConfig, "", deployment, trcPath, "", secretId, approleId, false, dronePtr)
}

// This is a controller program that can act as any command line utility.
Expand Down Expand Up @@ -262,7 +262,7 @@ func CommonMain(envPtr *string, addrPtr *string, envCtxPtr *string,
signal.Notify(ic, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP, syscall.SIGABRT)
} else {
dronePtr = new(bool)
*dronePtr = false
*dronePtr = true

signal.Notify(ic, os.Interrupt)
}
Expand All @@ -273,7 +273,7 @@ func CommonMain(envPtr *string, addrPtr *string, envCtxPtr *string,

flagset.Parse(argLines[1:])

if !eUtils.IsWindows() && !*dronePtr {
if !*dronePtr {
if len(*appRoleIDPtr) == 0 {
*appRoleIDPtr = os.Getenv("DEPLOY_ROLE")
}
Expand All @@ -294,7 +294,7 @@ func CommonMain(envPtr *string, addrPtr *string, envCtxPtr *string,
}

//Open deploy script and parse it.
ProcessDeploy(nil, config, "", "", *trcPathPtr, *projectServicePtr, secretIDPtr, appRoleIDPtr, true)
ProcessDeploy(nil, config, "", "", *trcPathPtr, *projectServicePtr, secretIDPtr, appRoleIDPtr, true, dronePtr)
} else {
agentToken := os.Getenv("AGENT_TOKEN")
agentEnv := os.Getenv("AGENT_ENV")
Expand Down Expand Up @@ -387,7 +387,7 @@ func CommonMain(envPtr *string, addrPtr *string, envCtxPtr *string,
deployopts.BuildOptions.InitSupportedDeployers(deployments)

for _, deployment := range deployments {
EnableDeployer(*gAgentConfig.Env, *regionPtr, deployment, *trcPathPtr, secretIDPtr, appRoleIDPtr, false, deployment)
EnableDeployer(*gAgentConfig.Env, *regionPtr, deployment, *trcPathPtr, secretIDPtr, appRoleIDPtr, false, deployment, dronePtr)
}

<-shutdown
Expand Down Expand Up @@ -691,7 +691,7 @@ func processPluginCmds(trcKubeDeploymentConfig **kube.TrcKubeConfig,
}
}

func processWindowsCmds(trcKubeDeploymentConfig *kube.TrcKubeConfig,
func processDroneCmds(trcKubeDeploymentConfig *kube.TrcKubeConfig,
onceKubeInit *sync.Once,
PipeOS billy.File,
env string,
Expand Down Expand Up @@ -723,7 +723,16 @@ func processWindowsCmds(trcKubeDeploymentConfig *kube.TrcKubeConfig,
// Returns:
//
// Nothing.
func ProcessDeploy(featherCtx *cap.FeatherContext, trcshDriverConfig *capauth.TrcshDriverConfig, token string, deployment string, trcPath string, projectServicePtr string, secretId *string, approleId *string, outputMemCache bool) {
func ProcessDeploy(featherCtx *cap.FeatherContext,
trcshDriverConfig *capauth.TrcshDriverConfig,
token string,
deployment string,
trcPath string,
projectServicePtr string,
secretId *string,
approleId *string,
outputMemCache bool,
dronePtr *bool) {

// Verify Billy implementation
configMemFs := trcshDriverConfig.DriverConfig.MemFs.(*trcshMemFs.TrcshMemFs)
Expand Down Expand Up @@ -1028,14 +1037,14 @@ collaboratorReRun:
os.Args = deployArgs
}
}
if eUtils.IsWindows() {
if *dronePtr {
// Log for traceability.
trcshDriverConfig.DriverConfig.CoreConfig.Log.Println(deployLine)
region := ""
if len(trcshDriverConfig.DriverConfig.Regions) > 0 {
region = trcshDriverConfig.DriverConfig.Regions[0]
}
err := processWindowsCmds(
err := processDroneCmds(
trcKubeDeploymentConfig,
&onceKubeInit,
PipeOS,
Expand Down Expand Up @@ -1091,7 +1100,7 @@ collaboratorReRun:
}
}
}
if eUtils.IsWindows() {
if *dronePtr {
for {
completeOnce := false
if atomic.LoadInt64(&featherCtx.RunState) == cap.RUNNING {
Expand Down
1 change: 1 addition & 0 deletions buildopts/deployopts/deploy_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func GetDecodedDeployerId(deployerCode string) (string, bool) {
// Override if you wish to provide a different encoding.
func GetEncodedDeployerId(deployer string, env string) (string, bool) {
if code, ok := succinctly.QCode(deployer); ok {
env = strings.Split(env, "_")[0]
return fmt.Sprintf("%s.%s", code, env), true
} else {
return "", false
Expand Down

0 comments on commit 288257e

Please sign in to comment.