controllers

package
v0.46.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRequestID added in v0.45.0

func GenerateRequestID() string

GenerateRequestID creates a new unique request ID.

func GetRequestID added in v0.45.0

func GetRequestID(r *http.Request) string

GetRequestID extracts the request ID from the request context or header, or generates a new one if not present.

func SetJSONContentType added in v0.45.0

func SetJSONContentType(w http.ResponseWriter)

SetJSONContentType sets the Content-Type header for JSON responses.

Types

type APIController added in v0.19.8

type APIController struct {
	APISecret                       []byte
	Locker                          locking.Locker `validate:"required"`
	DriftStorage                    drift.Storage
	RemediationService              drift.RemediationService
	ApplyLockChecker                locking.ApplyLockChecker
	EnableDriftRemediation          bool
	Logger                          logging.SimpleLogging           `validate:"required"`
	Parser                          events.EventParsing             `validate:"required"`
	ProjectCommandBuilder           events.ProjectCommandBuilder    `validate:"required"`
	ProjectPlanCommandRunner        events.ProjectPlanCommandRunner `validate:"required"`
	ProjectPolicyCheckCommandRunner events.ProjectPolicyCheckCommandRunner
	ProjectApplyCommandRunner       events.ProjectApplyCommandRunner `validate:"required"`
	FailOnPreWorkflowHookError      bool
	PreWorkflowHooksCommandRunner   events.PreWorkflowHooksCommandRunner  `validate:"required"`
	PostWorkflowHooksCommandRunner  events.PostWorkflowHooksCommandRunner `validate:"required"`
	RepoAllowlistChecker            *events.RepoAllowlistChecker          `validate:"required"`
	Scope                           tally.Scope                           `validate:"required"`
	VCSClient                       vcs.Client                            `validate:"required"`
	WorkingDir                      events.WorkingDir                     `validate:"required"`
	WorkingDirLocker                events.WorkingDirLocker               `validate:"required"`
	CommitStatusUpdater             events.CommitStatusUpdater            `validate:"required"`
	// PullReqStatusFetcher is optional. When set and the API request supplies a
	// PR number, it is used to populate command.Context.PullRequestStatus so
	// apply requirements like 'mergeable' and 'approved' evaluate against real
	// VCS state instead of always failing.
	PullReqStatusFetcher vcs.PullReqStatusFetcher
	// PullStatusFetcher is optional. When set and the API request supplies a PR
	// number, it is used to populate command.Context.PullStatus so generated
	// policy_check contexts can preserve existing policy approvals.
	PullStatusFetcher events.PullStatusFetcher
	// LivePullHeadFetcher is optional for tests. In production it is used for
	// PR-backed API requests to seed live PR identity data such as base branch.
	LivePullHeadFetcher events.LivePullHeadFetcher
	// DriftWebhookSender sends webhook notifications when drift is detected.
	// Nil when no drift webhooks are configured.
	DriftWebhookSender *webhooks.DriftWebhookSender
	// SilenceVCSStatusNoProjects is whether API should set commit status if no projects are found
	SilenceVCSStatusNoProjects bool
	// contains filtered or unexported fields
}

func (*APIController) Apply added in v0.19.8

func (a *APIController) Apply(w http.ResponseWriter, r *http.Request)

func (*APIController) DetectDrift added in v0.45.0

func (a *APIController) DetectDrift(w http.ResponseWriter, r *http.Request)

DetectDrift handles POST /api/drift/detect requests. It triggers drift detection by running plans for the specified projects. This is an authenticated endpoint that requires the API secret.

func (*APIController) DriftStatus added in v0.45.0

func (a *APIController) DriftStatus(w http.ResponseWriter, r *http.Request)

DriftStatus returns cached drift detection results for a repository. This is an authenticated endpoint that requires the API secret. Query parameters:

  • repository: required, the full repository name (owner/repo)
  • type: required, the VCS provider type
  • project: optional, filter by project name
  • path: optional, filter by repository-relative project path
  • workspace: optional, filter by workspace
  • ref: optional, filter by git ref
  • base_branch: optional, filter by branch context

func (*APIController) GetRemediationResult added in v0.45.0

func (a *APIController) GetRemediationResult(w http.ResponseWriter, r *http.Request)

GetRemediationResult handles GET /api/drift/remediate/{id} requests. It retrieves a specific remediation result by ID. This is an authenticated endpoint that requires the API secret.

func (*APIController) ListLocks added in v0.34.0

func (a *APIController) ListLocks(w http.ResponseWriter, r *http.Request)

func (*APIController) ListRemediationResults added in v0.45.0

func (a *APIController) ListRemediationResults(w http.ResponseWriter, r *http.Request)

ListRemediationResults handles GET /api/drift/remediate requests. It lists remediation results for a repository. Query parameters:

  • repository: required, the full repository name (owner/repo)
  • type: required, the VCS provider type
  • limit: optional, maximum number of results to return (default: 10)

This is an authenticated endpoint that requires the API secret.

func (*APIController) Plan added in v0.19.8

func (a *APIController) Plan(w http.ResponseWriter, r *http.Request)

func (*APIController) Remediate added in v0.45.0

func (a *APIController) Remediate(w http.ResponseWriter, r *http.Request)

Remediate handles POST /api/drift/remediate requests. It executes drift remediation (plan or apply) for the specified projects. This is an authenticated endpoint that requires the API secret.

type APIError added in v0.45.0

type APIError struct {
	// Code is a machine-readable error code.
	Code ErrorCode `json:"code"`
	// Message is a human-readable error message.
	Message string `json:"message"`
	// Details contains additional error context (e.g., field-level validation errors).
	Details any `json:"details,omitempty"`
}

APIError represents a structured error response.

func NewAPIError added in v0.45.0

func NewAPIError(code ErrorCode, message string) *APIError

NewAPIError creates a new APIError.

func NewValidationError added in v0.45.0

func NewValidationError(message string, fields ...ValidationError) *APIError

NewValidationError creates a validation APIError with field details.

func (*APIError) Error added in v0.45.0

func (e *APIError) Error() string

Error implements the error interface.

func (*APIError) WithDetails added in v0.45.0

func (e *APIError) WithDetails(details any) *APIError

WithDetails adds details to an APIError and returns it.

type APIMiddleware added in v0.45.0

type APIMiddleware struct {
	APISecret []byte
	Logger    logging.SimpleLogging
	Responder *APIResponder
}

APIMiddleware provides common middleware functions for API endpoints.

func NewAPIMiddleware added in v0.45.0

func NewAPIMiddleware(apiSecret []byte, logger logging.SimpleLogging) *APIMiddleware

NewAPIMiddleware creates a new APIMiddleware.

func (*APIMiddleware) RequireAuth added in v0.45.0

func (m *APIMiddleware) RequireAuth(w http.ResponseWriter, r *http.Request) bool

RequireAuth is middleware that validates the API secret token. Returns true if authentication passed, false if it failed (response already sent).

type APIRequest added in v0.19.8

type APIRequest struct {
	Repository string `validate:"required"`
	Ref        string `validate:"required"`
	BaseBranch string `json:"base_branch,omitempty"`
	Type       string `validate:"required"`
	PR         int
	Projects   []string
	Paths      []APIRequestPath
	// DiscoverProjects enables all-project discovery when no projects or paths
	// are specified. Only drift detection and remediation set this.
	DiscoverProjects bool `json:"-"`
}

type APIRequestPath added in v0.45.0

type APIRequestPath struct {
	ProjectName string `json:"project_name,omitempty"`
	Directory   string `json:"directory"`
	Workspace   string `json:"workspace,omitempty"`
}

type APIResponder added in v0.45.0

type APIResponder struct {
	Logger logging.SimpleLogging
}

APIResponder provides methods for sending consistent API responses.

func NewAPIResponder added in v0.45.0

func NewAPIResponder(logger logging.SimpleLogging) *APIResponder

NewAPIResponder creates a new APIResponder.

func (*APIResponder) Error added in v0.45.0

func (a *APIResponder) Error(w http.ResponseWriter, r *http.Request, httpCode int, apiErr *APIError)

Error sends an error JSON response.

func (*APIResponder) Forbidden added in v0.45.0

func (a *APIResponder) Forbidden(w http.ResponseWriter, r *http.Request, message string)

Forbidden sends a forbidden error response.

func (*APIResponder) InternalError added in v0.45.0

func (a *APIResponder) InternalError(w http.ResponseWriter, r *http.Request, err error)

InternalError sends an internal server error response. The full error is logged server-side but only a generic message is returned to the client.

func (*APIResponder) NotFound added in v0.45.0

func (a *APIResponder) NotFound(w http.ResponseWriter, r *http.Request, message string)

NotFound sends a not found error response.

func (*APIResponder) ServiceUnavailable added in v0.45.0

func (a *APIResponder) ServiceUnavailable(w http.ResponseWriter, r *http.Request, message string)

ServiceUnavailable sends a service unavailable error response.

func (*APIResponder) Success added in v0.45.0

func (a *APIResponder) Success(w http.ResponseWriter, r *http.Request, code int, data any)

Success sends a successful JSON response.

func (*APIResponder) Unauthorized added in v0.45.0

func (a *APIResponder) Unauthorized(w http.ResponseWriter, r *http.Request, message string)

Unauthorized sends an unauthorized error response.

func (*APIResponder) ValidationFailed added in v0.45.0

func (a *APIResponder) ValidationFailed(w http.ResponseWriter, r *http.Request, message string, fields ...ValidationError)

ValidationFailed sends a validation error response.

type APIResponse added in v0.45.0

type APIResponse struct {
	// Success indicates whether the request succeeded.
	Success bool `json:"success"`
	// Data contains the response payload on success.
	Data any `json:"data"`
	// Error contains error details on failure.
	Error *APIError `json:"error"`
	// RequestID is a unique identifier for request tracing.
	RequestID string `json:"request_id"`
	// Timestamp is when the response was generated.
	Timestamp time.Time `json:"timestamp"`
}

APIResponse is the standard envelope for newer API responses. Using a concrete type instead of generics for Go 1.18+ compatibility with json.Marshal.

func NewErrorResponse added in v0.45.0

func NewErrorResponse(requestID string, err *APIError) *APIResponse

NewErrorResponse creates an error API response.

func NewSuccessResponse added in v0.45.0

func NewSuccessResponse(requestID string, data any) *APIResponse

NewSuccessResponse creates a successful API response.

type CommandResultAPI added in v0.45.0

type CommandResultAPI struct {
	// Command is the command that was executed.
	Command string `json:"command"`
	// Projects contains results for each project.
	Projects []ProjectResultAPI `json:"projects"`
	// TotalProjects is the total number of projects.
	TotalProjects int `json:"total_projects"`
	// SuccessCount is the number of successful projects.
	SuccessCount int `json:"success_count"`
	// FailureCount is the number of failed projects.
	FailureCount int `json:"failure_count"`
	// ExecutedAt is when the command was executed.
	ExecutedAt time.Time `json:"executed_at"`
}

CommandResultAPI is the API representation of a command result with multiple projects.

func NewCommandResultAPI added in v0.45.0

func NewCommandResultAPI(cr *command.Result, cmdName string) CommandResultAPI

NewCommandResultAPI converts an internal CommandResult to its API representation.

type DriftDetailsAPI added in v0.45.0

type DriftDetailsAPI struct {
	// ToAdd is the number of resources to add.
	ToAdd int `json:"to_add"`
	// ToChange is the number of resources to change.
	ToChange int `json:"to_change"`
	// ToDestroy is the number of resources to destroy.
	ToDestroy int `json:"to_destroy"`
	// ToImport is the number of resources to import.
	ToImport int `json:"to_import"`
	// ToForget is the number of resources to forget.
	ToForget int `json:"to_forget"`
	// TotalChanges is the total number of changes.
	TotalChanges int `json:"total_changes"`
	// Summary is a human-readable summary.
	Summary string `json:"summary,omitempty"`
	// ChangesOutside indicates if changes were made outside Terraform.
	ChangesOutside bool `json:"changes_outside"`
}

DriftDetailsAPI is the API representation of drift details.

type DriftDetectionResultAPI added in v0.45.0

type DriftDetectionResultAPI struct {
	// ID is a unique identifier for this detection run.
	ID string `json:"id"`
	// Repository is the full repository name.
	Repository string `json:"repository"`
	// Projects contains drift status for each project checked.
	Projects []DriftProjectAPI `json:"projects"`
	// DetectedAt is when drift detection was performed.
	DetectedAt time.Time `json:"detected_at"`
	// Summary provides aggregate drift statistics.
	Summary DriftSummaryAPI `json:"summary"`
}

DriftDetectionResultAPI is the API response for drift detection.

func NewDriftDetectionResultAPI added in v0.45.0

func NewDriftDetectionResultAPI(dr *models.DriftDetectionResult) DriftDetectionResultAPI

NewDriftDetectionResultAPI converts an internal DriftDetectionResult to its API representation.

type DriftProjectAPI added in v0.45.0

type DriftProjectAPI struct {
	// ProjectName is the name of the project.
	ProjectName string `json:"project_name"`
	// Directory is the relative path to the project.
	Directory string `json:"directory"`
	// Workspace is the Terraform workspace.
	Workspace string `json:"workspace"`
	// Ref is the git reference that was checked.
	Ref string `json:"ref"`
	// BaseBranch is the branch context used for repo config branch filters.
	BaseBranch string `json:"base_branch,omitempty"`
	// ResolvedCommit is the checked-out commit SHA that produced this drift record.
	ResolvedCommit string `json:"resolved_commit,omitempty"`
	// DetectionID links this result to the detection run that produced it.
	DetectionID string `json:"detection_id,omitempty"`
	// HasDrift indicates whether drift was detected.
	HasDrift bool `json:"has_drift"`
	// Drift contains drift details if drift was detected.
	Drift *DriftDetailsAPI `json:"drift,omitempty"`
	// LastChecked is when drift was last checked.
	LastChecked time.Time `json:"last_checked"`
	// Error contains any error message if detection failed.
	Error string `json:"error,omitempty"`
}

DriftProjectAPI is the API representation of drift for a single project.

func NewDriftProjectAPI added in v0.45.0

func NewDriftProjectAPI(pd models.ProjectDrift) DriftProjectAPI

NewDriftProjectAPI converts an internal ProjectDrift to its API representation.

type DriftStatusAPI added in v0.45.0

type DriftStatusAPI struct {
	// Repository is the full repository name.
	Repository string `json:"repository"`
	// Projects contains drift status for each project.
	Projects []DriftProjectAPI `json:"projects"`
	// CheckedAt is when the status was checked.
	CheckedAt time.Time `json:"checked_at"`
	// Summary provides aggregate drift statistics.
	Summary DriftSummaryAPI `json:"summary"`
}

DriftStatusAPI is the API response for drift status.

func NewDriftStatusAPI added in v0.45.0

func NewDriftStatusAPI(ds models.DriftStatusResponse) DriftStatusAPI

NewDriftStatusAPI converts an internal DriftStatusResponse to its API representation.

type DriftSummaryAPI added in v0.45.0

type DriftSummaryAPI struct {
	// TotalProjects is the total number of projects.
	TotalProjects int `json:"total_projects"`
	// ProjectsWithDrift is the number of projects with drift.
	ProjectsWithDrift int `json:"projects_with_drift"`
	// ProjectsWithoutDrift is the number of projects without drift.
	ProjectsWithoutDrift int `json:"projects_without_drift"`
	// ProjectsWithErrors is the number of projects with errors.
	ProjectsWithErrors int `json:"projects_with_errors"`
}

DriftSummaryAPI is the aggregate drift summary.

type ErrorCode added in v0.45.0

type ErrorCode string

ErrorCode represents a machine-readable error code for API responses. Clients can use these codes for programmatic error handling.

const (
	// ErrCodeValidation indicates request validation failed.
	ErrCodeValidation ErrorCode = "VALIDATION_ERROR"
	// ErrCodeUnauthorized indicates missing or invalid authentication.
	ErrCodeUnauthorized ErrorCode = "UNAUTHORIZED"
	// ErrCodeForbidden indicates the request is not allowed.
	ErrCodeForbidden ErrorCode = "FORBIDDEN"
	// ErrCodeNotFound indicates the requested resource was not found.
	ErrCodeNotFound ErrorCode = "NOT_FOUND"
	// ErrCodeConflict indicates a conflict with current state.
	ErrCodeConflict ErrorCode = "CONFLICT"
	// ErrCodeInternal indicates an internal server error.
	ErrCodeInternal ErrorCode = "INTERNAL_ERROR"
	// ErrCodeServiceUnavailable indicates a required service is not available.
	ErrCodeServiceUnavailable ErrorCode = "SERVICE_UNAVAILABLE"
	// ErrCodeRateLimited indicates too many requests.
	ErrCodeRateLimited ErrorCode = "RATE_LIMITED"
)

type GithubAppController

type GithubAppController struct {
	AtlantisURL         *url.URL              `validate:"required"`
	Logger              logging.SimpleLogging `validate:"required"`
	GithubSetupComplete bool
	GithubHostname      string `validate:"required"`
	GithubOrg           string
}

GithubAppController handles the creation and setup of a new GitHub app

func (*GithubAppController) ExchangeCode

func (g *GithubAppController) ExchangeCode(w http.ResponseWriter, r *http.Request)

ExchangeCode handles the user coming back from creating their app A code query parameter is exchanged for this app's ID, key, and webhook_secret Implements https://developer.github.com/apps/building-github-apps/creating-github-apps-from-a-manifest/#implementing-the-github-app-manifest-flow

func (*GithubAppController) New

New redirects the user to create a new GitHub app

type JobIDKeyGenerator added in v0.18.3

type JobIDKeyGenerator struct{}

func (JobIDKeyGenerator) Generate added in v0.18.3

func (g JobIDKeyGenerator) Generate(r *http.Request) (string, error)

type JobsController added in v0.18.0

type JobsController struct {
	AtlantisVersion          string                       `validate:"required"`
	AtlantisURL              *url.URL                     `validate:"required"`
	Logger                   logging.SimpleLogging        `validate:"required"`
	ProjectJobsTemplate      web_templates.TemplateWriter `validate:"required"`
	ProjectJobsErrorTemplate web_templates.TemplateWriter `validate:"required"`
	Database                 db.Database                  `validate:"required"`
	WsMux                    *websocket.Multiplexor       `validate:"required"`
	KeyGenerator             JobIDKeyGenerator
	StatsScope               tally.Scope `validate:"required"`
}

func (*JobsController) GetProjectJobs added in v0.18.0

func (j *JobsController) GetProjectJobs(w http.ResponseWriter, r *http.Request)

func (*JobsController) GetProjectJobsWS added in v0.18.0

func (j *JobsController) GetProjectJobsWS(w http.ResponseWriter, r *http.Request)

type ListLocksResult added in v0.34.0

type ListLocksResult struct {
	Locks []LockDetail
}

ListLocksResult is deprecated - use ListLocksResultAPI instead. Kept for backwards compatibility during migration.

type ListLocksResultAPI added in v0.45.0

type ListLocksResultAPI struct {
	// Locks contains the list of active locks.
	Locks []LockDetailAPI `json:"locks"`
	// TotalCount is the total number of locks.
	TotalCount int `json:"total_count"`
}

ListLocksResultAPI is the API response for listing locks.

func NewListLocksResultAPI added in v0.45.0

func NewListLocksResultAPI(locks map[string]models.ProjectLock) ListLocksResultAPI

NewListLocksResultAPI creates a ListLocksResultAPI from the internal lock map. This converts from the Locker's internal representation to the API representation.

type LockDetail added in v0.34.0

type LockDetail struct {
	Name            string
	ProjectName     string
	ProjectRepo     string
	ProjectRepoPath string
	PullID          int `json:",string"`
	PullURL         string
	User            string
	Workspace       string
	Time            time.Time
}

LockDetail is deprecated - use LockDetailAPI instead. Kept for backwards compatibility during migration.

type LockDetailAPI added in v0.45.0

type LockDetailAPI struct {
	// ID is the unique lock identifier.
	ID string `json:"id"`
	// ProjectName is the name of the locked project.
	ProjectName string `json:"project_name"`
	// Repository is the full repository name (owner/repo).
	Repository string `json:"repository"`
	// Path is the relative path to the project within the repository.
	Path string `json:"path"`
	// Workspace is the Terraform workspace.
	Workspace string `json:"workspace"`
	// PullRequestID is the PR number that holds the lock.
	PullRequestID int `json:"pull_request_id"`
	// PullRequestURL is the URL to the pull request.
	PullRequestURL string `json:"pull_request_url"`
	// LockedBy is the username who created the lock.
	LockedBy string `json:"locked_by"`
	// LockedAt is when the lock was acquired.
	LockedAt time.Time `json:"locked_at"`
}

LockDetailAPI is the API representation of a project lock.

type LocksController

type LocksController struct {
	AtlantisVersion    string                       `validate:"required"`
	AtlantisURL        *url.URL                     `validate:"required"`
	Locker             locking.Locker               `validate:"required"`
	Logger             logging.SimpleLogging        `validate:"required"`
	ApplyLocker        locking.ApplyLocker          `validate:"required"`
	VCSClient          vcs.Client                   `validate:"required"`
	LockDetailTemplate web_templates.TemplateWriter `validate:"required"`
	WorkingDir         events.WorkingDir            `validate:"required"`
	WorkingDirLocker   events.WorkingDirLocker      `validate:"required"`
	Database           db.Database                  `validate:"required"`
	DeleteLockCommand  events.DeleteLockCommand     `validate:"required"`
}

LocksController handles all requests relating to Atlantis locks.

func (*LocksController) DeleteLock

func (l *LocksController) DeleteLock(w http.ResponseWriter, r *http.Request)

DeleteLock handles deleting the lock at id and commenting back on the pull request that the lock has been deleted.

func (*LocksController) GetLock

func (l *LocksController) GetLock(w http.ResponseWriter, r *http.Request)

GetLock is the GET /locks/{id} route. It renders the lock detail view.

func (*LocksController) LockApply

func (l *LocksController) LockApply(w http.ResponseWriter, _ *http.Request)

LockApply handles creating a global apply lock. If Lock already exists it will be a no-op

func (*LocksController) UnlockApply

func (l *LocksController) UnlockApply(w http.ResponseWriter, _ *http.Request)

UnlockApply handles releasing a global apply lock. If Lock doesn't exists it will be a no-op

type PlanDetailsAPI added in v0.45.0

type PlanDetailsAPI struct {
	// HasChanges indicates whether the plan contains changes.
	HasChanges bool `json:"has_changes"`
	// ToAdd is the number of resources to add.
	ToAdd int `json:"to_add"`
	// ToChange is the number of resources to change.
	ToChange int `json:"to_change"`
	// ToDestroy is the number of resources to destroy.
	ToDestroy int `json:"to_destroy"`
	// ToImport is the number of resources to import.
	ToImport int `json:"to_import"`
	// ToForget is the number of resources to forget.
	ToForget int `json:"to_forget"`
	// Summary is a human-readable summary.
	Summary string `json:"summary,omitempty"`
}

PlanDetailsAPI is the API representation of plan output details.

type ProjectResultAPI added in v0.45.0

type ProjectResultAPI struct {
	// ProjectName is the name of the project (from atlantis.yaml).
	ProjectName string `json:"project_name"`
	// Directory is the relative path to the project root.
	Directory string `json:"directory"`
	// Workspace is the Terraform workspace.
	Workspace string `json:"workspace"`
	// Command is the command that was executed.
	Command string `json:"command"`
	// Status indicates whether the command succeeded or failed.
	Status string `json:"status"`
	// Output contains the command output (plan/apply output).
	Output string `json:"output,omitempty"`
	// Error contains any error message.
	Error string `json:"error,omitempty"`
	// Failure contains any failure message (different from error).
	Failure string `json:"failure,omitempty"`
	// Plan contains plan-specific details if this was a plan command.
	Plan *PlanDetailsAPI `json:"plan,omitempty"`
}

ProjectResultAPI is the API representation of a project command result. It exposes only the fields appropriate for API consumers.

func NewProjectResultAPI added in v0.45.0

func NewProjectResultAPI(pr command.ProjectResult) ProjectResultAPI

NewProjectResultAPI converts an internal ProjectResult to its API representation.

type RemediationListAPI added in v0.45.0

type RemediationListAPI struct {
	// Repository is the full repository name.
	Repository string `json:"repository"`
	// Count is the number of results returned.
	Count int `json:"count"`
	// Results contains the remediation results.
	Results []RemediationResultAPI `json:"results"`
}

RemediationListAPI is the API response for listing remediation results.

type RemediationProjectAPI added in v0.45.0

type RemediationProjectAPI struct {
	// ProjectName is the name of the project.
	ProjectName string `json:"project_name"`
	// Directory is the relative path to the project.
	Directory string `json:"directory"`
	// Workspace is the Terraform workspace.
	Workspace string `json:"workspace"`
	// Status is the remediation status for this project.
	Status string `json:"status"`
	// PlanOutput contains the plan output.
	PlanOutput string `json:"plan_output,omitempty"`
	// ApplyOutput contains the apply output.
	ApplyOutput string `json:"apply_output,omitempty"`
	// Error contains any error message.
	Error string `json:"error,omitempty"`
	// DriftBefore contains drift state before remediation.
	DriftBefore *DriftDetailsAPI `json:"drift_before,omitempty"`
	// DriftAfter contains drift state after remediation.
	DriftAfter *DriftDetailsAPI `json:"drift_after,omitempty"`
}

RemediationProjectAPI is the API representation of a project remediation result.

type RemediationResultAPI added in v0.45.0

type RemediationResultAPI struct {
	// ID is the unique identifier for this remediation.
	ID string `json:"id"`
	// Repository is the full repository name.
	Repository string `json:"repository"`
	// Ref is the git reference that was remediated.
	Ref string `json:"ref"`
	// Action is the remediation action performed.
	Action string `json:"action"`
	// Status is the overall remediation status.
	Status string `json:"status"`
	// StartedAt is when the remediation started.
	StartedAt time.Time `json:"started_at"`
	// CompletedAt is when the remediation completed.
	CompletedAt *time.Time `json:"completed_at,omitempty"`
	// Projects contains results for each project.
	Projects []RemediationProjectAPI `json:"projects"`
	// Summary provides aggregate statistics.
	Summary RemediationSummaryAPI `json:"summary"`
	// Error contains any top-level error.
	Error string `json:"error,omitempty"`
}

RemediationResultAPI is the API response for remediation.

func NewRemediationResultAPI added in v0.45.0

func NewRemediationResultAPI(rr *models.RemediationResult) RemediationResultAPI

NewRemediationResultAPI converts an internal RemediationResult to its API representation.

type RemediationSummaryAPI added in v0.45.0

type RemediationSummaryAPI struct {
	// TotalProjects is the total number of projects targeted.
	TotalProjects int `json:"total_projects"`
	// SuccessCount is the number of successful remediations.
	SuccessCount int `json:"success_count"`
	// FailureCount is the number of failed remediations.
	FailureCount int `json:"failure_count"`
}

RemediationSummaryAPI provides aggregate remediation statistics.

type StatusController

type StatusController struct {
	Logger          logging.SimpleLogging `validate:"required"`
	Drainer         *events.Drainer       `validate:"required"`
	AtlantisVersion string                `validate:"required"`
}

StatusController handles the status of Atlantis.

func (*StatusController) Get

Get is the GET /status route.

type StatusResponse

type StatusResponse struct {
	ShuttingDown    bool   `json:"shutting_down"`
	InProgressOps   int    `json:"in_progress_operations"`
	AtlantisVersion string `json:"version"`
}

type ValidationError added in v0.45.0

type ValidationError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

ValidationError represents field-level validation errors.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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