Documentation
¶
Overview ¶
apply.go wraps Helm install/upgrade hooks so torque can apply releases.
template.go renders Helm manifests and change summaries for torque apply plan/install operations.
Index ¶
- Constants
- func ClassifyServerDryRunError(err error, kind string) (class, reason, message string)
- func DescribeDeployAction(desc ActionDescriptor) string
- func DetectServerSideReplaceKeys(ctx context.Context, client *kube.Client, proposedManifest string, ...) (map[string]bool, error)
- func DigestNormalizedManifest(manifest string) (digest string, hasHooks bool, err error)
- func FetchLatestReleaseManifest(actionCfg *action.Configuration, releaseName string) (string, string)
- func FormatDigestMismatch(want, got string) string
- func FormatDriftReport(report DriftReport, maxItems int, maxDiffLines int) string
- func IsSuccessfulStatus(status string) bool
- func ReleaseHistoryBreadcrumbs(actionCfg *action.Configuration, releaseName string, limit int) ([]HistoryBreadcrumb, *HistoryBreadcrumb, error)
- func RunDriftCheck(ctx context.Context, actionCfg *action.Configuration, ...) error
- type ActionDescriptor
- type Blocker
- type BlockerSeverity
- type CaptureFileHash
- type DiffPayload
- type DriftItem
- type DriftLiveGetter
- type DriftOptions
- type DriftReport
- type HealthSnapshot
- type HistoryBreadcrumb
- func BreadcrumbFromRelease(rel *release.Release) (HistoryBreadcrumb, bool)
- func CloneBreadcrumbPointer(crumb *HistoryBreadcrumb) *HistoryBreadcrumb
- func CloneBreadcrumbs(history []HistoryBreadcrumb) []HistoryBreadcrumb
- func PrependBreadcrumb(history []HistoryBreadcrumb, crumb HistoryBreadcrumb, limit int) []HistoryBreadcrumb
- type InstallOptions
- type InstallResult
- type LogPayload
- type ManifestTarget
- type PhasePayload
- type PlanAction
- type PlanChange
- type PlanHooksSummary
- type PlanSummary
- type ProgressObserver
- type ResourceStatus
- type ResourceTracker
- type SecretOptions
- type SecretRef
- type ServerDryRunReport
- type ServerDryRunResource
- type ServerDryRunResult
- type ServerDryRunSummary
- type ServerPlanOptions
- type StatusUpdateFunc
- type StreamBroadcaster
- func (b *StreamBroadcaster) AddObserver(obs StreamObserver)
- func (b *StreamBroadcaster) EmitEvent(level, message string)
- func (b *StreamBroadcaster) EmitSummary(summary SummaryPayload)
- func (b *StreamBroadcaster) HasObservers() bool
- func (b *StreamBroadcaster) ObserveLog(record tailer.LogRecord)
- func (b *StreamBroadcaster) PhaseCompleted(name, status, message string)
- func (b *StreamBroadcaster) PhaseStarted(name string)
- func (b *StreamBroadcaster) SetDiff(diff string)
- func (b *StreamBroadcaster) UpdateResources(rows []ResourceStatus)
- func (b *StreamBroadcaster) WantsResourceSnapshots() bool
- type StreamEvent
- type StreamEventKind
- type StreamObserver
- type SummaryPayload
- type TemplateOptions
- type TemplateResult
Constants ¶
const ( PhaseRender = "render" PhaseDiff = "diff" PhaseUpgrade = "upgrade" PhaseInstall = "install" PhaseWait = "wait" PhasePostHooks = "post-hooks" )
Deploy phase identifiers shared by CLI, observers, and the web UI timeline.
const ( ServerDryRunStatusPassed = "passed" ServerDryRunStatusFailed = "failed" ServerDryRunStatusSkipped = "skipped" ServerDryRunClassAdmissionDenied = "admission_denied" ServerDryRunClassAPIMappingMissing = "api_mapping_missing" ServerDryRunClassAPIError = "api_error" ServerDryRunClassFieldOwnershipConflict = "field_ownership_conflict" ServerDryRunClassImmutableField = "immutable_field" ServerDryRunClassNamespaceMissing = "namespace_missing" ServerDryRunClassNone = "" )
Variables ¶
This section is empty.
Functions ¶
func ClassifyServerDryRunError ¶ added in v1.0.7
ClassifyServerDryRunError converts Kubernetes API errors into simulation-proof classes.
func DescribeDeployAction ¶
func DescribeDeployAction(desc ActionDescriptor) string
func DetectServerSideReplaceKeys ¶
func DetectServerSideReplaceKeys(ctx context.Context, client *kube.Client, proposedManifest string, opts ServerPlanOptions) (map[string]bool, error)
DetectServerSideReplaceKeys attempts a server-side apply dry-run for each object in the proposed manifest and returns keys that should be treated as "replace" due to immutable-field errors.
func DigestNormalizedManifest ¶
DigestNormalizedManifest computes a stable digest for a Helm manifest after applying the same normalization rules used by plan diffing (metadata/status stripping and deterministic list ordering).
The digest is order-insensitive across documents and is suitable for cheap "does the stored release manifest match what we expect?" checks.
func FetchLatestReleaseManifest ¶
func FetchLatestReleaseManifest(actionCfg *action.Configuration, releaseName string) (string, string)
func FormatDigestMismatch ¶
func FormatDriftReport ¶
func FormatDriftReport(report DriftReport, maxItems int, maxDiffLines int) string
func IsSuccessfulStatus ¶
func ReleaseHistoryBreadcrumbs ¶
func ReleaseHistoryBreadcrumbs(actionCfg *action.Configuration, releaseName string, limit int) ([]HistoryBreadcrumb, *HistoryBreadcrumb, error)
func RunDriftCheck ¶
func RunDriftCheck(ctx context.Context, actionCfg *action.Configuration, settings *cli.EnvSettings, kubeClient *kube.Client, mode string, releaseName string, installOpts InstallOptions) error
RunDriftCheck executes the drift detection logic based on the specified mode. It supports "last-applied" (comparing against the live cluster) and "desired" (comparing the live cluster against a fresh render of the chart).
Types ¶
type ActionDescriptor ¶
type Blocker ¶
type Blocker struct {
Kind string `json:"kind"`
Namespace string `json:"namespace"`
Name string `json:"name"`
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
Message string `json:"message,omitempty"`
Severity BlockerSeverity `json:"severity"`
}
func TopBlockers ¶
func TopBlockers(rows []ResourceStatus, limit int) []Blocker
type BlockerSeverity ¶
type BlockerSeverity string
const ( BlockerFail BlockerSeverity = "fail" BlockerWarn BlockerSeverity = "warn" )
type CaptureFileHash ¶
type CaptureFileHash struct {
Path string `json:"path"`
SHA256 string `json:"sha256"`
Size int64 `json:"size"`
Error string `json:"error,omitempty"`
}
func HashFiles ¶
func HashFiles(paths []string) []CaptureFileHash
type DiffPayload ¶
DiffPayload describes a rendered diff, if requested.
type DriftLiveGetter ¶
type DriftLiveGetter func(ctx context.Context, target resourceTarget) (*unstructured.Unstructured, error)
func DriftLiveGetterFromKube ¶
func DriftLiveGetterFromKube(client *kube.Client) DriftLiveGetter
type DriftOptions ¶
type DriftReport ¶
type DriftReport struct {
Items []DriftItem
}
func CheckReleaseDrift ¶
func CheckReleaseDrift(ctx context.Context, releaseName string, manifest string, get DriftLiveGetter) (DriftReport, error)
func CheckReleaseDriftWithOptions ¶
func CheckReleaseDriftWithOptions(ctx context.Context, releaseName string, manifest string, get DriftLiveGetter, opts DriftOptions) (DriftReport, error)
func (DriftReport) Empty ¶
func (r DriftReport) Empty() bool
type HealthSnapshot ¶
type HealthSnapshot struct {
Ready int `json:"ready"`
Progressing int `json:"progressing"`
Failed int `json:"failed"`
Pending int `json:"pending"`
Total int `json:"total"`
LastUpdated string `json:"lastUpdated"`
}
HealthSnapshot aggregates readiness stats for the release.
type HistoryBreadcrumb ¶
type HistoryBreadcrumb struct {
Revision int `json:"revision"`
Status string `json:"status"`
Chart string `json:"chart,omitempty"`
Version string `json:"version,omitempty"`
AppVersion string `json:"appVersion,omitempty"`
Description string `json:"description,omitempty"`
DeployedAt string `json:"deployedAt,omitempty"`
}
HistoryBreadcrumb captures a prior Helm revision so UIs can show run breadcrumbs.
func BreadcrumbFromRelease ¶
func BreadcrumbFromRelease(rel *release.Release) (HistoryBreadcrumb, bool)
func CloneBreadcrumbPointer ¶
func CloneBreadcrumbPointer(crumb *HistoryBreadcrumb) *HistoryBreadcrumb
func CloneBreadcrumbs ¶
func CloneBreadcrumbs(history []HistoryBreadcrumb) []HistoryBreadcrumb
func PrependBreadcrumb ¶
func PrependBreadcrumb(history []HistoryBreadcrumb, crumb HistoryBreadcrumb, limit int) []HistoryBreadcrumb
type InstallOptions ¶
type InstallOptions struct {
Chart string
Version string
ReleaseName string
Namespace string
ValuesFiles []string
SetValues []string
SetStringValues []string
SetFileValues []string
Secrets *SecretOptions
Timeout time.Duration
Wait bool
Atomic bool
CreateNamespace bool
DryRun bool
Diff bool
UpgradeOnly bool
ProgressObservers []ProgressObserver
}
InstallOptions capture user-facing helm install/upgrade settings.
type InstallResult ¶
type InstallResult struct {
Release *release.Release
ManifestDiff string
PlanSummary *PlanSummary
PlanSummarizeError string
}
func GeneratePlanPreview ¶
func GeneratePlanPreview(ctx context.Context, actionCfg *action.Configuration, settings *cli.EnvSettings, kubeClient *kube.Client, opts InstallOptions, planServer bool) (*InstallResult, error)
GeneratePlanPreview renders the chart in dry-run mode to produce a plan summary. If planServer is true, it also performs server-side checks to detect replacements.
func InstallOrUpgrade ¶
func InstallOrUpgrade(ctx context.Context, actionCfg *action.Configuration, settings *cli.EnvSettings, opts InstallOptions) (*InstallResult, error)
InstallOrUpgrade renders the chart and applies it using Helm's upgrade --install semantics.
type LogPayload ¶
type LogPayload struct {
Level string `json:"level"`
Message string `json:"message"`
Source string `json:"source,omitempty"`
Namespace string `json:"namespace,omitempty"`
Pod string `json:"pod,omitempty"`
Container string `json:"container,omitempty"`
}
LogPayload reflects an emitted log/event message.
type ManifestTarget ¶
type ManifestTarget struct {
Group string
Version string
Kind string
Namespace string
Name string
Labels map[string]string
}
ManifestTarget is an object reference extracted from a rendered manifest. It is intentionally lightweight (GVK + namespace + name + labels).
func ManifestTargets ¶
func ManifestTargets(manifest string) []ManifestTarget
ManifestTargets extracts object targets from a rendered manifest.
type PhasePayload ¶
type PhasePayload struct {
Name string `json:"name"`
State string `json:"state"`
Status string `json:"status"`
Message string `json:"message,omitempty"`
StartedAt string `json:"startedAt,omitempty"`
CompletedAt string `json:"completedAt,omitempty"`
// contains filtered or unexported fields
}
PhasePayload captures timeline updates for Helm phases.
type PlanAction ¶
type PlanAction string
const ( PlanAdd PlanAction = "add" PlanUpdate PlanAction = "change" PlanReplace PlanAction = "replace" PlanDestroy PlanAction = "destroy" )
type PlanChange ¶
type PlanChange struct {
Action PlanAction
Group string
Version string
Kind string
Namespace string
Name string
IsHook bool
Hook string
}
func ListManifestResources ¶
func ListManifestResources(manifest string) ([]PlanChange, error)
func ListManifestResourcesWithHelmKube ¶
func ListManifestResourcesWithHelmKube(client *kube.Client, manifest string) ([]PlanChange, error)
type PlanHooksSummary ¶
type PlanHooksSummary struct {
Add int
Change int
Replace int
Destroy int
Changes []PlanChange
}
type PlanSummary ¶
type PlanSummary struct {
Add int
Change int
Replace int
Destroy int
Hooks PlanHooksSummary
Changes []PlanChange
}
func SummarizeManifestPlan ¶
func SummarizeManifestPlan(previousManifest, proposedManifest string) (*PlanSummary, error)
func SummarizeManifestPlanWithHelmKube ¶
func SummarizeManifestPlanWithHelmKube(client *kube.Client, previousManifest, proposedManifest string) (*PlanSummary, error)
type ProgressObserver ¶
type ProgressObserver interface {
PhaseStarted(name string)
PhaseCompleted(name, status, message string)
EmitEvent(level, message string)
SetDiff(diff string)
}
ProgressObserver receives instrumentation callbacks during Helm install/upgrade.
type ResourceStatus ¶
type ResourceStatus struct {
Kind string `json:"kind"`
Namespace string `json:"namespace"`
Name string `json:"name"`
Action string `json:"action"`
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
Message string `json:"message"`
}
ResourceStatus captures the readiness state of a Kubernetes object managed by a release.
type ResourceTracker ¶
type ResourceTracker struct {
// contains filtered or unexported fields
}
ResourceTracker periodically lists release resources and reports their status.
func NewResourceTracker ¶
func NewResourceTracker(client *kube.Client, namespace, release, manifest string, update StatusUpdateFunc) *ResourceTracker
NewResourceTracker constructs a tracker for the given release.
func (*ResourceTracker) Run ¶
func (t *ResourceTracker) Run(ctx context.Context)
Run starts the tracker loop until the context is canceled.
func (*ResourceTracker) Snapshot ¶
func (t *ResourceTracker) Snapshot(ctx context.Context) []ResourceStatus
Snapshot returns a point-in-time status listing without starting the tracker loop.
func (*ResourceTracker) WithInterval ¶
func (t *ResourceTracker) WithInterval(interval time.Duration) *ResourceTracker
WithInterval overrides the polling interval.
type SecretOptions ¶
type SecretOptions struct {
Resolver *secretstore.Resolver
AuditSink func(secretstore.AuditReport)
Validate bool
}
SecretOptions configures deploy-time secret resolution.
type SecretRef ¶
type SecretRef struct {
Provider string `json:"provider"`
Path string `json:"path,omitempty"`
Reference string `json:"reference,omitempty"`
Masked bool `json:"masked,omitempty"`
}
SecretRef represents a resolved secret reference for reporting/UI purposes.
type ServerDryRunReport ¶ added in v1.0.7
type ServerDryRunReport struct {
Version string `json:"version"`
FieldManager string `json:"fieldManager"`
Force bool `json:"force"`
Summary ServerDryRunSummary `json:"summary"`
Results []ServerDryRunResult `json:"results,omitempty"`
}
ServerDryRunReport records Kubernetes server-side dry-run behavior for a proposed manifest.
func RunServerDryRunReport ¶ added in v1.0.7
func RunServerDryRunReport(ctx context.Context, client *kube.Client, proposedManifest string, opts ServerPlanOptions) (*ServerDryRunReport, error)
RunServerDryRunReport attempts a server-side apply dry-run for each object in the manifest.
type ServerDryRunResource ¶ added in v1.0.7
type ServerDryRunResult ¶ added in v1.0.7
type ServerDryRunResult struct {
Resource ServerDryRunResource `json:"resource"`
Operation string `json:"operation"`
Status string `json:"status"`
ErrorClass string `json:"errorClass,omitempty"`
Reason string `json:"reason,omitempty"`
Message string `json:"message,omitempty"`
Hook string `json:"hook,omitempty"`
DryRun bool `json:"dryRun"`
}
type ServerDryRunSummary ¶ added in v1.0.7
type ServerDryRunSummary struct {
Total int `json:"total"`
Passed int `json:"passed"`
Failed int `json:"failed"`
Skipped int `json:"skipped"`
AdmissionDenied int `json:"admissionDenied"`
FieldOwnershipConflicts int `json:"fieldOwnershipConflicts"`
ImmutableFields int `json:"immutableFields"`
NamespaceMissing int `json:"namespaceMissing"`
APIMapperMissing int `json:"apiMapperMissing"`
}
type ServerPlanOptions ¶
type StatusUpdateFunc ¶
type StatusUpdateFunc func([]ResourceStatus)
StatusUpdateFunc consumes resource status snapshots.
type StreamBroadcaster ¶
type StreamBroadcaster struct {
// contains filtered or unexported fields
}
StreamBroadcaster fan-outs deploy telemetry to zero or more observers.
func NewStreamBroadcaster ¶
func NewStreamBroadcaster(release, namespace, chart string) *StreamBroadcaster
NewStreamBroadcaster constructs a deploy stream broadcaster for the given release.
func (*StreamBroadcaster) AddObserver ¶
func (b *StreamBroadcaster) AddObserver(obs StreamObserver)
AddObserver registers a sink for webcast events.
func (*StreamBroadcaster) EmitEvent ¶
func (b *StreamBroadcaster) EmitEvent(level, message string)
EmitEvent records an informational/warning/error line.
func (*StreamBroadcaster) EmitSummary ¶
func (b *StreamBroadcaster) EmitSummary(summary SummaryPayload)
EmitSummary publishes the final release outcome.
func (*StreamBroadcaster) HasObservers ¶
func (b *StreamBroadcaster) HasObservers() bool
HasObservers reports whether anything is listening to the stream.
func (*StreamBroadcaster) ObserveLog ¶
func (b *StreamBroadcaster) ObserveLog(record tailer.LogRecord)
ObserveLog satisfies tailer.LogObserver so Kubernetes events/logs can join the webcast feed.
func (*StreamBroadcaster) PhaseCompleted ¶
func (b *StreamBroadcaster) PhaseCompleted(name, status, message string)
PhaseCompleted marks a phase as completed with an explicit status (succeeded, failed, skipped).
func (*StreamBroadcaster) PhaseStarted ¶
func (b *StreamBroadcaster) PhaseStarted(name string)
PhaseStarted marks a phase as running.
func (*StreamBroadcaster) SetDiff ¶
func (b *StreamBroadcaster) SetDiff(diff string)
SetDiff shares the rendered diff (if any).
func (*StreamBroadcaster) UpdateResources ¶
func (b *StreamBroadcaster) UpdateResources(rows []ResourceStatus)
UpdateResources pushes a fresh snapshot of release resource readiness.
func (*StreamBroadcaster) WantsResourceSnapshots ¶
func (b *StreamBroadcaster) WantsResourceSnapshots() bool
WantsResourceSnapshots indicates whether the streamer needs live resource status.
type StreamEvent ¶
type StreamEvent struct {
Kind StreamEventKind `json:"kind"`
Timestamp string `json:"ts"`
Phase *PhasePayload `json:"phase,omitempty"`
Log *LogPayload `json:"log,omitempty"`
Resources []ResourceStatus `json:"resources,omitempty"`
Diff *DiffPayload `json:"diff,omitempty"`
Summary *SummaryPayload `json:"summary,omitempty"`
Health *HealthSnapshot `json:"health,omitempty"`
}
StreamEvent is the envelope shared over the deploy webcast WebSocket.
type StreamEventKind ¶
type StreamEventKind string
StreamEventKind enumerates the payload types used by the deploy webcast.
const ( StreamEventPhase StreamEventKind = "phase" StreamEventLog StreamEventKind = "event" StreamEventResources StreamEventKind = "resources" StreamEventDiff StreamEventKind = "diff" StreamEventSummary StreamEventKind = "summary" StreamEventHealth StreamEventKind = "health" )
type StreamObserver ¶
type StreamObserver interface {
HandleDeployEvent(StreamEvent)
}
StreamObserver consumes deploy webcast events.
type SummaryPayload ¶
type SummaryPayload struct {
Release string `json:"release"`
Namespace string `json:"namespace"`
Status string `json:"status"`
Chart string `json:"chart,omitempty"`
Version string `json:"version,omitempty"`
Action string `json:"action,omitempty"`
Notes string `json:"notes,omitempty"`
Error string `json:"error,omitempty"`
Duration string `json:"duration,omitempty"`
PhaseDurations map[string]string `json:"phaseDurations,omitempty"`
History []HistoryBreadcrumb `json:"history,omitempty"`
LastSuccessful *HistoryBreadcrumb `json:"lastSuccessful,omitempty"`
Secrets []SecretRef `json:"secrets,omitempty"`
}
SummaryPayload surfaces the final release outcome.
type TemplateOptions ¶
type TemplateOptions struct {
Chart string
Version string
RepoURL string
ReleaseName string
Namespace string
ValuesFiles []string
SetValues []string
SetStringValues []string
SetFileValues []string
Secrets *SecretOptions
IncludeCRDs bool
// UseCluster toggles between "client-only" rendering (fast, offline) and cluster-aware
// rendering (uses discovery to match actual API versions/capabilities).
UseCluster bool
}
TemplateOptions controls rendering behavior for helm template equivalents.
type TemplateResult ¶
type TemplateResult struct {
Manifest string
Notes string
ChartVersion string
Templates map[string]string
}
TemplateResult holds rendered manifests and optional notes.
func RenderTemplate ¶
func RenderTemplate(ctx context.Context, actionCfg *action.Configuration, settings *cli.EnvSettings, opts TemplateOptions) (*TemplateResult, error)
RenderTemplate renders the provided chart without applying it to the cluster.
Source Files
¶
- apply.go
- blockers.go
- drift.go
- drift_format.go
- drift_kube.go
- drift_orchestrator.go
- helpers.go
- manifest_digest.go
- manifest_normalize.go
- manifest_plan.go
- manifest_plan_helm.go
- manifest_targets.go
- plan_preview.go
- plan_server.go
- progress.go
- secrets.go
- server_dryrun_report.go
- status.go
- status_tracker.go
- stream.go
- template.go