model

package
v0.0.0-...-77c6198 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSignature = errors.New("invalid jit token signature")
	ErrJobFinished      = errors.New("job is already finished or expired")
	ErrJobNotFound      = errors.New("job not found")
)

Erros de Negócio

Functions

This section is empty.

Types

type AzureMetadata

type AzureMetadata struct {
	Organization string `firestore:"organization" json:"organization"`                 // Nome da organização
	Project      string `firestore:"project" json:"project"`                           // Nome do projeto
	ProjectID    string `firestore:"project_id,omitempty" json:"project_id,omitempty"` // GUID do projeto
	RepoGUID     string `firestore:"repo_guid" json:"repo_guid"`                       // GUID do repositório (igual ao ID principal)
}

AzureMetadata contém campos específicos do Azure DevOps

type Deployment

type Deployment struct {
	ID        string           `firestore:"id"`
	PRNumber  int              `firestore:"pr_number"`
	RepoID    string           `firestore:"repo_id"`
	User      string           `firestore:"user"`
	CreatedAt time.Time        `firestore:"created_at"`
	Status    DeploymentStatus `firestore:"status"`

	// ===== NOVOS CAMPOS PARA PLAN =====
	// SourceBranch of plan
	SourceBranch string `firestore:"source_branch"`
	// TargetBranch of plan
	TargetBranch string `firestore:"target_branch"`
	// HeadSHA é o commit SHA do PR no momento do plan (pode ser merge commit em Azure PR builds)
	HeadSHA string `firestore:"head_sha,omitempty"`

	// SourceBranchSHA é o SHA do tip da branch de origem (SYSTEM_PULLREQUEST_SOURCECOMMITID no Azure)
	// Usado para MergePR — LastMergeSourceCommit no Azure DevOps
	SourceBranchSHA string `firestore:"source_branch_sha,omitempty"`

	// PlanOutput contém o output completo do terraform plan
	// Usado para exibir no PR comment e para validações
	PlanOutput string `firestore:"plan_output,omitempty"`

	// Stacks é a lista de stacks afetados neste PR
	// Ex: ["prod/vpc", "prod/compute"]
	Stacks []string `firestore:"stacks,omitempty"`

	// PlanSucceeded indica se o último plan foi bem-sucedido
	PlanSucceeded bool `firestore:"plan_succeeded"`

	// PlanAt é o timestamp do último plan
	PlanAt time.Time `firestore:"plan_at,omitempty"`

	// PlanVersion incrementa a cada novo plan (para invalidar plans antigos)
	PlanVersion int `firestore:"plan_version"`
}

Deployment representa um Pull Request e seu estado no sistema Este model será renomeado para PullRequest no futuro (cleanup)

type DeploymentStatus

type DeploymentStatus string
const (
	DeploymentPlanned  DeploymentStatus = "planned"
	DeploymentApproved DeploymentStatus = "approved"
	DeploymentRejected DeploymentStatus = "rejected"
	DeploymentPending  DeploymentStatus = "pending"
	DeploymentFailed   DeploymentStatus = "failed"
	DeploymentRunning  DeploymentStatus = "running"
	DeploymentApplied  DeploymentStatus = "applied"
	DeploymentMerged   DeploymentStatus = "merged"
)

type GitHubMetadata

type GitHubMetadata struct {
	Owner        string `firestore:"owner" json:"owner"`                 // Nome do owner (user ou org)
	RepoName     string `firestore:"repo_name" json:"repo_name"`         // Nome do repositório
	RepositoryID int64  `firestore:"repository_id" json:"repository_id"` // ID numérico do repo (igual ao ID principal convertido)
}

GitHubMetadata contém campos específicos do GitHub

type GitLabMetadata

type GitLabMetadata struct {
	Namespace   string `firestore:"namespace" json:"namespace"`       // Namespace (group/subgroup)
	ProjectPath string `firestore:"project_path" json:"project_path"` // Path completo (namespace/project)
	ProjectID   int64  `firestore:"project_id" json:"project_id"`     // ID numérico do projeto (igual ao ID principal convertido)
}

GitLabMetadata contém campos específicos do GitLab

type Job

type Job struct {
	ID           string    `firestore:"id"`
	DeploymentID string    `firestore:"deployment_id"`
	RepoID       string    `firestore:"repo_id"`
	Status       OpStatus  `firestore:"status"`
	UpdatedAt    time.Time `firestore:"updated_at"`
	JITToken     string    `firestore:"jit_token"`

	// NOVO: Tipo de operação (plan ou apply)
	Operation string `firestore:"operation,omitempty"` // "plan" ou "apply"

	// NOVO: Quem disparou este job (para auditoria e locks)
	User string `firestore:"user,omitempty"`
}

Job representa uma execução de terraform (plan ou apply)

type Lock

type Lock struct {
	RepoID    string    `firestore:"repo_id"`
	StackPath string    `firestore:"stack_path"`
	PRNumber  int       `firestore:"pr_number"`
	User      string    `firestore:"user"`
	CreatedAt time.Time `firestore:"created_at"` // Quando foi criado (auditoria)
}

Lock representa um lock em um stack específico Locks NÃO expiram automaticamente - só são liberados explicitamente via: 1. Comando /unlock (chatops) 2. PR merged 3. PR closed

type OpStatus

type OpStatus string
const (
	StatusQueued  OpStatus = "QUEUED"
	StatusRunning OpStatus = "RUNNING"
	StatusSuccess OpStatus = "SUCCESS"
	StatusFailed  OpStatus = "FAILED"
)

type PipelineTriggerRequest

type PipelineTriggerRequest struct {
	Repo      string
	Branch    string
	CommitSHA string
	Variables map[string]string
}

PipelineTriggerRequest é usado para disparar pipelines

type RepositoryMetadata

type RepositoryMetadata struct {
	ID          string      `firestore:"id" json:"id"`                     // ID nativo do provider (GUID do Azure, número do GitHub/GitLab)
	Name        string      `firestore:"name" json:"name"`                 // Nome do repositório
	RepoURI     string      `firestore:"repo_uri" json:"repo_uri"`         // URI completa original
	SCMProvider SCMProvider `firestore:"scm_provider" json:"scm_provider"` // azure, github, gitlab
	KeyVersion  int         `firestore:"key_version" json:"key_version"`
	CreatedAt   time.Time   `firestore:"created_at" json:"created_at"`
	UpdatedAt   time.Time   `firestore:"updated_at,omitempty" json:"updated_at,omitempty"`

	// Metadados específicos por provider (apenas um será preenchido)
	Azure  *AzureMetadata  `firestore:"azure,omitempty" json:"azure,omitempty"`
	GitHub *GitHubMetadata `firestore:"github,omitempty" json:"github,omitempty"`
	GitLab *GitLabMetadata `firestore:"gitlab,omitempty" json:"gitlab,omitempty"`
}

RepositoryMetadata contém metadados de um repositório registrado

type SCMProvider

type SCMProvider string
const (
	SCMProviderAzure  SCMProvider = "azure"
	SCMProviderGitHub SCMProvider = "github"
	SCMProviderGitLab SCMProvider = "gitlab"
)

func (SCMProvider) Valid

func (t SCMProvider) Valid() bool

Valid verifica se o tipo é válido

Jump to

Keyboard shortcuts

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