resource

package
v0.11.11 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: Apache-2.0 Imports: 46 Imported by: 0

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddK8sNodeGroup

func AddK8sNodeGroup(nsId string, k8sClusterId string, u *model.K8sNodeGroupReq) (*model.K8sClusterInfo, error)

AddK8sNodeGroup adds a K8sNodeGroup

func BulkUpdateSpec added in v0.10.10

func BulkUpdateSpec(nsId string, updates map[string]float32) (int, error)

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.StrVM, 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.StrVM, "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 CheckK8sCluster

func CheckK8sCluster(nsId string, k8sClusterId string) (bool, error)

CheckK8sCluster returns the existence of the TB K8sCluster object in bool form.

func CheckResource

func CheckResource(nsId string, resourceType string, resourceId string) (bool, error)

CheckResource returns the existence of the TB Resource resource in bool form.

func ContainsZone added in v0.9.9

func ContainsZone(zones []string, zone string) bool

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(spiderMyImage model.SpiderMyImageInfo) (model.CustomImageInfo, 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(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(nsId string, req *model.K8sClusterReq, option string) (*model.K8sClusterInfo, error)

CreateK8sCluster create a k8s cluster

func CreateSecurityGroup

func CreateSecurityGroup(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(nsId string, resType string, connectionName string) error

CreateSharedResource is to register default resource from asset files (../assets/*.csv)

func CreateSiteToSiteVPN added in v0.9.22

func CreateSiteToSiteVPN(nsId string, mciId 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(nsId string, sqlDbReq *model.RestPostSqlDBRequest, retry string) (model.SqlDBInfo, error)

CreateSqlDB creates a SQL database via Terrarium

func CreateSshKey

func CreateSshKey(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(nsId string, vNetId string, subnetReq *model.SubnetReq) (model.SubnetInfo, error)

CreateSubnet creates and returns the vNet object

func CreateVNet

func CreateVNet(nsId string, vNetReq *model.VNetReq) (model.VNetInfo, error)

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.IdList, error)

DelAllResources deletes all TB Resource objects of the given resourceType.

func DelEleInSlice

func DelEleInSlice(arr interface{}, index int)

DelEleInSlice delete an element from slice by index

  • arr: the reference of slice
  • index: the index of element will be deleted

func DelResource

func DelResource(nsId string, resourceType string, resourceId string, forceFlag string) error

DelResource deletes the TB Resource object

func DeleteAllK8sCluster

func DeleteAllK8sCluster(nsId, subString, option string) (*model.IdList, error)

DeleteAllK8sCluster deletes all clusters

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 DeleteK8sCluster

func DeleteK8sCluster(nsId, k8sClusterId, option string) (bool, error)

DeleteK8sCluster deletes a k8s cluster

func DeleteSharedResources added in v0.11.2

func DeleteSharedResources(nsId string) (model.IdList, error)

DeleteSharedResources deletes all Default securityGroup, sshKey, vNet objects

func DeleteSiteToSiteVPN added in v0.9.22

func DeleteSiteToSiteVPN(nsId string, mciId string, vpnId string) (model.SimpleMsg, error)

DeleteSiteToSiteVPN deletes a site-to-site VPN via Terrarium

func DeleteSqlDB added in v0.10.2

func DeleteSqlDB(nsId string, sqlDbId string) (model.SimpleMsg, error)

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

func DeleteVNet(nsId string, vNetId string, actionParam string) (model.SimpleMsg, error)

DeleteVNet accepts vNet creation request, creates and returns an TB vNet object

func DeregisterSubnet added in v0.9.9

func DeregisterSubnet(nsId string, vNetId string, subnetId string) (model.SimpleMsg, error)

DeregisterSubnet deregister subnet and returns the result

func DeregisterVNet added in v0.9.9

func DeregisterVNet(nsId string, vNetId string, withSubnets string) (model.SimpleMsg, error)

DeregisterVNet accepts vNet unregistration request, deregister and returns the result

func DesignVNets added in v0.9.10

DesignVNets accepts a VNet design request, designs and returns a VNet design response

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

func FetchImagesForConnConfig(connConfig string, nsId string) (imageCount uint, err error)

FetchImagesForConnConfig gets lookups all images for the region of conn config, and saves into TB image objects

func FetchPriceForAllConnConfigs added in v0.10.7

func FetchPriceForAllConnConfigs() (connConfigCount uint, priceCount uint, err error)

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

func FetchSpecsForConnConfig(connConfigName string, nsId string) (uint, error)

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 GenSpecMapKey

func GenSpecMapKey(region, specName string) string

GenSpecMapKey generates a SpecMap key for storing or accessing data in a map

func GetAllIDsOfSiteToSiteVPN added in v0.9.22

func GetAllIDsOfSiteToSiteVPN(nsId string, mciId string) (model.VpnIdList, error)

GetAllIDsOfSiteToSiteVPN returns a list of site-to-site VPN IDs

func GetAllSiteToSiteVPN added in v0.9.22

func GetAllSiteToSiteVPN(nsId string, mciId string) (model.VpnInfoList, error)

GetSiteToSiteVPN returns a site-to-site VPN

func GetAssociatedObjectCount

func GetAssociatedObjectCount(nsId string, resourceType string, resourceId string) (int, error)

GetAssociatedObjectCount returns the number of Resource's associated Tumblebug objects

func GetAssociatedObjectList

func GetAssociatedObjectList(nsId string, resourceType string, resourceId string) ([]string, error)

GetAssociatedObjectList returns the list of Resource's associated Tumblebug objects

func GetAvailableRegionZonesForSpec added in v0.11.9

func GetAvailableRegionZonesForSpec(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

func GetAvailableRegionZonesForSpecList added in v0.11.9

func GetAvailableRegionZonesForSpecList(provider string, cspSpecNames []string) (model.SpecAvailabilityBatchResult, error)

GetAvailableRegionZonesForSpecList queries availability for multiple specs in parallel Returns batch results with performance metrics for all specs

func GetCspResourceId

func GetCspResourceId(nsId string, resourceType string, resourceId string) (string, error)

GetCspResourceId is func to retrieve CSP native resource ID (SystemId)

func GetCspResourceName added in v0.9.10

func GetCspResourceName(nsId string, resourceType string, resourceId string) (string, error)

GetCspResourceName is func to retrieve CSP native resource ID

func GetCspResourceStatus added in v0.11.3

func GetCspResourceStatus(connConfig string, resourceType string) (model.CspResourceStatusResponse, error)

GetCspResourceStatus retrieves resource status from CB-Spider for a specific connection and resource type

This function queries CB-Spider to get comprehensive resource information including: - Resources managed by both Tumblebug and Spider (MappedList) - Resources only managed by Spider (OnlySpiderList) - Resources only existing in CSP (OnlyCSPList)

Parameters:

  • connConfig: Connection configuration name for the target CSP
  • resourceType: Type of resource to query (e.g., model.StrVM, model.StrVNet, etc.)

Returns:

  • model.CspResourceStatusResponse: Structured response containing resource lists and metadata
  • error: Error if the operation fails

Example usage:

response, err := GetCspResourceStatus("aws-connection", model.StrVM)
if err != nil {
    log.Error().Err(err).Msg("Failed to get CSP resource status")
    return err
}

fmt.Printf("Found %d VMs mapped in Spider\n", len(response.AllList.MappedList))
fmt.Printf("Found %d VMs only in CSP\n", len(response.AllList.OnlyCSPList))

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.StrVM, 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 GetFirstNZones added in v0.9.10

func GetFirstNZones(connectionName string, firstN int) ([]string, int, error)

GetFirstNZones returns the first N zones of the given connection

func GetIdFromStruct

func GetIdFromStruct(u interface{}) (string, error)

GetIdFromStruct accepts any struct for argument, and returns value of the field 'Id'

func GetImage

func GetImage(nsId string, cspImageName string) (model.ImageInfo, error)

GetImage accepts namespace Id and imageKey(CspImageName), and returns the TB image object

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) (model.ImageInfo, error)

GetImageInfoFromLookupImage

func GetImagesByRegion added in v0.10.7

func GetImagesByRegion(nsId string, provider string, region string) ([]model.ImageInfo, error)

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 GetNameFromStruct

func GetNameFromStruct(u interface{}) (string, error)

GetNameFromStruct accepts any struct for argument, and returns value of the field 'Name'

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(nsId string, mciId string, vpnId string, reqId string) (model.Response, error)

GetRequestStatusOfSiteToSiteVpn checks the status of a specific request

func GetRequestStatusOfSqlDB added in v0.10.2

func GetRequestStatusOfSqlDB(nsId string, sqlDbId string, reqId string) (model.Response, error)

GetRequestStatusOfSqlDB checks the status of a specific request

func GetResource

func GetResource(nsId string, resourceType string, resourceId string) (interface{}, error)

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(nsId string, mciId string, vpnId string, detail string) (model.VpnInfo, error)

GetSiteToSiteVPN returns a site-to-site VPN via Terrarium

func GetSpec

func GetSpec(nsId string, specKey string) (model.SpecInfo, error)

GetSpec accepts namespace Id and specKey(Id,CspResourceName,...), and returns the TB spec object

func GetSqlDB added in v0.10.2

func GetSqlDB(nsId string, sqlDbId string, detail string) (model.SqlDBInfo, error)

GetSqlDB returns a SQL DB via Terrarium

func GetSubnet added in v0.9.9

func GetSubnet(nsId string, vNetId string, subnetId string) (model.SubnetInfo, error)

GetSubnet

func GetVNet added in v0.9.9

func GetVNet(nsId string, vNetId string) (model.VNetInfo, error)

func HandleK8sClusterAction added in v0.10.0

func HandleK8sClusterAction(nsId string, k8sClusterId string, action string) (string, error)

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 IsAvailableForUseInCSP(vNetReq *model.VNetReq, provider string) (bool, error)

func IsValidCspForSqlDB added in v0.10.1

func IsValidCspForSqlDB(csp string) (bool, error)

func IsValidCspPairForVpn added in v0.10.7

func IsValidCspPairForVpn(csp1, csp2 string) (bool, error)

func K8sClusterReqStructLevelValidation added in v0.11.9

func K8sClusterReqStructLevelValidation(sl validator.StructLevel)

K8sClusterReqStructLevelValidation is a function to validate 'model.K8sClusterReq' object.

func ListK8sCluster

func ListK8sCluster(nsId string, filterKey string, filterVal string) (interface{}, error)

ListK8sCluster returns the list of TB K8sCluster objects of given nsId

func ListK8sClusterId

func ListK8sClusterId(nsId string) ([]string, error)

ListK8sClusterId returns the list of TB K8sCluster object IDs of given nsId

func ListResource

func ListResource(nsId string, resourceType string, filterKey string, filterVal string) (interface{}, error)

ListResource returns the list of TB Resource objects of given resourceType

func ListResourceId

func ListResourceId(nsId string, resourceType string) ([]string, error)

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

func LoadAssets() (*model.IdList, error)

LoadAssets is to register common resources from asset files (../assets/*.csv)

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

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 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 RefineSubnet added in v0.9.15

func RefineSubnet(nsId string, vNetId string, subnetId string) (model.SimpleMsg, error)

func RefineVNet added in v0.9.15

func RefineVNet(nsId string, vNetId string) (model.SimpleMsg, error)

func RegisterCustomImageWithId

func RegisterCustomImageWithId(nsId string, u *model.CustomImageReq) (model.CustomImageInfo, error)

RegisterCustomImageWithId accepts customimage creation request, creates and returns an TB customimage object

func RegisterCustomImageWithInfo

func RegisterCustomImageWithInfo(nsId string, content model.CustomImageInfo) (model.CustomImageInfo, error)

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

func RegisterImageWithInfoInBulk(imageList []model.ImageInfo) error

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

func RegisterSpecWithInfoInBulk(specList []model.SpecInfo) error

RegisterSpecWithInfoInBulk register a list of specs in bulk

func RegisterSubnet added in v0.9.9

func RegisterSubnet(nsId string, vNetId string, subnetReq *model.RegisterSubnetReq) (model.SubnetInfo, error)

func RegisterVNet added in v0.9.9

func RegisterVNet(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

func RemoveK8sNodeGroup(nsId, k8sClusterId, k8sNodeGroupName, option string) (bool, error)

RemoveK8sNodeGroup removes a specified NodeGroup

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) ([]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 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 ToNamingRuleCompatible

func ToNamingRuleCompatible(rawName string) string

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, vmKey) to/from TB object's associatedObjectList

func UpdateExistingSpecListByAvailableRegionZones added in v0.11.9

func UpdateExistingSpecListByAvailableRegionZones(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 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

func UpdateResourceObject(nsId string, resourceType string, resourceObject interface{})

UpdateResourceObject is func to update the resource object

func UpdateSpec

func UpdateSpec(nsId string, specId string, fieldsToUpdate model.SpecInfo) (model.SpecInfo, error)

UpdateSpec accepts to-be TB spec objects, updates and returns the updated TB spec objects

func UpdateSpecsFromAsset added in v0.11.0

func UpdateSpecsFromAsset(nsId string) error

UpdateSpecsFromAsset updates spec information based on cloudspec.csv asset file

func UpdateSshKey

func UpdateSshKey(nsId string, sshKeyId string, fieldsToUpdate model.SshKeyInfo) (model.SshKeyInfo, error)

UpdateSshKey accepts to-be TB sshKey objects, updates and returns the updated TB sshKey objects

func UpgradeK8sCluster

func UpgradeK8sCluster(nsId string, k8sClusterId string, u *model.UpgradeK8sClusterReq) (*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 ValidateSubnetReq(subnetReq *model.SubnetReq, existingVNet model.VNetInfo) error

func ValidateVNetReq added in v0.9.9

func ValidateVNetReq(vNetReq *model.VNetReq) error

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 DataDiskUpsizeReq added in v0.11.9

type DataDiskUpsizeReq struct {
	DiskSize    string `json:"diskSize" validate:"required"`
	Description string `json:"description"`
}

DataDiskUpsizeReq is a struct to handle 'Upsize dataDisk' request toward CB-Tumblebug.

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 IdNameOnly struct {
	Id   string
	Name string
}

type NetworkAction added in v0.9.15

type NetworkAction string
const (
	ActionNone        NetworkAction = ""
	ActionRefine      NetworkAction = "refine"
	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 NetworkStatus added in v0.9.9

type NetworkStatus string

NetworkStatus represents the status of a network resource.

const (

	// CRUD operations
	NetworkOnConfiguring NetworkStatus = "Configuring" // Resources are being configured.
	NetworkOnReading     NetworkStatus = "Reading"     // The network information is being read.
	NetworkOnUpdating    NetworkStatus = "Updating"    // The network is being updated.
	NetworkOnDeleting    NetworkStatus = "Deleting"    // The network is being deleted.

	// Register/deregister operations
	NetworkOnRegistering   NetworkStatus = "Registering"  // The network is being registered.
	NetworkOnDeregistering NetworkStatus = "Dergistering" // The network is being registered.

	// NetworkAvailable status
	NetworkAvailable NetworkStatus = "Available" // The network is fully created and ready for use.

	// In Use status
	NetworkInUse NetworkStatus = "InUse" // The network is currently in use.

	// Unknwon status
	NetworkUnknown NetworkStatus = "Unknown" // The network status is unknown.

	// NetworkError Handling
	NetworkError              NetworkStatus = "Error"              // An error occurred during a CRUD operation.
	NetworkErrorOnConfiguring NetworkStatus = "ErrorOnConfiguring" // An error occurred during the configuring operation.
	NetworkErrorOnReading     NetworkStatus = "ErrorOnReading"     // An error occurred during the reading operation.
	NetworkErrorOnUpdating    NetworkStatus = "ErrorOnUpdating"    // An error occurred during the updating operation.
	NetworkErrorOnDeleting    NetworkStatus = "ErrorOnDeleting"    // An error occurred during the deleting operation.
	NetworkErrorOnRegistering NetworkStatus = "ErrorOnRegistering" // An error occurred during the registering operation.
)

type Range

type Range struct {
	Min float32 `json:"min"`
	Max float32 `json:"max"`
}

Range struct is for 'FilterSpecsByRange'

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.

)

Jump to

Keyboard shortcuts

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