Documentation
¶
Overview ¶
Package common is to include common methods for managing multi-cloud infra
Package common is to include common methods for managing multi-cloud infra ¶
Package common is to include common methods for managing multi-cloud infra
Index ¶
- Constants
- Variables
- func AdjustKeysToLowercase(cloudInfo *model.CloudInfo)
- func AppendIfMissing(slice []string, i string) []string
- func ChangeIdString(name string) string
- func CheckBasicOSImage(combinedInfo string, providerName string) bool
- func CheckConfig(id string) (bool, error)
- func CheckConnConfigAvailable(connConfigName string) (bool, error)
- func CheckElement(a string, list []string) bool
- func CheckNs(id string) (bool, error)
- func CheckSpiderReady() error
- func CheckString(name string) error
- func CompareVersions(version1, version2 string) int
- func ConvertToBaseCurrency(cost float32, currency string) float32
- func ConvertToMessage(inType string, inData string, obj interface{}) error
- func ConvertToOutput(outType string, obj interface{}) (string, error)
- func CopySrcToDest(src interface{}, dest interface{}) error
- func CreateNs(u *model.NsReq) (model.NsInfo, error)
- func DelAllNs() error
- func DelNs(id string) error
- func DeleteObject(key string) error
- func DeleteObjects(key string) error
- func ExtractOSInfo(combinedInfo string) string
- func FilterDigitsAndDots(input string) string
- func GenChildResourceKey(nsId string, resourceType string, parentResourceId string, resourceId string) string
- func GenConnectionKey(connectionId string) string
- func GenCredentialHolderKey(holderId string) string
- func GenK8sClusterKey(nsId string, k8sClusterId string) string
- func GenMciKey(nsId string, mciId string, vmId string) string
- func GenMciPolicyKey(nsId string, mciId string, vmId string) string
- func GenMciSubGroupKey(nsId string, mciId string, groupId string) string
- func GenRandomPassword(length int) string
- func GenResourceKey(nsId string, resourceType string, resourceId string) string
- func GenUid() string
- func GenerateNewRandomString(n int) string
- func GetAssetsFilePath(filename string) string
- func GetAvailableK8sNodeImage(providerName string, regionName string) (*[]model.K8sClusterNodeImageDetailAvailable, error)
- func GetAvailableK8sVersion(providerName string, regionName string) (*[]model.K8sClusterVersionDetailAvailable, error)
- func GetChildIdList(key string) []string
- func GetCloudInfo() (model.CloudInfo, error)
- func GetConfig(id string) (model.ConfigInfo, error)
- func GetConnConfig(ConnConfigName string) (model.ConnConfig, error)
- func GetConnConfigList(filterCredentialHolder string, filterVerified bool, ...) (model.ConnConfigList, error)
- func GetFuncName() string
- func GetK8sClusterInfo() (model.K8sClusterAssetInfo, error)
- func GetK8sNodeGroupNamingRule(providerName string) (string, error)
- func GetK8sNodeGroupsOnK8sCreation(providerName string) (bool, error)
- func GetK8sNodeImageDesignation(providerName string) (bool, error)
- func GetK8sRequiredSubnetCount(providerName string) (int, error)
- func GetModelK8sNodeGroupsOnK8sCreation(providerName string) (*model.K8sClusterNodeGroupsOnCreation, error)
- func GetModelK8sNodeImageDesignation(providerName string) (*model.K8sClusterNodeImageDesignation, error)
- func GetModelK8sRequiredSubnetCount(providerName string) (*model.K8sClusterRequiredSubnetCount, error)
- func GetNs(id string) (model.NsInfo, error)
- func GetObjectList(key string) []string
- func GetObjectValue(key string) (string, error)
- func GetProviderList() (*model.IdList, error)
- func GetProviderNameFromConnConfig(ConnConfigName string) (string, error)
- func GetPublicKeyForCredentialEncryption() (model.PublicKeyResponse, error)
- func GetRegion(ProviderName, RegionName string) (model.RegionDetail, error)
- func GetRegions(ProviderName string) (model.RegionList, error)
- func InitAllConfig() error
- func InitConfig(id string) error
- func IsDeprecatedImage(combinedInfo string) bool
- func IsGPUImage(combinedInfo string) bool
- func IsK8sImage(combinedInfo string) bool
- func ListConfig() ([]model.ConfigInfo, error)
- func ListConfigId() []string
- func ListNs() ([]model.NsInfo, error)
- func ListNsId() ([]string, error)
- func LookupKeyValueList(kvl []model.KeyValue, key string) string
- func NVL(str string, def string) string
- func NsValidation() echo.MiddlewareFunc
- func PrintCloudInfoTable(cloudInfo model.CloudInfo)
- func PrintCredentialInfo(credential model.Credential)
- func PrintJsonPretty(v interface{})
- func RandomSleep(from, to int)
- func RegisterAllCloudInfo() error
- func RegisterCloudInfo(providerName string) error
- func RegisterConnectionConfig(connConfig model.ConnConfig) (model.ConnConfig, error)
- func RegisterCredential(req model.CredentialReq) (model.CredentialInfo, error)
- func RegisterRegionZone(providerName string, regionName string) error
- func RetrieveRegionListFromCsp() (model.RetrievedRegionList, error)
- func SetupViperPaths(v *viper.Viper)
- func ToLower(name string) string
- func UpdateConfig(u *model.ConfigReq) (model.ConfigInfo, error)
- func UpdateGlobalVariable(id string) error
- func UpdateNs(id string, u *model.NsReq) (model.NsInfo, error)
Constants ¶
const DefaultNamingRule = "^.*$" // Wildcard Pattern
Variables ¶
var RuntimeCloudInfo = model.CloudInfo{}
RuntimeCloudInfo is global variable for model.CloudInfo
var RuntimeCloudNetworkInfo = model.CloudNetworkInfo{}
RuntimeNetworkInfo is global variable for model.NetworkInfo
var RuntimeConf = model.RuntimeConfig{}
RuntimeConf is global variable for cloud config
var RuntimeCredential = model.Credential{}
var RuntimeExtractPatternsInfo = model.ExtractPatternsInfo{}
RuntimeExtractPatternsInfo is global variable for model.ExtractPatternsInfo
var RuntimeK8sClusterInfo = model.K8sClusterAssetInfo{}
RuntimeK8sClusterInfo is global variable for model.K8sClusterAssetInfo
var RuntimeLatancyMap = [][]string{}
RuntimeLatancyMap is global variable for LatancyMap
var RuntimeLatancyMapIndex = make(map[string]int)
RuntimeLatancyMapIndex is global variable for LatancyMap (index)
Functions ¶
func AdjustKeysToLowercase ¶ added in v0.8.7
AdjustKeysToLowercase adjusts the keys of nested maps to lowercase.
func AppendIfMissing ¶ added in v0.3.11
func ChangeIdString ¶ added in v0.5.4
ChangeIdString is func to change strings in id or name (special chars to -, to lower string )
func CheckBasicOSImage ¶ added in v0.11.2
CheckBasicOSImage checks if the given combined info matches any basic OS image patterns Returns true if the image is considered a basic OS image based on predefined patterns providerName is used to apply CSP-specific rules (if defined) or common rules (as fallback)
Logic: 1. Determine include patterns:
- If CSP-specific include exists and not empty → use CSP-specific include
- Otherwise → use common include
2. Determine exclude patterns:
- If CSP-specific exclude exists and not empty → use CSP-specific exclude
- Otherwise → use common exclude
3. Check exclude patterns first (return false if matched) 4. Check include patterns (return true if matched)
func CheckConfig ¶ added in v0.3.1
func CheckConnConfigAvailable ¶ added in v0.8.8
CheckConnConfigAvailable is func to check if connection config is available by checking allkeypair list
func CheckElement ¶ added in v0.6.4
func CheckSpiderReady ¶ added in v0.8.8
func CheckSpiderReady() error
CheckSpiderStatus is func to check if CB-Spider is ready
func CheckString ¶ added in v0.3.7
CheckString is func to check string by the given rule `[a-z]([-a-z0-9]*[a-z0-9])?`
func CompareVersions ¶ added in v0.10.0
func ConvertToBaseCurrency ¶ added in v0.10.7
ConvertToBaseCurrency converts a cost value from a specific currency to the base currency (USD) This function handles currency conversion using predefined exchange rates
func ConvertToMessage ¶
ConvertToMessage is func to change input data to gRPC message
func ConvertToOutput ¶
ConvertToOutput is func to convert gRPC message to print format
func CopySrcToDest ¶
func CopySrcToDest(src interface{}, dest interface{}) error
CopySrcToDest is func to copy data from source to target
func DeleteObject ¶ added in v0.3.3
DeleteObject is func to delete the object
func DeleteObjects ¶ added in v0.3.3
DeleteObjects is func to delete objects
func ExtractOSInfo ¶ added in v0.10.7
ExtractOSInfo extracts OS name and version from string and returns formatted string like "Ubuntu 22.04"
func FilterDigitsAndDots ¶ added in v0.10.0
func GenChildResourceKey ¶ added in v0.4.10
func GenChildResourceKey(nsId string, resourceType string, parentResourceId string, resourceId string) string
GenChildResourceKey is func to generate a key from resource type and id
func GenConnectionKey ¶ added in v0.8.8
GenConnectionKey is func to generate a key for connection info
func GenCredentialHolderKey ¶ added in v0.8.9
GenCredentialHolderKey is func to generate a key for credentialHolder info
func GenK8sClusterKey ¶ added in v0.10.0
GenK8sClusterKey is func to generate a key from K8sCluster ID
func GenMciPolicyKey ¶ added in v0.9.5
GenMciPolicyKey is func to generate Mci policy key
func GenMciSubGroupKey ¶ added in v0.9.5
GenMciSubGroupKey is func to generate a key from subGroupId used in keyValue store
func GenRandomPassword ¶ added in v0.7.1
GenRandomPassword is func to return a RandomPassword
func GenResourceKey ¶
GenResourceKey is func to generate a key from resource type and id
func GenerateNewRandomString ¶ added in v0.6.7
generate a random string (from CB-MCKS source code)
func GetAssetsFilePath ¶ added in v0.11.20
GetAssetsFilePath returns the full path to an assets file. It tries multiple paths in order: 1. TB_ROOT_PATH environment variable + /assets/filename 2. ./assets/filename (current directory) 3. ../assets/filename (parent directory - default for src/ execution)
The function logs the attempted and resolved paths for debugging.
func GetAvailableK8sNodeImage ¶ added in v0.10.0
func GetAvailableK8sNodeImage(providerName string, regionName string) (*[]model.K8sClusterNodeImageDetailAvailable, error)
GetAvailableK8sNodeImage is func to get available kubernetes cluster node images for provider and region from model.K8sClusterInfo
func GetAvailableK8sVersion ¶ added in v0.10.0
func GetAvailableK8sVersion(providerName string, regionName string) (*[]model.K8sClusterVersionDetailAvailable, error)
GetAvailableK8sVersion is func to get available kubernetes cluster versions for provider and region from model.K8sClusterInfo
func GetChildIdList ¶
GetChildIdList is func to get child id list from given key
func GetCloudInfo ¶ added in v0.8.7
GetCloudInfo is func to get all cloud info from the asset
func GetConnConfig ¶
func GetConnConfig(ConnConfigName string) (model.ConnConfig, error)
GetConnConfig is func to get connection config
func GetConnConfigList ¶
func GetConnConfigList(filterCredentialHolder string, filterVerified bool, filterRegionRepresentative bool) (model.ConnConfigList, error)
GetConnConfigList is func to list filtered connection configs
func GetFuncName ¶ added in v0.5.4
func GetFuncName() string
GetFuncName is func to get the name of the running function
func GetK8sClusterInfo ¶ added in v0.8.14
func GetK8sClusterInfo() (model.K8sClusterAssetInfo, error)
GetK8sClusterInfo is func to get all kubernetes cluster info from the asset
func GetK8sNodeGroupNamingRule ¶ added in v0.10.2
GetK8sNodeGroupNamingRule is func to get nodegroup's naming rule
func GetK8sNodeGroupsOnK8sCreation ¶ added in v0.10.0
GetK8sNodeGroupsOnK8sCreation is func to get whether nodegroups are required during the k8scluster creation
func GetK8sNodeImageDesignation ¶ added in v0.10.0
GetK8sNodeImageDesignation is func to get whether node image designation is possible to create a k8scluster
func GetK8sRequiredSubnetCount ¶ added in v0.10.0
GetK8sRequiredSubnetCount is func to get the required subnet count to create a k8scluster
func GetModelK8sNodeGroupsOnK8sCreation ¶ added in v0.10.0
func GetModelK8sNodeGroupsOnK8sCreation(providerName string) (*model.K8sClusterNodeGroupsOnCreation, error)
GetModelK8sNodeGroupsOnK8sCreation is to convert a NodeGroupsOnK8sCreation value to model.K8sClusterNodeGroupsOnK8sCreation
func GetModelK8sNodeImageDesignation ¶ added in v0.10.0
func GetModelK8sNodeImageDesignation(providerName string) (*model.K8sClusterNodeImageDesignation, error)
GetModelK8sNodeImageDesignation is to convert a NodeImageDesignation value to model.K8sClusterNodeImageDesignation
func GetModelK8sRequiredSubnetCount ¶ added in v0.10.0
func GetModelK8sRequiredSubnetCount(providerName string) (*model.K8sClusterRequiredSubnetCount, error)
GetModelK8sRequiredSubnetCount is func to get the required subnet count to create a k8scluster
func GetObjectList ¶ added in v0.3.3
GetObjectList is func to return IDs of each child objects that has the same key
func GetObjectValue ¶ added in v0.3.3
GetObjectValue is func to return the object value
func GetProviderList ¶ added in v0.8.9
GetProviderList is func to list all cloud providers
func GetProviderNameFromConnConfig ¶ added in v0.11.3
GetConnConfig is func to get connection config
func GetPublicKeyForCredentialEncryption ¶ added in v0.9.7
func GetPublicKeyForCredentialEncryption() (model.PublicKeyResponse, error)
GetPublicKeyForCredentialEncryption generates an RSA key pair, stores the private key in memory, and returns the public key along with its token ID.
func GetRegion ¶
func GetRegion(ProviderName, RegionName string) (model.RegionDetail, error)
GetRegion is func to get regionInfo with the native region name
func GetRegions ¶ added in v0.9.10
func GetRegions(ProviderName string) (model.RegionList, error)
GetRegions is func to get regionInfo list
func InitAllConfig ¶ added in v0.3.9
func InitAllConfig() error
func InitConfig ¶ added in v0.3.9
func IsDeprecatedImage ¶ added in v0.10.7
IsDeprecatedImage checks if an image is deprecated
func IsGPUImage ¶ added in v0.10.7
IsGPUImage checks if an image has GPU support
func IsK8sImage ¶ added in v0.10.7
IsK8sImage checks if an image is for Kubernetes
func ListConfig ¶
func ListConfig() ([]model.ConfigInfo, error)
func ListConfigId ¶
func ListConfigId() []string
func LookupKeyValueList ¶
LookupKeyValueList is func to lookup model.KeyValue list
func NsValidation ¶
func NsValidation() echo.MiddlewareFunc
func PrintCloudInfoTable ¶ added in v0.8.5
PrintCloudInfoTable prints model.CloudInfo in table format
func PrintCredentialInfo ¶ added in v0.8.8
func PrintCredentialInfo(credential model.Credential)
PrintCredentialInfo prints model.Credential information in table format
func PrintJsonPretty ¶
func PrintJsonPretty(v interface{})
PrintJsonPretty is func to print JSON pretty with indent
func RandomSleep ¶ added in v0.4.10
func RandomSleep(from, to int)
RandomSleep is func to make a caller waits for during random Milliseconds (from ms, to ms)
func RegisterAllCloudInfo ¶ added in v0.8.8
func RegisterAllCloudInfo() error
RegisterAllCloudInfo is func to register all cloud info from asset to CB-Spider
func RegisterCloudInfo ¶ added in v0.8.8
RegisterCloudInfo is func to register cloud info from asset to CB-Spider
func RegisterConnectionConfig ¶ added in v0.8.8
func RegisterConnectionConfig(connConfig model.ConnConfig) (model.ConnConfig, error)
RegisterConnectionConfig is func to register connection config to CB-Spider
func RegisterCredential ¶ added in v0.8.8
func RegisterCredential(req model.CredentialReq) (model.CredentialInfo, error)
RegisterCredential is func to register credential and all related connection configs
func RegisterRegionZone ¶ added in v0.8.8
RegisterRegionZone is func to register all regions to CB-Spider
func RetrieveRegionListFromCsp ¶ added in v0.9.10
func RetrieveRegionListFromCsp() (model.RetrievedRegionList, error)
RetrieveRegionListFromCsp is func to retrieve region list
func SetupViperPaths ¶ added in v0.11.20
SetupViperPaths configures standard asset paths for a Viper instance. This centralizes the path configuration logic used across multiple config files. It adds paths in priority order: 1. TB_ROOT_PATH/assets (if TB_ROOT_PATH is set) 2. TB_ROOT_PATH (if TB_ROOT_PATH is set) 3. . (current directory) 4. ./assets/ 5. ../assets/ (default for src/ execution)
func ToLower ¶ added in v0.3.1
ToLower is func to change strings (_ to -, " " to -, to lower string ) (deprecated soon)
func UpdateConfig ¶
func UpdateConfig(u *model.ConfigReq) (model.ConfigInfo, error)
func UpdateGlobalVariable ¶ added in v0.3.9
Types ¶
This section is empty.