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 ¶
Package common is to include common methods for managing multi-cloud infra
Index ¶
- Constants
- Variables
- func ChangeIdString(name string) string
- func CheckElement(a string, list []string) bool
- func CheckString(name string) error
- 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 EndRequestWithLog(c echo.Context, err error, responseData interface{}) error
- func ExecuteHttpRequest[B any, T any](client *resty.Client, method string, url string, headers map[string]string, ...) error
- func GenChildResourceKey(nsId string, resourceType string, parentResourceId string, resourceId 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 GetFuncName() string
- func LookupKeyValueList(kvl []KeyValue, key string) string
- func NVL(str string, def string) string
- func PrintJsonPretty(v interface{})
- func RandomSleep(from int, to int)
- func SetUseBody(requestBody interface{}) bool
- func ToLower(name string) string
- type CacheItem
- type IID
- type IdList
- type KeyValue
- type NsInfo
- type NsReq
- type RequestDetails
- type RequestInfo
- type RestGetAllNsResponse
- type SimpleMsg
- type SpiderConnectionName
Constants ¶
const ( // VeryShortDuration is a duration for very short-term cache VeryShortDuration = 1 * time.Second // ShortDuration is a duration for short-term cache ShortDuration = 2 * time.Second // MediumDuration is a duration for medium-term cache MediumDuration = 5 * time.Second // LongDuration is a duration for long-term cache LongDuration = 10 * time.Second )
const ( StrTumblebugRestUrl string = "TUMBLEBUG_REST_URL" StrAutocontrolDurationMs string = "AUTOCONTROL_DURATION_MS" CbStoreKeyNotFoundErrorString string = "key not found" StrAdd string = "add" StrDelete string = "delete" StrSSHKey string = "sshKey" StrImage string = "image" StrCustomImage string = "customImage" StrSecurityGroup string = "securityGroup" StrSpec string = "spec" StrVNet string = "vNet" StrSubnet string = "subnet" StrDataDisk string = "dataDisk" StrNLB string = "nlb" StrVM string = "vm" StrMCI string = "mci" StrDefaultResourceName string = "-systemdefault-" // SystemCommonNs is const for SystemCommon NameSpace ID SystemCommonNs string = "system-purpose-common-ns" )
const NoBody = "NOBODY"
NoBody is a constant for empty body
Variables ¶
var AutocontrolDurationMs string
var DefaulNamespaceId = "mig01"
var RequestMap = sync.Map{}
RequestMap is a map for request details
var StartTime string
var SystemReady bool
SystemReady is global variable for checking SystemReady status
var TumblebugRestUrl string
Functions ¶
func ChangeIdString ¶
ChangeIdString is func to change strings in id or name (special chars to -, to lower string )
func CheckElement ¶
func CheckString ¶
CheckString is func to check string by the given rule `[a-z]([-a-z0-9]*[a-z0-9])?`
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 EndRequestWithLog ¶ added in v0.1.1
EndRequestWithLog updates the request details and sends the final response.
func ExecuteHttpRequest ¶
func ExecuteHttpRequest[B any, T any]( client *resty.Client, method string, url string, headers map[string]string, useBody bool, body *B, result *T, cacheDuration time.Duration, ) error
ExecuteHttpRequest performs the HTTP request and fills the result (var requestBody interface{} = nil for empty body)
func GenChildResourceKey ¶
func GenChildResourceKey(nsId string, resourceType string, parentResourceId string, resourceId string) string
GenChildResourceKey is func to generate a key from resource type and id
func GenMciPolicyKey ¶ added in v0.2.1
GenMciPolicyKey is func to generate Mci policy key
func GenMciSubGroupKey ¶ added in v0.2.1
GenMciSubGroupKey is func to generate a key from subGroupId used in keyValue store
func GenRandomPassword ¶
GenRandomPassword is func to return a RandomPassword
func GenResourceKey ¶
GenResourceKey is func to generate a key from resource type and id
func GenerateNewRandomString ¶
generate a random string (from CB-MCKS source code)
func GetFuncName ¶
func GetFuncName() string
GetFuncName is func to get the name of the running function
func LookupKeyValueList ¶
LookupKeyValueList is func to lookup KeyValue list
func PrintJsonPretty ¶
func PrintJsonPretty(v interface{})
PrintJsonPretty is func to print JSON pretty with indent
func RandomSleep ¶
RandomSleep is func to make a caller waits for during random time seconds (random value within x~y)
func SetUseBody ¶
func SetUseBody(requestBody interface{}) bool
SetUseBody returns false if the given body is NoBody
Types ¶
type IID ¶
Spider 2020-03-30 https://github.com/cloud-barista/cb-spider/blob/master/cloud-control-manager/cloud-driver/interfaces/resources/IId.go
type NsInfo ¶
type NsInfo struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
}
NsInfo is struct for namespace information
type RequestDetails ¶ added in v0.1.1
type RequestDetails struct {
StartTime time.Time `json:"startTime"` // The time when the request was received by the server.
EndTime time.Time `json:"endTime"` // The time when the request was fully processed.
Status string `json:"status"` // The current status of the request (e.g., "Handling", "Error", "Success").
RequestInfo RequestInfo `json:"requestInfo"` // Extracted information about the request.
ResponseData interface{} `json:"responseData"` // The data sent back in response to the request.
ErrorResponse string `json:"errorResponse"` // A message describing any error that occurred during request processing.
}
RequestDetails contains detailed information about an HTTP request and its processing status.
type RequestInfo ¶ added in v0.1.1
type RequestInfo struct {
Method string `json:"method"` // HTTP method (GET, POST, etc.), indicating the request's action type.
URL string `json:"url"` // The URL the request is made to.
Header map[string]string `json:"header"` // Key-value pairs of the request headers.
Body interface{} `json:"body,omitempty"` // Optional: request body
}
RequestInfo stores the essential details of an HTTP request.
func ExtractRequestInfo ¶ added in v0.1.1
func ExtractRequestInfo(r *http.Request) RequestInfo
ExtractRequestInfo extracts necessary information from http.Request
type RestGetAllNsResponse ¶ added in v0.1.1
type RestGetAllNsResponse struct {
//Name string `json:"name"`
Ns []NsInfo `json:"ns"`
}
Response structure for RestGetAllNs
type SimpleMsg ¶
type SimpleMsg struct {
Message string `json:"message" example:"Any message"`
}
SimpleMsg is struct for JSON Simple message
type SpiderConnectionName ¶
type SpiderConnectionName struct {
ConnectionName string `json:"ConnectionName"`
}