usecase

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCommonProjectPath = "common"

DefaultCommonProjectPath 는 공용 프로젝트의 기본 경로다.

GitLab 의 Container/Package Registry 는 프로젝트 종속이라, 조직 공용 베이스 이미지와 npm/maven 패키지를 두려면 그것을 소유할 프로젝트가 하나 필요하다. 이름은 조직 관례에 따라 바꿀 수 있다.

View Source
const DeployTokenVariable = scaffold.DeployTokenVar

DeployTokenVariable 은 CI 의 deploy 단계가 매니페스트를 되쓸 때 쓰는 변수다. 렌더러가 만드는 스크립트와 이름이 같아야 한다.

View Source
const MaxSecurityPipelines = 1000

MaxSecurityPipelines 는 보안 대시보드가 한 번에 읽는 파이프라인 수의 상한이다. 주기 동기화 대상 (ListWithStack)과 같은 값이다 — 상한에 닿는 조직이 생기면 그때 페이지를 나눈다(설계 §5.2).

Variables

View Source
var (
	ErrStackNotFound    = errors.New("referenced stack does not exist")
	ErrStackOrgMismatch = errors.New("stack belongs to a different organization")
	// ErrStackClusterMismatch 는 스택에 묶인 파이프라인에 스택과 다른 클러스터를 준 경우다.
	// 규칙은 도메인에 있다(domain.MatchStackCluster).
	ErrStackClusterMismatch = domain.ErrStackClusterMismatch
	// ErrTemplateSourceRequiresStack 은 원본을 가져오는 템플릿을 저장소 준비 없이 쓰려 한 경우다.
	// 원본을 넣을 저장소는 스택의 SCM 에 만든다 — 스택 없이 만들면 원본 없는 파이프라인이 남는다.
	ErrTemplateSourceRequiresStack = errors.New("원본을 가져오는 템플릿은 스택에 묶인 파이프라인으로만 만들 수 있습니다")
)

Sentinel errors for cross-context validation.

View Source
var (
	// ErrScanPipelineNotFound 는 파이프라인이 없다는 뜻이다.
	ErrScanPipelineNotFound = errors.New("파이프라인을 찾지 못했습니다")
	// ErrImageScanNotFound 는 그 파이프라인에 그 스캔 결과가 없다는 뜻이다.
	ErrImageScanNotFound = errors.New("스캔 결과를 찾지 못했습니다")
)
View Source
var ErrPipelineNotStackBound = errors.New("pipeline is not bound to a stack")

ErrPipelineNotStackBound 는 스택에 묶이지 않은 파이프라인의 정의를 갱신하려 한 경우다. 저장소도 CI 도 플랫폼이 만든 것이 아니라 다시 쓸 정의가 없다.

Functions

func BuildStepPlan

func BuildStepPlan(pipeline *domain.Pipeline, manifestTypes ...[]string) []string

func DeployClusterID added in v0.6.0

func DeployClusterID(ctx context.Context, reader port.StackReader, pipeline *domain.Pipeline) string

DeployClusterID 는 파이프라인의 앱이 실제로 서 있는 클러스터다.

규칙은 domain.Pipeline.DeployClusterID 에 있다. 여기서는 묶인 스택의 클러스터를 읽어 넘긴다. 파이프라인의 클러스터를 읽으면 모니터링은 빈 네임스페이스를 보고, 삭제는 없는 곳에서 "이미 없음" 을 성공으로 끝내 앱이 남는다. 실제로 그랬다. 스택을 읽지 못하면 저장된 값이 가장 나은 추정이다.

func MatchStackTarget added in v0.6.0

func MatchStackTarget(stack *port.StackSummary, orgID, requested string) (string, error)

MatchStackTarget 은 스택에 묶일 앱의 배포 클러스터를 정한다 — 생성과 직접 배포가 함께 쓴다. 스택이 없으면 ErrStackNotFound, 다른 조직의 스택이면 ErrStackOrgMismatch, 클러스터가 다르면 ErrStackClusterMismatch 다. 비어 있으면 스택 클러스터로 채운다.

조직을 먼저 본다. 클러스터가 다르다는 오류는 스택의 클러스터를 알려 주므로, 남의 조직에는 그보다 먼저 막는다.

func OTLPEndpointFor

func OTLPEndpointFor(ctx context.Context, reader port.StackReader, stackID string) string

OTLPEndpointFor 는 배포되는 앱에 넣어 줄 수집기 주소를 찾는다.

배포 경로가 둘이라(파이프라인 배포, 직접 배포) 각자 구현하면 한쪽만 고쳐져 "어떤 경로로 배포했느냐에 따라 추적이 되기도 하고 안 되기도 하는" 상태가 된다. 그래서 판단을 여기 하나로 모은다.

조회에 실패하거나 스택에 수집기가 없으면 빈 값을 돌려준다. 관측은 부가 기능이고, 그것 때문에 배포가 실패하면 더 나쁘다. 빈 값이면 호출부가 관련 환경변수를 아예 넣지 않는다 — 닿지 않는 주소를 박으면 앱이 영원히 재시도한다.

Types

type CreatePipeline

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

CreatePipeline creates a new pipeline configuration.

func NewCreatePipeline

func NewCreatePipeline(
	pipelineRepo port.PipelineRepository,
	templateRepo port.PipelineTemplateRepository,
	stackReader ...port.StackReader,
) *CreatePipeline

NewCreatePipeline constructs a CreatePipeline use case.

func (*CreatePipeline) Execute

Execute creates a new pipeline.

func (*CreatePipeline) WithRepositoryProvisioner

func (uc *CreatePipeline) WithRepositoryProvisioner(p RepositoryProvisioner) *CreatePipeline

WithRepositoryProvisioner 는 저장소 프로비저닝 기능을 켠다.

주입하지 않으면 ProvisionRepository 요청이 오류가 된다 — 조용히 무시하면 사용자는 저장소가 만들어진 줄 알고 기다리게 된다.

func (*CreatePipeline) WithScanPolicyPublisher added in v0.6.0

func (uc *CreatePipeline) WithScanPolicyPublisher(p ScanPolicyPipelinePublisher) *CreatePipeline

WithScanPolicyPublisher 는 파이프라인 생성 직후 스택의 스캔 정책을 싣도록 배선한다.

싣지 않으면 새 파이프라인은 스크립트 기본값으로 판정한다 — 운영자가 HIGH 를 막아 둔 스택에서 새 파이프라인만 HIGH 가 통과한다.

type CreatePipelineInput

type CreatePipelineInput struct {
	Name           string
	ExecutionMode  string
	TemplateID     string
	OrgID          string
	ClusterID      string
	StackID        string // optional — links pipeline to a stack
	Namespace      string
	AppType        domain.AppType
	GitRepoURL     string
	DockerfilePath string
	DockerContext  string
	EnvVars        map[string]string
	// ProvisionRepository 가 true 면 앱 저장소를 만들고 스캐폴딩을 커밋한 뒤
	// Argo CD Application 까지 연결한다. StackID 가 필요하다.
	ProvisionRepository bool
	// RequestedByEmail 은 요청한 사람의 이메일이다. 저장소가 든 조직의 멤버로
	// 넣는 데 쓴다 — 넣지 않으면 자기 저장소를 보지도 못한다.
	RequestedByEmail string
	// Port / Replicas 는 스캐폴딩 매니페스트에 반영된다.
	Port     int32
	Replicas int32
	// RegistryCredentials 는 외부 레지스트리 자격증명이다.
	RegistryCredentials map[string]string
}

CreatePipelineInput holds the parameters for creating a new pipeline.

type CreatePipelineOutput

type CreatePipelineOutput struct {
	Pipeline     *domain.Pipeline
	StackWarning string `json:"stack_warning,omitempty"` // non-empty when stack exists but is not completed

	// 아래는 저장소 프로비저닝을 수행했을 때만 채워진다.
	RepositoryPath         string   `json:"repository_path,omitempty"`
	ArgoApplicationCreated bool     `json:"argo_application_created,omitempty"`
	MissingVariables       []string `json:"missing_variables,omitempty"`
	Warnings               []string `json:"warnings,omitempty"`
	// ScaffoldSkipped 는 이미 있던 저장소라 스캐폴딩을 쓰지 않았음을 알린다.
	// 사용자가 파일이 갱신됐다고 오해하면 배포되지 않는 원인을 엉뚱한 데서 찾는다.
	ScaffoldSkipped bool `json:"scaffold_skipped,omitempty"`
}

CreatePipelineOutput holds the result of creating a pipeline.

type DeletePipeline

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

DeletePipeline 은 파이프라인과, 사용자가 고른 부수 리소스를 지운다.

func NewDeletePipeline

func NewDeletePipeline(
	pipelines port.PipelineRepository,
	factory port.SCMBundleFactory,
	kubeconfig port.KubeconfigProvider,
) *DeletePipeline

func (*DeletePipeline) Execute

Execute 는 고른 리소스를 지운 뒤 파이프라인 레코드를 지운다.

순서가 중요하다. 레코드를 먼저 지우면 저장소 경로·클러스터·네임스페이스를 잃어 남은 리소스를 찾을 방법이 없어진다.

요청한 삭제가 하나라도 실패하면 레코드를 남기고 오류를 돌려준다. 레코드가 사라지면 사용자는 목록에서 파이프라인을 못 보는데 리소스는 남아 있어, 다시 시도할 방법조차 없어지기 때문이다.

func (*DeletePipeline) WithCredentialObjectDeleter added in v0.6.0

func (uc *DeletePipeline) WithCredentialObjectDeleter(d port.PipelineCredentialObjectDeleter) *DeletePipeline

WithCredentialObjectDeleter 는 파이프라인 자격증명 회수 경로를 배선한다.

func (*DeletePipeline) WithPipelineNameLookup added in v0.6.0

func (uc *DeletePipeline) WithPipelineNameLookup(l port.PipelineNameLookup) *DeletePipeline

WithPipelineNameLookup 은 같은 이름의 다른 파이프라인을 찾는 경로를 배선한다.

func (*DeletePipeline) WithSecretDeleter added in v0.6.0

func (uc *DeletePipeline) WithSecretDeleter(d port.ManagedSecretDeleter) *DeletePipeline

WithSecretDeleter 는 플랫폼이 넣은 Secret 정리 경로를 배선한다.

func (*DeletePipeline) WithWorkloadDeleter

func (uc *DeletePipeline) WithWorkloadDeleter(d port.WorkloadDeleter) *DeletePipeline

WithWorkloadDeleter 는 직접 배포 워크로드 정리 경로를 배선한다.

type DeletePipelineInput

type DeletePipelineInput struct {
	PipelineID string
	// DeleteClusterResources 는 Argo CD Application 과 그것이 배포한 워크로드를 지운다.
	DeleteClusterResources bool
	// DeleteRepository 는 소스 저장소를 지운다. 되돌릴 수 없다.
	DeleteRepository bool
	// DeleteImages 는 레지스트리의 이미지 저장소를 지운다.
	DeleteImages bool
}

DeletePipelineInput 은 무엇까지 지울지 고른 결과다.

셋 다 기본값 false 다. 파이프라인 레코드만 지우는 것이 종전 동작이고, 그보다 파괴적인 일은 사용자가 명시적으로 골라야 한다.

type DeletePipelineOutput

type DeletePipelineOutput struct {
	ClusterResourcesDeleted bool
	RepositoryDeleted       bool
	ImagesDeleted           bool
	Warnings                []string
}

DeletePipelineOutput 은 실제로 무엇이 지워졌는지 알린다.

요청과 결과를 따로 두는 이유는, 지원하지 않는 레지스트리처럼 요청은 했지만 수행하지 못한 경우가 있기 때문이다. 요청만 보고 "지워졌다" 고 표시하면 사용자는 남아 있는 리소스를 영영 모른다.

type DeployOption

type DeployOption func(*DeployPipeline)

func WithBuildDelegate

func WithBuildDelegate(d port.BuildDelegate) DeployOption

WithBuildDelegate 는 러너 위임 경로를 배선한다.

배선되지 않으면 위임 대상 파이프라인의 배포는 오류로 끝난다. 조용히 직접 빌드로 되돌리지 않는다 — API 파드에는 도커 데몬이 없어 그 경로는 실패할 수 없는 경로이고, 되돌리면 사용자는 왜 실패했는지 알 수 없다.

func WithClusterTargetProvider

func WithClusterTargetProvider(p port.ClusterTargetProvider) DeployOption

func WithDeployTimeout

func WithDeployTimeout(d time.Duration) DeployOption

WithDeployTimeout 은 배포 한 번의 상한을 바꾼다. 0 이하면 기본값을 쓴다.

func WithImagePreparer

func WithImagePreparer(p port.ImagePreparer) DeployOption

func WithStackReader

func WithStackReader(r port.StackReader) DeployOption

WithStackReader 는 스택 요약 조회를 배선한다. 배선되지 않으면 배포는 그대로 되고 추적 환경변수만 빠진다 — 관측 배선 때문에 배포가 막히면 안 된다.

type DeployPipeline

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

func NewDeployPipeline

func NewDeployPipeline(
	pipelineRepo port.PipelineRepository,
	deploymentRepo port.DeploymentRepository,
	kubeconfigProvider port.KubeconfigProvider,
	applier port.ManifestApplier,
	opts ...DeployOption,
) *DeployPipeline

func (*DeployPipeline) ApplyAsync

func (uc *DeployPipeline) ApplyAsync(deploymentID string, manifestTypes ...[]string)

ApplyAsync runs the actual K8s deployment in the background.

func (*DeployPipeline) Execute

Execute runs the full synchronous flow (for tests and backward compat).

func (*DeployPipeline) Start

Start creates a Deployment record with status=running and returns immediately.

type DeployPipelineInput

type DeployPipelineInput struct {
	PipelineID    string
	Version       string
	DeployedBy    string
	ManifestTypes []string
}

type DeployPipelineOutput

type DeployPipelineOutput struct {
	Deployment *domain.Deployment
}

type ListPipelineSecurity added in v0.6.0

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

ListPipelineSecurity 는 보안 대시보드(#65)가 읽는 cicd 의 공개 경로다.

결과 테이블(image_scan_results · sast_results · dependency_scan_results · secret_scan_results)과 스캔 정책은 cicd 가 소유한다. 관측 모듈은 테이블을 직접 읽지 않고 이 유스케이스로 읽는다.

func NewListPipelineSecurity added in v0.6.0

func NewListPipelineSecurity(reader port.PipelineSecurityReader) *ListPipelineSecurity

NewListPipelineSecurity 는 유스케이스를 만든다.

func (*ListPipelineSecurity) Execute added in v0.6.0

Execute 는 조직의 파이프라인을 최근 만든 것부터 상한까지 돌려준다.

type ListPipelines

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

ListPipelines lists all pipelines for an organization.

func NewListPipelines

func NewListPipelines(pipelineRepo port.PipelineRepository) *ListPipelines

NewListPipelines constructs a ListPipelines use case.

func (*ListPipelines) Execute

Execute returns all pipelines for the given organization. When StackID is set, results are filtered to that stack via the dedicated repo method.

type ListPipelinesInput

type ListPipelinesInput struct {
	OrgID   string
	StackID string // optional — filters to pipelines linked to this stack
}

ListPipelinesInput holds the parameters for listing pipelines.

type ListPipelinesOutput

type ListPipelinesOutput struct {
	Pipelines []*domain.Pipeline
}

ListPipelinesOutput holds the result of listing pipelines.

type ProvisionAppProject

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

ProvisionAppProject 는 앱 저장소를 만들고 CI/CD 가 돌 수 있는 상태로 만든다.

소스와 배포 매니페스트가 한 저장소에 함께 산다. CI 가 이미지를 올린 뒤 deploy/ 의 태그를 갱신해 커밋하면 Argo CD 가 그 커밋을 보고 배포한다.

func NewProvisionAppProject

func NewProvisionAppProject(
	scm port.SCMProvisioner,
	pipeline port.PipelineConfigurator,
	registry port.ImageRegistryResolver,
) *ProvisionAppProject

NewProvisionAppProject 는 유스케이스를 만든다.

func (*ProvisionAppProject) Execute

Execute 는 프로젝트 생성 → 이미지 대상 결정 → 스캐폴딩 커밋 → CI 변수 등록을 수행한다.

func (*ProvisionAppProject) WithCIJobs

func (uc *ProvisionAppProject) WithCIJobs(
	jobs port.CIJobProvisioner,
	webhooks port.SCMWebhookProvisioner,
	ciBaseURL, scmURL string,
) *ProvisionAppProject

WithCIJobs 는 CI 서버 job 생성 경로를 배선한다.

Jenkins 처럼 job 이 먼저 존재해야 하는 CI 를 위한 것이다. 배선하지 않으면 job 생성을 건너뛴다 — 리포와 스캐폴딩은 만들어지되 빌드는 돌지 않는다.

func (*ProvisionAppProject) WithCredentialPlane

func (uc *ProvisionAppProject) WithCredentialPlane(plane port.PipelineCredentialPlane) *ProvisionAppProject

WithCredentialPlane 은 CI 변수 저장소가 없는 SCM 의 자격증명 경로를 배선한다.

func (*ProvisionAppProject) WithSourceArchive added in v0.6.0

func (uc *ProvisionAppProject) WithSourceArchive(sources port.SourceArchive) *ProvisionAppProject

WithSourceArchive 는 템플릿 원본을 가져올 경로를 배선한다.

배선하지 않은 채 원본이 있는 요청이 오면 오류다 — 빈 스캐폴딩으로 대신 만들면 원본 대신 자리표시자 nginx 가 배포된다.

type ProvisionAppProjectInput

type ProvisionAppProjectInput struct {
	AppName   string
	GroupPath string
	GroupID   string
	// Namespace 는 배포 대상 쿠버네티스 네임스페이스다.
	Namespace string
	Port      int32
	Replicas  int32
	// RepoAccessToken 은 저장소 쓰기에 쓸 토큰이다.
	//
	// 플랫폼이 프로젝트 범위 토큰을 지원하지 않을 때 채워진다(Gitea·GitHub).
	// deploy 단계가 매니페스트 태그를 되쓰려면 필요하다.
	RepoAccessToken string
	// RegistryCredentials 는 외부 레지스트리 자격증명이다.
	// SCM 프로젝트 레지스트리를 쓰는 구성에서는 필요 없다.
	RegistryCredentials map[string]string
	// Platform 은 파이프라인 파일 형식과 토큰 확보 경로를 정한다.
	// 비면 GitLab 으로 본다.
	Platform port.SCMPlatform
	// SharedAccessToken 은 리포 범위 토큰을 발급할 수 없는 플랫폼에서
	// Argo CD 인증에 재사용할 토큰이다 (GitHub 의 조직 PAT).
	SharedAccessToken string
	// ImageScannerEndpoint 는 스택 Trivy 서버 주소다. 비면 스캔 단계를
	// 만들지 않는다 — 돌지도 않을 단계를 선언하면 화면이 그것을 성공으로
	// 보여준다(마이그레이션 000070).
	ImageScannerEndpoint string
	// ImageScannerJavaDBRepository 는 에어갭 CI 잡이 Java DB 를 받을 내부 미러다. 비면 업스트림.
	ImageScannerJavaDBRepository string
	// DependencyScanEndpoint 는 의존성 스캔(SCA)이 붙을 스택 Trivy 서버 주소다. 비면 단계를 만들지 않는다.
	DependencyScanEndpoint string
	// SASTServerEndpoint 는 스택 SonarQube 주소다. 비면 소스 정적 분석 단계를 만들지 않는다.
	SASTServerEndpoint string
	// SASTToken 은 CI 가 분석에 쓸 토큰이다. 스택 설치가 발급해 OpenBao 에 둔 값이다.
	// 비어 있으면 단계는 만들되 사람이 채울 변수로 알린다.
	SASTToken string
	// AppType 은 어떤 앱을 스캐폴딩할지다. web 이면 바로 도는 React 앱을 만든다.
	AppType domain.AppType
	// AccessDomain / GatewayName / GatewayNamespace 가 있으면
	// 외부 접근용 HTTPRoute 도 스캐폴딩에 포함한다.
	AccessDomain     string
	GatewayName      string
	GatewayNamespace string
	// StackID 는 배포 매니페스트에 스택 라벨로 실린다. 클러스터에서 워크로드가
	// 어느 스택 소속인지 판별하는 유일한 키다.
	StackID string
	// TemplateID 는 배포 매니페스트에 템플릿 라벨로 실린다.
	// 템플릿별 자원 사용 비교나 템플릿 단위 조회에 쓴다.
	TemplateID string
	// RefreshDefinitionOnly 는 이미 있는 저장소에 파이프라인 정의 파일(.gitlab-ci.yml ·
	// 워크플로 · Jenkinsfile)만 다시 쓴다. 앱 코드·Dockerfile·배포 매니페스트는 건드리지
	// 않는다. SAST 리포트 같은 새 단계가 옛 파이프라인에 붙게 하는 길이다 — 전에는
	// 파이프라인을 다시 만드는 것 말고 방법이 없었다.
	RefreshDefinitionOnly bool
	// Source 가 있으면 새 저장소의 첫 커밋으로 이 원본을 가져온다(템플릿의 원본).
	// 이미 있던 저장소에는 쓰지 않는다 — 스캐폴딩과 같은 규칙이다.
	Source *domain.TemplateSource
}

ProvisionAppProjectInput 은 애플리케이션 프로젝트 프로비저닝 요청이다.

type ProvisionAppProjectOutput

type ProvisionAppProjectOutput struct {
	Project     *port.SCMProject
	ImageTarget *port.ImageTarget
	// ArgoReadToken 은 Argo CD 가 저장소를 읽는 데 쓸 토큰이다.
	// 발급에 실패하면 비어 있고 Warnings 에 사유가 담긴다.
	ArgoReadToken string
	// MissingVariables 는 파이프라인이 돌기 전에 사람이 채워야 할 변수다.
	MissingVariables []string
	// Warnings 는 치명적이지 않지만 알려야 하는 문제다.
	Warnings []string
	// ScaffoldSkipped 는 이미 있던 저장소라 스캐폴딩을 쓰지 않았음을 알린다.
	ScaffoldSkipped bool
	// DefinitionRefreshed 는 파이프라인 정의 파일을 플랫폼 기본으로 다시 썼음을 알린다.
	DefinitionRefreshed bool
	// RepositoryRecreated 는 정의를 갱신하려던 저장소가 없어 새로 만들고 전체 스캐폴딩을
	// 썼음을 알린다 — 앱 코드는 사용자가 다시 밀어야 한다.
	RepositoryRecreated bool
	// CIJobURL 은 만들어진 CI job 의 주소다. CI 가 SCM 과 분리된 플랫폼
	// (Jenkins)에서만 채워진다.
	CIJobURL string
	// Stages 는 스캐폴딩이 실제로 만든 파이프라인 단계다.
	//
	// 이미 있던 저장소라 스캐폴딩을 건너뛰었으면 비어 있다 — 그 안의 파이프라인
	// 파일은 우리가 만든 것이 아니므로 단계를 안다고 말하면 안 된다.
	Stages []string
	// CredentialManifests 는 파이프라인 자격증명 ExternalSecret 이다.
	//
	// 여기서 적용하지 않는다 — 클러스터 접근은 상위 유스케이스가 한곳에서
	// 맡는다(Argo CD 리소스와 같은 경로로 적용된다).
	CredentialManifests []string
	// ImportedSource 는 이번에 새 저장소로 가져온 원본이다. 가져오지 않았으면 nil 이다.
	ImportedSource *domain.TemplateSource
}

ProvisionAppProjectOutput 은 프로비저닝 결과다.

type ProvisionCommonProject

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

ProvisionCommonProject 는 조직 그룹과 공용 프로젝트를 보장한다.

func NewProvisionCommonProject

func NewProvisionCommonProject(scm port.SCMProvisioner) *ProvisionCommonProject

NewProvisionCommonProject 는 유스케이스를 만든다.

func (*ProvisionCommonProject) Execute

Execute 는 그룹 → 공용 프로젝트 → 사용 안내 문서 순으로 보장한다.

모든 단계가 멱등하므로 스택 설치가 재시도돼도 안전하다.

type ProvisionCommonProjectInput

type ProvisionCommonProjectInput struct {
	// GroupPath 는 조직 그룹 경로다 (예: "acme").
	GroupPath string
	// GroupName 은 그룹 표시 이름이다. 비면 GroupPath 를 쓴다.
	GroupName string
	// ProjectPath 는 공용 프로젝트 경로다. 비면 DefaultCommonProjectPath.
	ProjectPath string
	// Platform 은 안내 문서에 적을 패키지 레지스트리 주소 형식을 정한다.
	// 비면 GitLab 으로 본다.
	Platform port.SCMPlatform
}

ProvisionCommonProjectInput 은 공용 프로젝트 프로비저닝 요청이다.

type ProvisionCommonProjectOutput

type ProvisionCommonProjectOutput struct {
	Group   *port.SCMGroup
	Project *port.SCMProject
	// DocsSkipped 는 이미 있던 프로젝트라 README 를 쓰지 않았음을 알린다.
	DocsSkipped bool
}

ProvisionCommonProjectOutput 은 프로비저닝 결과다.

type ProvisionPipelineRepository

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

ProvisionPipelineRepository 는 파이프라인 하나가 돌기 위한 저장소 일체를 만든다.

공용 프로젝트 → 앱 프로젝트 + 스캐폴딩 → Argo CD Application 순이다. 앞 단계 결과가 뒷 단계 입력이므로 순서가 고정되어 있다.

func NewProvisionPipelineRepository

func NewProvisionPipelineRepository(
	factory port.SCMBundleFactory,
	applier port.ManifestApplier,
	kubeconfig port.KubeconfigProvider,
) *ProvisionPipelineRepository

NewProvisionPipelineRepository 는 유스케이스를 만든다.

func (*ProvisionPipelineRepository) Execute

Execute 는 저장소를 만들고 Argo CD 가 바라보게 한다.

func (*ProvisionPipelineRepository) WithSourceArchive added in v0.6.0

WithSourceArchive 는 템플릿 원본을 가져올 경로를 배선한다.

type ProvisionPipelineRepositoryInput

type ProvisionPipelineRepositoryInput struct {
	AppName string
	StackID string
	// TemplateID 는 배포 매니페스트에 템플릿 라벨로 실린다. 비면 라벨을 붙이지 않는다.
	TemplateID string
	// AppType 은 어떤 앱을 스캐폴딩할지다. web 이면 React 앱을 만든다.
	AppType domain.AppType
	// RequestedByEmail 은 파이프라인을 만든 사람의 이메일이다.
	// 저장소를 담은 조직의 멤버로 넣는 데 쓴다. 비면 건너뛴다.
	RequestedByEmail string
	// Namespace 는 배포 대상 쿠버네티스 네임스페이스다.
	Namespace string
	Port      int32
	Replicas  int32
	// CommonProjectPath 는 공용 프로젝트 경로다. 비면 기본값.
	CommonProjectPath string
	// RegistryCredentials 는 외부 레지스트리 자격증명이다.
	RegistryCredentials map[string]string
	// RefreshDefinitionOnly 는 이미 있는 저장소의 파이프라인 정의 파일만 다시 쓰고 CI 변수를
	// 다시 등록한다. Argo CD Application 은 건드리지 않는다.
	RefreshDefinitionOnly bool
	// Source 는 템플릿의 원본이다. 있으면 새 저장소의 첫 커밋으로 가져온다.
	Source *domain.TemplateSource
}

ProvisionPipelineRepositoryInput 은 파이프라인용 저장소 준비 요청이다.

type ProvisionPipelineRepositoryOutput

type ProvisionPipelineRepositoryOutput struct {
	CommonProject *port.SCMProject
	Project       *port.SCMProject
	// RepoURL / ImageRepository 는 파이프라인 레코드에 남길 값이다.
	RepoURL         string
	ImageRepository string

	ArgoApplicationCreated bool
	MissingVariables       []string
	Warnings               []string
	// ScaffoldSkipped 는 이미 있던 저장소라 스캐폴딩을 쓰지 않았음을 알린다.
	ScaffoldSkipped bool
	// DefinitionRefreshed / RepositoryRecreated 는 정의 갱신의 결과다(ProvisionAppProjectOutput).
	DefinitionRefreshed bool
	RepositoryRecreated bool
	// Stages 는 파이프라인 레코드에 남길 실효 단계다. 스캐폴딩을 건너뛰었으면 비어 있다.
	Stages []string
	// ImportedSource 는 새 저장소로 가져온 원본이다. 파이프라인 레코드에 남긴다.
	ImportedSource *domain.TemplateSource
}

ProvisionPipelineRepositoryOutput 은 준비 결과다.

type RefreshPipelineDefinition added in v0.6.0

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

RefreshPipelineDefinition 은 기존 파이프라인의 CI 정의 파일을 플랫폼 기본으로 다시 쓴다.

스캐폴딩은 새 저장소에만 쓰인다 — 기존 저장소에 다시 쓰면 사용자가 고친 Dockerfile·매니페스트와 CI 가 갱신한 이미지 태그가 되돌아간다. 그래서 SAST 리포트처럼 정의 파일이 새로 하는 일은 그 전에 만든 파이프라인에 붙지 않았고, 파이프라인을 다시 만드는 것 말고는 방법이 없었다. 이 유스케이스는 정의 파일 하나와 CI 변수만 다시 쓴다. 사용자가 손본 정의 파일은 덮어쓴다 — 호출부(화면)가 그 사실을 묻는다.

func NewRefreshPipelineDefinition added in v0.6.0

func NewRefreshPipelineDefinition(pipelines port.PipelineRepository, provisioner RepositoryProvisioner) *RefreshPipelineDefinition

func (*RefreshPipelineDefinition) Execute added in v0.6.0

func (*RefreshPipelineDefinition) WithScanPolicyPublisher added in v0.6.0

WithScanPolicyPublisher 는 갱신 뒤 스택의 스캔 정책을 다시 싣도록 배선한다 — 새 정의에 스캔 단계가 생겼으면 정책도 있어야 한다.

type RefreshPipelineDefinitionOutput added in v0.6.0

type RefreshPipelineDefinitionOutput struct {
	Pipeline *domain.Pipeline
	// Stages 는 다시 쓴 정의의 단계다. 비면 번들이 알려 주지 않은 것이다.
	Stages           []string
	Warnings         []string
	MissingVariables []string
	// RepositoryRecreated 는 저장소가 없어 다시 만들고 전체 스캐폴딩을 썼음을 알린다.
	RepositoryRecreated bool
}

RefreshPipelineDefinitionOutput 은 갱신 결과다.

type RepositoryProvisioner

type RepositoryProvisioner interface {
	Execute(ctx context.Context, input ProvisionPipelineRepositoryInput) (*ProvisionPipelineRepositoryOutput, error)
}

RepositoryProvisioner 는 파이프라인용 저장소 일체를 준비한다.

유스케이스끼리 직접 묶지 않고 인터페이스로 받는다 — 배선되지 않은 환경에서도 CreatePipeline 이 그대로 동작해야 한다.

type ScanPolicyPipelinePublisher added in v0.6.0

type ScanPolicyPipelinePublisher interface {
	PublishToPipeline(ctx context.Context, pipeline *domain.Pipeline) *ScanPolicyPush
}

ScanPolicyPipelinePublisher 는 새로 만든 스캔 파이프라인에 스택 정책을 싣는다. 스캔 단계가 없는 파이프라인에는 nil 을 돌려준다.

type ScanPolicyPush added in v0.6.0

type ScanPolicyPush struct {
	PipelineID   string               `json:"pipeline_id"`
	PipelineName string               `json:"pipeline_name"`
	Status       ScanPolicyPushStatus `json:"status"`
	Error        string               `json:"error,omitempty"`
}

ScanPolicyPush 는 파이프라인 하나에 대한 정책 푸시 결과다.

type ScanPolicyPushStatus added in v0.6.0

type ScanPolicyPushStatus string

ScanPolicyPushStatus 는 파이프라인 하나에 정책을 실은 결과다.

const (
	ScanPolicyPushApplied ScanPolicyPushStatus = "applied"
	ScanPolicyPushFailed  ScanPolicyPushStatus = "failed"
)

type ScanPolicyService added in v0.6.0

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

ScanPolicyService 는 스택의 이미지 스캔 정책을 저장하고 파이프라인에 싣는다.

판정은 CI 가 스스로 한다. 플랫폼은 정책이 바뀔 때와 스캔 파이프라인이 새로 생길 때 정책 값을 CI 가 읽는 자리에 싣는다 — CI 가 플랫폼에 되묻는 인바운드 경로(와 그 경로의 기계 인증)를 두지 않기 위해서다.

func NewScanPolicyService added in v0.6.0

func NewScanPolicyService(
	policies port.ScanPolicyRepository,
	pipelines port.PipelineRepository,
	bundles port.SCMBundleFactory,
) *ScanPolicyService

NewScanPolicyService 는 ScanPolicyService 를 만든다.

func (*ScanPolicyService) Get added in v0.6.0

func (s *ScanPolicyService) Get(ctx context.Context, stackID string) (*ScanPolicyView, error)

Get 은 스택의 현재 정책이다. 저장한 적 없으면 기본 정책이고 IsDefault 가 참이다.

func (*ScanPolicyService) PublishToPipeline added in v0.6.0

func (s *ScanPolicyService) PublishToPipeline(ctx context.Context, pipeline *domain.Pipeline) *ScanPolicyPush

PublishToPipeline 은 새로 만든 스캔 파이프라인에 스택의 현재 정책을 싣는다.

싣지 않으면 스크립트 기본값으로 돌아, 운영자가 HIGH 를 막아 둔 스택에서 새 파이프라인만 HIGH 가 통과한다. 스캔 단계가 없는 파이프라인은 nil 이다.

func (*ScanPolicyService) Update added in v0.6.0

func (s *ScanPolicyService) Update(
	ctx context.Context,
	stackID string,
	policy domain.ScanPolicy,
	actor string,
) (*UpdateScanPolicyResult, error)

Update 는 정책을 검증·저장한 뒤 그 스택의 스캔 파이프라인에 싣는다.

푸시 실패로 저장을 되돌리지 않는다. 저장된 정책이 기준이고, 실패한 파이프라인은 결과에 남겨 다시 저장하거나 원인을 고치게 한다 — 되돌리면 도달 가능한 파이프라인도 새 정책을 못 받는다.

type ScanPolicyView added in v0.6.0

type ScanPolicyView struct {
	StackID string            `json:"stack_id"`
	Policy  domain.ScanPolicy `json:"policy"`
	// IsDefault 는 저장한 적이 없어 기본 정책을 쓰고 있다는 뜻이다.
	IsDefault bool `json:"is_default"`
}

ScanPolicyView 는 스택의 현재 정책이다.

type ScanVulnerabilities added in v0.6.0

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

ScanVulnerabilities 는 파이프라인 스캔 결과의 취약점 목록을 돌려준다.

목록은 저장하지 않는다. 볼 때 CI 가 남긴 리포트를 다시 읽어 만든다 — 원본 리포트는 DB 에 넣지 않는다는 결정(이미지 스캔 설계 §8)을 지키고, 목록이 리포트와 어긋날 일이 없다. 대신 CI 가 보관 기간이 지나 리포트를 지우면 목록은 볼 수 없고 건수만 남는다.

func NewScanVulnerabilities added in v0.6.0

func NewScanVulnerabilities(
	pipelines port.PipelineRepository,
	scans port.ImageScanResultRepository,
	factory port.SCMBundleFactory,
) *ScanVulnerabilities

NewScanVulnerabilities 는 유스케이스를 만든다.

func (*ScanVulnerabilities) Execute added in v0.6.0

Execute 는 조건에 맞는 한 쪽을 돌려준다. 목록을 보일 수 없으면 이유를 담는다 — 빈 목록은 취약점 0건으로 읽힌다.

func (*ScanVulnerabilities) ExecuteInOrg added in v0.6.0

func (uc *ScanVulnerabilities) ExecuteInOrg(
	ctx context.Context,
	orgID, pipelineID, scanID string,
	filter shareddomain.VulnerabilityFilter,
) (*shareddomain.VulnerabilityPage, error)

ExecuteInOrg 는 Execute 와 같되, orgID 가 있으면 그 조직의 파이프라인만 본다(Security Dashboard 설계 §8 G4). 다른 조직의 파이프라인은 없는 것과 같게 답한다 — 있다는 사실도 알리지 않는다. orgID 가 비면 확인하지 않는다(신원이 없는 개발 모드).

type SyncPipelineRuns

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

SyncPipelineRuns 는 CI 서버의 빌드 이력을 배포 기록으로 들인다.

GitOps 경로에서는 플랫폼이 배포를 실행하지 않는다 — CI 가 빌드하고 Argo CD 가 동기화한다. 그래서 실행 기록이 CI 서버에만 있고, 들이지 않으면 빌드가 성공해도 화면의 실행 통계가 영원히 0 으로 남는다.

멱등하다. 배포 ID 를 job 과 빌드 번호에서 만들어, 같은 빌드를 여러 번 동기화해도 기록이 늘지 않고 상태만 갱신된다(실행 중 → 성공).

func NewSyncPipelineRuns

func NewSyncPipelineRuns(builds port.CIBuildReader, deployments port.DeploymentRepository) *SyncPipelineRuns

NewSyncPipelineRuns 는 SyncPipelineRuns 를 만든다.

func (*SyncPipelineRuns) Execute

func (uc *SyncPipelineRuns) Execute(ctx context.Context, input SyncPipelineRunsInput) (int, error)

Execute 는 최근 빌드를 읽어 배포 기록으로 반영한다.

func (*SyncPipelineRuns) ForPipeline

func (uc *SyncPipelineRuns) ForPipeline(ctx context.Context, pipelineID string) (int, error)

ForPipeline 은 파이프라인 하나의 실행 기록을 들인다.

CI 가 배선되지 않은 스택(Jenkins 자격증명을 못 읽은 경우 등)은 경고만 남기고 건너뛴다 — 실행 기록 조회 때문에 화면 조회 자체를 실패시키지 않는다.

func (*SyncPipelineRuns) SyncAll added in v0.6.0

func (uc *SyncPipelineRuns) SyncAll(ctx context.Context) (int, error)

SyncAll 은 스택에 묶인 모든 파이프라인의 실행 기록과 스캔 결과를 들이고, 동기화한 파이프라인 수를 돌려준다.

화면을 열 때만 들이면 아무도 보지 않는 파이프라인의 스캔 결과가 쌓이지 않는다. 번들은 스택마다 한 번만 만든다 — 조립마다 SCM 인증 확인이 따른다. 한 스택의 실패로 나머지를 멈추지 않는다.

func (*SyncPipelineRuns) WithArtifacts added in v0.6.0

func (uc *SyncPipelineRuns) WithArtifacts(reader port.CIArtifactReader) *SyncPipelineRuns

WithArtifacts 는 스캔 리포트를 읽어 건수를 채우도록 배선한다.

func (*SyncPipelineRuns) WithBundleFactory

func (uc *SyncPipelineRuns) WithBundleFactory(
	factory port.SCMBundleFactory,
	pipelines port.PipelineRepository,
) *SyncPipelineRuns

WithBundleFactory 는 파이프라인마다 CI 서버를 찾아 쓰도록 배선한다.

CI 서버는 스택마다 따로 서므로 기동 시점에 하나로 고정할 수 없다.

func (*SyncPipelineRuns) WithDependencyScans added in v0.6.0

WithDependencyScans 는 의존성 스캔(SCA) 단계의 결과를 남기도록 배선한다.

func (*SyncPipelineRuns) WithImageScans added in v0.6.0

WithImageScans 는 스캔 게이트 판정을 남기도록 배선한다.

func (*SyncPipelineRuns) WithSASTResults added in v0.6.0

func (uc *SyncPipelineRuns) WithSASTResults(repo port.SASTResultRepository) *SyncPipelineRuns

WithSASTResults 는 분석 단계의 결과를 남기도록 배선한다.

func (*SyncPipelineRuns) WithScanPolicies added in v0.6.0

func (uc *SyncPipelineRuns) WithScanPolicies(repo port.ScanPolicyRepository) *SyncPipelineRuns

WithScanPolicies 는 파이프라인의 스택 정책으로 판정하도록 배선한다.

func (*SyncPipelineRuns) WithSecretScans added in v0.6.0

WithSecretScans 는 시크릿 탐지 단계의 결과를 남기도록 배선한다.

func (*SyncPipelineRuns) WithSyncablePipelines added in v0.6.0

func (uc *SyncPipelineRuns) WithSyncablePipelines(lister port.SyncablePipelineLister) *SyncPipelineRuns

WithSyncablePipelines 는 주기 동기화가 돌 파이프라인 목록을 배선한다.

type SyncPipelineRunsInput

type SyncPipelineRunsInput struct {
	PipelineID string
	JobName    string
	Branch     string
	Limit      int
	// SASTWebURL 은 스택 SonarQube 의 공개 주소다. 분석 결과의 링크를 만든다.
	SASTWebURL string
	// Policy 는 판정에 쓸 스택 정책이다. nil 이면 기본 정책이다 — CI 는 푸시된 정책으로
	// 막으므로, 동기화도 같은 정책으로 읽어야 차단과 스캔 오류를 바르게 가른다.
	Policy *domain.ScanPolicy
	// PolicyUnavailable 은 스택 정책을 읽지 못했다는 뜻이다(nil Policy 와 다르다 — 그것은 저장한 적 없음).
	// 시크릿 탐지는 정책이 off 인지 모르면 기록하지 않는다. 다른 판정은 지금처럼 기본 정책으로 한다.
	PolicyUnavailable bool
}

SyncPipelineRunsInput 은 어느 job 의 어느 브랜치를 들일지다.

type UpdateScanPolicyResult added in v0.6.0

type UpdateScanPolicyResult struct {
	ScanPolicyView
	Pushes []ScanPolicyPush `json:"pushes"`
}

UpdateScanPolicyResult 는 저장한 정책과 파이프라인별 푸시 결과다.

Jump to

Keyboard shortcuts

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