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: 61 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateK8sWorkLoads added in v1.5.0

func CreateK8sWorkLoads(ctx context.Context, requestID, userName string, args *K8sWorkloadsArgs, log *zap.SugaredLogger) error

func CreatePMService added in v1.2.0

func CreatePMService(username string, args *ServiceTmplBuildObject, log *zap.SugaredLogger) error

func CreateWorkloadTemplate added in v1.5.0

func CreateWorkloadTemplate(userName string, args *commonmodels.Service, log *zap.SugaredLogger) error

CreateWorkloadTemplate only use for workload

func DeleteServiceTemplate

func DeleteServiceTemplate(serviceName, serviceType, productName, isEnvTemplate, visibility string, log *zap.SugaredLogger) error

func EditFileContent added in v1.9.9

func EditFileContent(serviceName, productName, createdBy, requestID string, param *HelmChartEditInfo, logger *zap.SugaredLogger) error

func GetDeployableEnvs added in v1.9.9

func GetDeployableEnvs(svcName, projectName string) ([]string, error)

The service can be deployed only in the following situations:

  1. All general environments are deployable.
  2. All base environments are deployable.
  3. If the service has been deployed in the baseline environment, all sub-environments of the baseline environment can deploy the service. Otherwise, all sub-environments of the baseline environment cannot deploy the service.

func GetFileContent added in v1.2.0

func GetFileContent(serviceName, productName string, param *GetFileContentParam, log *zap.SugaredLogger) (string, error)

func GetFilePath added in v1.2.0

func GetFilePath(serviceName, productName string, revision int64, dir string, _ *zap.SugaredLogger) ([]*types.FileInfo, error)

func GetGerritServiceYaml

func GetGerritServiceYaml(args *commonmodels.Service, log *zap.SugaredLogger) error

func GetHarborURL added in v1.2.0

func GetHarborURL(path string) (string, error)

func ListAvailablePublicServices added in v1.3.1

func ListAvailablePublicServices(productName string, log *zap.SugaredLogger) ([]*svcInfo, error)

ListAvailablePublicServices returns all public services which are not shared in the given project.

func ListServicePort

func ListServicePort(serviceName, serviceType, productName, excludeStatus string, revision int64, log *zap.SugaredLogger) ([]int, error)

func ListServicesInExtenalEnv

func ListServicesInExtenalEnv(tmpResp *commonservice.ServiceTmplResp, log *zap.SugaredLogger)

func LoadKubeWorkloadsYaml added in v1.9.9

func LoadKubeWorkloadsYaml(username string, params *LoadKubeWorkloadsYamlReq, force bool, log *zap.SugaredLogger) error

func LoadServiceFromCodeHost

func LoadServiceFromCodeHost(username string, codehostID int, repoOwner, namespace, repoName, repoUUID, branchName, remoteName string, args *LoadServiceReq, force bool, log *zap.SugaredLogger) error

LoadServiceFromCodeHost 根据提供的codehost信息加载服务

func LoadServiceFromYamlTemplate added in v1.6.0

func LoadServiceFromYamlTemplate(username string, req *LoadServiceFromYamlTemplateReq, force bool, logger *zap.SugaredLogger) error

func PreloadServiceFromCodeHost

func PreloadServiceFromCodeHost(codehostID int, repoOwner, repoName, repoUUID, branchName, remoteName, path string, isDir bool, log *zap.SugaredLogger) ([]string, error)

func PreviewServiceFromYamlTemplate added in v1.9.9

func PreviewServiceFromYamlTemplate(req *LoadServiceFromYamlTemplateReq, logger *zap.SugaredLogger) (string, error)

func ReloadServiceFromYamlTemplate added in v1.6.0

func ReloadServiceFromYamlTemplate(username string, req *LoadServiceFromYamlTemplateReq, logger *zap.SugaredLogger) error

func SplitYaml

func SplitYaml(yaml string) []string

func SyncServiceFromTemplate added in v1.9.9

func SyncServiceFromTemplate(userName, source, templateId, templateName string, logger *zap.SugaredLogger) error

SyncServiceFromTemplate syncs services from (yaml|chart)template

func UpdateReleaseNamingRule added in v1.9.9

func UpdateReleaseNamingRule(userName, requestID, projectName string, args *ReleaseNamingRule, log *zap.SugaredLogger) error

func UpdateServiceHealthCheckStatus added in v1.8.0

func UpdateServiceHealthCheckStatus(args *commonservice.ServiceTmplObject) error

func UpdateServiceVisibility added in v1.8.0

func UpdateServiceVisibility(args *commonservice.ServiceTmplObject) error

func UpdateWorkloads added in v1.5.0

func UpdateWorkloads(ctx context.Context, requestID, username, productName, envName string, args UpdateWorkloadsArgs, log *zap.SugaredLogger) error

func ValidateServiceUpdate

func ValidateServiceUpdate(codehostID int, serviceName, repoOwner, repoName, repoUUID, branchName, remoteName, path string, isDir bool, log *zap.SugaredLogger) error

ValidateServiceUpdate 根据服务名和提供的加载信息确认是否可以更新服务加载地址

func YamlValidator

func YamlValidator(args *YamlValidatorReq) []string

func YamlViewServiceTemplate added in v1.12.0

func YamlViewServiceTemplate(args *YamlViewServiceTemplateReq) (string, error)

Types

type BulkHelmServiceCreationArgs added in v1.6.0

type BulkHelmServiceCreationArgs struct {
	HelmLoadSource
	CreateFrom interface{}             `json:"createFrom"`
	CreatedBy  string                  `json:"createdBy"`
	RequestID  string                  `json:"-"`
	ValuesData *service.ValuesDataArgs `json:"valuesData"`
	AutoSync   bool                    `json:"auto_sync"`
}

func (*BulkHelmServiceCreationArgs) UnmarshalJSON added in v1.6.0

func (a *BulkHelmServiceCreationArgs) UnmarshalJSON(data []byte) error

type BulkHelmServiceCreationResponse added in v1.6.0

type BulkHelmServiceCreationResponse struct {
	SuccessServices []string         `json:"successServices"`
	FailedServices  []*FailedService `json:"failedServices"`
}

func CreateOrUpdateBulkHelmService added in v1.6.0

func CreateOrUpdateBulkHelmService(projectName string, args *BulkHelmServiceCreationArgs, force bool, logger *zap.SugaredLogger) (*BulkHelmServiceCreationResponse, error)

func CreateOrUpdateBulkHelmServiceFromTemplate added in v1.6.0

func CreateOrUpdateBulkHelmServiceFromTemplate(projectName string, args *BulkHelmServiceCreationArgs, force bool, logger *zap.SugaredLogger) (*BulkHelmServiceCreationResponse, error)

func CreateOrUpdateHelmService added in v1.4.0

func CreateOrUpdateHelmService(projectName string, args *HelmServiceCreationArgs, force bool, logger *zap.SugaredLogger) (*BulkHelmServiceCreationResponse, error)

func CreateOrUpdateHelmServiceFromChartRepo added in v1.9.9

func CreateOrUpdateHelmServiceFromChartRepo(projectName string, args *HelmServiceCreationArgs, force bool, log *zap.SugaredLogger) (*BulkHelmServiceCreationResponse, error)

func CreateOrUpdateHelmServiceFromChartTemplate added in v1.5.0

func CreateOrUpdateHelmServiceFromChartTemplate(projectName string, args *HelmServiceCreationArgs, force bool, logger *zap.SugaredLogger) (*BulkHelmServiceCreationResponse, error)

func CreateOrUpdateHelmServiceFromGitRepo added in v1.5.0

func CreateOrUpdateHelmServiceFromGitRepo(projectName string, args *HelmServiceCreationArgs, force bool, log *zap.SugaredLogger) (*BulkHelmServiceCreationResponse, error)

func CreateOrUpdateHelmServiceFromRepo added in v1.9.9

func CreateOrUpdateHelmServiceFromRepo(projectName string, args *HelmServiceCreationArgs, force bool, log *zap.SugaredLogger) (*BulkHelmServiceCreationResponse, error)

type Chart added in v1.2.0

type Chart struct {
	APIVersion string `json:"apiVersion"`
	Name       string `json:"name"`
	Version    string `json:"version"`
	AppVersion string `json:"appVersion"`
}

type ChartTemplateData added in v1.6.0

type ChartTemplateData struct {
	TemplateName      string
	TemplateData      *commonmodels.Chart
	ChartName         string
	ChartVersion      string
	DefaultValuesYAML []byte // content of values.yaml in template
}

type CreateFromChartRepo added in v1.9.9

type CreateFromChartRepo struct {
	ChartRepoName string `json:"chartRepoName"`
	ChartName     string `json:"chartName"`
	ChartVersion  string `json:"chartVersion"`
}

type CreateFromChartTemplate added in v1.5.0

type CreateFromChartTemplate struct {
	TemplateName string      `json:"templateName"`
	ValuesYAML   string      `json:"valuesYAML"`
	Variables    []*Variable `json:"variables"`
}

type CreateFromPublicRepo added in v1.5.0

type CreateFromPublicRepo struct {
	RepoLink string   `json:"repoLink"`
	Paths    []string `json:"paths"`
}

type CreateFromRepo added in v1.5.0

type CreateFromRepo struct {
	CodehostID int      `json:"codehostID"`
	Owner      string   `json:"owner"`
	Namespace  string   `json:"namespace"`
	Repo       string   `json:"repo"`
	Branch     string   `json:"branch"`
	Paths      []string `json:"paths"`
}

func PublicRepoToPrivateRepoArgs added in v1.5.0

func PublicRepoToPrivateRepoArgs(args *CreateFromPublicRepo) (*CreateFromRepo, error)

type CronjobResource

type CronjobResource struct {
	APIVersion string `yaml:"apiVersion"`
	Kind       string `yaml:"kind"`
	Metadata   struct {
		Name string `yaml:"name"`
	} `yaml:"metadata"`
	Spec struct {
		Template struct {
			Spec struct {
				Template struct {
					Spec struct {
						Containers []map[string]interface{} `yaml:"containers"`
					} `yaml:"spec"`
				} `yaml:"template"`
			} `yaml:"spec"`
		} `yaml:"jobTemplate"`
	} `yaml:"spec"`
}

type FailedService added in v1.6.0

type FailedService struct {
	Path  string `json:"path"`
	Error string `json:"error"`
}

type GetFileContentParam added in v1.8.0

type GetFileContentParam struct {
	FilePath        string `json:"filePath"        form:"filePath"`
	FileName        string `json:"fileName"        form:"fileName"`
	Revision        int64  `json:"revision"        form:"revision"`
	DeliveryVersion bool   `json:"deliveryVersion" form:"deliveryVersion"`
}

type GetKubeWorkloadsResp added in v1.9.9

type GetKubeWorkloadsResp struct {
	WorkloadsMap map[string][]string `json:"workloads_map"`
}

func GetKubeWorkloads added in v1.9.9

func GetKubeWorkloads(namespace, clusterID string, log *zap.SugaredLogger) (*GetKubeWorkloadsResp, error)

type GetKubeWorkloadsYamlResp added in v1.9.9

type GetKubeWorkloadsYamlResp struct {
	Services []ServiceYaml `json:"services"`
}

type HarborChartDetail added in v1.2.0

type HarborChartDetail struct {
	Metadata struct {
		Name        string    `json:"name"`
		Version     string    `json:"version"`
		Description string    `json:"description"`
		APIVersion  string    `json:"apiVersion"`
		AppVersion  string    `json:"appVersion"`
		Urls        []string  `json:"urls"`
		Created     time.Time `json:"created"`
		Digest      string    `json:"digest"`
	} `json:"metadata"`
	Dependencies []string               `json:"dependencies"`
	YamlValues   map[string]interface{} `json:"yaml_values"`
	Files        struct {
		ValuesYaml string `json:"values.yaml"`
	} `json:"files"`
	Security struct {
		Signature struct {
			Signed   bool   `json:"signed"`
			ProvFile string `json:"prov_file"`
		} `json:"signature"`
	} `json:"security"`
	Labels []string `json:"labels"`
}

func FindHarborChartDetail added in v1.2.0

func FindHarborChartDetail(project, chartName, version string, log *zap.SugaredLogger) (*HarborChartDetail, error)

type HarborChartRepo added in v1.2.0

type HarborChartRepo struct {
	Updated       string `json:"updated"`
	Name          string `json:"name"`
	Created       string `json:"created"`
	Deprecated    bool   `json:"deprecated"`
	TotalVersions int    `json:"total_versions"`
	LatestVersion string `json:"latest_version"`
	Home          string `json:"home"`
	Icon          string `json:"icon"`
}

func ListHarborChartRepos added in v1.2.0

func ListHarborChartRepos(project string, log *zap.SugaredLogger) ([]*HarborChartRepo, error)

type HarborChartVersion added in v1.2.0

type HarborChartVersion struct {
	Name        string    `json:"name"`
	Version     string    `json:"version"`
	Description string    `json:"description"`
	APIVersion  string    `json:"apiVersion"`
	AppVersion  string    `json:"appVersion"`
	Urls        []string  `json:"urls"`
	Created     time.Time `json:"created"`
	Digest      string    `json:"digest"`
	Labels      []string  `json:"labels"`
}

func ListHarborChartVersions added in v1.2.0

func ListHarborChartVersions(project, chartName string, log *zap.SugaredLogger) ([]*HarborChartVersion, error)

type HarborProject added in v1.2.0

type HarborProject struct {
	UpdateTime        string `json:"update_time"`
	OwnerName         string `json:"owner_name"`
	Name              string `json:"name"`
	Deleted           bool   `json:"deleted"`
	OwnerID           int    `json:"owner_id"`
	RepoCount         int    `json:"repo_count"`
	CreationTime      string `json:"creation_time"`
	Togglable         bool   `json:"togglable"`
	ProjectID         int    `json:"project_id"`
	CurrentUserRoleID int    `json:"current_user_role_id"`
	ChartCount        int    `json:"chart_count"`
	CveWhitelist      struct {
		Items []struct {
			CveID string `json:"cve_id"`
		} `json:"items"`
		ProjectID int `json:"project_id"`
		ID        int `json:"id"`
		ExpiresAt int `json:"expires_at"`
	} `json:"cve_whitelist"`
	Metadata struct {
		EnableContentTrust   string `json:"enable_content_trust"`
		AutoScan             string `json:"auto_scan"`
		Severity             string `json:"severity"`
		ReuseSysCveWhitelist string `json:"reuse_sys_cve_whitelist"`
		Public               string `json:"public"`
		PreventVul           string `json:"prevent_vul"`
	} `json:"metadata"`
}

func ListHarborProjects added in v1.2.0

func ListHarborProjects(page, pageSize int, log *zap.SugaredLogger) ([]*HarborProject, error)

type HelmChartEditInfo added in v1.9.9

type HelmChartEditInfo struct {
	FilePath    string `json:"file_path"`
	FileContent string `json:"file_content"`
}

type HelmLoadSource added in v1.5.0

type HelmLoadSource struct {
	Source LoadSource `json:"source"`
}

type HelmService added in v1.2.0

type HelmService struct {
	ServiceInfos []*commonmodels.Service `json:"service_infos"`
	FileInfos    []*types.FileInfo       `json:"file_infos"`
	Services     [][]string              `json:"services"`
}

func ListHelmServices added in v1.2.0

func ListHelmServices(productName string, log *zap.SugaredLogger) (*HelmService, error)

type HelmServiceCreationArgs added in v1.5.0

type HelmServiceCreationArgs struct {
	HelmLoadSource
	Name           string                  `json:"name"`
	CreatedBy      string                  `json:"createdBy"`
	RequestID      string                  `json:"-"`
	AutoSync       bool                    `json:"auto_sync"`
	CreateFrom     interface{}             `json:"createFrom"`
	ValuesData     *service.ValuesDataArgs `json:"valuesData"`
	CreationDetail interface{}             `json:"-"`
}

func (*HelmServiceCreationArgs) UnmarshalJSON added in v1.5.0

func (a *HelmServiceCreationArgs) UnmarshalJSON(data []byte) error

type HelmServiceModule added in v1.2.0

type HelmServiceModule struct {
	ServiceModules []*ServiceModule      `json:"service_modules"`
	Service        *commonmodels.Service `json:"service,omitempty"`
}

func GetHelmServiceModule added in v1.2.0

func GetHelmServiceModule(serviceName, productName string, revision int64, log *zap.SugaredLogger) (*HelmServiceModule, error)

type K8sWorkloadsArgs added in v1.9.9

type K8sWorkloadsArgs struct {
	WorkLoads   []commonmodels.Workload `json:"workLoads"`
	EnvName     string                  `json:"env_name"`
	ClusterID   string                  `json:"cluster_id"`
	Namespace   string                  `json:"namespace"`
	ProductName string                  `json:"product_name"`
	RegistryID  string                  `json:"registry_id"`
}

type KubeResource

type KubeResource struct {
	APIVersion string `yaml:"apiVersion"`
	Kind       string `yaml:"kind"`
	Metadata   struct {
		Name string `yaml:"name"`
	} `yaml:"metadata"`
	Spec struct {
		Template struct {
			Spec struct {
				Containers []map[string]interface{} `yaml:"containers"`
			} `yaml:"spec"`
		} `yaml:"template"`
	} `yaml:"spec"`
}

type KubeResourceKind

type KubeResourceKind struct {
	APIVersion string `yaml:"apiVersion"`
	Kind       string `yaml:"kind"`
	Metadata   struct {
		Name string `yaml:"name"`
	} `yaml:"metadata"`
}

type LoadKubeWorkloadsYamlReq added in v1.9.9

type LoadKubeWorkloadsYamlReq struct {
	ProductName string             `json:"product_name"`
	Visibility  string             `json:"visibility"`
	Type        string             `json:"type"`
	Namespace   string             `json:"namespace"`
	ClusterID   string             `json:"cluster_id"`
	Services    []ServiceWorkloads `json:"services"`
}

type LoadServiceFromYamlTemplateReq added in v1.9.9

type LoadServiceFromYamlTemplateReq struct {
	ServiceName  string      `json:"service_name"`
	ProjectName  string      `json:"project_name"`
	TemplateID   string      `json:"template_id"`
	AutoSync     bool        `json:"auto_sync"`
	Variables    []*Variable `json:"variables"`
	VariableYaml string      `json:"variable_yaml"`
}

type LoadServiceReq

type LoadServiceReq struct {
	Type        string `json:"type"`
	ProductName string `json:"product_name"`
	Visibility  string `json:"visibility"`
	LoadFromDir bool   `json:"is_dir"`
	LoadPath    string `json:"path"`
}

type LoadSource added in v1.5.0

type LoadSource string
const (
	LoadFromRepo          LoadSource = "repo" //exclude gerrit
	LoadFromGerrit        LoadSource = "gerrit"
	LoadFromPublicRepo    LoadSource = "publicRepo"
	LoadFromChartTemplate LoadSource = "chartTemplate"
	LoadFromChartRepo     LoadSource = "chartRepo"
)

type ReleaseNamingRule added in v1.9.9

type ReleaseNamingRule struct {
	NamingRule  string `json:"naming"`
	ServiceName string `json:"service_name"`
}

type ServiceModule

type ServiceModule struct {
	*commonmodels.Container
	BuildNames []string `json:"build_names"`
}

type ServiceOption

type ServiceOption struct {
	ServiceModules   []*ServiceModule           `json:"service_module"`
	SystemVariable   []*Variable                `json:"system_variable"`
	CustomVariable   []*templatemodels.RenderKV `json:"custom_variable"`
	TemplateVariable []*Variable                `json:"template_variable"`
	VariableYaml     string                     `json:"variable_yaml"`
	Yaml             string                     `json:"yaml"`
	Service          *commonmodels.Service      `json:"service,omitempty"`
}

func CreateServiceTemplate

func CreateServiceTemplate(userName string, args *commonmodels.Service, force bool, log *zap.SugaredLogger) (*ServiceOption, error)

func GetServiceOption

func GetServiceOption(args *commonmodels.Service, log *zap.SugaredLogger) (*ServiceOption, error)

func GetServiceTemplateOption

func GetServiceTemplateOption(serviceName, productName string, revision int64, log *zap.SugaredLogger) (*ServiceOption, error)

type ServiceTmplBuildObject added in v1.2.0

type ServiceTmplBuildObject struct {
	ServiceTmplObject *commonservice.ServiceTmplObject `json:"pm_service_tmpl"`
	Build             *commonmodels.Build              `json:"build"`
}

type ServiceWorkloads added in v1.9.9

type ServiceWorkloads struct {
	Name         string              `json:"name"`
	WorkloadsMap map[string][]string `json:"workloads_map"`
}

type ServiceWorkloadsUpdateAction added in v1.5.0

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

type ServiceYaml added in v1.9.9

type ServiceYaml struct {
	Name string `json:"name"`
	Yaml string `json:"yaml"`
}

type UpdateWorkloadsArgs added in v1.5.0

type UpdateWorkloadsArgs struct {
	WorkLoads []commonmodels.Workload `json:"workLoads"`
	ClusterID string                  `json:"cluster_id"`
	Namespace string                  `json:"namespace"`
}

type Variable

type Variable struct {
	Key         string `json:"key"`
	Value       string `json:"value"`
	Description string `json:"description,omitempty"`
}

func GetTemplateVariables added in v1.12.0

func GetTemplateVariables(args *commonmodels.Service) ([]*Variable, string)

type YamlPreview

type YamlPreview struct {
	Kind string `bson:"-"           json:"kind"`
}

type YamlPreviewForPorts

type YamlPreviewForPorts struct {
	Kind string `bson:"-"           json:"kind"`
	Spec *struct {
		Ports []struct {
			Name string `bson:"-"           json:"name"`
			Port int    `bson:"-"           json:"port"`
		} `bson:"-"           json:"ports"`
	} `bson:"-"           json:"spec"`
}

type YamlValidatorReq

type YamlValidatorReq struct {
	ServiceName string `json:"service_name"`
	Yaml        string `json:"yaml,omitempty"`
}

type YamlViewServiceTemplateReq added in v1.9.9

type YamlViewServiceTemplateReq struct {
	ServiceName string                     `json:"service_name"`
	ProjectName string                     `json:"project_name"`
	EnvName     string                     `json:"env_name"`
	Variables   []*templatemodels.RenderKV `json:"variables"`
}

Jump to

Keyboard shortcuts

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