Skip to content

Commit

Permalink
Minor improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-rieke committed Jul 1, 2024
1 parent acc3c0b commit 9a1d383
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
12 changes: 6 additions & 6 deletions atrium/vestibulum/trcdb/trcplgtoolbase/trcplgtoolbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
trcapimgmtbase "github.com/trimble-oss/tierceron/atrium/vestibulum/trcdb/trcapimgmtbase"
)

func CommonMain(envPtr *string,
func CommonMain(envDefaultPtr *string,
addrPtr *string,
tokenPtr *string,
envCtxPtr *string,
Expand Down Expand Up @@ -260,7 +260,7 @@ func CommonMain(envPtr *string,

//
if tokenNamePtr == nil || *tokenNamePtr == "" || tokenPtr == nil || *tokenPtr == "" {
autoErr := eUtils.AutoAuth(&trcshDriverConfigBase.DriverConfig, secretIDPtr, appRoleIDPtr, tokenPtr, tokenNamePtr, envPtr, addrPtr, envCtxPtr, *appRoleConfigPtr, false)
autoErr := eUtils.AutoAuth(&trcshDriverConfigBase.DriverConfig, secretIDPtr, appRoleIDPtr, tokenPtr, tokenNamePtr, envDefaultPtr, addrPtr, envCtxPtr, *appRoleConfigPtr, false)
if autoErr != nil {
eUtils.LogErrorMessage(&trcshDriverConfigBase.DriverConfig.CoreConfig, "Auth failure: "+autoErr.Error(), false)
return errors.New("auth failure")
Expand All @@ -278,7 +278,7 @@ func CommonMain(envPtr *string,
fmt.Println("Error: Could not find plugin config")
return errors.New("could not find plugin config")
}
pluginConfig["env"] = *envPtr
pluginConfig["env"] = *envDefaultPtr
pluginConfig["vaddress"] = *addrPtr
if tokenPtr != nil {
pluginConfig["token"] = *tokenPtr
Expand Down Expand Up @@ -309,12 +309,12 @@ func CommonMain(envPtr *string,
} else {
trcshDriverConfigBase.DriverConfig.SubSectionValue = *pluginNamePtr
}
mod.Env = *envPtr
mod.Env = *envDefaultPtr
if logger != nil {
logger.Printf("Certify mod initialized\n")
}

if strings.HasPrefix(*envPtr, "staging") || strings.HasPrefix(*envPtr, "prod") || strings.HasPrefix(*envPtr, "dev") {
if strings.HasPrefix(*envDefaultPtr, "staging") || strings.HasPrefix(*envDefaultPtr, "prod") || strings.HasPrefix(*envDefaultPtr, "dev") {
supportedRegions := eUtils.GetSupportedProdRegions()
if *regionPtr != "" {
for _, supportedRegion := range supportedRegions {
Expand All @@ -332,7 +332,7 @@ func CommonMain(envPtr *string,
}

if *updateAPIMPtr {
updateAPIMError := trcapimgmtbase.CommonMain(envPtr, addrPtr, tokenPtr, nil, secretIDPtr, appRoleIDPtr, tokenNamePtr, regionPtr, startDirPtr, config, mod)
updateAPIMError := trcapimgmtbase.CommonMain(envDefaultPtr, addrPtr, tokenPtr, nil, secretIDPtr, appRoleIDPtr, tokenNamePtr, regionPtr, startDirPtr, config, mod)
if updateAPIMError != nil {
fmt.Println(updateAPIMError.Error())
fmt.Println("Couldn't update APIM...proceeding with build")
Expand Down
10 changes: 5 additions & 5 deletions atrium/vestibulum/trcshbase/trcsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,24 +515,24 @@ func roleBasedRunner(
configRoleSlice := strings.Split(*gTrcshConfig.ConfigRole, ":")
tokenName := "config_token_" + trcshDriverConfig.DriverConfig.EnvBasis
tokenConfig := ""
configEnv := trcshDriverConfig.DriverConfig.EnvBasis
envDefaultPtr := trcshDriverConfig.DriverConfig.EnvBasis
var err error
trcshDriverConfig.DriverConfig.CoreConfig.Log.Printf("Role runner complete: %s\n", control)

switch control {
case "trcplgtool":
tokenConfig := token
configEnv = trcshDriverConfig.DriverConfig.Env
err = trcplgtoolbase.CommonMain(&configEnv, &trcshDriverConfig.DriverConfig.VaultAddress, &tokenConfig, &gTrcshConfig.EnvContext, &configRoleSlice[1], &configRoleSlice[0], &tokenName, &region, nil, deployArgLines, trcshDriverConfig)
envDefaultPtr = trcshDriverConfig.DriverConfig.Env
err = trcplgtoolbase.CommonMain(&envDefaultPtr, &trcshDriverConfig.DriverConfig.VaultAddress, &tokenConfig, &gTrcshConfig.EnvContext, &configRoleSlice[1], &configRoleSlice[0], &tokenName, &region, nil, deployArgLines, trcshDriverConfig)
case "trcconfig":
if trcshDriverConfig.DriverConfig.EnvBasis == "itdev" || trcshDriverConfig.DriverConfig.EnvBasis == "staging" || trcshDriverConfig.DriverConfig.EnvBasis == "prod" ||
trcshDriverConfig.DriverConfig.Env == "itdev" || trcshDriverConfig.DriverConfig.Env == "staging" || trcshDriverConfig.DriverConfig.Env == "prod" {
trcshDriverConfig.DriverConfig.OutputMemCache = false
}
err = trcconfigbase.CommonMain(&configEnv, &trcshDriverConfig.DriverConfig.VaultAddress, &tokenConfig, &gTrcshConfig.EnvContext, &configRoleSlice[1], &configRoleSlice[0], &tokenName, &region, nil, deployArgLines, &trcshDriverConfig.DriverConfig)
err = trcconfigbase.CommonMain(&envDefaultPtr, &trcshDriverConfig.DriverConfig.VaultAddress, &tokenConfig, &gTrcshConfig.EnvContext, &configRoleSlice[1], &configRoleSlice[0], &tokenName, &region, nil, deployArgLines, &trcshDriverConfig.DriverConfig)
case "trcsub":
trcshDriverConfig.DriverConfig.EndDir = trcshDriverConfig.DriverConfig.EndDir + "/trc_templates"
err = trcsubbase.CommonMain(&configEnv, &trcshDriverConfig.DriverConfig.VaultAddress, &gTrcshConfig.EnvContext, &configRoleSlice[1], &configRoleSlice[0], nil, deployArgLines, &trcshDriverConfig.DriverConfig)
err = trcsubbase.CommonMain(&envDefaultPtr, &trcshDriverConfig.DriverConfig.VaultAddress, &gTrcshConfig.EnvContext, &configRoleSlice[1], &configRoleSlice[0], nil, deployArgLines, &trcshDriverConfig.DriverConfig)
}
ResetModifier(&trcshDriverConfig.DriverConfig) //Resetting modifier cache to avoid token conflicts.

Expand Down
4 changes: 2 additions & 2 deletions cmd/trcctl/trcctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ func main() {
case "init":
trcinitbase.CommonMain(envPtr, &addrPtr, &envContext, flagset, os.Args)
case "config":
trcconfigbase.CommonMain(envPtr, &addrPtr, tokenPtr, &envContext, secretIDPtr, appRoleIDPtr, tokenNamePtr, nil, nil, os.Args, nil)
trcconfigbase.CommonMain(envPtr, &addrPtr, tokenPtr, &envContext, secretIDPtr, appRoleIDPtr, tokenNamePtr, nil, flagset, os.Args, nil)
case "x":
trcxbase.CommonMain(nil, xutil.GenerateSeedsFromVault, envPtr, &addrPtr, &envContext, nil, nil, os.Args)
trcxbase.CommonMain(nil, xutil.GenerateSeedsFromVault, envPtr, &addrPtr, &envContext, nil, flagset, os.Args)
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/utils/versionUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ func GetProjectService(driverConfig *DriverConfig, templateFile string) (string,
startDir = driverConfig.StartDir
}

trcTemplateParam := coreopts.BuildOptions.GetFolderPrefix(startDir) + "_templates"

for i, component := range splitDir {
if component == coreopts.BuildOptions.GetFolderPrefix(startDir)+"_templates" {
if component == trcTemplateParam {
offsetBase = i
break
}
Expand All @@ -190,8 +192,8 @@ func GetProjectService(driverConfig *DriverConfig, templateFile string) (string,
serviceIndex = 0
}
} else {
service = splitDir[offsetBase+2]
serviceIndex = offsetBase + 2
service = splitDir[serviceIndex]

// Clean up service naming (Everything after '.' removed)
if !strings.Contains(templateFile, "Common") {
Expand Down

0 comments on commit 9a1d383

Please sign in to comment.