identityresolve

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MPL-2.0 Imports: 10 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

Overview

Package identityresolve is choudoufu's identity-resolution seam on the new runtime (#2256 U6, #2342). It is a fork-only package, the sibling of configadjust: upstream's planning engine adopts an existing object only through an import statement (`#4726`, `#4727`), so the planning engine asks a ResourceIdentityResolver about each desired managed resource instance that has no prior object and no import statement, and turns a found target into an import statement of its own.

ResourceIdentityResolver mirrors internal/tofu's interface of the same name method for method; internal/tofu checks at compile time that the two stay identical. The helpers below are the rules the old runtime applies to a resolver-supplied target in NodePlannableResourceInstance (internal/tofu/node_resource_plan_instance.go), shared so the two runtimes read one copy:

  • a resolver's target is a guess, not the operator's promise an import block is, so an import that finds nothing (ImportAbsent) plans a create instead of failing the plan;
  • a type with no classic Importer gets the stub ImportResourceState would have returned, built from the target's own identity object (IdentityValues, noimporter.SynthesizeStub), or the refusal NoImporterRefusal when the target carries only an opaque ID.

Index

Constants

View Source
const NoImporterRefusalSummary = "Resource type has no classic Importer"

NoImporterRefusalSummary is the summary of NoImporterRefusal.

Variables

This section is empty.

Functions

func IdentityValues

func IdentityValues(target providers.ImportTarget) map[string]string

IdentityValues extracts a target's identity object as one string per attribute, keyed by the provider's own name for it, the shape noimporter.SynthesizeStub needs. Only an identity-based target reports anything: an opaque ID has no attribute breakdown, and none is invented. A null, unknown or unconvertible attribute is skipped rather than forced.

func ImportAbsent

func ImportAbsent(diags tfdiags.Diagnostics, target providers.ImportTarget, providerType string) bool

ImportAbsent reports whether every error in diags describes an ordinary absence of the object target names, either one of the import path's own "nothing here" diagnostics or a provider's not-found-shaped error, rather than a genuine failure to answer. diags with no errors reports false.

providerType is the type name of the provider the import was asked of: an Azure 404 reads as absence only from an Azure provider and only when it is about that object (absent.Object, GitHub issues #2133 and #2140).

func NoImporterRefusal

func NoImporterRefusal(addr fmt.Stringer, target providers.ImportTarget, detail string) tfdiags.Diagnostic

NoImporterRefusal is the error for a resolved target of a type whose provider implements no ImportResourceState, when the target carries no identity values to build a stub from. detail is noimporter.Diagnostics' own account of the provider's answer.

func PeelEngineMarks

func PeelEngineMarks(config cty.Value) cty.Value

PeelEngineMarks removes every mark on config, at any depth, that is not one of the language's own (configadjust.IsLanguageMark): the new runtime's bookkeeping, chiefly objchange.PendingChange.

The new runtime marks each part of a resource instance's planned value that the plan changes with PendingChange, and a reference carries the mark into whatever reads it. So a resource whose identity argument interpolates a sibling's ordinary attribute ("crash-read-${a.data["suffix"]}"), while that sibling is being created or updated, reaches the resolver with a known string marked on that one attribute. NodeResolver refuses a marked identity value, because a marked value may be sensitive (identity.ComponentsFromValue), so the instance failed with "No source for this instance's identity" (reference-k8s day2_crash on #2256). The old runtime puts no such mark on the value it hands the resolver. The value is the planned one either way; the mark only says it is not applied yet, which says nothing about the identity it names.

The language's marks (Sensitive, Ephemeral, deprecation) stay, so a sensitive identity argument is still refused. configadjust's peel removes only the marks on the whole value, because a marker adjuster's own attribute marks are its business; the resolver reads attributes, so it needs them gone at depth.

func Resolve

Resolve asks r about one instance. It loads the schema only when r is not nil, and reports found only for a target that names something (an ID or an identity object), the same test NodeResolver's own steps apply. config reaches r with the engine's own marks removed (PeelEngineMarks).

Types

type ResourceIdentityResolver

type ResourceIdentityResolver interface {
	ResolveResourceIdentity(ctx context.Context, addr addrs.AbsResourceInstance, config cty.Value, schema providers.Schema) (target providers.ImportTarget, found bool, diags tfdiags.Diagnostics)
}

ResourceIdentityResolver is internal/tofu's ResourceIdentityResolver. See its doc comment there for the contract: it is asked once per desired managed resource instance that has no prior object and no import statement, and found is false when it has nothing to say.

Jump to

Keyboard shortcuts

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