cluster

package
v0.0.0-...-d125d34 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 86 Imported by: 0

Documentation

Index

Constants

View Source
const ServerlessTemplateName = "serverless"

Variables

This section is empty.

Functions

func RenderOutputObject

func RenderOutputObject(outPutStr, templateName string,
	clusterValueFiles ...gitrepo.ClusterValueFile) (interface{}, error)

Types

type Application

type Application struct {
	ID   uint   `json:"id"`
	Name string `json:"name"`
}

type Base

type Base struct {
	Description   string                `json:"description"`
	Git           *codemodels.Git       `json:"git"`
	Template      *Template             `json:"template"`
	TemplateInput *TemplateInput        `json:"templateInput"`
	Tags          []*tagmodels.TagBasic `json:"tags"`
}

type BatchResponse

type BatchResponse map[string]OperationResult

type BuildDeployRequest

type BuildDeployRequest struct {
	Title       string                 `json:"title"`
	Description string                 `json:"description"`
	Git         *BuildDeployRequestGit `json:"git"`
}

type BuildDeployRequestGit

type BuildDeployRequestGit struct {
	Branch string `json:"branch"`
	Tag    string `json:"tag"`
	Commit string `json:"commit"`
}

type BuildDeployResponse

type BuildDeployResponse struct {
	PipelinerunID uint `json:"pipelinerunID"`
}

type BuildTemplateInfo

type BuildTemplateInfo struct {
	BuildConfig    map[string]interface{}
	TemplateInfo   *codemodels.TemplateInfo
	TemplateConfig map[string]interface{}
}

func (*BuildTemplateInfo) Validate

func (info *BuildTemplateInfo) Validate(ctx context.Context,
	trGetter templateschema.Getter, templateSchemaRenderVal map[string]string, buildSchema *build.Schema) error

type CodeInfo

type CodeInfo struct {
	// deploy branch info
	Branch string `json:"branch,omitempty"`
	// deploy tag info
	Tag string `json:"tag,omitempty"`
	// current branch commit
	CommitID string `json:"commitID"`
	// commit message
	CommitMsg string `json:"commitMsg"`
	// code history link
	Link string `json:"link"`
}

type Controller

type Controller interface {
	CreateCluster(ctx context.Context, applicationID uint, environment, region string,
		request *CreateClusterRequest, mergePatch bool) (*GetClusterResponse, error)
	UpdateCluster(ctx context.Context, clusterID uint,
		request *UpdateClusterRequest, mergePatch bool) (*GetClusterResponse, error)
	DeleteCluster(ctx context.Context, clusterID uint, hard bool) error

	GetCluster(ctx context.Context, clusterID uint) (*GetClusterResponse, error)
	GetClusterByName(ctx context.Context,
		clusterName string) (*GetClusterByNameResponse, error)
	GetClusterOutput(ctx context.Context, clusterID uint) (interface{}, error)
	List(ctx context.Context, query *q.Query) ([]*ListClusterWithFullResponse, int, error)
	ListByApplication(ctx context.Context, query *q.Query) (int, []*ListClusterWithFullResponse, error)
	ListClusterWithExpiry(ctx context.Context, query *q.Query) ([]*ListClusterWithExpiryResponse, error)

	BuildDeploy(ctx context.Context, clusterID uint,
		request *BuildDeployRequest) (*BuildDeployResponse, error)
	Restart(ctx context.Context, clusterID uint) (*PipelinerunIDResponse, error)
	Deploy(ctx context.Context, clusterID uint, request *DeployRequest) (*PipelinerunIDResponse, error)
	Rollback(ctx context.Context, clusterID uint, request *RollbackRequest) (*PipelinerunIDResponse, error)

	FreeCluster(ctx context.Context, clusterID uint) error

	// InternalDeploy todo(zx): remove after InternalDeployV2 is stabilized
	InternalDeploy(ctx context.Context, clusterID uint,
		r *InternalDeployRequest) (_ *InternalDeployResponse, err error)

	ExecuteAction(ctx context.Context, clusterID uint, action string,
		gvk schema.GroupVersionResource) error

	// Deprecated: GetClusterStatus
	GetClusterStatus(ctx context.Context, clusterID uint) (_ *GetClusterStatusResponse, err error)
	// Deprecated
	Online(ctx context.Context, clusterID uint, r *ExecRequest) (ExecResponse, error)
	// Deprecated
	Offline(ctx context.Context, clusterID uint, r *ExecRequest) (ExecResponse, error)
	Exec(ctx context.Context, clusterID uint, r *ExecRequest) (_ ExecResponse, err error)

	GetDiff(ctx context.Context, clusterID uint, refType, ref string) (*GetDiffResponse, error)
	GetContainerLog(ctx context.Context, clusterID uint, podName, containerName string, tailLines int64) (
		<-chan string, error)

	DeleteClusterPods(ctx context.Context, clusterID uint, podName []string) (BatchResponse, error)
	GetClusterPod(ctx context.Context, clusterID uint, podName string) (
		*GetClusterPodResponse, error)

	GetPodEvents(ctx context.Context, clusterID uint, podName string) (interface{}, error)
	GetContainers(ctx context.Context, clusterID uint, podName string) (interface{}, error)
	GetGrafanaDashBoard(c context.Context, clusterID uint) (*GetGrafanaDashboardsResponse, error)

	CreateClusterV2(ctx context.Context, params *CreateClusterParamsV2) (*CreateClusterResponseV2, error)
	GetClusterV2(ctx context.Context, clusterID uint) (*GetClusterResponseV2, error)
	UpdateClusterV2(ctx context.Context, clusterID uint, r *UpdateClusterRequestV2, mergePatch bool) error
	// InternalDeployV2 deploy only used by internal system
	InternalDeployV2(ctx context.Context, clusterID uint,
		r *InternalDeployRequestV2) (_ *InternalDeployResponseV2, err error)
	InternalGetClusterStatus(ctx context.Context, clusterID uint) (_ *GetClusterStatusResponse, err error)
	GetClusterStatusV2(ctx context.Context, clusterID uint) (_ *StatusResponseV2, err error)
	GetClusterPipelinerunStatus(ctx context.Context, clusterID uint) (*PipelinerunStatusResponse, error)
	GetResourceTree(ctx context.Context, clusterID uint) (*GetResourceTreeResponse, error)
	GetStep(ctx context.Context, clusterID uint) (resp *GetStepResponse, err error)
	// Deprecated: for internal usage, v1 to v2
	Upgrade(ctx context.Context, clusterID uint) error
	ToggleLikeStatus(ctx context.Context, clusterID uint, like *WhetherLike) (err error)
	CreatePipelineRun(ctx context.Context, clusterID uint, r *CreatePipelineRunRequest) (*prmodels.PipelineBasic, error)
}

func NewController

func NewController(config *config.Config, param *param.Param) Controller

type CreateClusterParamsV2

type CreateClusterParamsV2 struct {
	*CreateClusterRequestV2
	ApplicationID uint
	Environment   string
	Region        string
	// whether to merge json schema form data
	MergePatch bool
}

type CreateClusterRequest

type CreateClusterRequest struct {
	*Base

	Name       string `json:"name"`
	Namespace  string `json:"namespace"`
	ExpireTime string `json:"expireTime"`
	// TODO(gjq): remove these two params after migration
	Image        string            `json:"image"`
	ExtraMembers map[string]string `json:"extraMembers"`
}

type CreateClusterRequestV2

type CreateClusterRequestV2 struct {
	Name        string              `json:"name"`
	Description string              `json:"description"`
	Priority    string              `json:"priority"`
	ExpireTime  string              `json:"expireTime"`
	Git         *codemodels.Git     `json:"git"`
	Image       *string             `json:"image"`
	Tags        tagmodels.TagsBasic `json:"tags"`

	BuildConfig    map[string]interface{}   `json:"buildConfig"`
	TemplateInfo   *codemodels.TemplateInfo `json:"templateInfo"`
	TemplateConfig map[string]interface{}   `json:"templateConfig"`

	// TODO(tom): just for internal usage
	ExtraMembers map[string]string `json:"extraMembers"`
}

type CreateClusterResponseV2

type CreateClusterResponseV2 struct {
	ID            uint         `json:"id"`
	Name          string       `json:"name"`
	FullPath      string       `json:"fullPath"`
	ApplicationID uint         `json:"applicationID"`
	Scope         *Scope       `json:"scope"`
	Application   *Application `json:"application"`
	CreatedAt     time.Time    `json:"createdAt"`
	UpdatedAt     time.Time    `json:"updatedAt"`
}

type CreatePipelineRunRequest

type CreatePipelineRunRequest struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	Action      string `json:"action"`
	// for build deploy
	Git      *BuildDeployRequestGit `json:"git,omitempty"`
	ImageTag string                 `json:"imageTag,omitempty"`
	// for rollback
	PipelinerunID uint `json:"pipelinerunID,omitempty"`
}

type DeployRequest

type DeployRequest struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	ImageTag    string `json:"imageTag"`
}

type ExecRequest

type ExecRequest struct {
	Commands []string `json:"commands"`
	PodList  []string `json:"podList"`
}

type ExecResponse

type ExecResponse map[string]ExecResult

type ExecResult

type ExecResult struct {
	OperationResult
	Stdout string `json:"stdout,omitempty"`
	Stderr string `json:"stderr,omitempty"`
}

type ExecuteActionRequest

type ExecuteActionRequest struct {
	Action   string `json:"action"`
	Group    string `json:"group"`
	Version  string `json:"version"`
	Resource string `json:"resource"`
}

type GetClusterByNameResponse

type GetClusterByNameResponse struct {
	ID          uint            `json:"id"`
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Template    *Template       `json:"template"`
	Git         *codemodels.Git `json:"git"`
	CreatedAt   time.Time       `json:"createdAt"`
	UpdatedAt   time.Time       `json:"updatedAt"`
	FullPath    string          `json:"fullPath"`
}

type GetClusterPodResponse

type GetClusterPodResponse struct {
	corev1.Pod
}

type GetClusterResponse

type GetClusterResponse struct {
	*CreateClusterRequest

	ID                   uint         `json:"id"`
	FullPath             string       `json:"fullPath"`
	Application          *Application `json:"application"`
	Priority             string       `json:"priority"`
	Template             *Template    `json:"template"`
	Scope                *Scope       `json:"scope"`
	LatestDeployedCommit string       `json:"latestDeployedCommit,omitempty"`
	Status               string       `json:"status,omitempty"`
	CreatedAt            time.Time    `json:"createdAt"`
	UpdatedAt            time.Time    `json:"updatedAt"`
	TTLInSeconds         *uint        `json:"ttlInSeconds"`
	CreatedBy            *User        `json:"createdBy,omitempty"`
	UpdatedBy            *User        `json:"updatedBy,omitempty"`
}

type GetClusterResponseV2

type GetClusterResponseV2 struct {
	// basic infos
	ID              uint                `json:"id"`
	Name            string              `json:"name"`
	Description     string              `json:"description"`
	Priority        string              `json:"priority"`
	ExpireTime      string              `json:"expireTime"`
	Scope           *Scope              `json:"scope"`
	FullPath        string              `json:"fullPath"`
	ApplicationName string              `json:"applicationName"`
	ApplicationID   uint                `json:"applicationID"`
	Tags            tagmodels.TagsBasic `json:"tags"`

	// source info
	Git   *codemodels.Git `json:"git"`
	Image string          `json:"image"`

	// git config info
	BuildConfig    map[string]interface{}   `json:"buildConfig"`
	TemplateInfo   *codemodels.TemplateInfo `json:"templateInfo"`
	TemplateConfig map[string]interface{}   `json:"templateConfig"`
	Manifest       map[string]interface{}   `json:"manifest"`

	// status and update info
	Status       string    `json:"status"`
	CreatedAt    time.Time `json:"createdAt"`
	UpdatedAt    time.Time `json:"updatedAt"`
	CreatedBy    *User     `json:"createdBy,omitempty"`
	UpdatedBy    *User     `json:"updatedBy,omitempty"`
	TTLInSeconds *uint     `json:"ttlInSeconds,omitempty"`
}

type GetClusterStatusResponse

type GetClusterStatusResponse struct {
	RunningTask       *RunningTask       `json:"runningTask" yaml:"runningTask"`
	LatestPipelinerun *LatestPipelinerun `json:"latestPipelinerun,omitempty"`
	ClusterStatus     interface{}        `json:"clusterStatus,omitempty" yaml:"clusterStatus,omitempty"`
	TTLSeconds        *uint              `json:"ttlSeconds,omitempty" yaml:"ttlSeconds,omitempty"`
}

type GetDiffResponse

type GetDiffResponse struct {
	CodeInfo   *CodeInfo `json:"codeInfo"`
	ConfigDiff string    `json:"configDiff"`
}

type GetGrafanaDashboardsResponse

type GetGrafanaDashboardsResponse struct {
	Host       string               `json:"host"`
	Params     map[string]string    `json:"params"`
	Dashboards []*grafana.Dashboard `json:"dashboards"`
}

type GetResourceTreeResponse

type GetResourceTreeResponse struct {
	Nodes map[string]*ResourceNode `json:"nodes"`
}

type GetStepResponse

type GetStepResponse struct {
	Index        int     `json:"index"`
	Total        int     `json:"total"`
	Replicas     []int   `json:"replicas"`
	ManualPaused bool    `json:"manualPaused"`
	AutoPromote  bool    `json:"autoPromote"`
	Extra        *string `json:"extra"`
}

type GitResponse

type GitResponse struct {
	GitURL  string `json:"gitURL"`
	HTTPURL string `json:"httpURL"`
}

type InternalDeployRequest

type InternalDeployRequest struct {
	PipelinerunID uint `json:"pipelinerunID"`
}

type InternalDeployRequestV2

type InternalDeployRequestV2 struct {
	PipelinerunID uint                   `json:"pipelinerunID"`
	Output        map[string]interface{} `json:"output"`
}

type InternalDeployResponse

type InternalDeployResponse struct {
	PipelinerunID uint   `json:"pipelinerunID"`
	Commit        string `json:"commit"`
}

type InternalDeployResponseV2

type InternalDeployResponseV2 struct {
	PipelinerunID uint   `json:"pipelinerunID"`
	Commit        string `json:"commit"`
}

type LatestPipelinerun

type LatestPipelinerun struct {
	ID     uint   `json:"id"`
	Action string `json:"action"`
}

LatestPipelinerun latest pipelinerun

type ListClusterResponse

type ListClusterResponse struct {
	ID          uint                  `json:"id"`
	Name        string                `json:"name"`
	Type        *string               `json:"type,omitempty"`
	Description string                `json:"description"`
	Scope       *Scope                `json:"scope"`
	Template    *Template             `json:"template"`
	Git         *GitResponse          `json:"git"`
	IsFavorite  *bool                 `json:"isFavorite"`
	CreatedAt   time.Time             `json:"createdAt"`
	UpdatedAt   time.Time             `json:"updatedAt"`
	Tags        []*tagmodels.TagBasic `json:"tags,omitempty"`
}

type ListClusterWithExpiryResponse

type ListClusterWithExpiryResponse struct {
	ID              uint      `json:"id"`
	Name            string    `json:"name"`
	EnvironmentName string    `json:"environmentName"`
	Status          string    `json:"status"`
	ExpireSeconds   uint      `json:"expireSeconds"`
	UpdatedAt       time.Time `json:"updatedAt"`
}

type ListClusterWithFullResponse

type ListClusterWithFullResponse struct {
	*ListClusterResponse
	IsFavorite *bool  `json:"isFavorite,omitempty"`
	FullName   string `json:"fullName,omitempty"`
	FullPath   string `json:"fullPath,omitempty"`
}

type OperationResult

type OperationResult struct {
	// Result bool value indicates whether the result is successfully
	Result   bool   `json:"result"`
	Error    error  `json:"error,omitempty"`
	ErrorMsg string `json:"errorMsg,omitempty"`
}

type PipelinerunIDResponse

type PipelinerunIDResponse struct {
	PipelinerunID uint `json:"pipelinerunID"`
}

type PipelinerunStatusResponse

type PipelinerunStatusResponse struct {
	LatestPipelinerun *LatestPipelinerun `json:"latestPipelinerun,omitempty"`
	RunningTask       *RunningTask       `json:"runningTask,omitempty"`
}

type ResourceNode

type ResourceNode struct {
	v1alpha1.ResourceNode
	PodDetail interface{} `json:"podDetail,omitempty"`
}

type Revision

type Revision struct {
	Pods map[string]interface{} `json:"pods"`
}

type RollbackRequest

type RollbackRequest struct {
	PipelinerunID uint `json:"pipelinerunID"`
}

type RunningTask

type RunningTask struct {
	Task string `json:"task" yaml:"task"`
	// the latest buildDeploy pipelinerun ID
	PipelinerunID uint   `json:"pipelinerunID,omitempty"`
	TaskStatus    string `json:"taskStatus,omitempty" yaml:"taskStatus,omitempty"`
}

RunningTask the most recent task in progress

type Scope

type Scope struct {
	Environment       string `json:"environment"`
	Region            string `json:"region"`
	RegionDisplayName string `json:"regionDisplayName,omitempty"`
}

type StatusResponseV2

type StatusResponseV2 struct {
	Status string `json:"status"`
}

type Step

type Step struct {
	Index    int   `json:"index"`
	Total    int   `json:"total"`
	Replicas []int `json:"replicas"`
}

type Template

type Template struct {
	Name    string `json:"name"`
	Release string `json:"release"`
}

type TemplateInput

type TemplateInput struct {
	Application map[string]interface{} `json:"application"`
	Pipeline    map[string]interface{} `json:"pipeline"`
}

type UpdateClusterRequest

type UpdateClusterRequest struct {
	*Base
	Environment string `json:"environment"`
	Region      string `json:"region"`
	ExpireTime  string `json:"expireTime"`
}

type UpdateClusterRequestV2

type UpdateClusterRequestV2 struct {
	// basic infos
	Description string `json:"description"`
	Priority    string `json:"priority"`
	ExpireTime  string `json:"expireTime"`

	// env and region info (can only be modified after cluster freed)
	Environment *string `json:"environment"`
	Region      *string `json:"region"`

	Tags tagmodels.TagsBasic `json:"tags"`
	// source info
	Git   *codemodels.Git `json:"git"`
	Image *string         `json:"image"`

	// git config info
	BuildConfig    map[string]interface{}   `json:"buildConfig"`
	TemplateInfo   *codemodels.TemplateInfo `json:"templateInfo"`
	TemplateConfig map[string]interface{}   `json:"templateConfig"`
}

type User

type User struct {
	ID    uint   `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

type WhetherLike

type WhetherLike struct {
	IsFavorite bool `json:"isFavorite"`
}

Jump to

Keyboard shortcuts

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