client

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewK8SConfig

func NewK8SConfig() (c *k8sConfig)

func Set

func Set(key, value interface{}, exp time.Duration)

Set @Description 内存变量过期 类redis @param: key 变量名 @param: value 变量值 @param: exp 过期时间 @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/26 19:00

Types

type Annotations

type Annotations struct {
	AliasName   string `json:"kubesphere.io/alias-name"`
	Creator     string `json:"kubesphere.io/creator"`
	Description string `json:"kubesphere.io/description"`
}

type AppListResponse

type AppListResponse struct {
	Items []struct {
		Name    string `json:"name"`
		Cluster struct {
			AppId      string `json:"app_id"`
			ClusterId  string `json:"cluster_id"`
			CreateTime string `json:"create_time"`
			Env        string `json:"env"`
			Name       string `json:"name"`
			Owner      string `json:"owner"`
			RuntimeId  string `json:"runtime_id"`
			Status     string `json:"status"`
			StatusTime string `json:"status_time"`
			VersionId  string `json:"version_id"`
			Zone       string `json:"zone"`
		} `json:"cluster"`
		Version struct {
			AppId     string `json:"app_id"`
			Name      string `json:"name"`
			VersionId string `json:"version_id"`
		} `json:"version"`
		App struct {
			AppId       string `json:"app_id"`
			CategorySet string `json:"category_set"`
			ChartName   string `json:"chart_name"`
			Name        string `json:"name"`
		} `json:"app"`
	} `json:"items"`
	TotalCount int `json:"total_count"`
}

AppListResponse k8s应用列表

type AppRepoResponse

type AppRepoResponse struct {
	Items []struct {
		RepoId string `json:"repo_id"`
		Url    string `json:"url"`
	} `json:"items"`
	TotalCount int `json:"total_count"`
}

AppRepoResponse 应用列表

type ConfigMapMetadata

type ConfigMapMetadata struct {
	Annotations struct {
		KubesphereIoCreator string `json:"kubesphere.io/creator"`
	} `json:"annotations"`
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	Labels    struct {
	} `json:"labels"`
}

type CreateConfigMapRequest

type CreateConfigMapRequest struct {
	APIVersion        string `json:"apiVersion"`
	Kind              string `json:"kind"`
	ConfigMapMetadata `json:"metadata"`

	Spec struct {
		Template struct {
			Metadata struct {
				Labels struct {
				} `json:"labels"`
				Annotations struct {
					KubesphereIoCreator string `json:"kubesphere.io/creator"`
				} `json:"annotations"`
			} `json:"metadata"`
		} `json:"template"`
	} `json:"spec"`
	Data interface{} `json:"data"`
}

func NewCreateConfigMap

func NewCreateConfigMap(projectName string, data interface{}, configMapName string) (req CreateConfigMapRequest)

NewCreateConfigMap @Description 创建数据字典 @params projectName string 项目名称 @params data string 数据字典的值 @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/26 19:48

type CreateProjectAppRequest

type CreateProjectAppRequest struct {
	Appid     string `json:"app_id"`
	Conf      string `json:"conf"`
	Name      string `json:"name"`
	VersionId string `json:"version_id"`
}

CreateProjectAppRequest 创建实际应用项目请求参数

type CreateProjectLabels

type CreateProjectLabels struct {
	Workspace string `json:"kubesphere.io/workspace"`
}

type CreateProjectMetadata

type CreateProjectMetadata struct {
	Name                string `json:"name"`
	Annotations         `json:"annotations"`
	CreateProjectLabels `json:"labels"`
}

type CreateProjectRequest

type CreateProjectRequest struct {
	ApiVersion            string `json:"apiVersion"`
	Kind                  string `json:"kind"`
	CreateProjectMetadata `json:"metadata"`
}

func NewCreateProjectRequest

func NewCreateProjectRequest(name, workspace string) (req CreateProjectRequest)

NewCreateProjectRequest @description: 创建项目初始化请求参数 @param: @author: GJing @email: guojing@tna.cn @date: 2022/9/1 10:39 @success:

type CreateRepoRequest

type CreateRepoRequest struct {
	Status     string   `json:"app_default_status"`
	Credential string   `json:"credential"`
	Name       string   `json:"name"`
	Providers  []string `json:"providers"`
	RepoType   string   `json:"repoType"`
	SyncPeriod string   `json:"sync_period"`
	Type       string   `json:"type"`
	Url        string   `json:"url"`
	Visibility string   `json:"visibility"`
}

CreateRepoRequest 创建应用仓库请求体

func NewCreateRepoRequest

func NewCreateRepoRequest(url, repoName, projectName string) (req CreateRepoRequest)

type CreateRepoResponse

type CreateRepoResponse struct {
	RepoId string `json:"repo_id"`
}

type CreateWorkspacesRequest

type CreateWorkspacesRequest struct {
	ApiVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Metadata   `json:"metadata"`
	Spec       `json:"spec"`
}

CreateWorkspacesRequest 创建企业空间请求参数

func NewCreateWorkspacesRequest

func NewCreateWorkspacesRequest(name string) (req CreateWorkspacesRequest)

NewCreateWorkspacesRequest @description: 初始化创建企业空间请求参数 @param: @author: GJing @email: guojing@tna.cn @date: 2022/8/30 20:45 @success:

type DeployInNewWS

type DeployInNewWS interface {
	CreateWorkspaces(unitId string) error
	CreateProject(name, workspace string) error
	CreateRepos(workspace, repoName, projectName string) (*CreateRepoResponse, error)
	CreateConfigMap(projectName, data string) error
	CreateApp(workspace, namespace, appName string) error
	DeleteWS(name string) error
}

type FilesResponse

type FilesResponse struct {
	Files struct {
		Helmignore string `json:".helmignore"`
		ValuesYaml string `json:"values.yaml"`
	} `json:"files"`
	VersionId string `json:"version_id"`
}

type GetRepoAppListRequest

type GetRepoAppListRequest struct {
	Conditions string `json:"conditions"`
	Reverse    bool   `json:"reverse"`
	OrderBy    string `json:"orderBy"`
}

type GetRepoAppListResponse

type GetRepoAppListResponse struct {
}

type K8sAppAndVersion

type K8sAppAndVersion struct {
	App     *AppListResponse
	Version *VersionResponse
}

type MessageResponse

type MessageResponse struct {
	Message string `json:"message"`
}

type Metadata

type Metadata struct {
	Name        string `json:"name"`
	Annotations `json:"annotations"`
}

type ReposAppsResponse

type ReposAppsResponse struct {
	Items []struct {
		Appid            string `json:"app_id"`
		Name             string `json:"name"`
		LatestAppVersion struct {
			Appid       string    `json:"app_id"`
			Name        string    `json:"name"`
			PackageName string    `json:"package_name"`
			UpdateTime  time.Time `json:"update_time"`
			VersionId   string    `json:"version_id"`
		} `json:"latest_app_version"`
		RepoId string `json:"repo_id"`
		Url    string `json:"url"`
	} `json:"items"`
	TotalCount int `json:"total_count"`
}

type Result

type Result struct {
	Code int
	Err  error
}

type ServicePorts added in v0.1.2

type ServicePorts struct {
	NodePort uint16 `json:"nodePort"`
}

type ServiceYmlResp added in v0.1.2

type ServiceYmlResp struct {
	ServiceSpec struct {
		Ports []ServicePorts `json:"ports"`
	} `json:"spec"`
}

type Spec

type Spec struct {
	Template `json:"template"`
}

type Template

type Template struct {
	TemplateSpec `json:"spec"`
}

type TemplateSpec

type TemplateSpec struct {
	Manager string `json:"manager"`
}

type TokenRequest

type TokenRequest struct {
	GrantType    string `json:"grant_type"`
	Username     string `json:"username"`
	Password     string `json:"password"`
	ClientId     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
}

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int    `json:"expires_in"`
}

type UpVersionReq

type UpVersionReq struct {
	AppId     string `json:"app_id"`
	ClusterId string `json:"cluster_id"`
	Cluster   string `json:"cluster"`
	Conf      string `json:"conf"`
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
	Owner     string `json:"owner"`
	VersionId string `json:"version_id"`
	Workspace string `json:"workspace"`
}

type UpdateRequest

type UpdateRequest struct {
	Action string `json:"action"`
}

type VersionResponse

type VersionResponse struct {
	Items []struct {
		Active      bool   `json:"active"`
		AppId       string `json:"app_id"`
		CreateTime  string `json:"create_time"`
		Name        string `json:"name"`
		Owner       string `json:"owner"`
		PackageName string `json:"package_name"`
		Status      string `json:"status"`
		StatusTime  string `json:"status_time"`
		UpdateTime  string `json:"update_time"`
		VersionId   string `json:"version_id"`
	} `json:"items"`
	TotalCount int `json:"total_count"`
}

VersionResponse 版本信息

type WorkSpace

type WorkSpace struct {
	// contains filtered or unexported fields
}

WorkSpace 企业空间

func (*WorkSpace) CreateApp

func (ws *WorkSpace) CreateApp(workspace, namespace, appName string) error

CreateApp @Description 部署应用,该方法涉及其他方法,使用应用列表中的第一个应用仓库 @params @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/27 10:46

func (*WorkSpace) CreateConfigMap

func (ws *WorkSpace) CreateConfigMap(projectName, configmapName string, data interface{}) error

CreateConfigMap @Description 创建数据字典 @params @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/26 19:32

func (*WorkSpace) CreateProject

func (ws *WorkSpace) CreateProject(name, workspace string) error

CreateProject @Description: 创建企业空间下的项目 @params @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/26 19:17

func (*WorkSpace) CreateProjectApp

func (ws *WorkSpace) CreateProjectApp(workspace, namespace, appid, versionId, conf, name string) error

CreateProjectApp @Description 创建实际项目应用。企业空间-项目-应用 @params @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/27 10:39

func (*WorkSpace) CreateRepos

func (ws *WorkSpace) CreateRepos(workspace, repoName, projectName string) (*CreateRepoResponse, error)

CreateRepos @Description: 添加应用仓库 @params @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/26 19:20 该函数停止调用,统一使用tcs-master主管单位中的应用仓库,避免每个用户单位创建企业空间

func (*WorkSpace) CreateWorkspaces

func (ws *WorkSpace) CreateWorkspaces(name string) error

CreateWorkspaces @Description: 创建企业空间 @param: unitId string 要创建的企业空间名称(用户单位唯一标识) @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/26 19:10

func (*WorkSpace) DeleteWS

func (ws *WorkSpace) DeleteWS(name string) (err error)

DeleteWS @Description 删除企业空间及其下资源 @params @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/27 11:37

func (*WorkSpace) DeployWSApp

func (ws *WorkSpace) DeployWSApp(unitId, appName string, configmapData interface{}) (err error)

DeployWSApp @Description 创建企业空间并部署应用(添加用户单位时请求k8s入口) @params unitId string 用户单位标识 @params unitName string 用户单位名称 @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/27 11:17

func (*WorkSpace) DeployWSProject added in v0.1.1

func (ws *WorkSpace) DeployWSProject(wsName, projectName string) (err error)

DeployWSProject @Description 创建企业空间和项目 @params wsName string 企业空间名称 @params projectName string 项目/namespace名称 @contact.name GJing @contact.email gjing1st@gmail.com @date 2024/3/30 10:14

func (*WorkSpace) DropWorkSpace

func (ws *WorkSpace) DropWorkSpace(unitId string) (err error)

DropWorkSpace @Description 删除企业空间及所有资源 @params @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/27 12:14

func (*WorkSpace) Files

func (ws *WorkSpace) Files(appid, versionId string) (valuesYaml string, err error)

Files @Description 获取版本文件,主要提取values.yaml文件数据 @params @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/27 10:33

func (*WorkSpace) GetAppList

func (ws *WorkSpace) GetAppList(repoId string) (res *ReposAppsResponse, err error)

GetAppList @Description 获取仓库中的应用列表 @params @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/26 21:55

func (WorkSpace) GetConfigmapName

func (c WorkSpace) GetConfigmapName() string

func (WorkSpace) GetHarborAddr

func (c WorkSpace) GetHarborAddr() string

func (WorkSpace) GetHarborProject

func (c WorkSpace) GetHarborProject() string

func (WorkSpace) GetKsAddr

func (c WorkSpace) GetKsAddr() string

func (WorkSpace) GetPassword

func (c WorkSpace) GetPassword() string

func (*WorkSpace) GetRepoList

func (ws *WorkSpace) GetRepoList(workspaces string) (res *AppRepoResponse, err error)

GetRepoList @Description 应用仓库列表 @params @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/27 10:03

func (WorkSpace) GetRepoName

func (c WorkSpace) GetRepoName() string

func (WorkSpace) GetRepoWorkspace

func (c WorkSpace) GetRepoWorkspace() string

func (*WorkSpace) GetServiceYaml added in v0.1.2

func (ws *WorkSpace) GetServiceYaml(projectName, serviceName string) string

GetServiceYaml @Description 获取服务的yaml文件 @params projectName string 项目名称/namespace名称 @params serviceName string 服务名称 @contact.name GJing @contact.email gjing1st@gmail.com @date 2024/4/2 16:40

func (*WorkSpace) GetToken

func (ws *WorkSpace) GetToken() (token string, err error)

GetToken @Description 获取ks token @params @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/26 18:45

func (WorkSpace) GetUsername

func (c WorkSpace) GetUsername() string

func (*WorkSpace) HttpDelete

func (ws *WorkSpace) HttpDelete(reqUrl string) error

HttpDelete @Description 删除资源 @params @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/27 12:16

func (*WorkSpace) HttpGet

func (ws *WorkSpace) HttpGet(reqUrl string, reqData url.Values, res interface{}) error

HttpGet @Description 发送get请求 @params @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/27 9:47

func (*WorkSpace) HttpPost

func (ws *WorkSpace) HttpPost(reqUrl string, reqData, res interface{}) error

HttpPost @Description 发送http-post请求 @params reqUrl 请求的url @params req 请求参数 @params res 要接收的返回参数 @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/26 19:13

func (*WorkSpace) HttpPut added in v0.1.2

func (ws *WorkSpace) HttpPut(reqUrl string, reqData, res interface{}) error

func (*WorkSpace) OpenNodePort added in v0.1.2

func (ws *WorkSpace) OpenNodePort(projectName, serviceName string) (nodePort uint16, err error)

OpenNodePort @Description 开启nodePort外部访问模式 @params projectName string 项目名称/namespace名称 @params serviceName string 服务名称 @params serviceYml string 服务的yaml文件,此处为ws.GetServiceYaml返回的数据 @contact.name GJing @contact.email gjing1st@gmail.com @date 2024/4/2 16:40

func (WorkSpace) SetApisixAdminaddr

func (c WorkSpace) SetApisixAdminaddr(apisixAdminaddr string) *k8sConfig

func (WorkSpace) SetApisixConsumerKey

func (c WorkSpace) SetApisixConsumerKey(apisixConsumerKey string) *k8sConfig

func (WorkSpace) SetApisixGatewayAddr

func (c WorkSpace) SetApisixGatewayAddr(apisixGatewayAddr string) *k8sConfig

func (*WorkSpace) SetConfig

func (ws *WorkSpace) SetConfig(ks *k8sConfig) *WorkSpace

func (WorkSpace) SetConfigmapName

func (c WorkSpace) SetConfigmapName(configmapName string) *k8sConfig

func (WorkSpace) SetDebug

func (c WorkSpace) SetDebug(debug bool) *k8sConfig

func (WorkSpace) SetHarborAddr

func (c WorkSpace) SetHarborAddr(harborAddr string) *k8sConfig

func (WorkSpace) SetHarborProject

func (c WorkSpace) SetHarborProject(harborProject string) *k8sConfig

func (WorkSpace) SetKsAddr

func (c WorkSpace) SetKsAddr(ksAddr string) *k8sConfig

func (WorkSpace) SetPassword

func (c WorkSpace) SetPassword(password string) *k8sConfig

func (WorkSpace) SetRepoName

func (c WorkSpace) SetRepoName(repoName string) *k8sConfig

func (WorkSpace) SetRepoWorkspace

func (c WorkSpace) SetRepoWorkspace(repoWorkspace string) *k8sConfig

func (WorkSpace) SetUsername

func (c WorkSpace) SetUsername(username string) *k8sConfig

func (*WorkSpace) UpdateRepo

func (ws *WorkSpace) UpdateRepo(workspaces, repoId string) (message string, err error)

UpdateRepo @Description @params @contact.name GJing @contact.email gjing1st@gmail.com @date 2023/4/27 10:08

Jump to

Keyboard shortcuts

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