utils

package
v1.54.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 35 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SubPathFilter        *string
	ServiceNameFilterPtr *string
	ServiceFilterPtr     *string
	IndexNameFilterPtr   *string
	IndexValueFilterPtr  *string
	IndexedPtr           *string
	RestrictedPtr        *string
	ProtectedPtr         *string
	BasePtr              *bool
	OnlyBasePtr          = false
)
View Source
var (
	EMPTY_STRING string = ""
)

Functions

func AutoAuth

func AutoAuth(driverConfig *config.DriverConfig,
	wantedTokenNamePtr *string,
	tokenProvidedPtr **string,
	envPtr *string,
	envCtxPtr *string,
	roleEntityPtr *string,
	ping bool,
) error

AutoAuth attempts to authenticate a user.

func BoundCheck

func BoundCheck(driverConfig *config.DriverConfig, versionNumbers []int, version string)

func CheckError

func CheckError(config *coreconfig.CoreConfig, err error, exit bool)

CheckError Simplifies the error checking process

func CheckErrorNoStack

func CheckErrorNoStack(config *coreconfig.CoreConfig, err error, exit bool)

CheckErrorNoStack Simplifies the error checking process

func CheckInitFlags

func CheckInitFlags(flagset *flag.FlagSet, arguments []string) error

func CheckWarning

func CheckWarning(config *coreconfig.CoreConfig, warning string, exit bool)

CheckWarning Checks warnings returned from various vault relation operations

func CheckWarnings

func CheckWarnings(config *coreconfig.CoreConfig, warnings []string, exit bool)

CheckWarnings Checks warnings returned from various vault relation operations

func DiffHelper

func DiffHelper(configCtx *config.ConfigContext, config bool)

func EmptyStringRef added in v1.21.0

func EmptyStringRef() *string

func FilterSupportedRegions added in v1.43.1

func FilterSupportedRegions(driverConfig *config.DriverConfig, regions []string) []string

func GetAcceptedTemplatePaths

func GetAcceptedTemplatePaths(driverConfig *config.DriverConfig, modCheck *helperkv.Modifier, templatePaths []string) ([]string, error)

func GetEnvBasis added in v1.11.9

func GetEnvBasis(env string) string

func GetProjectService

func GetProjectService(driverConfig *config.DriverConfig, templateFile string) (string, string, int, string)

GetProjectService - returns project, service, and path to template on filesystem. driverConfig - driver configuration templateFile - full path to template file returns project, service, templatePath

func GetProjectServices

func GetProjectServices(driverConfig *config.DriverConfig, templateFiles []string) ([]string, []string, []string)

func GetProjectVersionInfo

func GetProjectVersionInfo(driverConfig *config.DriverConfig, mod *helperkv.Modifier) map[string]map[string]any

func GetProjectVersions

func GetProjectVersions(driverConfig *config.DriverConfig, versionMetadataMap map[string]map[string]any) []int

func GetReadAccess added in v1.52.2

func GetReadAccess(driverConfig *config.DriverConfig) error

GetReadAccess performs OAuth authentication for read-only access This is the default mode for trcsh and is typically called automatically at startup Example usage in trcsh: utils.GetReadAccess(driverConfig)

func GetSetEnvContext added in v1.28.9

func GetSetEnvContext(env string, envContext string) (string, string, error)

func GetStringInBetween

func GetStringInBetween(str string, start string, end string) (result string)

func GetSupportedProdRegions

func GetSupportedProdRegions() []string

func GetTemplateFileName

func GetTemplateFileName(templateFile string, service string) string

func GetUnrestrictedAccess added in v1.52.2

func GetUnrestrictedAccess(driverConfig *config.DriverConfig) error

GetUnrestrictedAccess performs OAuth authentication for unrestricted write access This can be called from trcsh at any time to obtain write-access credentials Example usage in trcsh: utils.GetUnrestrictedAccess(driverConfig)

func IToString added in v1.28.2

func IToString(src any) string

func InitDriverConfigForPlugin added in v1.38.6

func InitDriverConfigForPlugin(pluginConfig map[string]any, tokenCache *cache.TokenCache, currentTokenName string, logger *log.Logger) (*config.DriverConfig, error)

func InitHeadless

func InitHeadless(headless bool)

func InitPluginLogs added in v1.23.1

func InitPluginLogs(pluginConfig map[string]any, logger *log.Logger) *log.Logger

func InitVaultMod

func InitVaultMod(driverConfig *config.DriverConfig) (*config.DriverConfig, *helperkv.Modifier, *sys.Vault, error)

InitVaultMod helps to easily initialize a vault and a modifier all at once.

func InitVaultModForPlugin

func InitVaultModForPlugin(pluginConfig map[string]any, tokenCache *cache.TokenCache, currentTokenName string, logger *log.Logger) (*config.DriverConfig, *helperkv.Modifier, *sys.Vault, error)

InitVaultModForPlugin Helper to easiliy intialize a vault and a mod all at once.

func InitVaultModForTool added in v1.23.1

func InitVaultModForTool(pluginConfig map[string]any, driverConfig *config.DriverConfig) (*config.DriverConfig, *helperkv.Modifier, *sys.Vault, error)

InitVaultModForTool Helper to easiliy intialize a vault and a mod all at once.

func IsRegionSupported added in v1.43.1

func IsRegionSupported(driverConfig *config.DriverConfig, region string) bool

func IsWindows

func IsWindows() bool

func KernelZOAuthForRole added in v1.52.2

func KernelZOAuthForRole(driverConfig *config.DriverConfig, roleName string, forceLoginPrompt bool, alwaysReauth bool) error

KernelZOAuthForRole performs OAuth authentication for a specific role at runtime This can be called at any point to get credentials for a different role (e.g., unrestricted write access) forceLoginPrompt: if true, adds prompt=login to force authentication even if browser has session alwaysReauth: if true, skips cache and always performs fresh authentication (used for initial shell startup)

func LineByLineDiff

func LineByLineDiff(stringA *string, stringB *string, patchData bool, colorSkip bool) string

func LogAndSafeExit

func LogAndSafeExit(config *coreconfig.CoreConfig, message string, code int) error

LogAndSafeExit -- provides isolated location of os.Exit to ensure os.Exit properly processed.

func LogError

func LogError(config *coreconfig.CoreConfig, err error, f *os.File, exit bool)

LogError Writes error to the log file and terminates if an error occurs

func LogErrorAndSafeExit

func LogErrorAndSafeExit(config *coreconfig.CoreConfig, err error, code int) error

LogErrorAndSafeExit -- provides isolated location of os.Exit to ensure os.Exit properly processed.

func LogErrorMessage

func LogErrorMessage(config *coreconfig.CoreConfig, errorMessage string, exit bool)

LogErrorMessage writes errors to the passed logger object and exits

func LogErrorObject

func LogErrorObject(config *coreconfig.CoreConfig, err error, exit bool)

LogErrorObject writes errors to the passed logger object and exits

func LogInfo

func LogInfo(config *coreconfig.CoreConfig, msg string)

LogInfo writes informational messages to the passed logger object

func LogMessageErrorObject

func LogMessageErrorObject(config *coreconfig.CoreConfig, errorMessage string, err error, exit bool)

LogMessageErrorObject writes errors to the passed logger object and exits

func LogSyncAndExit added in v1.48.4

func LogSyncAndExit(logger *log.Logger, message string, exitCode int)

LogSyncAndExit synchronizes logger output and exits with the specified exit code

func LogWarningMessage

func LogWarningMessage(config *coreconfig.CoreConfig, warningMessage string, exit bool)

LogWarningMessage writes warnings to the passed logger object and exits

func LogWarnings

func LogWarnings(config *coreconfig.CoreConfig, warnings []string, f *os.File, exit bool)

LogWarnings Writes array of warnings to the log file and terminates

func LogWarningsObject

func LogWarningsObject(config *coreconfig.CoreConfig, warnings []string, exit bool)

LogWarningsObject writes warnings to the passed logger object and exits

func LoginToLocal

func LoginToLocal() (string, error)

LoginToLocal prompts the user to enter credentials from the terminal and resolves granular local environment

func Parse

func Parse(filepath string, service string, filename string) (map[string]any, error)

Parse Extracts default values as key-value pairs from template files. Before being uploaded, the service and filename will be appended so the uploaded value will be <Service>.<Filename>.<Key> Underscores in key names will be replaced with periods before being uploaded

func ReadAuthParts added in v1.38.0

func ReadAuthParts(driverConfig *config.DriverConfig,
	readAuthParts bool,
) (bool, string, error)

func RefContains added in v1.41.3

func RefContains(src *string, contains string) bool

func RefEquals added in v1.21.0

func RefEquals(src *string, dest string) bool

func RefEqualsAny added in v1.21.0

func RefEqualsAny(src *string, dest []string) bool

func RefLength added in v1.21.0

func RefLength(src *string) int

func RefMap added in v1.21.0

func RefMap(m map[string]any, key string) *string

func RefRefEquals added in v1.31.6

func RefRefEquals(src *string, dest *string) bool

func RefRefHasPrefix added in v1.41.3

func RefRefHasPrefix(src *string, prefix *string) bool

func RefSliceLength added in v1.38.0

func RefSliceLength(src *[]string) int

func RefString added in v1.21.0

func RefString(src *string) *string

func RemoveDuplicateValues

func RemoveDuplicateValues(intSlice []string) []string

func RemoveDuplicates

func RemoveDuplicates(versionFilter []string) []string

func SanitizeForLogging

func SanitizeForLogging(errMsg string) string

func SplitEnv

func SplitEnv(env string) []string

func TrimLastDotAfterLastSlash added in v1.35.12

func TrimLastDotAfterLastSlash(s string) (string, int)

func VersionHelper

func VersionHelper(versionData map[string]any, templateOrValues bool, valuePath string, first bool)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL