app

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: Apache-2.0 Imports: 41 Imported by: 16

Documentation

Index

Constants

View Source
const (
	Initiate              string = "Initiate"
	ScalingReplicaSetDown string = "ScalingReplicaSetDown"
)
View Source
const AcdInvalidAppErr = "invalid acd app name and env"
View Source
const NotDeployed = "Not Deployed"

Variables

This section is empty.

Functions

This section is empty.

Types

type AppListingService

type AppListingService interface {
	FetchAppsByEnvironment(fetchAppListingRequest FetchAppListingRequest, w http.ResponseWriter, r *http.Request, token string) ([]*bean.AppEnvironmentContainer, error)
	BuildAppListingResponse(fetchAppListingRequest FetchAppListingRequest, envContainers []*bean.AppEnvironmentContainer) ([]*bean.AppContainer, error)

	FetchAppDetails(appId int, envId int) (bean.AppDetailContainer, error)

	PodCountByAppLabel(appLabel string, namespace string, env string, proEndpoint string) int
	PodListByAppLabel(appLabel string, namespace string, env string, proEndpoint string) map[string]string

	// below 4 functions used for pod level cpu and memory usage
	CpuUsageGroupByPod(namespace string, env string, proEndpoint string) map[string]string
	CpuRequestGroupByPod(namespace string, env string, proEndpoint string) map[string]string
	MemoryUsageGroupByPod(namespace string, env string, proEndpoint string) map[string]string
	MemoryRequestGroupByPod(namespace string, env string, proEndpoint string) map[string]string

	//Currently not in use
	CpuUsageGroupByContainer(podName string, namespace string, env string, proEndpoint string) map[string]string
	CpuRequestGroupByContainer(podName string, namespace string, env string, proEndpoint string) map[string]string
	MemoryUsageGroupByContainer(podName string, namespace string, env string, proEndpoint string) map[string]string
	MemoryRequestGroupByContainer(podName string, namespace string, env string, proEndpoint string) map[string]string

	//Currently not in use (intent to fetch graph data from prometheus)
	CpuUsageGroupByPodGraph(podName string, namespace string, env string, proEndpoint string, r v1.Range) map[string][]interface{}
	MemoryUsageGroupByPodGraph(podName string, namespace string, env string, proEndpoint string, r v1.Range) map[string][]interface{}
	GraphAPI(appId int, envId int) error

	FetchAppTriggerView(appId int) ([]bean.TriggerView, error)
	FetchAppStageStatus(appId int) ([]bean.AppStageStatus, error)

	FetchOtherEnvironment(appId int) ([]*bean.Environment, error)
	RedirectToLinkouts(Id int, appId int, envId int, podName string, containerName string) (string, error)
	GetLastDeploymentStatusesByAppNames(appNames []string) ([]repository.DeploymentStatus, error)
	GetLastDeploymentStatuses() (map[string]repository.DeploymentStatus, error)
	ISLastReleaseStopType(appId, envId int) (bool, error)
	ISLastReleaseStopTypeV2(pipelineIds []int) (map[int]bool, error)
	GetReleaseCount(appId, envId int) (int, error)
}

type AppListingServiceImpl

type AppListingServiceImpl struct {
	Logger *zap.SugaredLogger
	// contains filtered or unexported fields
}

func NewAppListingServiceImpl

func NewAppListingServiceImpl(Logger *zap.SugaredLogger, appListingRepository repository.AppListingRepository, application application2.ServiceClient, appRepository pipelineConfig.AppRepository, appListingViewBuilder AppListingViewBuilder, pipelineRepository pipelineConfig.PipelineRepository, linkoutsRepository repository.LinkoutsRepository, appLevelMetricsRepository repository.AppLevelMetricsRepository, envLevelMetricsRepository repository.EnvLevelAppMetricsRepository, cdWorkflowRepository pipelineConfig.CdWorkflowRepository, pipelineOverrideRepository chartConfig.PipelineOverrideRepository) *AppListingServiceImpl

func (AppListingServiceImpl) BuildAppListingResponse

func (impl AppListingServiceImpl) BuildAppListingResponse(fetchAppListingRequest FetchAppListingRequest, envContainers []*bean.AppEnvironmentContainer) ([]*bean.AppContainer, error)

func (AppListingServiceImpl) CpuRequestGroupByContainer deprecated

func (impl AppListingServiceImpl) CpuRequestGroupByContainer(podName string, namespace string, env string, proEndpoint string) map[string]string

Deprecated: Currently not in use

func (AppListingServiceImpl) CpuRequestGroupByPod

func (impl AppListingServiceImpl) CpuRequestGroupByPod(namespace string, env string, proEndpoint string) map[string]string

func (AppListingServiceImpl) CpuUsageGroupByContainer deprecated

func (impl AppListingServiceImpl) CpuUsageGroupByContainer(podName string, namespace string, env string, proEndpoint string) map[string]string

Deprecated: Currently not in use

func (AppListingServiceImpl) CpuUsageGroupByPod

func (impl AppListingServiceImpl) CpuUsageGroupByPod(namespace string, env string, proEndpoint string) map[string]string

func (AppListingServiceImpl) CpuUsageGroupByPodGraph deprecated

func (impl AppListingServiceImpl) CpuUsageGroupByPodGraph(podName string, namespace string, env string, proEndpoint string, r v1.Range) map[string][]interface{}

Deprecated: Currently not in use (intent to fetch graph data from prometheus)

func (AppListingServiceImpl) FetchAppDetails

func (impl AppListingServiceImpl) FetchAppDetails(appId int, envId int) (bean.AppDetailContainer, error)

func (AppListingServiceImpl) FetchAppStageStatus

func (impl AppListingServiceImpl) FetchAppStageStatus(appId int) ([]bean.AppStageStatus, error)

func (AppListingServiceImpl) FetchAppTriggerView

func (impl AppListingServiceImpl) FetchAppTriggerView(appId int) ([]bean.TriggerView, error)

func (AppListingServiceImpl) FetchAppsByEnvironment

func (impl AppListingServiceImpl) FetchAppsByEnvironment(fetchAppListingRequest FetchAppListingRequest, w http.ResponseWriter, r *http.Request, token string) ([]*bean.AppEnvironmentContainer, error)

func (AppListingServiceImpl) FetchOtherEnvironment

func (impl AppListingServiceImpl) FetchOtherEnvironment(appId int) ([]*bean.Environment, error)

func (AppListingServiceImpl) GetLastDeploymentStatuses

func (impl AppListingServiceImpl) GetLastDeploymentStatuses() (map[string]repository.DeploymentStatus, error)

func (AppListingServiceImpl) GetLastDeploymentStatusesByAppNames

func (impl AppListingServiceImpl) GetLastDeploymentStatusesByAppNames(appNames []string) ([]repository.DeploymentStatus, error)

func (AppListingServiceImpl) GetReleaseCount

func (impl AppListingServiceImpl) GetReleaseCount(appId, envId int) (int, error)

func (AppListingServiceImpl) GraphAPI deprecated

func (impl AppListingServiceImpl) GraphAPI(appId int, envId int) error

Deprecated: Currently not in use (intent to fetch graph data from prometheus)

func (AppListingServiceImpl) ISLastReleaseStopType

func (impl AppListingServiceImpl) ISLastReleaseStopType(appId, envId int) (bool, error)

func (AppListingServiceImpl) ISLastReleaseStopTypeV2

func (impl AppListingServiceImpl) ISLastReleaseStopTypeV2(pipelineIds []int) (map[int]bool, error)

func (AppListingServiceImpl) MemoryRequestGroupByContainer deprecated

func (impl AppListingServiceImpl) MemoryRequestGroupByContainer(podName string, namespace string, env string, proEndpoint string) map[string]string

Deprecated: Currently not in use

func (AppListingServiceImpl) MemoryRequestGroupByPod

func (impl AppListingServiceImpl) MemoryRequestGroupByPod(namespace string, env string, proEndpoint string) map[string]string

func (AppListingServiceImpl) MemoryUsageGroupByContainer deprecated

func (impl AppListingServiceImpl) MemoryUsageGroupByContainer(podName string, namespace string, env string, proEndpoint string) map[string]string

Deprecated: Currently not in use

func (AppListingServiceImpl) MemoryUsageGroupByPod

func (impl AppListingServiceImpl) MemoryUsageGroupByPod(namespace string, env string, proEndpoint string) map[string]string

func (AppListingServiceImpl) MemoryUsageGroupByPodGraph deprecated

func (impl AppListingServiceImpl) MemoryUsageGroupByPodGraph(podName string, namespace string, env string, proEndpoint string, r v1.Range) map[string][]interface{}

Deprecated: Currently not in use (intent to fetch graph data from prometheus)

func (AppListingServiceImpl) PodCountByAppLabel

func (impl AppListingServiceImpl) PodCountByAppLabel(appLabel string, namespace string, env string, proEndpoint string) int

Return only a integer value pod count, aggregated of all the pod inside a app (includes all the pods running different cd pipeline for same app)

func (AppListingServiceImpl) PodListByAppLabel

func (impl AppListingServiceImpl) PodListByAppLabel(appLabel string, namespace string, env string, proEndpoint string) map[string]string

Returns map of running pod names

func (AppListingServiceImpl) RedirectToLinkouts

func (impl AppListingServiceImpl) RedirectToLinkouts(Id int, appId int, envId int, podName string, containerName string) (string, error)

type AppListingViewBuilder

type AppListingViewBuilder interface {
	BuildView(fetchAppListingRequest FetchAppListingRequest, appEnvMap map[string][]*bean.AppEnvironmentContainer) ([]*bean.AppContainer, error)
}

type AppListingViewBuilderImpl

type AppListingViewBuilderImpl struct {
	Logger *zap.SugaredLogger
}

func NewAppListingViewBuilderImpl

func NewAppListingViewBuilderImpl(Logger *zap.SugaredLogger) *AppListingViewBuilderImpl

func (*AppListingViewBuilderImpl) BuildView

func (impl *AppListingViewBuilderImpl) BuildView(fetchAppListingRequest FetchAppListingRequest, appEnvMap map[string][]*bean.AppEnvironmentContainer) ([]*bean.AppContainer, error)

type AppService

type AppService interface {
	TriggerRelease(overrideRequest *bean.ValuesOverrideRequest, ctx context.Context) (id int, err error)
	UpdateReleaseStatus(request *bean.ReleaseStatusUpdateRequest) (bool, error)
	AppendCurrentApplicationStatus(application v1alpha1.Application) (bool, error)
	TriggerCD(artifact *repository.CiArtifact, cdWorkflowId int, pipeline *pipelineConfig.Pipeline, async bool) error
	GetConfigMapAndSecretJson(appId int, envId int, pipelineId int) ([]byte, error)
	UpdateCdWorkflowRunnerByACDObject(app v1alpha1.Application) error
	GetCmSecretNew(appId int, envId int) (*bean.ConfigMapJson, *bean.ConfigSecretJson, error)
	MarkImageScanDeployed(appId int, envId int, imageDigest string, clusterId int) error
}

type AppServiceImpl

type AppServiceImpl struct {
	ArgoK8sClient argocdServer.ArgoK8sClient
	// contains filtered or unexported fields
}

func NewAppService

func NewAppService(
	environmentConfigRepository chartConfig.EnvConfigOverrideRepository,
	pipelineOverrideRepository chartConfig.PipelineOverrideRepository,
	mergeUtil *MergeUtil,
	logger *zap.SugaredLogger,
	ciArtifactRepository repository.CiArtifactRepository,
	pipelineRepository pipelineConfig.PipelineRepository,
	dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository,
	eventClient client.EventClient,
	eventFactory client.EventFactory, acdClient application.ServiceClient,
	cache *user.TokenCache, authConfig *user.ACDAuthConfig,
	enforcer rbac.Enforcer, enforcerUtil rbac.EnforcerUtil, user user.UserService,
	appListingRepository repository.AppListingRepository,
	appRepository pipelineConfig.AppRepository,
	envRepository cluster.EnvironmentRepository,
	pipelineConfigRepository chartConfig.PipelineConfigRepository, configMapRepository chartConfig.ConfigMapRepository,
	appLevelMetricsRepository repository.AppLevelMetricsRepository, envLevelMetricsRepository repository.EnvLevelAppMetricsRepository,
	chartRepository chartConfig.ChartRepository,
	ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository,
	cdWorkflowRepository pipelineConfig.CdWorkflowRepository, commonService commonService.CommonService,
	imageScanDeployInfoRepository security.ImageScanDeployInfoRepository, imageScanHistoryRepository security.ImageScanHistoryRepository,
	ArgoK8sClient argocdServer.ArgoK8sClient,
	gitFactory *GitFactory) *AppServiceImpl

func (AppServiceImpl) AppendCurrentApplicationStatus

func (impl AppServiceImpl) AppendCurrentApplicationStatus(app v1alpha1.Application) (bool, error)

func (*AppServiceImpl) BuildCDSuccessPayload

func (impl *AppServiceImpl) BuildCDSuccessPayload(appName string, environmentName string) *client.Payload

func (*AppServiceImpl) BuildPayload

func (impl *AppServiceImpl) BuildPayload(overrideRequest *bean.ValuesOverrideRequest, pipeline *pipelineConfig.Pipeline,
	envOverride *chartConfig.EnvConfigOverride, materialInfo map[string]string, artifact *repository.CiArtifact) *client.Payload

func (AppServiceImpl) GetCmSecretNew

func (impl AppServiceImpl) GetCmSecretNew(appId int, envId int) (*bean.ConfigMapJson, *bean.ConfigSecretJson, error)

FIXME tmp workaround

func (AppServiceImpl) GetConfigMapAndSecretJson

func (impl AppServiceImpl) GetConfigMapAndSecretJson(appId int, envId int, pipelineId int) ([]byte, error)

depricated TODO remove this method

func (AppServiceImpl) MarkImageScanDeployed

func (impl AppServiceImpl) MarkImageScanDeployed(appId int, envId int, imageDigest string, clusterId int) error

func (*AppServiceImpl) TriggerCD

func (impl *AppServiceImpl) TriggerCD(artifact *repository.CiArtifact, cdWorkflowId int, pipeline *pipelineConfig.Pipeline, async bool) error

func (AppServiceImpl) TriggerRelease

func (impl AppServiceImpl) TriggerRelease(overrideRequest *bean.ValuesOverrideRequest, ctx context.Context) (id int, err error)

func (*AppServiceImpl) UpdateCdWorkflowRunnerByACDObject

func (impl *AppServiceImpl) UpdateCdWorkflowRunnerByACDObject(app v1alpha1.Application) error

func (AppServiceImpl) UpdateReleaseStatus

func (impl AppServiceImpl) UpdateReleaseStatus(updateStatusRequest *bean.ReleaseStatusUpdateRequest) (bool, error)

func (*AppServiceImpl) WriteCDSuccessEvent

func (impl *AppServiceImpl) WriteCDSuccessEvent(appId int, appName string, envId int, envName string, override *chartConfig.PipelineOverride)

func (*AppServiceImpl) WriteCDTriggerEvent

func (impl *AppServiceImpl) WriteCDTriggerEvent(overrideRequest *bean.ValuesOverrideRequest, pipeline *pipelineConfig.Pipeline,
	envOverride *chartConfig.EnvConfigOverride, materialInfoMap map[string]string, artifact *repository.CiArtifact, releaseId, pipelineOverrideId int)

type DeploymentEvent

type DeploymentEvent struct {
	ApplicationId      int
	EnvironmentId      int
	ReleaseId          int
	PipelineOverrideId int
	TriggerTime        time.Time
	PipelineMaterials  []*PipelineMaterialInfo
	CiArtifactId       int
}

type DeploymentFailureHandler

type DeploymentFailureHandler interface {
	Handle(jobEvent *repository.JobEvent, event client.Event) error
}

type DeploymentFailureHandlerImpl

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

func NewDeploymentFailureHandlerImpl

func NewDeploymentFailureHandlerImpl(logger *zap.SugaredLogger, appListingService AppListingService, eventClient client.EventClient, eventFactory client.EventFactory) *DeploymentFailureHandlerImpl

func (*DeploymentFailureHandlerImpl) BuildPayload

func (impl *DeploymentFailureHandlerImpl) BuildPayload(appName string, deploymentFailureTime time.Time) *client.Payload

func (*DeploymentFailureHandlerImpl) Handle

func (impl *DeploymentFailureHandlerImpl) Handle(jobEvent *repository.JobEvent, event client.Event) error

func (*DeploymentFailureHandlerImpl) WriteCDFailureEvent

func (impl *DeploymentFailureHandlerImpl) WriteCDFailureEvent(ds repository.DeploymentStatus, eventdata client.Event)

type EnvironmentOverride

type EnvironmentOverride struct {
	Enabled   bool        `json:"enabled"`
	EnvValues []*KeyValue `json:"envValues"`
}

type FetchAppListingRequest

type FetchAppListingRequest struct {
	Environments      []int            `json:"environments"`
	Statuses          []string         `json:"statuses"`
	Teams             []int            `json:"teams"`
	AppNameSearch     string           `json:"appNameSearch"`
	SortOrder         helper.SortOrder `json:"sortOrder"`
	SortBy            helper.SortBy    `json:"sortBy"`
	Offset            int              `json:"offset"`
	Size              int              `json:"size"`
	DeploymentGroupId int              `json:"deploymentGroupId"`
}

type KeyValue

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

type PipelineMaterialInfo

type PipelineMaterialInfo struct {
	PipelineMaterialId int
	CommitHash         string
}

type ReleaseAttributes

type ReleaseAttributes struct {
	Name           string
	Tag            string
	PipelineName   string
	ReleaseVersion string
	DeploymentType string
	App            string
	Env            string
	AppMetrics     *bool
}

type ReleaseDataService

type ReleaseDataService interface {
	TriggerEventForAllRelease(appId, environmentId int) error
	GetDeploymentMetrics(request *lens.MetricRequest) (resBody []byte, resCode *lens.StatusCode, err error)
}

type ReleaseDataServiceImpl

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

func NewReleaseDataServiceImpl

func NewReleaseDataServiceImpl(
	pipelineOverrideRepository chartConfig.PipelineOverrideRepository,
	logger *zap.SugaredLogger,
	ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository,
	eventClient client.EventClient,
	lensClient lens.LensClient) *ReleaseDataServiceImpl

func (*ReleaseDataServiceImpl) GetDeploymentMetrics

func (impl *ReleaseDataServiceImpl) GetDeploymentMetrics(request *lens.MetricRequest) (resBody []byte, resCode *lens.StatusCode, err error)

func (*ReleaseDataServiceImpl) TriggerEventForAllRelease

func (impl *ReleaseDataServiceImpl) TriggerEventForAllRelease(appId, environmentId int) error

Jump to

Keyboard shortcuts

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