mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-07 15:41:41 +00:00
21aeed4f4e
Phase 0 closure (Path B2, post-rewrite):
addlicense sweep — adds the canonical certctl LLC copyright + BUSL-1.1
SPDX header to every production Go file. Template:
// Copyright 2026 certctl LLC. All rights reserved.
// SPDX-License-Identifier: BUSL-1.1
Coverage: 338 / 338 production Go files (cmd/ + internal/, excluding
*_test.go and **/testdata/**). Pre-sweep coverage was 22 / 338 (6.5%);
post-sweep is 338 / 338 (100%).
Normalized 22 pre-existing legacy headers (`// Copyright (c) certctl`
+ `// SPDX-License-Identifier: BSL-1.1`) and 1 file using a
`Certctl Contributors` attribution. The legacy SPDX ID `BSL-1.1`
is non-standard; the official SPDX identifier for Business Source
License 1.1 is `BUSL-1.1` (capital U). All 338 files now share the
canonical form.
Generated via:
addlicense -c "certctl LLC" -y 2026 \
-f cowork/legal/copyright-header.tpl \
-ignore '**/testdata/**' -ignore '**/*_test.go' \
cmd/ internal/
Verification:
find cmd internal -name '*.go' -not -name '*_test.go' \
-not -path '*/testdata/*' \
-exec grep -L '^// Copyright 2026 certctl LLC' {} \; | wc -l
Returns: 0
gofmt clean. Header additions are comments only, no compile impact.
Closes: cowork/certctl-architecture-diligence-audit.html#fix-RED-4
75 lines
2.9 KiB
Go
75 lines
2.9 KiB
Go
// Copyright 2026 certctl LLC. All rights reserved.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
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"`
|
|
AgentID *string `json:"agent_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"`
|
|
VerificationStatus VerificationStatus `json:"verification_status"`
|
|
VerifiedAt *time.Time `json:"verified_at,omitempty"`
|
|
VerificationError *string `json:"verification_error,omitempty"`
|
|
VerificationFp *string `json:"verification_fingerprint,omitempty"`
|
|
}
|
|
|
|
// 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"`
|
|
}
|