mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-07 18:01:37 +00:00
b0549e6f05
Ownership: owners/teams GUI pages, notification email resolution via resolveRecipient (owner_id → owner.email lookup). Agent groups: dynamic device grouping by OS/arch/IP CIDR/version with manual include/exclude membership, migration 000004, full CRUD stack (domain → repo → service → handler → frontend). Interactive approval: AwaitingApproval job state, approve/reject API endpoints with reason tracking. Tests: 12 agent group handler tests, 8 approve/reject job handler tests, integration tests updated for 13-param RegisterHandlers. Docs updated across architecture, concepts, and seed data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
67 lines
2.3 KiB
Go
67 lines
2.3 KiB
Go
package domain
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
// Job represents a unit of work in the certificate control plane.
|
|
type Job struct {
|
|
ID string `json:"id"`
|
|
Type JobType `json:"type"`
|
|
CertificateID string `json:"certificate_id"`
|
|
TargetID *string `json:"target_id,omitempty"`
|
|
Status JobStatus `json:"status"`
|
|
Attempts int `json:"attempts"`
|
|
MaxAttempts int `json:"max_attempts"`
|
|
LastError *string `json:"last_error,omitempty"`
|
|
ScheduledAt time.Time `json:"scheduled_at"`
|
|
StartedAt *time.Time `json:"started_at,omitempty"`
|
|
CompletedAt *time.Time `json:"completed_at,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// JobType represents the classification of work to be performed.
|
|
type JobType string
|
|
|
|
const (
|
|
JobTypeIssuance JobType = "Issuance"
|
|
JobTypeRenewal JobType = "Renewal"
|
|
JobTypeDeployment JobType = "Deployment"
|
|
JobTypeValidation JobType = "Validation"
|
|
)
|
|
|
|
// JobStatus represents the execution state of a job.
|
|
type JobStatus string
|
|
|
|
const (
|
|
JobStatusPending JobStatus = "Pending"
|
|
JobStatusAwaitingCSR JobStatus = "AwaitingCSR"
|
|
JobStatusAwaitingApproval JobStatus = "AwaitingApproval"
|
|
JobStatusRunning JobStatus = "Running"
|
|
JobStatusCompleted JobStatus = "Completed"
|
|
JobStatusFailed JobStatus = "Failed"
|
|
JobStatusCancelled JobStatus = "Cancelled"
|
|
)
|
|
|
|
// DeploymentJob represents a job that deploys a certificate to a target via an agent.
|
|
type DeploymentJob struct {
|
|
Job `json:"job"`
|
|
AgentID string `json:"agent_id"`
|
|
DeploymentResult json.RawMessage `json:"deployment_result,omitempty"`
|
|
}
|
|
|
|
// WorkItem enriches a Job with target details so the agent knows which connector to use.
|
|
// Returned by GET /api/v1/agents/{id}/work.
|
|
type WorkItem struct {
|
|
ID string `json:"id"`
|
|
Type JobType `json:"type"`
|
|
CertificateID string `json:"certificate_id"`
|
|
CommonName string `json:"common_name,omitempty"`
|
|
SANs []string `json:"sans,omitempty"`
|
|
TargetID *string `json:"target_id,omitempty"`
|
|
TargetType string `json:"target_type,omitempty"`
|
|
TargetConfig json.RawMessage `json:"target_config,omitempty"`
|
|
Status JobStatus `json:"status"`
|
|
}
|