service

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: Apache-2.0 Imports: 57 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Timeout          = 60
	UpdateTypeSystem = "systemVar"
	UpdateTypeEnv    = "envVar"
)

Variables

View Source
var DefaultCleanWhiteList = []string{"spockadmin"}

Functions

func CleanProductCronJob

func CleanProductCronJob(requestID string, log *zap.SugaredLogger)

func CleanProducts

func CleanProducts()

func CreateHelmProduct added in v1.5.0

func CreateHelmProduct(productName, userName, requestID string, args []*CreateHelmProductArg, log *zap.SugaredLogger) error

func CreateProduct

func CreateProduct(user, requestID string, args *commonmodels.Product, log *zap.SugaredLogger) (err error)

CreateProduct create a new product with its dependent stacks

func DeletePod

func DeletePod(envName, productName, podName string, log *zap.SugaredLogger) error

func ExportYaml

func ExportYaml(envName, productName, serviceName string, log *zap.SugaredLogger) []string

ExportYaml 查询使用到服务模板的服务组模板

func FillProductVars

func FillProductVars(products []*commonmodels.Product, log *zap.SugaredLogger) error

func FindHelmRenderSet added in v1.2.0

func FindHelmRenderSet(productName, renderName string, log *zap.SugaredLogger) (*commonmodels.RenderSet, error)

func GeneEstimatedValues added in v1.6.0

func GeneEstimatedValues(productName, envName, serviceName, scene, format string, arg *EstimateValuesArg, log *zap.SugaredLogger) (interface{}, error)

func GetEstimatedRenderCharts added in v1.5.0

func GetEstimatedRenderCharts(productName, envName, serviceNameListStr string, log *zap.SugaredLogger) ([]*commonservice.RenderChartArg, error)

func GetHelmChartVersions added in v1.2.0

func GetHelmChartVersions(productName, envName string, log *zap.SugaredLogger) ([]*commonmodels.HelmVersions, error)

func GetIngressInfo

func GetIngressInfo(product *commonmodels.Product, service *commonmodels.Service, log *zap.SugaredLogger) *commonservice.IngressInfo

func GetInitProduct

func GetInitProduct(productTmplName string, log *zap.SugaredLogger) (*commonmodels.Product, error)

func GetMergedYamlContent added in v1.6.0

func GetMergedYamlContent(arg *YamlContentRequestArg, paths []string) (string, error)

func GetProductInfo

func GetProductInfo(username, envName, productName string, log *zap.SugaredLogger) (*commonmodels.Product, error)

func GetRenderCharts added in v1.5.0

func GetRenderCharts(productName, envName, serviceName string, log *zap.SugaredLogger) ([]*commonservice.RenderChartArg, error)

func GetServiceContainer

func GetServiceContainer(envName, productName, serviceName, container string, log *zap.SugaredLogger) error

func ListAvailableNamespaces

func ListAvailableNamespaces(clusterID string, log *zap.SugaredLogger) ([]*resource.Namespace, error)

ListAvailableNamespaces lists available namespaces created by non-koderover

func ListConfigMaps

func ListConfigMaps(args *ListConfigMapArgs, log *zap.SugaredLogger) ([]*configMapWithHistory, error)

func ListGroups

func ListGroups(serviceName, envName, productName string, perPage, page int, log *zap.SugaredLogger) ([]*commonservice.ServiceResp, int, error)

func ListKubeEvents

func ListKubeEvents(env string, productName string, name string, rtype string, log *zap.SugaredLogger) ([]*resource.Event, error)

func ListPodEvents

func ListPodEvents(envName, productName, podName string, log *zap.SugaredLogger) ([]*resource.Event, error)

func ListRenderCharts

func ListRenderCharts(productName, envName string, log *zap.SugaredLogger) ([]*template.RenderChart, error)

ListRenderCharts 获取集成环境中的values.yaml的值

func ListServicePods

func ListServicePods(productName, envName string, serviceName string, log *zap.SugaredLogger) ([]*resource.Pod, error)

func ResetProductsStatus

func ResetProductsStatus()

func RestartScale

func RestartScale(args *RestartScaleArgs, _ *zap.SugaredLogger) error

func RestartService

func RestartService(envName string, args *SvcOptArgs, log *zap.SugaredLogger) (err error)

RestartService 在kube中, 如果资源存在就更新不存在就创建

func RollBackConfigMap

func RollBackConfigMap(envName string, args *RollBackConfigMapArgs, userName, userID string, log *zap.SugaredLogger) error

func Scale

func Scale(args *ScaleArgs, logger *zap.SugaredLogger) error

func ScaleService

func ScaleService(envName, productName, serviceName string, number int, log *zap.SugaredLogger) (err error)

ScaleService 增加或者缩减服务的deployment或者stafefulset的副本数量

func UpdateConfigMap

func UpdateConfigMap(envName string, args *UpdateConfigMapArgs, userName, userID string, log *zap.SugaredLogger) error

func UpdateContainerImage

func UpdateContainerImage(requestID string, args *UpdateContainerImageArgs, log *zap.SugaredLogger) error

func UpdateHelmProduct added in v1.2.0

func UpdateHelmProduct(productName, envName, updateType, username, requestID string, overrideCharts []*commonservice.RenderChartArg, log *zap.SugaredLogger) error

func UpdateHelmProductRenderset added in v1.6.0

func UpdateHelmProductRenderset(productName, envName, userName, requestID string, args *EnvRendersetArg, log *zap.SugaredLogger) error

func UpdateHelmProductVariable added in v1.2.0

func UpdateHelmProductVariable(productName, envName, username, requestID string, updatedRcs []*template.RenderChart, renderset *commonmodels.RenderSet, log *zap.SugaredLogger) error

func UpdateProduct

func UpdateProduct(existedProd, updateProd *commonmodels.Product, renderSet *commonmodels.RenderSet, log *zap.SugaredLogger) (err error)

func UpdateProductRecycleDay added in v1.2.0

func UpdateProductRecycleDay(envName, productName string, recycleDay int) error

func UpdateProductV2

func UpdateProductV2(envName, productName, user, requestID string, force bool, kvs []*template.RenderKV, log *zap.SugaredLogger) (err error)

func UpdateService

func UpdateService(args *SvcOptArgs, log *zap.SugaredLogger) error

Types

type AutoCreator added in v1.5.0

type AutoCreator struct {
	Param *CreateProductParam
}

func (*AutoCreator) Create added in v1.5.0

func (autoCreator *AutoCreator) Create(envName string) (string, error)

type ConfigDiffResult

type ConfigDiffResult struct {
	Current TmplConfig `json:"current,omitempty"`
	Latest  TmplConfig `json:"latest,omitempty"`
}

type ConfigTmplData

type ConfigTmplData struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type ContainerNotFound

type ContainerNotFound struct {
	ServiceName string
	Container   string
	EnvName     string
	ProductName string
}

func (*ContainerNotFound) Error

func (c *ContainerNotFound) Error() string

type CreateHelmProductArg added in v1.5.0

type CreateHelmProductArg struct {
	ProductName   string                          `json:"productName"`
	EnvName       string                          `json:"envName"`
	Namespace     string                          `json:"namespace"`
	ClusterID     string                          `json:"clusterID"`
	DefaultValues string                          `json:"defaultValues"`
	ChartValues   []*commonservice.RenderChartArg `json:"chartValues"`
}

type CreateProductParam added in v1.5.0

type CreateProductParam struct {
	UserName    string
	RequestId   string
	ProductName string
	EnvType     string
	// contains filtered or unexported fields
}

type DefaultProductCreator added in v1.5.0

type DefaultProductCreator struct {
}

func (*DefaultProductCreator) Create added in v1.5.0

func (creator *DefaultProductCreator) Create(user, requestID string, args *models.Product, log *zap.SugaredLogger) error

type DefaultValuesResp added in v1.6.0

type DefaultValuesResp struct {
	DefaultValues string `json:"defaultValues"`
}

func GetDefaultValues added in v1.6.0

func GetDefaultValues(productName, envName string, log *zap.SugaredLogger) (*DefaultValuesResp, error)

type EnvRenderChartArg added in v1.5.0

type EnvRenderChartArg struct {
	ChartValues []*commonservice.RenderChartArg `json:"chartValues"`
}

type EnvRendersetArg added in v1.6.0

type EnvRendersetArg struct {
	DefaultValues string                          `json:"defaultValues"`
	ChartValues   []*commonservice.RenderChartArg `json:"chartValues"`
}

type EnvStatus

type EnvStatus struct {
	EnvName    string `json:"env_name,omitempty"`
	Status     string `json:"status"`
	ErrMessage string `json:"err_message"`
}

func AutoCreateProduct

func AutoCreateProduct(productName, envType, requestID string, log *zap.SugaredLogger) []*EnvStatus

自动创建环境

func AutoUpdateProduct

func AutoUpdateProduct(envNames []string, productName, requestID string, force bool, log *zap.SugaredLogger) ([]*EnvStatus, error)

func GetProductStatus added in v1.6.0

func GetProductStatus(productName string, log *zap.SugaredLogger) ([]*EnvStatus, error)

func UpdateMultipleHelmEnv added in v1.5.0

func UpdateMultipleHelmEnv(requestID string, args *UpdateMultiHelmProductArg, log *zap.SugaredLogger) ([]*EnvStatus, error)

type EstimateValuesArg added in v1.6.0

type EstimateValuesArg struct {
	DefaultValues  string                  `json:"defaultValues"`
	OverrideYaml   string                  `json:"overrideYaml"`
	OverrideValues []*commonservice.KVPair `json:"overrideValues,omitempty"`
}

type ExternalProductCreator added in v1.5.0

type ExternalProductCreator struct {
}

func (*ExternalProductCreator) Create added in v1.5.0

func (creator *ExternalProductCreator) Create(user, requestID string, args *models.Product, log *zap.SugaredLogger) error

type HelmProductCreator added in v1.5.0

type HelmProductCreator struct{}

func (*HelmProductCreator) Create added in v1.5.0

func (creator *HelmProductCreator) Create(user, requestID string, args *models.Product, log *zap.SugaredLogger) error

type IProductCreator added in v1.5.0

type IProductCreator interface {
	Create(string, string, *models.Product, *zap.SugaredLogger) error
}

type K8sService

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

type ListConfigMapArgs

type ListConfigMapArgs struct {
	EnvName     string `json:"env_name"`
	ProductName string `json:"product_name"`
	ServiceName string `json:"service_name"`
}

type PMProductCreator added in v1.5.0

type PMProductCreator struct {
}

func (*PMProductCreator) Create added in v1.5.0

func (creator *PMProductCreator) Create(user, requestID string, args *models.Product, log *zap.SugaredLogger) error

type PMService added in v1.2.0

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

type ProductIngressInfo

type ProductIngressInfo struct {
	IngressInfos []*commonservice.IngressInfo `json:"ingress_infos"`
	EnvName      string                       `json:"env_name"`
}

func GetProductIngress

func GetProductIngress(username, productName string, log *zap.SugaredLogger) ([]*ProductIngressInfo, error)

type ProductParams

type ProductParams struct {
	IsPublic        bool     `json:"isPublic"`
	EnvName         string   `json:"envName"`
	RoleID          int      `json:"roleId"`
	PermissionUUIDs []string `json:"permissionUUIDs"`
}

type ProductResp

type ProductResp struct {
	ID          string                   `json:"id"`
	ProductName string                   `json:"product_name"`
	Namespace   string                   `json:"namespace"`
	Status      string                   `json:"status"`
	Error       string                   `json:"error"`
	EnvName     string                   `json:"env_name"`
	UpdateBy    string                   `json:"update_by"`
	UpdateTime  int64                    `json:"update_time"`
	Services    [][]string               `json:"services"`
	Render      *commonmodels.RenderInfo `json:"render"`
	Vars        []*template.RenderKV     `json:"vars"`
	IsPublic    bool                     `json:"isPublic"`
	ClusterID   string                   `json:"cluster_id,omitempty"`
	RecycleDay  int                      `json:"recycle_day"`
	IsProd      bool                     `json:"is_prod"`
	Source      string                   `json:"source"`
}

func GetProduct

func GetProduct(username, envName, productName string, log *zap.SugaredLogger) (*ProductResp, error)

func ListProducts

func ListProducts(productNameParam string, userName string, log *zap.SugaredLogger) (resp []*ProductResp, err error)

type ProductRevision

type ProductRevision struct {
	ID          string `json:"id,omitempty"`
	EnvName     string `json:"env_name"`
	ProductName string `json:"product_name"`
	// 表示该产品更新前版本
	CurrentRevision int64 `json:"current_revision"`
	// 表示该产品更新后版本
	NextRevision int64 `json:"next_revision"`
	// true: 表示该产品的服务发生变化, 需要更新
	// false: 表示该产品的服务未发生变化, 无需更新
	Updatable bool `json:"updatable"`
	// 可以自动更新产品, 展示用户更新前和更新后的服务组以及服务详细对比
	ServiceRevisions []*SvcRevision `json:"services"`
	IsPublic         bool           `json:"isPublic"`
}

func GetProductRevision

func GetProductRevision(product *commonmodels.Product, allServiceTmpls []*commonmodels.Service, allRender []*commonmodels.RenderSet, newRender *commonmodels.RenderSet, log *zap.SugaredLogger) (*ProductRevision, error)

func ListProductsRevision

func ListProductsRevision(productName, envName string, log *zap.SugaredLogger) (prodRevs []*ProductRevision, err error)

func ListProductsRevisionByFacility added in v1.4.0

func ListProductsRevisionByFacility(basicFacility string, log *zap.SugaredLogger) ([]*ProductRevision, error)

func (*ProductRevision) GroupsUpdated

func (pr *ProductRevision) GroupsUpdated() bool

type RawYamlResp added in v1.6.0

type RawYamlResp struct {
	YamlContent string `json:"yamlContent"`
}

type RestartScaleArgs

type RestartScaleArgs struct {
	Type        string `json:"type"`
	ProductName string `json:"product_name"`
	EnvName     string `json:"env_name"`
	ServiceName string `json:"service_name"`
	Name        string `json:"name"`
}

type RollBackConfigMapArgs

type RollBackConfigMapArgs struct {
	EnvName          string `json:"env_name"`
	ProductName      string `json:"product_name"`
	ServiceName      string `json:"service_name"`
	SrcConfigName    string `json:"src_config_name"`
	DestinConfigName string `json:"destin_config_name"`
}

type ScaleArgs

type ScaleArgs struct {
	Type        string `json:"type"`
	ProductName string `json:"product_name"`
	EnvName     string `json:"env_name"`
	ServiceName string `json:"service_name"`
	Name        string `json:"name"`
	Number      int    `json:"number"`
}

type SvcDiffResult

type SvcDiffResult struct {
	Current TmplYaml `json:"current,omitempty"`
	Latest  TmplYaml `json:"latest,omitempty"`
}

func GetServiceDiff added in v1.3.0

func GetServiceDiff(envName, productName, serviceName string, log *zap.SugaredLogger) (*SvcDiffResult, error)

GetServiceDiff 获得服务模板当前版本和最新版本的对比

type SvcOptArgs

type SvcOptArgs struct {
	EnvName     string
	ProductName string
	ServiceName string
	ServiceType string
	ServiceRev  *SvcRevision
	UpdateBy    string
}

type SvcResp

type SvcResp struct {
	ServiceName string                       `json:"service_name"`
	Scales      []*internalresource.Workload `json:"scales"`
	Ingress     []*internalresource.Ingress  `json:"ingress"`
	Services    []*internalresource.Service  `json:"service_endpoints"`
	EnvName     string                       `json:"env_name"`
	ProductName string                       `json:"product_name"`
	GroupName   string                       `json:"group_name"`
}

SvcResp struct 产品-服务详情页面Response

func GetService

func GetService(envName, productName, serviceName string, workLoadType string, log *zap.SugaredLogger) (ret *SvcResp, err error)

type SvcRevision

type SvcRevision struct {
	ServiceName     string                    `json:"service_name"`
	Type            string                    `json:"type"`
	CurrentRevision int64                     `json:"current_revision"`
	NextRevision    int64                     `json:"next_revision"`
	Updatable       bool                      `json:"updatable"`
	Deleted         bool                      `json:"deleted"`
	New             bool                      `json:"new"`
	Containers      []*commonmodels.Container `json:"containers,omitempty"`
}

type TmplConfig

type TmplConfig struct {
	Data []ConfigTmplData `json:"data,omitempty"`
}

type TmplYaml

type TmplYaml struct {
	Yaml     string `json:"yaml,omitempty"`
	UpdateBy string `json:"update_by,omitempty"`
	Revision int64  `json:"revision,omitempty"`
}

type UpdateConfigMapArgs

type UpdateConfigMapArgs struct {
	EnvName     string            `json:"env_name"`
	ProductName string            `json:"product_name"`
	ServiceName string            `json:"service_name"`
	ConfigName  string            `json:"config_name"`
	Data        map[string]string `json:"data"`
}

type UpdateContainerImageArgs

type UpdateContainerImageArgs struct {
	Type          string `json:"type"`
	ProductName   string `json:"product_name"`
	EnvName       string `json:"env_name"`
	ServiceName   string `json:"service_name"`
	Name          string `json:"name"`
	ContainerName string `json:"container_name"`
	Image         string `json:"image"`
}

type UpdateMultiHelmProductArg added in v1.5.0

type UpdateMultiHelmProductArg struct {
	ProductName   string                          `json:"productName"`
	EnvNames      []string                        `json:"envNames"`
	ChartValues   []*commonservice.RenderChartArg `json:"chartValues"`
	ReplacePolicy string                          `json:"replacePolicy"` // TODO logic not implemented
}

type YamlContentRequestArg added in v1.6.0

type YamlContentRequestArg struct {
	CodehostID  int    `json:"codehostID" form:"codehostID"`
	Owner       string `json:"owner" form:"owner"`
	Repo        string `json:"repo" form:"repo"`
	Branch      string `json:"branch" form:"branch"`
	RepoLink    string `json:"repoLink" form:"repoLink"`
	ValuesPaths string `json:"valuesPaths" form:"valuesPaths"`
}

Jump to

Keyboard shortcuts

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