utils

package
v1.10.10 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: MIT Imports: 26 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func AutoAuth

func AutoAuth(driverConfig *DriverConfig,
	secretIDPtr *string,
	appRoleIDPtr *string,
	tokenPtr *string,
	tokenNamePtr *string,
	envPtr *string,
	addrPtr *string,
	envCtxPtr *string,
	appRoleConfig string,
	ping bool) error

AutoAuth attempts to authenticate a user.

func BoundCheck

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

func CheckError

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

CheckError Simplifies the error checking process

func CheckErrorNoStack

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

CheckErrorNoStack Simplifies the error checking process

func CheckInitFlags

func CheckInitFlags(flagset *flag.FlagSet)

func CheckWarning

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

CheckWarnings Checks warnings returned from various vault relation operations

func CheckWarnings

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

CheckWarnings Checks warnings returned from various vault relation operations

func ConfigControl

func ConfigControl(ctx ProcessContext, configCtx *ConfigContext, driverConfig *DriverConfig, drive ConfigDriver)

ConfigControl Setup initializes the directory structures in preparation for parsing templates.

func DiffHelper

func DiffHelper(configCtx *ConfigContext, config bool)

func GetAcceptedTemplatePaths

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

func GetProjectService

func GetProjectService(templateFile string) (string, string, string)

func GetProjectServices

func GetProjectServices(templateFiles []string) ([]string, []string, []string)

func GetProjectVersionInfo

func GetProjectVersionInfo(driverConfig *DriverConfig, mod *helperkv.Modifier) map[string]map[string]interface{}

func GetProjectVersions

func GetProjectVersions(driverConfig *DriverConfig, versionMetadataMap map[string]map[string]interface{}) []int

func GetRawEnv

func GetRawEnv(env string) string

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 InitHeadless

func InitHeadless(headless bool)

func IsWindows

func IsWindows() bool

func LineByLineDiff

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

func LogAndSafeExit

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

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

func LogError

func LogError(config *core.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 *core.CoreConfig, err error, code int) error

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

func LogErrorMessage

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

LogErrorObject writes errors to the passed logger object and exits

func LogErrorObject

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

LogErrorObject writes errors to the passed logger object and exits

func LogInfo

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

LogErrorObject writes errors to the passed logger object and exits

func LogMessageErrorObject

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

LogErrorObject writes errors to the passed logger object and exits

func LogWarningMessage

func LogWarningMessage(config *core.CoreConfig, errorMessage string, exit bool)

LogErrorObject writes errors to the passed logger object and exits

func LogWarnings

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

LogWarnings Writes array of warnings to the log file and terminates

func LogWarningsObject

func LogWarningsObject(config *core.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]interface{}, 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 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 VersionHelper

func VersionHelper(versionData map[string]interface{}, templateOrValues bool, valuePath string, first bool)

Types

type ConfigContext

type ConfigContext struct {
	ResultMap            map[string]*string
	EnvSlice             []string
	ProjectSectionsSlice []string
	ResultChannel        chan *ResultData
	FileSysIndex         int
	DiffFileCount        int32
	EnvLength            int
	ConfigWg             sync.WaitGroup
	Mutex                *sync.Mutex
}

func (*ConfigContext) GetDiffFileCount

func (cfgContext *ConfigContext) GetDiffFileCount() int32

func (*ConfigContext) SetDiffFileCount

func (cfgContext *ConfigContext) SetDiffFileCount(cnt int)

type ConfigDriver

type ConfigDriver func(ctx ProcessContext, configCtx *ConfigContext, driverConfig *DriverConfig) (interface{}, error)

type DriverConfig

type DriverConfig struct {
	CoreConfig core.CoreConfig

	// Process context used by new tool implementations in callbacks.
	// Tools can attach their own context here for later access in
	// certain callbacks.
	Context ProcessContext

	// Internal systems...
	Insecure          bool
	IsShellSubProcess bool // If subshell

	// Vault Configurations...
	Token         string
	VaultAddress  string
	EnvRaw        string // May change depending on tool running...
	Env           string // Immutable...
	Regions       []string
	FileFilter    []string // Which systems to operate on.
	SubPathFilter []string // Which subpaths to operate on.
	PathParam     string   // Path parameter for dynamic pathing...

	SecretMode bool
	// Tierceron source and destination I/O
	StartDir       []string // Starting directory. possibly multiple
	EndDir         string
	OutputMemCache bool
	MemFs          MemoryFileSystem

	// Config modes....
	ZeroConfig  bool
	GenAuth     bool
	TrcShellRaw string   //Used for TrcShell
	Trcxe       []string //Used for TRCXE
	Trcxr       bool     //Used for TRCXR

	Clean  bool
	Update func(*ConfigContext, *string, string)

	// KeyStore Output tooling
	KeyStore         *keystore.KeyStore
	KeystorePassword string
	WantKeystore     string // If provided and non nil, pem files will be put into a java compatible keystore.

	// Diff tooling
	Diff          bool
	DiffCounter   int
	VersionInfo   func(map[string]interface{}, bool, string, bool)
	VersionFilter []string

	// Vault Pathing....
	// This section stores information useful in directing I/O with Vault.
	AppRoleConfig   string
	ServicesWanted  []string
	ProjectSections []string
	SectionKey      string // Restricted or Index
	SectionName     string // extension provided name
	SubSectionName  string // extension provided subsection name
	SubSectionValue string
	ServiceFilter   []string // Which tables to use.

	DeploymentConfig         map[string]interface{} // For trcsh to indicate which deployment to work on
	DeploymentCtlMessageChan chan string
}

DriverConfig -- contains many structures necessary for Tierceron tool functionality.

func InitVaultMod

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

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

func InitVaultModForPlugin

func InitVaultModForPlugin(pluginConfig map[string]interface{}, logger *log.Logger) (*DriverConfig, *helperkv.Modifier, *sys.Vault, error)

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

type MemoryFileSystem added in v1.9.10

type MemoryFileSystem interface {
	WriteToMemFile(driverConfig *DriverConfig, memCacheLocal *sync.Mutex, byteData *[]byte, path string)
}

type ProcessContext

type ProcessContext interface{}

type ResultData

type ResultData struct {
	Done   bool
	InData *string
	InPath string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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