service

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: Apache-2.0 Imports: 97 Imported by: 0

Documentation

Index

Constants

View Source
const K8sBetaVersionForEphemeralContainer = "v1.23"
View Source
const (
	Timeout = 60
)
View Source
const ZadigDebugContainerName = "zadig-debug"

Variables

View Source
var ClusterInformersMap sync.Map
View Source
var ClusterStopChanMap sync.Map
View Source
var DefaultCleanWhiteList = []string{"spockadmin"}
View Source
var ErrUnsupportedService = errors.New("unsupported workload type (only support Deployment/StatefulSet) or workload number is not 1")

Functions

func AutoDeployHelmServiceToEnvs added in v1.9.9

func AutoDeployHelmServiceToEnvs(userName, requestID, projectName string, serviceTemplates []*commonmodels.Service, log *zap.SugaredLogger) error

func AutoDeployYamlServiceToEnvs added in v1.9.9

func AutoDeployYamlServiceToEnvs(userName, requestID string, serviceTemplate *commonmodels.Service, log *zap.SugaredLogger) error

func BulkCopyHelmProduct added in v1.9.9

func BulkCopyHelmProduct(projectName, user, requestID string, arg CopyHelmProductArg, log *zap.SugaredLogger) error

func BulkCopyYamlProduct added in v1.9.9

func BulkCopyYamlProduct(projectName, user, requestID string, arg CopyYamlProductArg, log *zap.SugaredLogger) error

func CheckServicesDeployedInSubEnvs added in v1.9.9

func CheckServicesDeployedInSubEnvs(ctx context.Context, productName, envName string, services []string) (map[string][]string, error)

Map of map[ServiceName][]string{EnvName} is returned.

func CheckWorkloadsK8sServices added in v1.9.9

func CheckWorkloadsK8sServices(ctx context.Context, envName, productName string) ([]string, error)

Slice of `<workload name>.<workload type>` and error are returned.

func CleanProductCronJob

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

func CleanProducts

func CleanProducts()

func ConnectSshPmExec added in v1.9.9

func ConnectSshPmExec(c *gin.Context, username, envName, productName, ip, hostId string, cols, rows int, log *zap.SugaredLogger) error

func CopyHelmProduct added in v1.8.0

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

func CopyYamlProduct added in v1.9.9

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

CopyYamlProduct copy product from source product

func CreateCommonEnvCfg added in v1.9.9

func CreateCommonEnvCfg(args *models.CreateUpdateCommonEnvCfgArgs, userName string, log *zap.SugaredLogger) error

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 DeleteClusterInformer added in v1.9.9

func DeleteClusterInformer(clusterID string)

func DeleteCommonEnvCfg added in v1.9.9

func DeleteCommonEnvCfg(envName, productName, objectName string, commonEnvCfgType config.CommonEnvCfgType, log *zap.SugaredLogger) error

func DeletePod

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

func DeleteProduct added in v1.9.9

func DeleteProduct(username, envName, productName, requestID string, isDelete bool, log *zap.SugaredLogger) (err error)

func DeleteProductServices added in v1.9.9

func DeleteProductServices(userName, requestID, envName, productName string, serviceNames []string, log *zap.SugaredLogger) (err error)

func DisableBaseEnv added in v1.9.9

func DisableBaseEnv(ctx context.Context, envName, productName string) error

func DownloadFile added in v1.9.9

func DownloadFile(envName, productName, podName, container, path string, log *zap.SugaredLogger) ([]byte, string, error)

func EnableBaseEnv added in v1.9.9

func EnableBaseEnv(ctx context.Context, envName, productName string) error

func EnsureDeletePreCreatedServices added in v1.12.0

func EnsureDeletePreCreatedServices(ctx context.Context, productName, namespace string, chartSpec *helmclient.ChartSpec, helmClient *helmtool.HelmClient) error

func EnsureDeleteShareEnvConfig added in v1.9.9

func EnsureDeleteShareEnvConfig(ctx context.Context, env *commonmodels.Product, istioClient versionedclient.Interface) error

func EnsureDeleteZadigService added in v1.9.9

func EnsureDeleteZadigService(ctx context.Context, env *commonmodels.Product, svcSelector labels.Selector, kclient client.Client, istioClient versionedclient.Interface) error

func EnsureDeleteZadigServiceByHelmRelease added in v1.12.0

func EnsureDeleteZadigServiceByHelmRelease(ctx context.Context, env *commonmodels.Product, releaseName string, helmClient helmclient.Client) error

func EnsureGrayEnvConfig added in v1.9.9

func EnsureGrayEnvConfig(ctx context.Context, env *commonmodels.Product, kclient client.Client, istioClient versionedclient.Interface) error

func EnsureUpdateZadigService added in v1.9.9

func EnsureUpdateZadigService(ctx context.Context, env *commonmodels.Product, svcName string, kclient client.Client, istioClient versionedclient.Interface) error

func EnsureZadigServiceByManifest added in v1.12.0

func EnsureZadigServiceByManifest(ctx context.Context, productName, namespace, manifest string) 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, envName 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 GetBundleResources added in v1.7.1

func GetBundleResources(logger *zap.SugaredLogger) ([]*resourceSpec, error)

func GetEnvServiceList added in v1.9.9

func GetEnvServiceList(ctx context.Context, productName, baseEnvName string) ([][]string, 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, envType types.EnvType, isBaseEnv bool, baseEnvName string, log *zap.SugaredLogger) (*commonmodels.Product, error)

func GetMergedYamlContent added in v1.6.0

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

func GetProductAndFilterNs added in v1.9.9

func GetProductAndFilterNs(namespace, workloadName, svcName string) (*models.Product, bool)

func GetProductInfo

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

func GetServiceContainer

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

func InstallService added in v1.9.9

func InstallService(helmClient *helmtool.HelmClient, param *ReleaseInstallParam) error

func ListAvailableNamespaces

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

ListAvailableNamespaces lists available namespaces created by non-koderover

func ListCustomWorkload added in v1.9.9

func ListCustomWorkload(clusterID, namespace string, log *zap.SugaredLogger) ([]string, 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 ListNamespace added in v1.9.9

func ListNamespace(clusterID string, log *zap.SugaredLogger) ([]string, error)

func ListPodEvents

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

func ListServicePods

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

func MigrateHistoryConfigMaps added in v1.9.9

func MigrateHistoryConfigMaps(envName, productName string, log *zap.SugaredLogger) ([]*models.EnvResource, error)

func NewClusterInformerFactory added in v1.9.9

func NewClusterInformerFactory(clusterID string, cls *kubernetes.Clientset) (informers.SharedInformerFactory, error)

func PatchDebugContainer added in v1.9.9

func PatchDebugContainer(ctx context.Context, projectName, envName, podName, debugImage string) error

func PatchWorkload added in v1.9.9

func PatchWorkload(ctx context.Context, projectName, envName, serviceName, devImage string) (*types.WorkloadInfo, error)

func ReInstallHelmSvcInAllEnvs added in v1.9.9

func ReInstallHelmSvcInAllEnvs(productName string, templateSvc *commonmodels.Service) error

ReInstallHelmSvcInAllEnvs reinstall svc in all envs in which the svc is already installed

func RecoverWorkload added in v1.9.9

func RecoverWorkload(ctx context.Context, projectName, envName, serviceName string) 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 StartClusterInformer added in v1.9.9

func StartClusterInformer()

func SyncEnvResource added in v1.9.9

func SyncEnvResource(args *SyncEnvResourceArg, log *zap.SugaredLogger) error

func SyncHelmProductEnvironment added in v1.9.9

func SyncHelmProductEnvironment(productName, envName, requestID string, log *zap.SugaredLogger) error

func SyncYamlFromSource added in v1.9.9

func SyncYamlFromSource(yamlData *templatemodels.CustomYaml, curValue string) (bool, string, error)

SyncYamlFromSource sync values.yaml from source NOTE currently only support gitHub and gitlab

func UninstallService added in v1.11.0

func UninstallService(helmClient helmclient.Client, env *commonmodels.Product, revisionSvc *commonmodels.Service, force bool) error

func UninstallServiceByName added in v1.11.0

func UninstallServiceByName(helmClient helmclient.Client, serviceName string, env *commonmodels.Product, revision int64, force bool) error

func UpdateCommonEnvCfg added in v1.9.9

func UpdateCommonEnvCfg(args *models.CreateUpdateCommonEnvCfgArgs, userName string, updateContentOnly bool, log *zap.SugaredLogger) error

func UpdateConfigMap

func UpdateConfigMap(args *models.CreateUpdateCommonEnvCfgArgs, userName 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, username, requestID string, overrideCharts []*commonservice.RenderChartArg, deletedServices []string, log *zap.SugaredLogger) error

func UpdateHelmProductCharts added in v1.9.9

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

func UpdateHelmProductDefaultValues added in v1.12.0

func UpdateHelmProductDefaultValues(productName, envName, userName, requestID string, args *EnvRendersetArg, 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 []*templatemodels.RenderChart, renderset *commonmodels.RenderSet, log *zap.SugaredLogger) error

func UpdateOrCreateIngress added in v1.9.9

func UpdateOrCreateIngress(args *models.CreateUpdateCommonEnvCfgArgs, userName string, isCreate bool, log *zap.SugaredLogger) error

func UpdateProduct

func UpdateProduct(serviceNames []string, 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 UpdateProductRegistry added in v1.8.0

func UpdateProductRegistry(envName, productName, registryID string, log *zap.SugaredLogger) (err error)

func UpdateProductV2

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

func UpdatePvc added in v1.9.9

func UpdatePvc(args *models.CreateUpdateCommonEnvCfgArgs, userName string, log *zap.SugaredLogger) error

func UpdateSecret added in v1.9.9

func UpdateSecret(args *models.CreateUpdateCommonEnvCfgArgs, userName string, log *zap.SugaredLogger) error

func UpdateService

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

func VisitDeployment added in v1.9.9

func VisitDeployment(deployment *appsv1.Deployment) (sets.String, sets.String, sets.String)

func VisitStatefulSet added in v1.9.9

func VisitStatefulSet(sts *appsv1.StatefulSet) (sets.String, sets.String, sets.String)

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 ChartImagesResp added in v1.9.9

type ChartImagesResp struct {
	ServiceImages []*ServiceImages `json:"serviceImages"`
}

func GetImageInfos added in v1.9.9

func GetImageInfos(productName, envName, serviceNames string, log *zap.SugaredLogger) (*ChartImagesResp, error)

type ChartInfo added in v1.8.0

type ChartInfo struct {
	ServiceName string `json:"serviceName"`
	Revision    int64  `json:"revision"`
}

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 CopyHelmProductArg added in v1.9.9

type CopyHelmProductArg struct {
	Items []HelmProductItem
}

type CopyYamlProductArg added in v1.9.9

type CopyYamlProductArg struct {
	Items []YamlProductItem `json:"items"`
}

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"`
	ValuesData    *commonservice.ValuesDataArgs   `json:"valuesData"`
	RegistryID    string                          `json:"registry_id"`
	ChartValues   []*commonservice.RenderChartArg `json:"chartValues"`
	BaseEnvName   string                          `json:"baseEnvName"`
	BaseName      string                          `json:"base_name,omitempty"`
	IsExisted     bool                            `json:"is_existed"`
	// New Since v1.12.0
	ShareEnv commonmodels.ProductShareEnv `json:"share_env"`
	// New Since v1.13.0
	EnvConfigs []*commonmodels.CreateUpdateCommonEnvCfgArgs `json:"env_configs"`
}

type CreateProductParam added in v1.5.0

type CreateProductParam struct {
	UserName    string
	RequestId   string
	ProductName string
	EnvType     string

	RegistryID 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"`
	YamlData      *templatemodels.CustomYaml `json:"yaml_data,omitempty"`
}

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"`
	ValuesData        *commonservice.ValuesDataArgs   `json:"valuesData"`
	ChartValues       []*commonservice.RenderChartArg `json:"chartValues"`
	UpdateServiceTmpl bool                            `json:"updateServiceTmpl"`
}

type EnvResp added in v1.7.1

type EnvResp struct {
	ProjectName string   `json:"projectName"`
	Status      string   `json:"status"`
	Error       string   `json:"error"`
	Name        string   `json:"name"`
	UpdateBy    string   `json:"updateBy"`
	UpdateTime  int64    `json:"updateTime"`
	IsPublic    bool     `json:"isPublic"`
	ClusterName string   `json:"clusterName"`
	ClusterID   string   `json:"cluster_id"`
	Production  bool     `json:"production"`
	Source      string   `json:"source"`
	RegistryID  string   `json:"registry_id"`
	BaseRefs    []string `json:"base_refs"`
	BaseName    string   `json:"base_name"`
	IsExisted   bool     `json:"is_existed"`

	// New Since v1.11.0
	ShareEnvEnable  bool   `json:"share_env_enable"`
	ShareEnvIsBase  bool   `json:"share_env_is_base"`
	ShareEnvBaseEnv string `json:"share_env_base_env"`
}

func ListProducts

func ListProducts(projectName string, envNames []string, log *zap.SugaredLogger) ([]*EnvResp, error)

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(args []*UpdateEnv, envNames []string, productName, requestID string, force bool, log *zap.SugaredLogger) ([]*EnvStatus, error)

func UpdateMultipleHelmEnv added in v1.5.0

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

type EnvoyAddress added in v1.9.9

type EnvoyAddress struct {
	SocketAddress EnvoySocketAddress `json:"socket_address"`
}

type EnvoyClusterConfigLoadAssignment added in v1.9.9

type EnvoyClusterConfigLoadAssignment struct {
	ClusterName string             `json:"cluster_name"`
	Endpoints   []EnvoyLBEndpoints `json:"endpoints"`
}

type EnvoyEndpoint added in v1.9.9

type EnvoyEndpoint struct {
	Address EnvoyAddress `json:"address"`
}

type EnvoyEndpoints added in v1.9.9

type EnvoyEndpoints struct {
	Endpoint EnvoyEndpoint `json:"endpoint"`
}

type EnvoyLBEndpoints added in v1.9.9

type EnvoyLBEndpoints struct {
	LBEndpoints []EnvoyEndpoints `json:"lb_endpoints"`
}

type EnvoySocketAddress added in v1.9.9

type EnvoySocketAddress struct {
	Protocol  string `json:"protocol"`
	Address   string `json:"address"`
	PortValue int    `json:"port_value"`
}

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 HelmChartsResp added in v1.8.0

type HelmChartsResp struct {
	ChartInfos []*ChartInfo      `json:"chartInfos"`
	FileInfos  []*types.FileInfo `json:"fileInfos"`
}

func GetChartInfos added in v1.8.0

func GetChartInfos(productName, envName, serviceName string, log *zap.SugaredLogger) (*HelmChartsResp, 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 HelmProductItem added in v1.9.9

type HelmProductItem struct {
	OldName       string                          `json:"old_name"`
	NewName       string                          `json:"new_name"`
	BaseName      string                          `json:"base_name"`
	DefaultValues string                          `json:"default_values"`
	ChartValues   []*commonservice.RenderChartArg `json:"chart_values"`
}

type HelmReleaseQueryArgs added in v1.9.9

type HelmReleaseQueryArgs struct {
	ProjectName string `json:"projectName"     form:"projectName"`
	Filter      string `json:"filter"          form:"filter"`
}

type HelmReleaseResp added in v1.8.0

type HelmReleaseResp struct {
	ReleaseName string        `json:"releaseName"`
	ServiceName string        `json:"serviceName"`
	Revision    int           `json:"revision"`
	Chart       string        `json:"chart"`
	AppVersion  string        `json:"appVersion"`
	Status      ReleaseStatus `json:"status"`
	Updatable   bool          `json:"updatable"`
	Error       string        `json:"error"`
}

func ListReleases added in v1.8.0

func ListReleases(args *HelmReleaseQueryArgs, envName string, log *zap.SugaredLogger) ([]*HelmReleaseResp, error)

type IProductCreator added in v1.5.0

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

type ImageData added in v1.9.9

type ImageData struct {
	ImageName string `json:"imageName"`
	ImageTag  string `json:"imageTag"`
	Selected  bool   `json:"selected"`
}

type K8sService

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

type ListCommonEnvCfgHistoryArgs added in v1.9.9

type ListCommonEnvCfgHistoryArgs struct {
	EnvName          string                  `json:"env_name"            form:"envName"`
	ProjectName      string                  `json:"project_name"        form:"projectName"`
	Name             string                  `json:"name"                form:"name"`
	CommonEnvCfgType config.CommonEnvCfgType `json:"common_env_cfg_type" form:"commonEnvCfgType"`
	AutoSync         bool                    `json:"auto_sync"           form:"autoSync"`
}

type ListCommonEnvCfgHistoryRes added in v1.9.9

type ListCommonEnvCfgHistoryRes struct {
	ID             primitive.ObjectID     `json:"id,omitempty"`
	ProductName    string                 `json:"product_name"`
	CreateTime     int64                  `json:"create_time"`
	UpdateUserName string                 `json:"update_user_name"`
	Namespace      string                 `json:"namespace,omitempty"`
	EnvName        string                 `json:"env_name"`
	Name           string                 `json:"name"`
	Type           string                 `json:"type"`
	YamlData       string                 `json:"yaml_data"`
	SourceDetail   *models.CreateFromRepo `json:"source_detail"`
}

func ListEnvResourceHistory added in v1.9.9

func ListEnvResourceHistory(args *ListCommonEnvCfgHistoryArgs, log *zap.SugaredLogger) ([]*ListCommonEnvCfgHistoryRes, error)

func ListLatestEnvResources added in v1.9.9

func ListLatestEnvResources(args *ListCommonEnvCfgHistoryArgs, log *zap.SugaredLogger) ([]*ListCommonEnvCfgHistoryRes, error)

type ListConfigMapArgs

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

type ListConfigMapRes added in v1.9.9

type ListConfigMapRes struct {
	*ResourceResponseBase
	CmName    string            `json:"cm_name"`
	Immutable bool              `json:"immutable"`
	CmData    map[string]string `json:"cm_data"`
}

func ListConfigMaps

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

type ListIngressesResponse added in v1.9.9

type ListIngressesResponse struct {
	*ResourceResponseBase
	IngressName string `json:"ingress_name"`
	HostInfo    string `json:"host_info"`
	Address     string `json:"address"`
	Ports       string `json:"ports"`
	ErrorReason string `json:"error_reason"`
}

func ListIngresses added in v1.9.9

func ListIngresses(envName, productName string, log *zap.SugaredLogger) ([]*ListIngressesResponse, error)

type ListPvcsResponse added in v1.9.9

type ListPvcsResponse struct {
	*ResourceResponseBase
	PvcName      string `json:"pvc_name"`
	Status       string `json:"status"`
	Volume       string `json:"volume"`
	AccessModes  string `json:"access_modes"`
	StorageClass string `json:"storageclass"`
	Capacity     string `json:"capacity"`
}

func ListPvcs added in v1.9.9

func ListPvcs(envName, productName string, log *zap.SugaredLogger) ([]*ListPvcsResponse, error)

type ListSecretsResponse added in v1.9.9

type ListSecretsResponse struct {
	*ResourceResponseBase
	SecretName string `json:"secret_name"`
	SecretType string `json:"secret_type"`
}

func ListSecrets added in v1.9.9

func ListSecrets(envName, productName string, log *zap.SugaredLogger) ([]*ListSecretsResponse, error)

type MatchedEnv added in v1.9.9

type MatchedEnv struct {
	EnvName   string
	Namespace string
}

type MigrateHistoryConfigMapsRes added in v1.9.9

type MigrateHistoryConfigMapsRes struct {
}

type NodeResp added in v1.8.0

type NodeResp struct {
	Nodes  []*internalresource.Node `json:"data"`
	Labels []string                 `json:"labels"`
}

func ListAvailableNodes added in v1.8.0

func ListAvailableNodes(clusterID string, log *zap.SugaredLogger) (*NodeResp, error)

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"`
}

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        []*templatemodels.RenderKV `json:"vars"`
	IsPublic    bool                       `json:"isPublic"`
	ClusterID   string                     `json:"cluster_id,omitempty"`
	ClusterName string                     `json:"cluster_name,omitempty"`
	RecycleDay  int                        `json:"recycle_day"`
	IsProd      bool                       `json:"is_prod"`
	IsLocal     bool                       `json:"is_local"`
	IsExisted   bool                       `json:"is_existed"`
	Source      string                     `json:"source"`
	RegisterID  string                     `json:"registry_id"`

	// New Since v1.11.0
	ShareEnvEnable  bool   `json:"share_env_enable"`
	ShareEnvIsBase  bool   `json:"share_env_is_base"`
	ShareEnvBaseEnv string `json:"share_env_base_env"`
}

func GetProduct

func GetProduct(username, envName, productName string, log *zap.SugaredLogger) (*ProductResp, 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, log *zap.SugaredLogger) (*ProductRevision, error)

func ListProductsRevision

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

func ListProductsRevisionByOption added in v1.11.0

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

ListProductsRevisionByOption called by service cron

func (*ProductRevision) GroupsUpdated

func (pr *ProductRevision) GroupsUpdated() bool

type RawYamlResp added in v1.6.0

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

type ReleaseFilter added in v1.9.9

type ReleaseFilter struct {
	Name   string        `json:"name"`
	Status ReleaseStatus `json:"status"`
}

type ReleaseInstallParam added in v1.11.0

type ReleaseInstallParam struct {
	ProductName  string
	Namespace    string
	ReleaseName  string
	MergedValues string
	RenderChart  *templatemodels.RenderChart

	DryRun bool
	// contains filtered or unexported fields
}

type ReleaseStatus added in v1.9.9

type ReleaseStatus string
const (
	HelmReleaseStatusPending     ReleaseStatus = "pending"
	HelmReleaseStatusDeployed    ReleaseStatus = "deployed"
	HelmReleaseStatusFailed      ReleaseStatus = "failed"
	HelmReleaseStatusNotDeployed ReleaseStatus = "notDeployed"
)

type ResourceResponseBase added in v1.9.9

type ResourceResponseBase struct {
	Name           string                  `json:"-"`
	Type           config.CommonEnvCfgType `json:"-"`
	EnvName        string                  `json:"-"`
	ProjectName    string                  `json:"-"`
	YamlData       string                  `json:"yaml_data"`
	UpdateUserName string                  `json:"update_username"`
	CreateTime     time.Time               `json:"create_time"`
	Services       []string                `json:"services"`
	SourceDetail   *models.CreateFromRepo  `json:"source_detail"`
	AutoSync       bool                    `json:"auto_sync"`
}

type ResourceWithLabel added in v1.9.9

type ResourceWithLabel interface {
	GetLabels() map[string]string
	SetLabels(labels map[string]string)
	SetNamespace(ns string)
}

func GetResourceByCfgType added in v1.9.9

func GetResourceByCfgType(namespace, name string, cfgType config.CommonEnvCfgType, client client.Client, clientset *kubernetes.Clientset) (ResourceWithLabel, error)

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 ServiceImages added in v1.9.9

type ServiceImages struct {
	ServiceName string       `json:"serviceName"`
	Images      []*ImageData `json:"imageData"`
}

type ServiceMatchedDeploymentContainers added in v1.9.9

type ServiceMatchedDeploymentContainers struct {
	ServiceName string `json:"service_name"`
	Deployment  struct {
		DeploymentName string   `json:"deployments_name"`
		ContainerNames []string `json:"container_names"`
	} `json:"deployment"`
}

func ListCanaryDeploymentServiceInfo added in v1.9.9

func ListCanaryDeploymentServiceInfo(clusterID, namespace string, log *zap.SugaredLogger) ([]*ServiceMatchedDeploymentContainers, error)

list serivce and matched deployment containers for canary and blue-green deployment.

type ShareEnvOp added in v1.9.9

type ShareEnvOp string
const (
	ShareEnvEnable  ShareEnvOp = "enable"
	ShareEnvDisable ShareEnvOp = "disable"
)

type ShareEnvReady added in v1.9.9

type ShareEnvReady struct {
	IsReady bool                `json:"is_ready"`
	Checks  ShareEnvReadyChecks `json:"checks"`
}

func CheckShareEnvReady added in v1.9.9

func CheckShareEnvReady(ctx context.Context, envName, op, productName string) (*ShareEnvReady, error)

func (*ShareEnvReady) CheckAndSetReady added in v1.9.9

func (s *ShareEnvReady) CheckAndSetReady(state ShareEnvOp)

Note: `WorkloadsHaveK8sService` is an optional condition.

type ShareEnvReadyChecks added in v1.9.9

type ShareEnvReadyChecks struct {
	NamespaceHasIstioLabel  bool `json:"namespace_has_istio_label"`
	VirtualServicesDeployed bool `json:"virtualservice_deployed"`
	PodsHaveIstioProxy      bool `json:"pods_have_istio_proxy"`
	WorkloadsReady          bool `json:"workloads_ready"`
	WorkloadsHaveK8sService bool `json:"workloads_have_k8s_service"`
}

type SvcDataSet added in v1.9.9

type SvcDataSet struct {
	ProdSvc    *models.ProductService
	TmplSvc    *models.Service
	SvcRelease *release.Release
}

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 SyncEnvResourceArg added in v1.9.9

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

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"`
	YamlData             string   `json:"yaml_data"`
	RestartAssociatedSvc bool     `json:"restart_associated_svc"`
	Services             []string `json:"services"`
}

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 UpdateEnv added in v1.9.9

type UpdateEnv struct {
	EnvName      string               `json:"env_name"`
	ServiceNames []string             `json:"service_names"`
	UpdateType   string               `json:"update_type,omitempty"`
	Vars         []*template.RenderKV `json:"vars,omitempty"`
}

type UpdateIngressArgs added in v1.9.9

type UpdateIngressArgs struct {
	EnvName              string `json:"env_name"`
	ProductName          string `json:"product_name"`
	IngressName          string `json:"ingress_name"`
	YamlData             string `json:"yaml_data"`
	RestartAssociatedSvc bool   `json:"restart_associated_svc"`
}

type UpdateMultiHelmProductArg added in v1.5.0

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

type UpdatePvcArgs added in v1.9.9

type UpdatePvcArgs struct {
	EnvName              string `json:"env_name"`
	ProductName          string `json:"product_name"`
	PvcName              string `json:"pvc_name"`
	YamlData             string `json:"yaml_data"`
	RestartAssociatedSvc bool   `json:"restart_associated_svc"`
}

type ValuesResp added in v1.12.0

type ValuesResp struct {
	ValuesYaml string `json:"valuesYaml"`
}

func GetChartValues added in v1.12.0

func GetChartValues(projectName, envName, serviceName string) (*ValuesResp, error)

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"`
	Namespace   string `json:"namespace" form:"namespace"`
	Branch      string `json:"branch" form:"branch"`
	RepoLink    string `json:"repoLink" form:"repoLink"`
	ValuesPaths string `json:"valuesPaths" form:"valuesPaths"`
}

type YamlProductItem added in v1.9.9

type YamlProductItem struct {
	OldName  string                     `json:"old_name"`
	NewName  string                     `json:"new_name"`
	BaseName string                     `json:"base_name"`
	Vars     []*templatemodels.RenderKV `json:"vars"`
}

Jump to

Keyboard shortcuts

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