plan

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SourceAuthSCRAM  = "scram"
	SourceAuthIAM    = "iam"
	SourceAuthMTLS   = "mtls"
	SourceAuthUnauth = "unauth"
	// SourceAuthSASLPlain is SASL/PLAIN, an OSK/CP-only source auth (MSK's SASL is
	// SCRAM). It maps to the engine's "API keys (SASL/PLAIN)" source-auth string.
	SourceAuthSASLPlain = "sasl-plain"
	// SourceAuthKerberos is Kerberos (GSSAPI), an OSK/CP-only source auth. It is an
	// ACL-bearing method like SCRAM, mTLS and SASL/PLAIN.
	SourceAuthKerberos = "kerberos"
)

Source-auth tokens. Stable strings — the profile builder (engine_adapter.go) and the plan renderer map on them to describe how the source authenticates. Keep them in sync with the source-auth answer vocabulary.

View Source
const (
	DiscoveredClientAuthIAM             = "IAM"
	DiscoveredClientAuthSASLSCRAM       = "SASL_SCRAM"
	DiscoveredClientAuthTLS             = "TLS"
	DiscoveredClientAuthUnauthenticated = "UNAUTHENTICATED"
	DiscoveredClientAuthUnknown         = "UNKNOWN"
)

DiscoveredClientAuth* mirrors the literal strings that `kcp scan client-inventory` writes into `DiscoveredClient.Auth` (see `cmd/scan/client_inventory/kafka_trace_line_parser.go`).

**Heads-up:** `types.AuthTypeIAM` in `internal/types/types.go` resolves to `"SASL/IAM"` — a DIFFERENT string used elsewhere. Use these constants when comparing against the persisted client inventory, not the `types.AuthType*` constants.

View Source
const (
	StateReady           = "ready"            // no open required questions, not withheld
	StateNeedsAnswers    = "needs_answers"    // has open required questions
	StateNeedsSpecialist = "needs_specialist" // routed to a specialist (withheld)
)

Canonical plan-state vocabulary, shared by plan.md (display labels) and plan.json (machine codes) so the two can never drift. A plan half or a whole cluster is in exactly one of these states.

View Source
const ScanlessClusterName = "your-cluster"

ScanlessClusterName is the key of the single synthetic cluster used when the planner runs with no scan file. It becomes the cluster's heading and its key in plan-inputs.yaml.

Variables

This section is empty.

Functions

func FilterState added in v0.11.0

func FilterState(state report.ProcessedState, clusterID, region string) (report.ProcessedState, int)

FilterState returns a processed state keeping only clusters that match the given cluster id (name or ARN) and/or region. An empty filter value matches everything: with both empty the original state is returned unchanged; otherwise a new state is built with fresh Sources/Regions/Clusters slices (the cluster values, and the data they point at, are shared with the original — this is a structural prune, not a deep copy). Regions and sources that end up empty are dropped. The second return is the number of clusters that matched.

func RenderEnginePlanJSON added in v0.11.0

func RenderEnginePlanJSON(ep *EnginePlan) (string, error)

RenderEnginePlanJSON marshals the engine plan with stable, indented JSON.

func RenderEnginePlanMarkdown added in v0.11.0

func RenderEnginePlanMarkdown(ep *EnginePlan) string

RenderEnginePlanMarkdown renders the engine-driven plan as Markdown. A withheld cluster shows only why it needs a specialist (no automated recommendation, in plan.md or plan.json); every other cluster shows the full recommendation set. The "Talk to a person" section renders once at the end.

func RenderPlanInputsYAML added in v0.11.0

func RenderPlanInputsYAML(ep *EnginePlan) string

RenderPlanInputsYAML generates a round-trip plan-inputs.yaml. A single-cluster fleet renders flat: one section under `clusters:` carrying every question with its full wording inline. A multi-cluster fleet uses progressive disclosure — fleet-wide decisions live in a `all_clusters:` block (answered once, full wording), per-cluster questions are documented once in a reference catalog, and each cluster's section is terse: `key: token # [tok | tok | …]` one-liners. Re-running after answering may reveal follow-ups.

func ScanlessState added in v0.11.0

func ScanlessState() report.ProcessedState

ScanlessState returns a processed state with one placeholder cluster and no scanned data, so the planner can run as a pure questionnaire without a state file: every fact the scan would normally derive is absent, so it surfaces as a question in plan-inputs.yaml for the customer to fill in. The cluster carries zero-value AWS/Kafka client info (nil slices), which the profile builder reads as "not scanned" for every signal.

func ValidateDeclaredClusters added in v0.11.0

func ValidateDeclaredClusters(declared DeclaredInputs, state report.ProcessedState, scanless bool) []string

ValidateDeclaredClusters returns one message per declared cluster key that matches no cluster in the scan (a misspelled cluster name), listing the valid names. Answers under such a key never reach any plan, so the caller treats these as fatal input errors. It is validated against the full scan so an active --cluster-id/--region filter can't make an out-of-scope but correctly spelled key look like a typo. With no scan (scanless) the only cluster is the synthetic questionnaire one, so any other key would be silently dropped; it is reported the same way, with the scanless explanation.

func ValidateDeclaredSources added in v0.11.0

func ValidateDeclaredSources(declared DeclaredInputs, state report.ProcessedState, scanless bool) []string

ValidateDeclaredSources returns one message per cluster for two mistakes a hand-written plan-inputs.yaml can make about a cluster's source:

  1. A declared option offered only for some sources (an opt with a non-nil Applies, e.g. source_auth: iam, offered only for Amazon MSK) declared on a cluster whose resolved source doesn't offer it.
  2. A declared source_platform that contradicts what the scan detected (an MSK scan declared apache-kafka/confluent-platform, or an OSK scan declared msk). A declared confluent-platform on an OSK scan is NOT a contradiction: an OSK scan can't tell Confluent Platform apart from Apache Kafka, so the declaration is a refinement, not a conflict.

The source resolves the same way buildProfile resolves it (the cluster's own source_platform, else all_clusters.source_platform, else the scan), except a scanless run with nothing declared leaves it genuinely unknown, and (1) is skipped for that cluster rather than checked against an assumed source.

Types

type AppPlan added in v0.11.0

type AppPlan struct {
	Name            string              `json:"name"`
	Questions       []ResolvedQuestion  `json:"questions"`
	Plan            engine.PlanResult   `json:"plan"`
	Contingent      map[string][]string `json:"contingent,omitempty"` // verdict → open required questions that would change it
	ConnectorSource *ConnectorSource    `json:"connector_source,omitempty"`
}

AppPlan is one declared application's migration plan: the app-scoped answers plus a full engine verdict set. Its infra verdicts (cluster type / networking / auth) match the enclosing ClusterPlan by construction; only the app verdicts (switchover, schema, connectors, topics, historical) differ.

func (AppPlan) MarshalJSON added in v0.11.0

func (ap AppPlan) MarshalJSON() ([]byte, error)

MarshalJSON keeps plan.json's `contingent` keyed by display labels (the existing JSON contract) even though the in-memory map is keyed by node IDs, and stamps `pending: true` on this application's still-held verdicts (see ClusterPlan.MarshalJSON).

type ClusterPlan added in v0.11.0

type ClusterPlan struct {
	ClusterID string `json:"cluster_id"`
	Arn       string `json:"arn,omitempty"`
	Key       string `json:"key"` // plan-inputs.yaml key: name, or name@region on collision
	Region    string `json:"region"`
	// SourcePlatform names a non-MSK source's platform ("Apache Kafka" | "Confluent
	// Platform") for the cluster header. Empty (omitted) for an MSK source, so MSK
	// plan.json is byte-for-byte unchanged; the header then falls back to its MSK copy.
	SourcePlatform  string              `json:"source_platform,omitempty"`
	MigrationInfra  MigrationInfra      `json:"migration_infra"`
	IsServerless    bool                `json:"is_serverless"`
	TopicCount      int                 `json:"topic_count"`
	BrokerCount     int                 `json:"broker_count"`
	SourceAuths     []string            `json:"source_auths"`
	ScanFacts       []Fact              `json:"scan_facts,omitempty"`
	Questions       []ResolvedQuestion  `json:"questions"`
	Observations    []Observation       `json:"observations,omitempty"`
	Plan            engine.PlanResult   `json:"plan"`
	State           string              `json:"state"`       // canonical whole-cluster state (StateReady|StateNeedsAnswers|StateNeedsSpecialist)
	InfraState      string              `json:"infra_state"` // state of the infrastructure half (matches the plan.md summary column)
	AppState        string              `json:"app_state"`   // state of the application half
	PartitionCount  int                 `json:"partition_count"`
	Contingent      map[string][]string `json:"contingent,omitempty"`    // verdict → open required questions that would change it
	SchemaSource    *SchemaSourceRef    `json:"schema_source,omitempty"` // scan-derived source Schema Registry, for the migrate-schemas command
	ConnectorSource *ConnectorSource    `json:"connector_source,omitempty"`
	Apps            []AppPlan           `json:"apps,omitempty"`
	// contains filtered or unexported fields
}

ClusterPlan is one scanned cluster's plan: the source summary, the shared infra verdicts, and one migration plan per application. With no declared apps the single implicit app is the cluster's own Plan (Apps is empty).

func (ClusterPlan) MarshalJSON added in v0.11.0

func (cp ClusterPlan) MarshalJSON() ([]byte, error)

MarshalJSON keeps plan.json's `contingent` keyed by display labels (the existing JSON contract) even though the in-memory map is keyed by node IDs, and stamps `pending: true` (blanking the concrete value) on every verdict still held on an unanswered question, so plan.json represents "pending" uniformly — the same gate plan.md reads off the contingent map — instead of leaking a provisional recommendation. a is a marshaling copy, so the source ClusterPlan is untouched.

type ConnectorSource added in v0.11.0

type ConnectorSource struct {
	MSKConnect  bool `json:"msk_connect,omitempty"`
	SelfManaged bool `json:"self_managed,omitempty"`
}

ConnectorSource records which source connector runtimes this plan runs, so the migrate-connectors step can pick the right subcommand(s): MSK Connect -> `msk`, self-managed Kafka Connect -> `self-managed`. A plan can run both. Nil when the plan runs no connectors (nothing to migrate).

type DeclaredCluster added in v0.11.0

type DeclaredCluster struct {
	Inputs IntakeInputs
	Apps   map[string]IntakeInputs // nil when no `applications:` block is declared
}

DeclaredCluster holds one cluster's declared answers: its own cluster-level inputs plus optional per-application overrides (keyed by app name). The cluster level doubles as the default for its apps.

type DeclaredInputs added in v0.11.0

type DeclaredInputs struct {
	Defaults IntakeInputs
	Clusters map[string]DeclaredCluster
}

DeclaredInputs is the parsed plan-inputs.yaml: fleet-wide `all_clusters:` plus per-cluster answers under a `clusters:` map (keyed by cluster display key — bare name, or name@region on a name collision). Answers layer app → cluster → defaults, each level optional.

func LoadDeclaredInputs added in v0.11.0

func LoadDeclaredInputs(path string) (DeclaredInputs, []string, error)

LoadDeclaredInputs reads a per-cluster, token-based plan-inputs.yaml and resolves each cluster's answers to IntakeInputs (engine strings), validating each value against its option vocabulary. Unknown values are reported as warnings and skipped. An empty path returns no inputs.

func ParseDeclaredInputs added in v0.11.0

func ParseDeclaredInputs(data []byte) (DeclaredInputs, []string, error)

ParseDeclaredInputs resolves a plan-inputs.yaml byte slice into DeclaredInputs (the same logic LoadDeclaredInputs runs on a file). Empty input returns no inputs. For library callers that hold the YAML in memory rather than on disk.

func (DeclaredInputs) AppNames added in v0.11.0

func (d DeclaredInputs) AppNames(key string) []string

AppNames returns the declared application names for a cluster, in sorted order (empty when the cluster declares no apps).

func (DeclaredInputs) For added in v0.11.0

func (d DeclaredInputs) For(key string) IntakeInputs

For returns the effective cluster-level inputs for a cluster key: defaults with the cluster's own answers layered on top.

func (DeclaredInputs) ForApp added in v0.11.0

func (d DeclaredInputs) ForApp(key, app string) IntakeInputs

ForApp returns the effective inputs for one application: defaults, then the cluster, then the app's own answers layered on top.

type EnginePlan added in v0.11.0

type EnginePlan struct {
	Header       PlanHeader    `json:"header"`
	Summary      PlanSummary   `json:"summary"`
	Clusters     []ClusterPlan `json:"clusters"`
	TotalRegions int           `json:"total_regions"`
	Warnings     []string      `json:"warnings,omitempty"`
}

EnginePlan is the fleet output: a header plus one ClusterPlan per scanned cluster. Questions are per-cluster (kcp models one plan per cluster).

func BuildEnginePlan added in v0.11.0

func BuildEnginePlan(state report.ProcessedState, declared DeclaredInputs, stateFilePath string, now func() time.Time) *EnginePlan

BuildEnginePlan produces the engine-driven plan from processed state and the customer-declared inputs. Each cluster is mapped through buildProfile and run through engine.ComputePlan. Inputs are layered: fleet-wide `all_clusters:` are overlaid with each cluster's own answers (declared.For(key)).

type Fact added in v0.11.0

type Fact struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Fact is a scan-derived answer shown for reference (not a question).

type IntakeInputs added in v0.11.0

type IntakeInputs struct {
	// Source platform + cloud. SourcePlatform is an engine platform string ("Amazon
	// MSK" | "Apache Kafka" | "Confluent Platform"); empty means MSK. SourceCloud is
	// the source's cloud, declared only for a non-MSK source (MSK is AWS).
	SourcePlatform string
	SourceCloud    string

	// Networking requirement — the public/private fork. "Yes" = public is fine.
	PublicEndpointsOK string
	ConnectsToday     string

	// Human assist.
	UseCaseBreadth string

	// Data movement.
	NeedsDataMigration       string
	AnyAppNeedsDataMigration string
	CCEgressRequired         string

	// Switchover.
	DowntimeTolerance        string
	ClientCoordinationBurden string
	EosStreams               []string

	// Adaptive ceiling declarations (default "No").
	ExceedsStandardLimits   string
	ExceedsEnterpriseLimits string

	// Target overrides.
	TargetCloud         string
	TargetIdentityModel []string

	// Schema.
	SchemaStrategy                string
	SourceSRType                  string
	SourceSROutboundReachableToCC string

	// Topics / historical / connectors.
	ConsumerHistoryRequirement string
	ConnectorDestination       string

	// Scan-fact overrides (optional; blank/empty = use the scanned value). These
	// let a customer correct or supply a fact the scan got wrong or missed. Values
	// are engine strings, resolved from tokens by the scan question catalog.
	OvClusterType   string
	OvKafkaVersion  string
	OvSourceAuth    []string
	OvTiered        string // "Yes" | "No"
	OvMSKConnect    string // "Yes" | "No"
	OvSelfManaged   string // "Yes" | "No"
	OvTopicSettings string // "Yes" | "No" — override the scan-derived custom-topic-settings flag
	// Sizing/mechanism facts that the scan usually supplies but a customer answers
	// when it can't: a partition band (when the scan has no exact count) and the
	// inter-broker protocol relative to the 2.8 Cluster Linking floor.
	OvPartitionBand       string
	OvInterBrokerProtocol string // "Yes" (IBP >= 2.8) | "No" (below 2.8)
}

IntakeInputs are the customer-declared facts the scan cannot derive — the required intake answers that become plan-inputs.yaml fields / Open Questions in kcp. Everything else on engine.Profile is filled from scanned state (see buildProfile).

Field values use the engine's own vocabulary strings (e.g. downtime_tolerance is a styleMap key). Empty means "not declared"; the engine applies its own default, and the plan layer raises an Open Question where the value is required with no safe default. The struct is never (un)marshalled directly — plan-inputs.yaml is parsed through the token catalog (see resolveDeclared), which populates these fields via each question's set func — so it carries no struct tags.

type MigrationInfra added in v0.11.0

type MigrationInfra struct {
	// Kind is the machine discriminator, since Type 0 covers several outcomes:
	// "cluster_link" (Type 1-5), "replicator", "start_fresh", or "specialist".
	Kind            string `json:"kind"`
	Pending         bool   `json:"pending,omitempty"` // set at JSON marshal when the infra/data-migration verdicts it derives from are unanswered; provisional fields are blanked
	Type            int    `json:"type"`              // 1-5 for cluster_link, else 0
	Label           string `json:"label"`
	Rationale       string `json:"rationale"`
	CCType          string `json:"cc_type"`                    // "commercial" | "government"
	Alternative     string `json:"alternative,omitempty"`      // an alternative type worth noting
	AlternativeType int    `json:"alternative_type,omitempty"` // the --type N of that alternative
	JumpCluster     bool   `json:"jump_cluster,omitempty"`     // types 4/5 need extra jump-cluster inputs
	// SpecialistClusterLinkable: for a Type-0 specialist outcome, whether the standard
	// Cluster Linking cutover steps still apply (mTLS/undetected auth, CL available) vs
	// no Cluster Linking at all (government). Render-only discriminator; not serialized.
	SpecialistClusterLinkable bool `json:"-"`
}

MigrationInfra names the concrete `kcp create-asset migration-infra --type N` for a cluster, mapping the source's accessibility and authentication onto the migration-infra type (1–5). Type 0 means "no standard type fits" — a specialist designs it.

type Observation added in v0.11.0

type Observation struct {
	Severity string `json:"severity"` // "warn" | "info"
	Title    string `json:"title"`
	Detail   string `json:"detail"`
}

Observation is a scan-derived signal worth surfacing alongside the plan — a thing to watch ("warn") or a scoping note ("info"). These are additive to the engine's verdicts; they never change a recommendation.

type PlanHeader added in v0.8.6

type PlanHeader struct {
	Source            string    `json:"source"`
	StateFilePath     string    `json:"state_file_path"`
	KCPVersion        string    `json:"kcp_version"`
	GeneratedAt       time.Time `json:"generated_at"`
	StateGeneratedAt  time.Time `json:"state_generated_at,omitempty"`
	PlanSchemaVersion string    `json:"plan_schema_version"`
}

PlanHeader is the plan document header: provenance for the generated plan.

type PlanSummary added in v0.11.0

type PlanSummary struct {
	Clusters        int `json:"clusters"`
	Regions         int `json:"regions"`
	Ready           int `json:"ready"`            // StateReady
	NeedsAnswers    int `json:"needs_answers"`    // StateNeedsAnswers
	NeedsSpecialist int `json:"needs_specialist"` // StateNeedsSpecialist
	OpenRequired    int `json:"open_required"`
	OpenOptional    int `json:"open_optional"`
}

PlanSummary is the fleet-level roll-up: how many clusters are ready to act on vs. still need answers (open required questions) vs. need a specialist, plus the total open-question counts across the fleet. Field names mirror the canonical State* codes.

type ResolvedQuestion added in v0.11.0

type ResolvedQuestion struct {
	Key        string   `json:"key"`
	Prompt     string   `json:"prompt"`
	Hint       string   `json:"hint,omitempty"`
	Legend     []string `json:"legend,omitempty"` // "token → wording — detail" lines
	Tokens     []string `json:"tokens,omitempty"` // raw option tokens (for terse inline hints)
	Required   bool     `json:"required"`
	Status     string   `json:"status"`               // "open_required" | "open_optional" | "answered" | "scan"
	Value      string   `json:"value"`                // token(s): the answer, or the default for an unanswered optional (display form)
	ValueList  []string `json:"value_list,omitempty"` // multi questions only: the tokens as a typed array for machine consumers
	Multi      bool     `json:"multi,omitempty"`
	Scan       bool     `json:"scan,omitempty"`       // answered from the scan (editable override)
	Overridden bool     `json:"overridden,omitempty"` // a scan fact the customer overrode (render live, not commented)
	ReadOnly   bool     `json:"read_only,omitempty"`  // a scan fact the scan is authoritative on: shown for audit, not advertised as editable
	Source     string   `json:"source,omitempty"`     // canonical source code: app | cluster | all_clusters | built_in_default | scan | override
	// contains filtered or unexported fields
}

ResolvedQuestion is a catalog question evaluated against the current profile and declared inputs — for display in plan.md.

type SchemaSourceRef added in v0.11.0

type SchemaSourceRef struct {
	GlueRegistry string `json:"glue_registry,omitempty"`
	GlueRegion   string `json:"glue_region,omitempty"`
	ConfluentURL string `json:"confluent_url,omitempty"`
}

SchemaSourceRef carries the source Schema Registry identifiers the migrate-schemas command needs. Schema registries are environment-level in the scan, so this is the same for every cluster; it is filled only when the scan found exactly one registry (otherwise the command falls back to a placeholder).

Directories

Path Synopsis
Package engine is the decision core behind `kcp report plan`: it turns a source cluster's migration-relevant facts into the target recommendations (size band, cluster type, networking, auth, switchover, and the human-assist handoffs).
Package engine is the decision core behind `kcp report plan`: it turns a source cluster's migration-relevant facts into the target recommendations (size band, cluster type, networking, auth, switchover, and the human-assist handoffs).

Jump to

Keyboard shortcuts

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