utils

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTreeStructure

func BuildTreeStructure(nodes []*model.TreeNode) []*model.TreeNode

BuildTreeStructure 构建树形结构

func DecryptPassword

func DecryptPassword(encryptedPassword string) (string, error)

DecryptPassword 解密密码

func EncryptPassword

func EncryptPassword(password string) (string, error)

EncryptPassword 加密密码

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 SetSSHDefaults

func SetSSHDefaults(port *int, username *string)

SetSSHDefaults 设置SSH连接的默认值

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 ValidateAndSetPaginationDefaults

func ValidateAndSetPaginationDefaults(page, size *int)

ValidateAndSetPaginationDefaults 验证并设置分页参数的默认值

func ValidateID

func ValidateID(id int) error

ValidateID 验证ID是否有效

func ValidateMemberType

func ValidateMemberType(memberType string) error

ValidateMemberType 验证成员类型

func ValidateNodeMove

func ValidateNodeMove(nodeID, newParentID int) error

ValidateNodeMove 验证节点移动操作

func ValidateParentID

func ValidateParentID(parentID int) error

ValidateParentID 验证父节点ID是否有效

func ValidateResourceIDs

func ValidateResourceIDs(resourceIDs []int) error

ValidateResourceIDs 验证资源ID列表

func ValidateTreeNodeIDs

func ValidateTreeNodeIDs(treeNodeIDs []int) bool

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 验证阿里云凭证

type AliyunSyncConfig

type AliyunSyncConfig struct {
	AccessKey      string
	SecretKey      string
	Region         string
	CloudAccountID int
	ResourceType   model.CloudResourceType
	InstanceIDs    []string
	SyncMode       model.SyncMode
}

AliyunSyncConfig 阿里云同步配置

Jump to

Keyboard shortcuts

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