Documentation
¶
Overview ¶
Package resource is to manage multi-cloud infra resource
Package resource is to manage multi-cloud infra resource ¶
Package resource is to manage multi-cloud infra resource ¶
Package resource is to manage multi-cloud infra resource ¶
Package resource is to manage multi-cloud infra resource ¶
Package resource is to manage multi-cloud infra resource ¶
Package resource is to manage multi-cloud infra resource ¶
Package resource is to manage multi-cloud infra resource ¶
Package resource is to manage multi-cloud infra resource ¶
Package resource is to manage multi-cloud infra resource ¶
Package resource is to manage multi-cloud infra resource ¶
Package resource is to manage multi-cloud infra resource ¶
Package resource is to manage multi-cloud infra resource ¶
Package resource is to manage multi-cloud infra resource
Index ¶
- Constants
- func AddK8sNodeGroup(ctx context.Context, nsId string, k8sClusterId string, ...) (*model.K8sClusterInfo, error)
- func BatchRemoveFromAssociatedObjectList(nsId string, resourceType string, resourceId string, objectKeys []string) error
- func BulkDeleteGlobalDnsRecords(ctx context.Context, req *model.GlobalDnsBulkDeleteReq) (model.GlobalDnsBulkDeleteResponse, error)
- func BulkUpdateSpec(nsId string, updates map[string]float32) (int, error)
- func ChangeK8sNodeGroupAutoscaleSize(nsId string, k8sClusterId string, k8sNodeGroupName string, ...) (*model.ChangeK8sNodeGroupAutoscaleSizeRes, error)
- func CheckAssociatedCspResourceExistence(nsId string, resourceType string, resourceId string, connConfig string) (onCsp bool, onSpider bool, err error)
- func CheckChildResource(nsId string, resourceType string, parentResourceId string, resourceId string) (bool, error)
- func CheckImageRegionCompatibility(connectionName string, imageInfo model.ImageInfo) (string, error)
- func CheckK8sCluster(nsId string, k8sClusterId string) (bool, error)
- func CheckObjectStorageExistence(nsId, osId string) (bool, error)
- func CheckResource(nsId string, resourceType string, resourceId string) (bool, error)
- func CheckSubnetInUseByNodes(nsId string, vNetId string, subnetId string) (bool, error)
- func ComplementSshKey(nsId string, sshKeyId string, req model.SshKeyComplementReq) (model.SshKeyInfo, error)
- func ContainsZone(zones []string, zone string) bool
- func ConvertFirewallRuleRequestObjToInfoObjs(req model.FirewallRuleReq) []model.FirewallRuleInfo
- func ConvertSpiderImageToTumblebugImage(nsId, connConfig string, spiderImage model.SpiderImageInfo) (model.ImageInfo, error)
- func ConvertSpiderMyImageToTumblebugCustomImage(connConfig model.ConnConfig, spiderMyImage model.SpiderMyImageInfo) (model.ImageInfo, error)
- func ConvertSpiderSpecToTumblebugSpec(connConfig model.ConnConfig, spiderSpec model.SpiderSpecInfo) (model.SpecInfo, error)
- func ConvertSpiderToFirewallRuleInfo(s model.SpiderSecurityRuleInfo) model.FirewallRuleInfo
- func ConvertTbToSpiderSecurityRuleInfo(t model.FirewallRuleInfo) model.SpiderSecurityRuleInfo
- func CreateDataDisk(ctx context.Context, nsId string, u *model.DataDiskReq, option string) (model.DataDiskInfo, error)
- func CreateFirewallRules(nsId string, securityGroupId string, req []model.FirewallRuleInfo, ...) (model.SecurityGroupInfo, error)
- func CreateK8sCluster(ctx context.Context, nsId string, req *model.K8sClusterReq, option string, ...) (*model.K8sClusterInfo, error)
- func CreateObjectStorage(ctx context.Context, nsId string, req model.ObjectStorageCreateRequest) (model.ObjectStorageInfo, error)
- func CreatePlaceholderSshKey(ctx context.Context, nsId string, connectionName string, nodeName string, ...) (model.SshKeyInfo, error)
- func CreateSecurityGroup(ctx context.Context, nsId string, u *model.SecurityGroupReq, option string) (model.SecurityGroupInfo, error)
- func CreateSharedResource(ctx context.Context, nsId string, resType string, connectionName string) error
- func CreateSharedResourceWithOptions(ctx context.Context, nsId string, resType string, connectionName string, ...) error
- func CreateSiteToSiteVPN(ctx context.Context, nsId string, infraId string, ...) (model.VpnInfo, error)
- func CreateSqlDB(ctx context.Context, nsId string, sqlDbReq *model.RestPostSqlDBRequest, ...) (model.SqlDBInfo, error)
- func CreateSshKey(ctx context.Context, nsId string, u *model.SshKeyReq, option string) (model.SshKeyInfo, error)
- func CreateSubnet(ctx context.Context, nsId string, vNetId string, subnetReq *model.SubnetReq) (model.SubnetInfo, error)
- func CreateVNet(ctx context.Context, nsId string, vNetReq *model.VNetReq) (model.VNetInfo, error)
- func CustomImageReqStructLevelValidation(sl validator.StructLevel)
- func DataDiskReqStructLevelValidation(sl validator.StructLevel)
- func DelAllResources(nsId string, resourceType string, subString string, forceFlag string) (model.ResourceDeleteResults, error)
- func DelEleInSlice(arr any, index int)
- func DelResource(nsId string, resourceType string, resourceId string, forceFlag string) error
- func DeleteAllK8sCluster(nsId, subString, option string) (*model.IdList, error)
- func DeleteDataObject(nsId, osId, objectKey string) error
- func DeleteFirewallRules(nsId string, securityGroupId string, req []model.FirewallRuleInfo) (model.SecurityGroupInfo, error)
- func DeleteGlobalDnsRecord(ctx context.Context, req *model.GlobalDnsDeleteReq) (model.SimpleMsg, error)
- func DeleteK8sCluster(nsId, k8sClusterId, option string) (bool, error)
- func DeleteObjectStorage(nsId, osId string, force, empty bool) error
- func DeleteObjectStorageCorsConfigurations(nsId, osId string) error
- func DeleteSharedResources(nsId string) (model.ResourceDeleteResults, error)
- func DeleteSiteToSiteVPN(ctx context.Context, nsId string, infraId string, vpnId string) (model.SimpleMsg, error)
- func DeleteSqlDB(nsId string, sqlDbId string) (model.SimpleMsg, error)
- func DeleteSubnet(nsId string, vNetId string, subnetId string, actionParam string) (model.SimpleMsg, error)
- func DeleteVNet(nsId string, vNetId string, actionParam string) (model.SimpleMsg, error)
- func DeleteVersionedObject(nsId, osId, objectKey, versionId string) error
- func DeregisterResource(nsId string, resourceType string, resourceId string) error
- func DeregisterSubnet(nsId string, vNetId string, subnetId string) (model.SimpleMsg, error)
- func DeregisterVNet(nsId string, vNetId string, withSubnets string) (model.SimpleMsg, error)
- func DesignVNets(reqt *model.VNetDesignRequest) (model.VNetDesignResponse, error)
- func EnsureImageAvailable(ctx context.Context, nsId, connectionName, imageId string) (model.ImageInfo, bool, error)
- func FetchImagesForAllConnConfigsAsync(nsId string, option *model.ImageFetchOption) error
- func FetchImagesForConnConfig(connConfig string, nsId string) (imageCount uint, err error)
- func FetchPriceForAllConnConfigs() (connConfigCount uint, priceCount uint, err error)
- func FetchPriceForConnConfig(config model.ConnConfig) error
- func FetchSpecsForAllConnConfigsAsync(nsId string, option *model.SpecFetchOption) error
- func FetchSpecsForConnConfig(connConfigName string, nsId string) (uint, error)
- func FilterSpecsByRange(nsId string, filter model.FilterSpecsByRangeRequest, orderBy string) ([]model.SpecInfo, error)
- func FindSubnetByZone(nsId string, vNetId string, zone string) (subnetId string, subnetZone string, err error)
- func GenSpecMapKey(region, specName string) string
- func GeneratePresignedURL(nsId, osId, objectKey string, expires time.Duration, operation string) (model.ObjectStoragePresignedUrlResponse, error)
- func GetAllIDsOfSiteToSiteVPN(ctx context.Context, nsId string, infraId string) (model.VpnIdList, error)
- func GetAllSiteToSiteVPN(ctx context.Context, nsId string, infraId string) (model.VpnInfoList, error)
- func GetAssociatedObjectCount(nsId string, resourceType string, resourceId string) (int, error)
- func GetAssociatedObjectList(nsId string, resourceType string, resourceId string) ([]string, error)
- func GetAvailableRegionZonesForSpec(ctx context.Context, provider string, cspSpecName string) (model.SpecAvailabilityInfo, error)
- func GetAvailableRegionZonesForSpecList(ctx context.Context, provider string, cspSpecNames []string) (model.SpecAvailabilityBatchResult, error)
- func GetAvailableZonesForSpec(ctx context.Context, specId string) (*model.AvailableZonesInfo, *model.AvailableZonesError)
- func GetCspResourceId(nsId string, resourceType string, resourceId string) (string, error)
- func GetCspResourceName(nsId string, resourceType string, resourceId string) (string, error)
- func GetCspResourceStatus(connConfig string, resourceType string, filter ...ResourceStatusFilter) (model.CspResourceStatusResponse, error)
- func GetCspResourceStatusBatch(connConfig string, resourceTypes []string) (map[string]model.CspResourceStatusResponse, error)
- func GetDataObject(nsId, osId, objectKey string) (model.Object, error)
- func GetFirstNZones(connectionName string, firstN int) ([]string, int, error)
- func GetGlobalDnsRecord(ctx context.Context, domainName string, recordName string, recordType string) (model.RestGetGlobalDnsRecordResponse, error)
- func GetIdFromStruct(u any) (string, error)
- func GetImage(nsId string, cspImageName string) (model.ImageInfo, error)
- func GetImageByPrimaryKey(nsId string, provider string, cspImageName string) (model.ImageInfo, error)
- func GetImageInfoFromLookupImage(nsId string, u model.ImageReq, allowCustomImage ...bool) (model.ImageInfo, error)
- func GetImagesByRegion(nsId string, provider string, region string) ([]model.ImageInfo, error)
- func GetK8sCluster(nsId string, k8sClusterId string) (*model.K8sClusterInfo, error)
- func GetK8sClusterKubeconfig(nsId string, k8sClusterId string) (*model.K8sClusterKubeconfigResponse, error)
- func GetK8sClusterToken(nsId string, k8sClusterId string) (*model.K8sClusterTokenResponse, error)
- func GetNameFromStruct(u any) (string, error)
- func GetObjectStorage(nsId, osId string) (model.ObjectStorageInfo, error)
- func GetObjectStorageCorsConfigurations(nsId, osId string) (model.ObjectStorageGetCorsResponse, error)
- func GetObjectStorageLocation(nsId, osId string) (model.ObjectStorageLocationResponse, error)
- func GetObjectStorageSupport(cspType string) (model.ObjectStorageSupportResponse, error)
- func GetObjectStorageVersioning(nsId, osId string) (model.ObjectStorageGetVersioningResponse, error)
- func GetProviderRegionZoneResourceKey(providerName, regionName, zoneName, resourceName string) string
- func GetRequestStatusOfSiteToSiteVpn(ctx context.Context, nsId string, infraId string, vpnId string, reqId string) (model.Response, error)
- func GetRequestStatusOfSqlDB(nsId string, sqlDbId string, reqId string) (model.Response, error)
- func GetResource(nsId string, resourceType string, resourceId string) (any, error)
- func GetSecurityGroup(nsId string, securityGroupId string) (model.SecurityGroupInfo, error)
- func GetSiteToSiteVPN(ctx context.Context, nsId string, infraId string, vpnId string, detail string, ...) (model.VpnInfo, error)
- func GetSpec(nsId string, specKey string) (model.SpecInfo, error)
- func GetSqlDB(nsId string, sqlDbId string, detail string) (model.SqlDBInfo, error)
- func GetSubnet(nsId string, vNetId string, subnetId string) (model.SubnetInfo, error)
- func GetVNet(nsId string, vNetId string) (model.VNetInfo, error)
- func HandleK8sClusterAction(nsId string, k8sClusterId string, action string) (string, error)
- func ImageReqStructLevelValidation(sl validator.StructLevel)
- func IsAvailableForUseInCSP(vNetReq *model.VNetReq, provider string) (bool, error)
- func IsValidCspForSqlDB(csp string) (bool, error)
- func IsValidCspPairForVpn(csp1, csp2 string) (bool, error)
- func K8sClusterReqStructLevelValidation(sl validator.StructLevel)
- func ListDataObjects(nsId, osId string) (model.ObjectStorageListObjectsResponse, error)
- func ListHostedZones(ctx context.Context) (model.RestGetHostedZonesResponse, error)
- func ListK8sCluster(nsId string, filterKey string, filterVal string) (any, error)
- func ListK8sClusterId(nsId string) ([]string, error)
- func ListObjectVersions(nsId, osId string) (model.ObjectStorageListObjectVersionsResponse, error)
- func ListResource(nsId string, resourceType string, filterKey string, filterVal string) (any, error)
- func ListResourceId(nsId string, resourceType string) ([]string, error)
- func ListSubnet(nsId string, vNetId string) ([]model.SubnetInfo, error)
- func LoadAssets(includeAzure bool) (*model.IdList, error)
- func LookupImage(connConfig string, imageId string) (model.SpiderImageInfo, error)
- func LookupImageList(connConfigName string) (model.SpiderImageList, error)
- func LookupMyImage(connConfig string, myImageId string) (model.SpiderMyImageInfo, error)
- func LookupPriceList(connConfig model.ConnConfig) (model.SpiderCloudPrice, error)
- func LookupPublicImageOnly(connConfig string, imageId string) (model.SpiderImageInfo, error)
- func LookupSpec(connConfig string, specName string) (model.SpiderSpecInfo, error)
- func LookupSpecList(connConfig string) (model.SpiderSpecList, error)
- func MapSpiderToTumblebugImageStatus(spiderStatus string) model.ImageStatus
- func PollResourceDeletedViaSpider(getURL string, headers map[string]string, maxAttempts int, ...) (deleted bool, verifyErr error)
- func ReconcileObjectStorage(nsId, osId string) (model.ObjectStorageReconcileResponse, error)
- func ReconcileSiteToSiteVPN(ctx context.Context, nsId, infraId, vpnId string) (model.VpnReconcileResponse, error)
- func RegisterCustomImageWithId(nsId string, u *model.CustomImageReq) (model.ImageInfo, error)
- func RegisterCustomImageWithInfo(nsId string, content model.ImageInfo) (model.ImageInfo, error)
- func RegisterImageWithId(nsId string, u *model.ImageReq, update bool, RDBonly bool) (model.ImageInfo, error)
- func RegisterImageWithInfo(nsId string, content *model.ImageInfo, update bool) (model.ImageInfo, error)
- func RegisterImageWithInfoInBulk(imageList []model.ImageInfo) error
- func RegisterSpecWithCspResourceId(nsId string, u *model.SpecReq, update bool) (model.SpecInfo, error)
- func RegisterSpecWithInfo(nsId string, content *model.SpecInfo, update bool) (model.SpecInfo, error)
- func RegisterSpecWithInfoInBulk(specList []model.SpecInfo) error
- func RegisterSubnet(ctx context.Context, nsId string, vNetId string, ...) (model.SubnetInfo, error)
- func RegisterVNet(ctx context.Context, nsId string, vNetRegisterReq *model.RegisterVNetReq) (model.VNetInfo, error)
- func RemoteCommandToK8sClusterContainer(nsId string, k8sClusterId string, k8sClusterNamespace string, ...) (*model.K8sClusterContainerCmdResults, error)
- func RemoveDuplicateImagesInSQL() error
- func RemoveDuplicateSpecsInSQL() error
- func RemoveK8sNodeGroup(nsId, k8sClusterId, k8sNodeGroupName, option string) (bool, error)
- func ResolveLatestCspImageNameForVMCreation(ctx context.Context, ...) string
- func ResolveLatestImageForVMCreation(ctx context.Context, connectionName string, imageInfo model.ImageInfo) model.ImageInfo
- func ResolveProviderRegionZoneResourceKey(key string) (providerName string, regionName string, zoneName string, resourceName string, ...)
- func SearchImage(nsId string, req model.SearchImageRequest, isCustomImage bool) ([]model.ImageInfo, int, error)
- func SearchImageOptions() (model.SearchImageRequestOptions, error)
- func SecurityGroupReqStructLevelValidation(sl validator.StructLevel)
- func SetK8sNodeGroupAutoscaling(nsId string, k8sClusterId string, k8sNodeGroupName string, ...) (*model.SetK8sNodeGroupAutoscalingRes, error)
- func SetObjectStorageCorsConfigurations(nsId, osId string, req model.ObjectStorageSetCorsRequest) error
- func SetObjectStorageVersioning(nsId, osId string, req model.ObjectStorageSetVersioningRequest) error
- func SpecReqStructLevelValidation(sl validator.StructLevel)
- func SshKeyReqStructLevelValidation(sl validator.StructLevel)
- func SubnetReqStructLevelValidation(sl validator.StructLevel)
- func SyncVNetState(nsId string, vNetInfo *model.VNetInfo, ...) (model.SimpleMsg, error)
- func ToNamingRuleCompatible(rawName string) string
- func TransferFileToK8sClusterContainer(nsId string, k8sClusterId string, k8sClusterNamespace string, ...) (*model.K8sClusterContainerCmdResult, error)
- func UpdateAssociatedObjectList(nsId string, resourceType string, resourceId string, cmd string, ...) ([]string, error)
- func UpdateExistingSpecListByAvailableRegionZones(ctx context.Context, nsId string, provider string) (model.SpecCleanupResult, error)
- func UpdateFirewallRules(nsId string, securityGroupId string, desiredRules []model.FirewallRuleReq) (model.SecurityGroupUpdateResponse, error)
- func UpdateFirewallRulesBatch(nsId string, securityGroupIds []string, desiredRules []model.FirewallRuleReq) model.RestWrapperSecurityGroupUpdateResponse
- func UpdateGlobalDnsRecord(ctx context.Context, req *model.GlobalDnsRecordReq) (model.SimpleMsg, error)
- func UpdateImage(nsId string, imageId string, fieldsToUpdate model.ImageInfo, RDBonly bool) (model.ImageInfo, error)
- func UpdateMultipleFirewallRules(nsId string, securityGroupIds []string, desiredRules []model.FirewallRuleReq) model.RestWrapperSecurityGroupUpdateResponse
- func UpdateResourceObject(nsId string, resourceType string, resourceObject any)
- func UpdateSpec(nsId string, specId string, fieldsToUpdate model.SpecInfo) (model.SpecInfo, error)
- func UpdateSpecsFromAsset(nsId string) error
- func UpdateSshKey(nsId string, sshKeyId string, update model.SshKeyUpdateReq) (model.SshKeyInfo, error)
- func UpgradeK8sCluster(ctx context.Context, nsId string, k8sClusterId string, ...) (*model.K8sClusterInfo, error)
- func UpsizeDataDisk(nsId string, resourceId string, u *model.DataDiskUpsizeReq) (model.DataDiskInfo, error)
- func VNetReqStructLevelValidation(sl validator.StructLevel)
- func ValidateSubnetReq(subnetReq *model.SubnetReq, existingVNet model.VNetInfo) error
- func ValidateVNetReq(vNetReq *model.VNetReq) error
- func WarmSpecNameCache(nsId, specId, cspSpecName string)
- type ConnectionImageResult
- type ConnectionSpecResult
- type FetchImagesAsyncResult
- type FetchSpecsAsyncResult
- type IdNameOnly
- type NetworkAction
- type ObjectStorageVersioningOption
- type Range
- type ResourceStatusFilter
- type SharedResourceOptions
- type SqlDBAction
- type SqlDBStatus
Constants ¶
const ( DefaultPollMaxAttempts = 5 DefaultPollInterval = 3 * time.Second )
Default parameters for post-deletion polling via Spider.
const ( ZoneErrorCodeNone = "" ZoneErrorCodeSpecNotFound = "SPEC_NOT_FOUND" ZoneErrorCodeProviderNotAvailable = "PROVIDER_NOT_AVAILABLE" ZoneErrorCodeRegionNotAvailable = "REGION_NOT_AVAILABLE" ZoneErrorCodeNoVerifiedZones = "NO_VERIFIED_ZONES" ZoneErrorCodeNoZonesAfterFiltering = "NO_ZONES_AFTER_FILTERING" ZoneErrorCodeInternalError = "INTERNAL_ERROR" )
Error codes for GetAvailableZonesForSpec
const CustomImageCreationTimeout = 30 * time.Minute
CustomImageCreationTimeout is the maximum time to wait for a custom image to become available If an image stays in "Creating" state longer than this, it will be marked as "Failed"
Variables ¶
This section is empty.
Functions ¶
func AddK8sNodeGroup ¶
func AddK8sNodeGroup(ctx context.Context, nsId string, k8sClusterId string, u *model.K8sNodeGroupReq) (*model.K8sClusterInfo, error)
AddK8sNodeGroup adds a K8sNodeGroup
func BatchRemoveFromAssociatedObjectList ¶ added in v0.12.9
func BatchRemoveFromAssociatedObjectList(nsId string, resourceType string, resourceId string, objectKeys []string) error
BatchRemoveFromAssociatedObjectList removes multiple objectKeys from a resource's associatedObjectList in a single read-modify-write, avoiding N round-trips for N nodes. Keys not present in the list are silently skipped. Returns nil if the resource does not exist.
func BulkDeleteGlobalDnsRecords ¶ added in v0.12.4
func BulkDeleteGlobalDnsRecords(ctx context.Context, req *model.GlobalDnsBulkDeleteReq) (model.GlobalDnsBulkDeleteResponse, error)
BulkDeleteGlobalDnsRecords deletes multiple DNS records in a single batch per domain. Records are grouped by domain and submitted as one ChangeBatch per domain to Route53.
func BulkUpdateSpec ¶ added in v0.10.10
BulkUpdateSpec updates multiple specs with proper type casting
func ChangeK8sNodeGroupAutoscaleSize ¶
func ChangeK8sNodeGroupAutoscaleSize(nsId string, k8sClusterId string, k8sNodeGroupName string, u *model.ChangeK8sNodeGroupAutoscaleSizeReq) (*model.ChangeK8sNodeGroupAutoscaleSizeRes, error)
ChangeK8sNodeGroupAutoscaleSize change NodeGroup's Autoscaling Size
func CheckAssociatedCspResourceExistence ¶ added in v0.11.3
func CheckAssociatedCspResourceExistence(nsId string, resourceType string, resourceId string, connConfig string) (onCsp bool, onSpider bool, err error)
CheckAssociatedCspResourceExistence checks if a CB-TB resource's associated CSP resource exists in Spider and CSP
This function takes a CB-TB resource and checks if its corresponding CSP resource exists in:
- CSP (Cloud Service Provider): Checks MappedList and OnlyCSPList
- Spider (CB-Spider): Checks MappedList and OnlySpiderList
Parameters:
- nsId: Namespace ID of the CB-TB resource
- resourceType: Type of the CB-TB resource (e.g., model.StrNode, model.StrVNet, etc.)
- resourceId: ID of the CB-TB resource
- connConfig: Connection configuration name for the target CSP
Returns:
- onCsp: true if the resource exists in CSP (either mapped or CSP-only)
- onSpider: true if the resource exists in Spider (either mapped or Spider-only)
- error: Error if the operation fails (connection errors, resource not found, etc.)
Example usage:
onCsp, onSpider, err := CheckAssociatedCspResourceExistence("default", model.StrNode, "my-vm-01", "aws-connection")
if err != nil {
log.Error().Err(err).Msg("Failed to check resource existence")
return err
}
if onCsp && onSpider {
fmt.Println("Resource exists in both CSP and Spider (mapped)")
} else if onCsp && !onSpider {
fmt.Println("Resource exists only in CSP")
} else if !onCsp && onSpider {
fmt.Println("Resource exists only in Spider")
} else {
fmt.Println("Resource does not exist in either CSP or Spider")
}
func CheckChildResource ¶
func CheckChildResource(nsId string, resourceType string, parentResourceId string, resourceId string) (bool, error)
CheckChildResource returns the existence of the TB Resource resource in bool form.
func CheckImageRegionCompatibility ¶ added in v0.12.7
func CheckImageRegionCompatibility(connectionName string, imageInfo model.ImageInfo) (string, error)
CheckImageRegionCompatibility evaluates whether the stored image can be used in the target connection's region.
Returns:
- ("", nil) : compatible, or check skipped (empty inputs / lookup failure)
- (warning, nil) : region mismatch but the provider has a family-based resolver (e.g. Alibaba ImageFamily) that will pick the correct image at VM-creation time. Caller may surface the warning.
- ("", err) : region mismatch and no recovery path; treat as hard error.
func CheckK8sCluster ¶
CheckK8sCluster returns the existence of the TB K8sCluster object in bool form.
func CheckObjectStorageExistence ¶ added in v0.12.2
CheckObjectStorageExistence checks if the object storage exists in both the key-value store and Spider
func CheckResource ¶
CheckResource returns the existence of the TB Resource resource in bool form.
func CheckSubnetInUseByNodes ¶ added in v0.12.6
CheckSubnetInUseByNodes checks if a subnet is being used by any VMs It retrieves the VNet's associatedObjectList and checks each VM's subnetId field
func ComplementSshKey ¶ added in v0.12.3
func ComplementSshKey(nsId string, sshKeyId string, req model.SshKeyComplementReq) (model.SshKeyInfo, error)
ComplementSshKey enable remote command execution for registered SSH keys by updating username and privateKey required for SSH authentication
func ContainsZone ¶ added in v0.9.9
func ConvertFirewallRuleRequestObjToInfoObjs ¶ added in v0.11.2
func ConvertFirewallRuleRequestObjToInfoObjs(req model.FirewallRuleReq) []model.FirewallRuleInfo
ConvertFirewallRuleRequestObjToInfoObjs converts a FirewallRuleReq object to a slice of FirewallRuleInfo objects. It handles single ports, port ranges, and multiple ports/ranges in a comma-separated format.
func ConvertSpiderImageToTumblebugImage ¶
func ConvertSpiderImageToTumblebugImage(nsId, connConfig string, spiderImage model.SpiderImageInfo) (model.ImageInfo, error)
ConvertSpiderImageToTumblebugImage accepts an Spider image object, converts to and returns an TB image object
func ConvertSpiderMyImageToTumblebugCustomImage ¶
func ConvertSpiderMyImageToTumblebugCustomImage(connConfig model.ConnConfig, spiderMyImage model.SpiderMyImageInfo) (model.ImageInfo, error)
ConvertSpiderMyImageToTumblebugCustomImage accepts an Spider MyImage object, converts to and returns an TB customImage object
func ConvertSpiderSpecToTumblebugSpec ¶
func ConvertSpiderSpecToTumblebugSpec(connConfig model.ConnConfig, spiderSpec model.SpiderSpecInfo) (model.SpecInfo, error)
ConvertSpiderSpecToTumblebugSpec accepts an Spider spec object, converts to and returns an TB spec object
func ConvertSpiderToFirewallRuleInfo ¶ added in v0.11.9
func ConvertSpiderToFirewallRuleInfo(s model.SpiderSecurityRuleInfo) model.FirewallRuleInfo
SpiderSecurityRuleInfo → FirewallRuleInfo
func ConvertTbToSpiderSecurityRuleInfo ¶ added in v0.11.2
func ConvertTbToSpiderSecurityRuleInfo(t model.FirewallRuleInfo) model.SpiderSecurityRuleInfo
FirewallRuleInfo → SpiderSecurityRuleInfo
func CreateDataDisk ¶
func CreateDataDisk(ctx context.Context, nsId string, u *model.DataDiskReq, option string) (model.DataDiskInfo, error)
CreateDataDisk accepts DataDisk creation request, creates and returns an TB dataDisk object
func CreateFirewallRules ¶
func CreateFirewallRules(nsId string, securityGroupId string, req []model.FirewallRuleInfo, objectOnly bool) (model.SecurityGroupInfo, error)
CreateFirewallRules accepts firewallRule creation request, creates and returns an TB securityGroup object
func CreateK8sCluster ¶
func CreateK8sCluster(ctx context.Context, nsId string, req *model.K8sClusterReq, option string, skipVersionCheck bool) (*model.K8sClusterInfo, error)
CreateK8sCluster create a k8s cluster
func CreateObjectStorage ¶ added in v0.10.2
func CreateObjectStorage(ctx context.Context, nsId string, req model.ObjectStorageCreateRequest) (model.ObjectStorageInfo, error)
CreateObjectStorage creates a new object storage (bucket) in the specified namespace
func CreatePlaceholderSshKey ¶ added in v0.12.3
func CreatePlaceholderSshKey(ctx context.Context, nsId string, connectionName string, nodeName string, nodeUid string) (model.SshKeyInfo, error)
CreatePlaceholderSshKey creates a placeholder SSH key for CSPs that do not manage SSH keys as independent resources (e.g., GCP). It delegates actual creation to CreateSshKey (Spider abstracts SSH key API even for GCP), then modifies the returned object to mark it as a placeholder. The user can later update this SSH key via ComplementSshKey API to set username and privateKey.
func CreateSecurityGroup ¶
func CreateSecurityGroup(ctx context.Context, nsId string, u *model.SecurityGroupReq, option string) (model.SecurityGroupInfo, error)
CreateSecurityGroup accepts SG creation request, creates and returns an TB SG object
func CreateSharedResource ¶ added in v0.9.10
func CreateSharedResource(ctx context.Context, nsId string, resType string, connectionName string) error
CreateSharedResource is to register default resource from asset files (../assets/*.csv) This is a wrapper function that maintains backward compatibility
func CreateSharedResourceWithOptions ¶ added in v0.12.2
func CreateSharedResourceWithOptions(ctx context.Context, nsId string, resType string, connectionName string, options *SharedResourceOptions) error
CreateSharedResourceWithOptions creates shared resources with optional parameters
func CreateSiteToSiteVPN ¶ added in v0.9.22
func CreateSiteToSiteVPN(ctx context.Context, nsId string, infraId string, vpnReq *model.RestPostVpnRequest, retry string) (model.VpnInfo, error)
CreateSiteToSiteVPN creates a site-to-site VPN via Terrarium
func CreateSqlDB ¶ added in v0.10.2
func CreateSqlDB(ctx context.Context, nsId string, sqlDbReq *model.RestPostSqlDBRequest, retry string) (model.SqlDBInfo, error)
CreateSqlDB creates a SQL database via Terrarium
func CreateSshKey ¶
func CreateSshKey(ctx context.Context, nsId string, u *model.SshKeyReq, option string) (model.SshKeyInfo, error)
CreateSshKey accepts SSH key creation request, creates and returns an TB sshKey object
func CreateSubnet ¶
func CreateSubnet(ctx context.Context, nsId string, vNetId string, subnetReq *model.SubnetReq) (model.SubnetInfo, error)
CreateSubnet creates and returns the vNet object
func CreateVNet ¶
CreateVNet accepts vNet creation request, creates and returns an TB vNet object
func CustomImageReqStructLevelValidation ¶ added in v0.11.9
func CustomImageReqStructLevelValidation(sl validator.StructLevel)
ImageReqStructLevelValidation func is for Validation
func DataDiskReqStructLevelValidation ¶ added in v0.11.9
func DataDiskReqStructLevelValidation(sl validator.StructLevel)
DataDiskReqStructLevelValidation func is for Validation
func DelAllResources ¶
func DelAllResources(nsId string, resourceType string, subString string, forceFlag string) (model.ResourceDeleteResults, error)
DelAllResources deletes all TB Resource objects of the given resourceType.
func DelEleInSlice ¶
DelEleInSlice delete an element from slice by index
- arr: the reference of slice
- index: the index of element will be deleted
func DelResource ¶
DelResource deletes the TB Resource object
func DeleteAllK8sCluster ¶
DeleteAllK8sCluster deletes all clusters
func DeleteDataObject ¶ added in v0.12.2
DeleteDataObject deletes a specific object from the specified object storage (bucket)
func DeleteFirewallRules ¶
func DeleteFirewallRules(nsId string, securityGroupId string, req []model.FirewallRuleInfo) (model.SecurityGroupInfo, error)
DeleteFirewallRules accepts firewallRule deletion request, deletes specified rules and returns an TB securityGroup object
func DeleteGlobalDnsRecord ¶ added in v0.12.4
func DeleteGlobalDnsRecord(ctx context.Context, req *model.GlobalDnsDeleteReq) (model.SimpleMsg, error)
DeleteGlobalDnsRecord deletes DNS records from Route53
func DeleteK8sCluster ¶
DeleteK8sCluster deletes a k8s cluster
func DeleteObjectStorage ¶ added in v0.10.2
DeleteObjectStorage deletes the specified object storage (bucket) from the specified namespace. If force is true, Spider force-deletes the bucket with all its contents. If empty is true, Spider empties the bucket contents first, then deletes it. When empty is true, the post-delete GET verification is skipped because the operation targets bucket contents, not bucket existence.
func DeleteObjectStorageCorsConfigurations ¶ added in v0.12.2
DeleteObjectStorageCorsConfigurations deletes the CORS configuration for the specified object storage (bucket)
func DeleteSharedResources ¶ added in v0.11.2
func DeleteSharedResources(nsId string) (model.ResourceDeleteResults, error)
DeleteSharedResources deletes all Default securityGroup, sshKey, vNet objects
func DeleteSiteToSiteVPN ¶ added in v0.9.22
func DeleteSiteToSiteVPN(ctx context.Context, nsId string, infraId string, vpnId string) (model.SimpleMsg, error)
DeleteSiteToSiteVPN deletes a site-to-site VPN via Terrarium
func DeleteSqlDB ¶ added in v0.10.2
DeleteSqlDB deletes a SQL database via Terrarium
func DeleteSubnet ¶ added in v0.9.9
func DeleteSubnet(nsId string, vNetId string, subnetId string, actionParam string) (model.SimpleMsg, error)
DeleteSubnet deletes and returns the result
func DeleteVNet ¶ added in v0.9.9
DeleteVNet accepts vNet creation request, creates and returns an TB vNet object
func DeleteVersionedObject ¶ added in v0.12.2
DeleteVersionedObject deletes a specific version of an object in the specified object storage (bucket)
func DeregisterResource ¶ added in v0.12.3
DeregisterResource deregisters the TB Resource object from Spider and TB without deleting the actual CSP resource This function only removes the resource mapping from Spider and TB internal storage (kvstore, label, etc.) The actual CSP resource remains intact and can be re-registered later
func DeregisterSubnet ¶ added in v0.9.9
DeregisterSubnet deregister subnet and returns the result
func DeregisterVNet ¶ added in v0.9.9
DeregisterVNet accepts vNet unregistration request, deregister and returns the result
func DesignVNets ¶ added in v0.9.10
func DesignVNets(reqt *model.VNetDesignRequest) (model.VNetDesignResponse, error)
DesignVNets accepts a VNet design request, designs and returns a VNet design response
func EnsureImageAvailable ¶ added in v0.12.0
func EnsureImageAvailable(ctx context.Context, nsId, connectionName, imageId string) (model.ImageInfo, bool, error)
EnsureImageAvailable checks if an image is available in DB or CSP, and auto-registers if needed. It first checks the DB (including CustomImage), then looks up in CSP and registers if found. ctx carries the x-credential-holder so any provider-specific "latest image" resolution (e.g. Alibaba ImageFamily) uses the requesting tenant's credentials. Returns: ImageInfo, isAutoRegistered, error
func FetchImagesForAllConnConfigsAsync ¶ added in v0.10.7
func FetchImagesForAllConnConfigsAsync(nsId string, option *model.ImageFetchOption) error
FetchImagesForAllConnConfigsAsync starts fetching images in background with provider-based grouping
func FetchImagesForConnConfig ¶
FetchImagesForConnConfig gets lookups all images for the region of conn config, and saves into TB image objects
func FetchPriceForAllConnConfigs ¶ added in v0.10.7
FetchPriceForAllConnConfigs gets all conn configs from Spider, lookups all Price for each region of conn config, and saves into TB Price objects. This implementation uses parallel processing with concurrency control and retries failed connections once.
func FetchPriceForConnConfig ¶ added in v0.10.7
func FetchPriceForConnConfig(config model.ConnConfig) error
FetchPriceForConnConfig lookups all Price for region of conn config, processes them in batch
func FetchSpecsForAllConnConfigsAsync ¶ added in v0.11.0
func FetchSpecsForAllConnConfigsAsync(nsId string, option *model.SpecFetchOption) error
FetchSpecsForAllConnConfigsAsync starts fetching specs in background with provider-based grouping
func FetchSpecsForConnConfig ¶
FetchSpecsForConnConfig lookups all specs for region of conn config, and saves into TB spec objects
func FilterSpecsByRange ¶
func FilterSpecsByRange(nsId string, filter model.FilterSpecsByRangeRequest, orderBy string) ([]model.SpecInfo, error)
FilterSpecsByRange accepts criteria ranges for filtering, and returns the list of filtered TB spec objects
func FindSubnetByZone ¶ added in v0.12.2
func FindSubnetByZone(nsId string, vNetId string, zone string) (subnetId string, subnetZone string, err error)
FindSubnetByZone finds a subnet that matches the specified zone from a VNet. If zone is empty or no matching subnet is found, returns the first (default) subnet. This is useful for VM placement in a specific zone when the user explicitly specifies one.
Parameters:
- nsId: Namespace ID
- vNetId: VNet ID to search subnets in
- zone: Target zone to find matching subnet (empty string means use default)
Returns:
- subnetId: The ID of the matching or default subnet
- subnetZone: The actual zone of the selected subnet
- error: Error if VNet doesn't exist or has no subnets
func GenSpecMapKey ¶
GenSpecMapKey generates a SpecMap key for storing or accessing data in a map
func GeneratePresignedURL ¶ added in v0.12.2
func GeneratePresignedURL(nsId, osId, objectKey string, expires time.Duration, operation string) (model.ObjectStoragePresignedUrlResponse, error)
GeneratePresignedURL generates a presigned URL for downloading or uploading an object
func GetAllIDsOfSiteToSiteVPN ¶ added in v0.9.22
func GetAllIDsOfSiteToSiteVPN(ctx context.Context, nsId string, infraId string) (model.VpnIdList, error)
GetAllIDsOfSiteToSiteVPN returns a list of site-to-site VPN IDs
func GetAllSiteToSiteVPN ¶ added in v0.9.22
func GetAllSiteToSiteVPN(ctx context.Context, nsId string, infraId string) (model.VpnInfoList, error)
GetSiteToSiteVPN returns a site-to-site VPN
func GetAssociatedObjectCount ¶
GetAssociatedObjectCount returns the number of Resource's associated Tumblebug objects
func GetAssociatedObjectList ¶
GetAssociatedObjectList returns the list of Resource's associated Tumblebug objects
func GetAvailableRegionZonesForSpec ¶ added in v0.11.9
func GetAvailableRegionZonesForSpec(ctx context.Context, provider string, cspSpecName string) (model.SpecAvailabilityInfo, error)
GetAvailableRegionZonesForSpec queries the availability of a specific spec across all regions/zones Returns detailed availability information including regions, zones, and query performance metrics. ctx carries the x-credential-holder so the underlying connection lookup is scoped to the requesting tenant rather than the system default holder.
func GetAvailableRegionZonesForSpecList ¶ added in v0.11.9
func GetAvailableRegionZonesForSpecList(ctx context.Context, provider string, cspSpecNames []string) (model.SpecAvailabilityBatchResult, error)
GetAvailableRegionZonesForSpecList queries availability for multiple specs in parallel Returns batch results with performance metrics for all specs. ctx carries the x-credential-holder so per-spec connection lookups are scoped to the requesting tenant.
func GetAvailableZonesForSpec ¶ added in v0.12.2
func GetAvailableZonesForSpec(ctx context.Context, specId string) (*model.AvailableZonesInfo, *model.AvailableZonesError)
GetAvailableZonesForSpec queries available (verified) zones for a specific spec ID It uses connection configs to determine which zones are verified and available. For Alibaba Cloud, it additionally filters zones using CSP API to check spec availability.
Parameters:
- ctx: Request context (contains credential holder info)
- specId: TB spec ID (format: provider+region+cspSpecName)
Returns:
- *model.AvailableZonesInfo: Success result with available zones (nil if error)
- *model.AvailableZonesError: Error result with details (nil if success)
func GetCspResourceId ¶
GetCspResourceId is func to retrieve CSP native resource ID (SystemId)
func GetCspResourceName ¶ added in v0.9.10
GetCspResourceName is func to retrieve CSP native resource ID
func GetCspResourceStatus ¶ added in v0.11.3
func GetCspResourceStatus(connConfig string, resourceType string, filter ...ResourceStatusFilter) (model.CspResourceStatusResponse, error)
GetCspResourceStatus returns Mapped/SpiderOnly/CspOnly resource lists from CB-Spider. Pass a ResourceStatusFilter to scope child resources to a specific parent (e.g., VPC NameId when querying StrSubnet).
func GetCspResourceStatusBatch ¶ added in v0.11.3
func GetCspResourceStatusBatch(connConfig string, resourceTypes []string) (map[string]model.CspResourceStatusResponse, error)
GetCspResourceStatusBatch retrieves resource status for multiple resource types in a single connection
This is a convenience function that calls GetCspResourceStatus for multiple resource types and returns a map of results. This is useful when you need to check multiple resource types for the same connection configuration.
Parameters:
- connConfig: Connection configuration name for the target CSP
- resourceTypes: List of resource types to query
Returns:
- map[string]model.CspResourceStatusResponse: Map of resource type to response
- error: Error if any of the operations fail (returns first error encountered)
Example usage:
resourceTypes := []string{model.StrNode, model.StrVNet, model.StrSecurityGroup}
responses, err := GetCspResourceStatusBatch("aws-connection", resourceTypes)
if err != nil {
log.Error().Err(err).Msg("Failed to get batch CSP resource status")
return err
}
for resourceType, response := range responses {
fmt.Printf("%s: %s\n", resourceType, response.SystemMessage)
}
func GetDataObject ¶ added in v0.12.2
GetDataObject retrieves a specific object from the specified object storage (bucket)
func GetFirstNZones ¶ added in v0.9.10
GetFirstNZones returns the first N zones of the given connection
func GetGlobalDnsRecord ¶ added in v0.12.4
func GetGlobalDnsRecord(ctx context.Context, domainName string, recordName string, recordType string) (model.RestGetGlobalDnsRecordResponse, error)
GetGlobalDnsRecord lists DNS records from Route53
func GetIdFromStruct ¶
GetIdFromStruct accepts any struct for argument, and returns value of the field 'Id'
func GetImage ¶
GetImage retrieves an image by namespace and CSP image name, with process-level caching.
func GetImageByPrimaryKey ¶ added in v0.10.7
func GetImageByPrimaryKey(nsId string, provider string, cspImageName string) (model.ImageInfo, error)
GetImageByPrimaryKey retrieves image information based on namespace, provider, and CSP image name
func GetImageInfoFromLookupImage ¶ added in v0.9.16
func GetImageInfoFromLookupImage(nsId string, u model.ImageReq, allowCustomImage ...bool) (model.ImageInfo, error)
GetImageInfoFromLookupImage looks up image from Spider and converts to TumblebugImage allowCustomImage: if false, only looks up public images (used for enrichment); if true, also checks custom images
func GetImagesByRegion ¶ added in v0.10.7
GetImagesByRegion retrieves images based on namespace, provider, and region
func GetK8sCluster ¶
func GetK8sCluster(nsId string, k8sClusterId string) (*model.K8sClusterInfo, error)
GetK8sCluster retrives a k8s cluster information
func GetK8sClusterKubeconfig ¶ added in v0.12.6
func GetK8sClusterKubeconfig(nsId string, k8sClusterId string) (*model.K8sClusterKubeconfigResponse, error)
GetK8sClusterKubeconfig resolves nsId/k8sClusterId and returns a CSP native kubeconfig.
func GetK8sClusterToken ¶ added in v0.12.3
func GetK8sClusterToken(nsId string, k8sClusterId string) (*model.K8sClusterTokenResponse, error)
GetK8sClusterToken resolves nsId/k8sClusterId to CspResourceName/ConnectionName and returns an access token.
func GetNameFromStruct ¶
GetNameFromStruct accepts any struct for argument, and returns value of the field 'Name'
func GetObjectStorage ¶ added in v0.10.2
func GetObjectStorage(nsId, osId string) (model.ObjectStorageInfo, error)
GetObjectStorage retrieves the object storage (bucket) information from the specified namespace
func GetObjectStorageCorsConfigurations ¶ added in v0.12.2
func GetObjectStorageCorsConfigurations(nsId, osId string) (model.ObjectStorageGetCorsResponse, error)
GetObjectStorageCorsConfigurations retrieves the CORS configuration for the specified object storage (bucket)
func GetObjectStorageLocation ¶ added in v0.12.2
func GetObjectStorageLocation(nsId, osId string) (model.ObjectStorageLocationResponse, error)
GetObjectStorageLocation retrieves the location of the specified object storage (bucket)
func GetObjectStorageSupport ¶ added in v0.12.3
func GetObjectStorageSupport(cspType string) (model.ObjectStorageSupportResponse, error)
GetObjectStorageSupport retrieves the CSP support information for object storage features If cspType is provided, it returns support information for that specific CSP If cspType is empty, it returns support information for all CSPs
func GetObjectStorageVersioning ¶ added in v0.12.2
func GetObjectStorageVersioning(nsId, osId string) (model.ObjectStorageGetVersioningResponse, error)
GetObjectStorageVersioning retrieves the versioning configuration for the specified object storage (bucket)
func GetProviderRegionZoneResourceKey ¶
func GetProviderRegionZoneResourceKey(providerName, regionName, zoneName, resourceName string) string
GenResourceKey generates a Resource key for concatenating providerName, regionName, zoneName, resourceName
func GetRequestStatusOfSiteToSiteVpn ¶ added in v0.9.22
func GetRequestStatusOfSiteToSiteVpn(ctx context.Context, nsId string, infraId string, vpnId string, reqId string) (model.Response, error)
GetRequestStatusOfSiteToSiteVpn returns the status of a site-to-site VPN request
func GetRequestStatusOfSqlDB ¶ added in v0.10.2
GetRequestStatusOfSqlDB checks the status of a specific request
func GetResource ¶
GetResource returns the requested TB Resource object
func GetSecurityGroup ¶ added in v0.11.2
func GetSecurityGroup(nsId string, securityGroupId string) (model.SecurityGroupInfo, error)
GetSecurityGroup retrieves a security group object from the key-value store
func GetSiteToSiteVPN ¶ added in v0.9.22
func GetSiteToSiteVPN(ctx context.Context, nsId string, infraId string, vpnId string, detail string, refresh bool) (model.VpnInfo, error)
GetSiteToSiteVPN returns a site-to-site VPN via Terrarium
func GetSpec ¶
GetSpec accepts namespace Id and specKey(Id,CspResourceName,...), and returns the TB spec object
func HandleK8sClusterAction ¶ added in v0.10.0
HandleK8sClusterAction is func to handle actions to K8sCluster
func ImageReqStructLevelValidation ¶ added in v0.11.9
func ImageReqStructLevelValidation(sl validator.StructLevel)
ImageReqStructLevelValidation func is for Validation
func IsAvailableForUseInCSP ¶ added in v0.10.7
func IsValidCspForSqlDB ¶ added in v0.10.1
func IsValidCspPairForVpn ¶ added in v0.10.7
func K8sClusterReqStructLevelValidation ¶ added in v0.11.9
func K8sClusterReqStructLevelValidation(sl validator.StructLevel)
K8sClusterReqStructLevelValidation is a function to validate 'model.K8sClusterReq' object.
func ListDataObjects ¶ added in v0.12.2
func ListDataObjects(nsId, osId string) (model.ObjectStorageListObjectsResponse, error)
ListDataObjects lists the objects in the specified object storage (bucket)
func ListHostedZones ¶ added in v0.12.4
func ListHostedZones(ctx context.Context) (model.RestGetHostedZonesResponse, error)
ListHostedZones returns all hosted zones from Route53
func ListK8sCluster ¶
ListK8sCluster returns the list of TB K8sCluster objects of given nsId
func ListK8sClusterId ¶
ListK8sClusterId returns the list of TB K8sCluster object IDs of given nsId
func ListObjectVersions ¶ added in v0.12.2
func ListObjectVersions(nsId, osId string) (model.ObjectStorageListObjectVersionsResponse, error)
ListObjectVersions lists the versions of objects in the specified object storage (bucket)
func ListResource ¶
func ListResource(nsId string, resourceType string, filterKey string, filterVal string) (any, error)
ListResource returns the list of TB Resource objects of given resourceType
func ListResourceId ¶
ListResourceId returns the list of TB Resource object IDs of given resourceType
func ListSubnet ¶ added in v0.9.9
func ListSubnet(nsId string, vNetId string) ([]model.SubnetInfo, error)
ListSubnet
func LoadAssets ¶ added in v0.9.10
LoadAssets is to register common resources from asset files (../assets/*.csv) includeAzure: if true, Azure images will be fetched (may take 40+ minutes)
func LookupImage ¶
func LookupImage(connConfig string, imageId string) (model.SpiderImageInfo, error)
LookupImage accepts Spider conn config and CSP image ID, lookups and returns the Spider image object If the regular image lookup fails, it checks for custom images in the database
func LookupImageList ¶
func LookupImageList(connConfigName string) (model.SpiderImageList, error)
LookupImageList accepts Spider conn config, lookups and returns the list of all images in the region of conn config in the form of the list of Spider image objects
func LookupMyImage ¶
func LookupMyImage(connConfig string, myImageId string) (model.SpiderMyImageInfo, error)
LookupMyImage accepts Spider conn config and CSP myImage ID, lookups and returns the Spider image object
func LookupPriceList ¶ added in v0.10.7
func LookupPriceList(connConfig model.ConnConfig) (model.SpiderCloudPrice, error)
LookupPriceList returns the list of all prices in the region of conn config in the form of the list of Spider price objects
func LookupPublicImageOnly ¶ added in v0.12.6
func LookupPublicImageOnly(connConfig string, imageId string) (model.SpiderImageInfo, error)
LookupPublicImageOnly accepts Spider conn config and CSP image ID, lookups public image only (no custom image fallback) Used for enrichment during asset loading to avoid unnecessary custom image checks For Azure, uses direct Azure SDK instead of Spider API
func LookupSpec ¶
func LookupSpec(connConfig string, specName string) (model.SpiderSpecInfo, error)
LookupSpec accepts Spider conn config and CSP spec name, lookups and returns the Spider spec object
func LookupSpecList ¶
func LookupSpecList(connConfig string) (model.SpiderSpecList, error)
LookupSpecList accepts Spider conn config, lookups and returns the list of all specs in the region of conn config in the form of the list of Spider spec objects
func MapSpiderToTumblebugImageStatus ¶ added in v0.12.3
func MapSpiderToTumblebugImageStatus(spiderStatus string) model.ImageStatus
MapSpiderToTumblebugImageStatus maps CB-Spider's image status to CB-Tumblebug's enhanced status CB-Spider only returns "Available" or "Unavailable", but CB-Tumblebug needs more granular states Exported for use by other packages (e.g., infra/snapshot.go)
func PollResourceDeletedViaSpider ¶ added in v0.12.10
func PollResourceDeletedViaSpider(getURL string, headers map[string]string, maxAttempts int, interval time.Duration) (deleted bool, verifyErr error)
PollResourceDeletedViaSpider polls Spider GET (query-param ConnectionName) up to maxAttempts×interval to confirm deletion. Handles GCP anomaly (200+Result:false → deleted) and eventual consistency. Returns: (true,nil) confirmed | (false,nil) still exists | (false,err) inconclusive.
func ReconcileObjectStorage ¶ added in v0.12.9
func ReconcileObjectStorage(nsId, osId string) (model.ObjectStorageReconcileResponse, error)
ReconcileObjectStorage repairs discrepancies between Tumblebug metadata and the actual CSP resource:
- Uid empty (CSP resource never created) → orphaned metadata removed.
- Uid set but CSP bucket missing → orphaned metadata removed.
- CSP bucket exists and metadata stuck in Failed(DeletionFailed) → status restored to Available.
Otherwise returns "NoActionNeeded".
func ReconcileSiteToSiteVPN ¶ added in v0.12.10
func ReconcileSiteToSiteVPN(ctx context.Context, nsId, infraId, vpnId string) (model.VpnReconcileResponse, error)
ReconcileSiteToSiteVPN checks for discrepancies between Tumblebug VPN metadata and the actual Terrarium resource, then takes corrective action:
- If the Terrarium resource no longer exists, orphaned metadata is removed.
- If the Terrarium resource exists but the metadata is stuck in a terminal-failure state (Ready=False with Reason ∈ {DeletionFailed, DeregisterFailed}), the status is restored to Available.
In-flight states (Creating, Deleting, etc.) and CreationFailed are intentionally not restored to avoid masking concurrent operations or partially-created resources.
func RegisterCustomImageWithId ¶
RegisterCustomImageWithId accepts customimage creation request, creates and returns an TB customimage object
func RegisterCustomImageWithInfo ¶
RegisterCustomImageWithInfo accepts customimage registration request, creates and returns an TB customimage object
func RegisterImageWithId ¶
func RegisterImageWithId(nsId string, u *model.ImageReq, update bool, RDBonly bool) (model.ImageInfo, error)
RegisterImageWithId accepts image creation request, creates and returns an TB image object
func RegisterImageWithInfo ¶
func RegisterImageWithInfo(nsId string, content *model.ImageInfo, update bool) (model.ImageInfo, error)
RegisterImageWithInfo accepts image creation request, creates and returns an TB image object
func RegisterImageWithInfoInBulk ¶ added in v0.9.16
RegisterImageWithInfoInBulk register a list of images in bulk
func RegisterSpecWithCspResourceId ¶ added in v0.9.10
func RegisterSpecWithCspResourceId(nsId string, u *model.SpecReq, update bool) (model.SpecInfo, error)
RegisterSpecWithCspResourceId accepts spec creation request, creates and returns an TB spec object
func RegisterSpecWithInfo ¶
func RegisterSpecWithInfo(nsId string, content *model.SpecInfo, update bool) (model.SpecInfo, error)
RegisterSpecWithInfo accepts spec creation request, creates and returns an TB spec object
func RegisterSpecWithInfoInBulk ¶ added in v0.9.16
RegisterSpecWithInfoInBulk register a list of specs in bulk
func RegisterSubnet ¶ added in v0.9.9
func RegisterSubnet(ctx context.Context, nsId string, vNetId string, subnetReq *model.RegisterSubnetReq) (model.SubnetInfo, error)
func RegisterVNet ¶ added in v0.9.9
func RegisterVNet(ctx context.Context, nsId string, vNetRegisterReq *model.RegisterVNetReq) (model.VNetInfo, error)
RegisterVNet accepts vNet registration request, register and returns an TB vNet object
func RemoteCommandToK8sClusterContainer ¶ added in v0.10.4
func RemoteCommandToK8sClusterContainer(nsId string, k8sClusterId string, k8sClusterNamespace string, k8sClusterPodName string, k8sClusterContainerName string, req *model.K8sClusterContainerCmdReq) (*model.K8sClusterContainerCmdResults, error)
RemoteCommandToK8sClusterContainer is func to command to specified Container in K8sCluster by Kubernetes API
func RemoveDuplicateImagesInSQL ¶ added in v0.9.16
func RemoveDuplicateImagesInSQL() error
RemoveDuplicateImagesInSQL is to remove duplicate images in db to refine batch insert duplicates
func RemoveDuplicateSpecsInSQL ¶ added in v0.9.16
func RemoveDuplicateSpecsInSQL() error
RemoveDuplicateSpecsInSQL is to remove duplicate specs in db to refine batch insert duplicates
func RemoveK8sNodeGroup ¶
RemoveK8sNodeGroup removes a specified NodeGroup
func ResolveLatestCspImageNameForVMCreation ¶ added in v0.12.7
func ResolveLatestCspImageNameForVMCreation(ctx context.Context, nsId, connectionName, tumblebugImageId, cspImageName string) string
ResolveLatestCspImageNameForVMCreation is a convenience wrapper that takes a stored CSP image name, looks up the full ImageInfo, applies the provider- specific "latest image" resolution via ResolveLatestImageForVMCreation, and returns the (possibly updated) CSP image name to use in the VM-creation request to cb-spider.
If the lookup fails, the original cspImageName is returned unchanged and no error is raised (the caller should already have validated the image via EnsureImageAvailable). Resolution failure is also non-fatal.
Used by K8s cluster/node-group creation paths where only the CSP image name string (not the full ImageInfo) is threaded into the Spider request.
func ResolveLatestImageForVMCreation ¶ added in v0.12.7
func ResolveLatestImageForVMCreation(ctx context.Context, connectionName string, imageInfo model.ImageInfo) model.ImageInfo
ResolveLatestImageForVMCreation performs CSP-specific "latest image" resolution for the given stored ImageInfo, right before the image is handed off to cb-spider for VM creation.
Currently implemented for Alibaba Cloud only: Alibaba deprecates individual image IDs (date-stamped builds) rapidly while the enclosing ImageFamily (e.g. "acs:ubuntu_22_04_x64") remains stable. This function extracts the family stored in imageInfo.Details, asks the Alibaba ECS API for the latest available image in that family, and returns an ImageInfo copy whose CspImageName is replaced with the resolved latest ID. All other fields are preserved. The DB record is NOT modified.
For other providers the input is returned unchanged.
Any resolution failure (missing family, missing region, API error, empty result) is non-fatal: the original imageInfo is returned so the caller can proceed with the stored ID. Observability is provided via logs.
Safe to call more than once per VM creation; resolution is short-circuited when the resolved ID equals the stored ID.
func ResolveProviderRegionZoneResourceKey ¶ added in v0.10.2
func ResolveProviderRegionZoneResourceKey(key string) (providerName string, regionName string, zoneName string, resourceName string, err error)
ResolveProviderRegionZoneResourceKey resolves the Resource key into providerName, regionName, zoneName, resourceName
func SearchImage ¶
func SearchImage(nsId string, req model.SearchImageRequest, isCustomImage bool) ([]model.ImageInfo, int, error)
SearchImage returns a list of images based on the search criteria
func SearchImageOptions ¶ added in v0.10.7
func SearchImageOptions() (model.SearchImageRequestOptions, error)
SearchImageOptions returns the available options for searching images
func SecurityGroupReqStructLevelValidation ¶ added in v0.11.9
func SecurityGroupReqStructLevelValidation(sl validator.StructLevel)
SecurityGroupReqStructLevelValidation is a function to validate 'SecurityGroupReq' object.
func SetK8sNodeGroupAutoscaling ¶
func SetK8sNodeGroupAutoscaling(nsId string, k8sClusterId string, k8sNodeGroupName string, u *model.SetK8sNodeGroupAutoscalingReq) (*model.SetK8sNodeGroupAutoscalingRes, error)
SetK8sNodeGroupAutoscaling set NodeGroup's Autoscaling On/Off
func SetObjectStorageCorsConfigurations ¶ added in v0.12.2
func SetObjectStorageCorsConfigurations(nsId, osId string, req model.ObjectStorageSetCorsRequest) error
SetObjectStorageCorsConfigurations sets the CORS configuration for the specified object storage (bucket)
func SetObjectStorageVersioning ¶ added in v0.12.2
func SetObjectStorageVersioning(nsId, osId string, req model.ObjectStorageSetVersioningRequest) error
SetObjectStorageVersioning sets the versioning configuration for the specified object storage (bucket)
func SpecReqStructLevelValidation ¶ added in v0.11.9
func SpecReqStructLevelValidation(sl validator.StructLevel)
SpecReqStructLevelValidation is a function to validate 'SpecReq' object.
func SshKeyReqStructLevelValidation ¶ added in v0.11.9
func SshKeyReqStructLevelValidation(sl validator.StructLevel)
SshKeyReqStructLevelValidation is a function to validate 'SshKeyReq' object.
func SubnetReqStructLevelValidation ¶ added in v0.11.9
func SubnetReqStructLevelValidation(sl validator.StructLevel)
SubnetReqStructLevelValidation is a function to validate 'SubnetReq' object.
func SyncVNetState ¶ added in v0.12.14
func SyncVNetState(nsId string, vNetInfo *model.VNetInfo, optPreloadedVNetStatus *model.CspResourceStatusResponse) (model.SimpleMsg, error)
SyncVNetState checks if the CSP/Spider VNet still exists and synchronizes metadata accordingly. Called exclusively by the reconciler, which guarantees nsId and vNetInfo are valid. optPreloadedVNetStatus: optional pre-fetched VNet status; if nil, will be fetched internally.
func ToNamingRuleCompatible ¶
ToNamingRuleCompatible function transforms a given string to match the regex pattern [a-z]([-a-z0-9]*[a-z0-9])?.
func TransferFileToK8sClusterContainer ¶ added in v0.10.7
func TransferFileToK8sClusterContainer(nsId string, k8sClusterId string, k8sClusterNamespace string, k8sClusterPodName string, k8sClusterContainerName string, fileData []byte, fileName, targetPath string) (*model.K8sClusterContainerCmdResult, error)
TransferFileToK8sClusterContainer is func to transfer a file to specified Container in K8sCluster by Kubernetes API
func UpdateAssociatedObjectList ¶
func UpdateAssociatedObjectList(nsId string, resourceType string, resourceId string, cmd string, objectKey string) ([]string, error)
UpdateAssociatedObjectList adds or deletes the objectKey (currently, nodeKey) to/from TB object's associatedObjectList
func UpdateExistingSpecListByAvailableRegionZones ¶ added in v0.11.9
func UpdateExistingSpecListByAvailableRegionZones(ctx context.Context, nsId string, provider string) (model.SpecCleanupResult, error)
UpdateExistingSpecListByAvailableRegionZones cleans up unavailable specs from the database Queries all specs for a specific provider across all regions, checks their availability, and removes specs that are not available in their respective regions
func UpdateFirewallRules ¶ added in v0.11.2
func UpdateFirewallRules(nsId string, securityGroupId string, desiredRules []model.FirewallRuleReq) (model.SecurityGroupUpdateResponse, error)
UpdateFirewallRules updates the firewall rules of a security group
func UpdateFirewallRulesBatch ¶ added in v0.11.2
func UpdateFirewallRulesBatch(nsId string, securityGroupIds []string, desiredRules []model.FirewallRuleReq) model.RestWrapperSecurityGroupUpdateResponse
UpdateFirewallRulesBatch updates firewall rules for multiple security groups
func UpdateGlobalDnsRecord ¶ added in v0.12.4
func UpdateGlobalDnsRecord(ctx context.Context, req *model.GlobalDnsRecordReq) (model.SimpleMsg, error)
UpdateGlobalDnsRecord updates a DNS record in Route53
func UpdateImage ¶
func UpdateImage(nsId string, imageId string, fieldsToUpdate model.ImageInfo, RDBonly bool) (model.ImageInfo, error)
UpdateImage accepts to-be TB image objects, updates and returns the updated TB image objects
func UpdateMultipleFirewallRules ¶ added in v0.11.2
func UpdateMultipleFirewallRules(nsId string, securityGroupIds []string, desiredRules []model.FirewallRuleReq) model.RestWrapperSecurityGroupUpdateResponse
UpdateMultipleFirewallRules updates firewall rules for multiple security groups with parallel processing
func UpdateResourceObject ¶
UpdateResourceObject is func to update the resource object
func UpdateSpec ¶
UpdateSpec accepts to-be TB spec objects, updates and returns the updated TB spec objects
func UpdateSpecsFromAsset ¶ added in v0.11.0
UpdateSpecsFromAsset updates spec information based on cloudspec.csv asset file
func UpdateSshKey ¶
func UpdateSshKey(nsId string, sshKeyId string, update model.SshKeyUpdateReq) (model.SshKeyInfo, error)
UpdateSshKey accepts to-be TB sshKey objects, updates and returns the updated TB sshKey objects
func UpgradeK8sCluster ¶
func UpgradeK8sCluster(ctx context.Context, nsId string, k8sClusterId string, u *model.UpgradeK8sClusterReq, skipVersionCheck bool) (*model.K8sClusterInfo, error)
UpgradeK8sCluster upgrades an existing k8s cluster to the specified version
func UpsizeDataDisk ¶
func UpsizeDataDisk(nsId string, resourceId string, u *model.DataDiskUpsizeReq) (model.DataDiskInfo, error)
UpsizeDataDisk accepts DataDisk upsize request, creates and returns an TB dataDisk object
func VNetReqStructLevelValidation ¶ added in v0.11.9
func VNetReqStructLevelValidation(sl validator.StructLevel)
VNetReqStructLevelValidation is a function to validate 'VNetReq' object.
func ValidateSubnetReq ¶ added in v0.9.9
func ValidateVNetReq ¶ added in v0.9.9
func WarmSpecNameCache ¶ added in v0.12.9
func WarmSpecNameCache(nsId, specId, cspSpecName string)
WarmSpecNameCache pre-populates the cache for a given namespace/specId with a known CspSpecName. Used by provisioning callers that resolve via a fallback namespace to avoid repeated miss queries.
Types ¶
type ConnectionImageResult ¶ added in v0.10.7
type ConnectionImageResult struct {
ConnName string `json:"connName"`
Provider string `json:"provider"`
Region string `json:"region"`
ImageCount int `json:"imageCount"`
StartTime time.Time `json:"startTime"`
ElapsedTime string `json:"elapsedTime"`
Success bool `json:"success"`
ErrorMsg string `json:"errorMsg,omitempty"`
}
ConnectionImageResult is the result of fetching images for a single connection
type ConnectionSpecResult ¶ added in v0.11.0
type ConnectionSpecResult struct {
ConnName string `json:"connName"`
Provider string `json:"provider"`
Region string `json:"region"`
SpecCount int `json:"specCount"`
StartTime time.Time `json:"startTime"`
ElapsedTime string `json:"elapsedTime"`
Success bool `json:"success"`
ErrorMsg string `json:"errorMsg,omitempty"`
}
ConnectionSpecResult is the result of fetching specs for a single connection
type FetchImagesAsyncResult ¶ added in v0.10.7
type FetchImagesAsyncResult struct {
NamespaceID string `json:"namespaceId"`
TotalRegions int `json:"totalRegions"`
FetchOption model.ImageFetchOption `json:"fetchOption"`
InProgress bool `json:"inProgress"`
RegisteredImages int `json:"registeredImages"`
SucceedRegions int `json:"succeedRegions"`
FailedRegions int `json:"failedRegions"`
StartTime time.Time `json:"startTime"`
ElapsedTime string `json:"elapsedTime"`
ResultInDetail []ConnectionImageResult `json:"resultInDetail"`
}
FetchImagesAsyncResult is the result of the most recent fetch images operation
func FetchImagesForAllConnConfigs ¶
func FetchImagesForAllConnConfigs(nsId string, option *model.ImageFetchOption) (*FetchImagesAsyncResult, error)
FetchImagesForAllConnConfigs fetches images synchronously for all connection configs
func GetFetchImagesAsyncResult ¶ added in v0.10.7
func GetFetchImagesAsyncResult(nsId string) (*FetchImagesAsyncResult, error)
GetFetchImagesAsyncResult returns the result of the most recent fetch images operation
func UpdateImagesFromAsset ¶ added in v0.10.7
func UpdateImagesFromAsset(nsId string) (*FetchImagesAsyncResult, error)
UpdateImagesFromAsset updates image information based on cloudimage.csv asset file
type FetchSpecsAsyncResult ¶ added in v0.11.0
type FetchSpecsAsyncResult struct {
NamespaceID string `json:"namespaceId"`
TotalRegions int `json:"totalRegions"`
FetchOption model.SpecFetchOption `json:"fetchOption"`
InProgress bool `json:"inProgress"`
RegisteredSpecs int `json:"registeredSpecs"`
SucceedRegions int `json:"succeedRegions"`
FailedRegions int `json:"failedRegions"`
StartTime time.Time `json:"startTime"`
ElapsedTime string `json:"elapsedTime"`
ResultInDetail []ConnectionSpecResult `json:"resultInDetail"`
}
FetchSpecsAsyncResult is the result of the most recent fetch specs operation
func FetchSpecsForAllConnConfigs ¶
func FetchSpecsForAllConnConfigs(nsId string, option *model.SpecFetchOption) (*FetchSpecsAsyncResult, error)
FetchSpecsForAllConnConfigs synchronously fetches specs for all connection configs in the namespace
func GetFetchSpecsAsyncResult ¶ added in v0.11.0
func GetFetchSpecsAsyncResult(nsId string) (*FetchSpecsAsyncResult, error)
GetFetchSpecsAsyncResult returns the result of the most recent fetch specs operation
type IdNameOnly ¶
type NetworkAction ¶ added in v0.9.15
type NetworkAction string
const ( ActionNone NetworkAction = "" ActionReconcile NetworkAction = "reconcile" ActionForce NetworkAction = "force" ActionWithSubnets NetworkAction = "withsubnets" )
func ParseNetworkAction ¶ added in v0.9.15
func ParseNetworkAction(s string) (NetworkAction, bool)
func (NetworkAction) IsValidToDeleteSubnet ¶ added in v0.9.15
func (na NetworkAction) IsValidToDeleteSubnet() bool
func (NetworkAction) IsValidToDeleteVNet ¶ added in v0.9.15
func (na NetworkAction) IsValidToDeleteVNet() bool
func (NetworkAction) String ¶ added in v0.9.15
func (na NetworkAction) String() string
type ObjectStorageVersioningOption ¶ added in v0.12.2
type ObjectStorageVersioningOption string
const ( ObjectStorageVersioningEnabled ObjectStorageVersioningOption = "Enabled" // Versioning is enabled for the object storage. ObjectStorageVersioningSuspended ObjectStorageVersioningOption = "Suspended" // Versioning is suspended for the object storage. ObjectStorageVersioningUnversioned ObjectStorageVersioningOption = "Unversioned" // Versioning is not enabled for the object storage. )
type ResourceStatusFilter ¶ added in v0.12.14
type ResourceStatusFilter struct {
// ParentResourceId is the parent's Spider NameId (e.g., VPC NameId for StrSubnet).
// Empty means no scoping.
ParentResourceId string
}
ResourceStatusFilter scopes GetCspResourceStatus to a specific parent resource.
type SharedResourceOptions ¶ added in v0.12.2
type SharedResourceOptions struct {
// If specified, the subnet will be created in this zone.
// Useful for GPU VMs or other resources only available in specific zones.
// If empty, auto-selection based on connection config applies.
Zone string
// If empty, defaults to model.DefaultCredentialHolder ("admin").
CredentialHolder string
// of the default hard-coded CIDR generation. If the template is not found, falls back
// to the default behavior.
VNetTemplateId string
// instead of the default all-open firewall rules. If the template is not found, falls
// back to the default behavior.
SgTemplateId string
}
SharedResourceOptions contains optional parameters for creating shared resources
type SqlDBAction ¶ added in v0.10.1
type SqlDBAction string
type SqlDBStatus ¶ added in v0.10.1
type SqlDBStatus string
SqlDBStatus represents the status of a network resource.
const ( // CRUD operations SqlDBOnConfiguring SqlDBStatus = "Configuring" // Resources are being configured. // SqlDBOnReading SqlDBStatus = "Reading" // The network information is being read. // SqlDBOnUpdating SqlDBStatus = "Updating" // The network is being updated. SqlDBOnDeleting SqlDBStatus = "Deleting" // The network is being deleted. // NetworkAvailable status SqlDBAvailable SqlDBStatus = "Available" // The network is fully created and ready for use. )