Documentation
¶
Index ¶
- func BuildTreeStructure(nodes []*model.TreeNode) []*model.TreeNode
- func DecryptPassword(encryptedPassword string) (string, error)
- func EncryptPassword(password string) (string, error)
- func ExportAsCSV(accounts []*model.CloudAccount) [][]string
- func ExportAsJSON(accounts []*model.CloudAccount) interface{}
- func GetAvailableRegionsByProvider(ctx context.Context, provider model.CloudProvider, accessKey, secretKey string, ...) ([]model.AvailableRegion, error)
- func GetAvailableRegionsByProviderWithoutCredentials(provider model.CloudProvider) []model.AvailableRegion
- func GetDefaultRegion(regions []*model.CloudAccountRegion) (string, error)
- func GetProviderName(provider model.CloudProvider) string
- func SanitizeCloudAccount(account *model.CloudAccount)
- func SanitizeCloudAccounts(accounts []*model.CloudAccount)
- func SetSSHDefaults(port *int, username *string)
- func SyncAWSResources(ctx context.Context, req *model.SyncTreeCloudResourceReq, logger *zap.Logger) error
- func SyncAliyunResources(ctx context.Context, config *AliyunSyncConfig, logger *zap.Logger) ([]*model.TreeCloudResource, error)
- func SyncAzureResources(ctx context.Context, req *model.SyncTreeCloudResourceReq, logger *zap.Logger) error
- func SyncGCPResources(ctx context.Context, req *model.SyncTreeCloudResourceReq, logger *zap.Logger) error
- func SyncHuaweiResources(ctx context.Context, req *model.SyncTreeCloudResourceReq, logger *zap.Logger) error
- func SyncTencentResources(ctx context.Context, req *model.SyncTreeCloudResourceReq, logger *zap.Logger) error
- func ValidateAndNormalizeRegions(regions []model.CreateCloudAccountRegionItem) ([]model.CreateCloudAccountRegionItem, error)
- func ValidateAndSetPaginationDefaults(page, size *int)
- func ValidateID(id int) error
- func ValidateMemberType(memberType string) error
- func ValidateNodeMove(nodeID, newParentID int) error
- func ValidateParentID(parentID int) error
- func ValidateResourceIDs(resourceIDs []int) error
- func ValidateTreeNodeIDs(treeNodeIDs []int) bool
- func VerifyAWSCredentials(ctx context.Context, req *model.VerifyCloudCredentialsReq, logger *zap.Logger) error
- func VerifyAliyunCredentials(ctx context.Context, req *model.VerifyCloudCredentialsReq, logger *zap.Logger) error
- func VerifyAzureCredentials(ctx context.Context, req *model.VerifyCloudCredentialsReq, logger *zap.Logger) error
- func VerifyGCPCredentials(ctx context.Context, req *model.VerifyCloudCredentialsReq, logger *zap.Logger) error
- func VerifyHuaweiCredentials(ctx context.Context, req *model.VerifyCloudCredentialsReq, logger *zap.Logger) error
- func VerifyTencentCredentials(ctx context.Context, req *model.VerifyCloudCredentialsReq, logger *zap.Logger) error
- type AliyunClient
- func (c *AliyunClient) GetAvailableRegions(ctx context.Context) ([]model.AvailableRegion, error)
- func (c *AliyunClient) GetECSInstanceByID(ctx context.Context, instanceID string) (*model.TreeCloudResource, error)
- func (c *AliyunClient) ListECSInstances(ctx context.Context, instanceIDs []string) ([]*model.TreeCloudResource, error)
- func (c *AliyunClient) VerifyCredentials(ctx context.Context) error
- type AliyunSyncConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildTreeStructure ¶
BuildTreeStructure 构建树形结构
func DecryptPassword ¶
DecryptPassword 解密密码
func ExportAsCSV ¶ added in v0.0.20
func ExportAsCSV(accounts []*model.CloudAccount) [][]string
ExportAsCSV 导出为 CSV 格式
func ExportAsJSON ¶ added in v0.0.20
func ExportAsJSON(accounts []*model.CloudAccount) interface{}
ExportAsJSON 导出为 JSON 格式
func GetAvailableRegionsByProvider ¶ added in v0.0.17
func GetAvailableRegionsByProvider(ctx context.Context, provider model.CloudProvider, accessKey, secretKey string, logger *zap.Logger) ([]model.AvailableRegion, error)
GetAvailableRegionsByProvider 根据云厂商获取可用区域列表(通过API动态获取)
func GetAvailableRegionsByProviderWithoutCredentials ¶ added in v0.0.17
func GetAvailableRegionsByProviderWithoutCredentials(provider model.CloudProvider) []model.AvailableRegion
GetAvailableRegionsByProviderWithoutCredentials 获取云厂商可用区域列表(无需凭证,返回常用区域作为降级方案)
func GetDefaultRegion ¶ added in v0.0.20
func GetDefaultRegion(regions []*model.CloudAccountRegion) (string, error)
GetDefaultRegion 从云账户的区域列表中获取默认区域 返回默认区域的Region字符串,如果没有找到默认区域则返回第一个区域 如果区域列表为空,返回空字符串和错误
func GetProviderName ¶ added in v0.0.20
func GetProviderName(provider model.CloudProvider) string
GetProviderName 获取云厂商名称
func SanitizeCloudAccount ¶ added in v0.0.20
func SanitizeCloudAccount(account *model.CloudAccount)
SanitizeCloudAccount 清理云账户敏感信息(双重保险) 虽然AccessKey和SecretKey已经设置了json:"-"标签,但这个方法提供额外的安全保障
func SanitizeCloudAccounts ¶ added in v0.0.20
func SanitizeCloudAccounts(accounts []*model.CloudAccount)
SanitizeCloudAccounts 批量清理云账户敏感信息
func SyncAWSResources ¶
func SyncAWSResources(ctx context.Context, req *model.SyncTreeCloudResourceReq, logger *zap.Logger) error
SyncAWSResources 同步AWS资源
func SyncAliyunResources ¶
func SyncAliyunResources(ctx context.Context, config *AliyunSyncConfig, logger *zap.Logger) ([]*model.TreeCloudResource, error)
SyncAliyunResources 同步阿里云资源
func SyncAzureResources ¶
func SyncAzureResources(ctx context.Context, req *model.SyncTreeCloudResourceReq, logger *zap.Logger) error
SyncAzureResources 同步Azure资源
func SyncGCPResources ¶
func SyncGCPResources(ctx context.Context, req *model.SyncTreeCloudResourceReq, logger *zap.Logger) error
SyncGCPResources 同步GCP资源
func SyncHuaweiResources ¶
func SyncHuaweiResources(ctx context.Context, req *model.SyncTreeCloudResourceReq, logger *zap.Logger) error
SyncHuaweiResources 同步华为云资源
func SyncTencentResources ¶
func SyncTencentResources(ctx context.Context, req *model.SyncTreeCloudResourceReq, logger *zap.Logger) error
SyncTencentResources 同步腾讯云资源
func ValidateAndNormalizeRegions ¶ added in v0.0.20
func ValidateAndNormalizeRegions(regions []model.CreateCloudAccountRegionItem) ([]model.CreateCloudAccountRegionItem, error)
ValidateAndNormalizeRegions 验证和规范化区域列表 检查区域是否为空、是否重复、默认区域是否唯一 如果没有指定默认区域,会将第一个区域设置为默认 返回规范化后的区域列表(新切片),不修改传入的切片
func ValidateAndSetPaginationDefaults ¶
func ValidateAndSetPaginationDefaults(page, size *int)
ValidateAndSetPaginationDefaults 验证并设置分页参数的默认值
func ValidateMemberType ¶
ValidateMemberType 验证成员类型
func ValidateNodeMove ¶
ValidateNodeMove 验证节点移动操作
func ValidateResourceIDs ¶
ValidateResourceIDs 验证资源ID列表
func ValidateTreeNodeIDs ¶
ValidateTreeNodeIDs 验证树节点ID列表
func VerifyAWSCredentials ¶
func VerifyAWSCredentials(ctx context.Context, req *model.VerifyCloudCredentialsReq, logger *zap.Logger) error
VerifyAWSCredentials 验证AWS凭证
func VerifyAliyunCredentials ¶
func VerifyAliyunCredentials(ctx context.Context, req *model.VerifyCloudCredentialsReq, logger *zap.Logger) error
VerifyAliyunCredentials 验证阿里云凭证
func VerifyAzureCredentials ¶
func VerifyAzureCredentials(ctx context.Context, req *model.VerifyCloudCredentialsReq, logger *zap.Logger) error
VerifyAzureCredentials 验证Azure凭证
func VerifyGCPCredentials ¶
func VerifyGCPCredentials(ctx context.Context, req *model.VerifyCloudCredentialsReq, logger *zap.Logger) error
VerifyGCPCredentials 验证GCP凭证
func VerifyHuaweiCredentials ¶
func VerifyHuaweiCredentials(ctx context.Context, req *model.VerifyCloudCredentialsReq, logger *zap.Logger) error
VerifyHuaweiCredentials 验证华为云凭证
func VerifyTencentCredentials ¶
func VerifyTencentCredentials(ctx context.Context, req *model.VerifyCloudCredentialsReq, logger *zap.Logger) error
VerifyTencentCredentials 验证腾讯云凭证
Types ¶
type AliyunClient ¶
type AliyunClient struct {
// contains filtered or unexported fields
}
AliyunClient 阿里云客户端封装
func NewAliyunClient ¶
func NewAliyunClient(accessKey, secretKey, region string, logger *zap.Logger) (*AliyunClient, error)
NewAliyunClient 创建阿里云客户端
func (*AliyunClient) GetAvailableRegions ¶ added in v0.0.17
func (c *AliyunClient) GetAvailableRegions(ctx context.Context) ([]model.AvailableRegion, error)
GetAvailableRegions 获取阿里云所有可用区域列表
func (*AliyunClient) GetECSInstanceByID ¶
func (c *AliyunClient) GetECSInstanceByID(ctx context.Context, instanceID string) (*model.TreeCloudResource, error)
GetECSInstanceByID 根据实例ID获取单个ECS实例
func (*AliyunClient) ListECSInstances ¶
func (c *AliyunClient) ListECSInstances(ctx context.Context, instanceIDs []string) ([]*model.TreeCloudResource, error)
ListECSInstances 获取ECS实例列表
func (*AliyunClient) VerifyCredentials ¶
func (c *AliyunClient) VerifyCredentials(ctx context.Context) error
VerifyCredentials 验证阿里云凭证