IF Commons GitHub

dialect

Written to: 7 requirements: 7 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-opentofu-dialect FR-001, 0002-opentofu-dialect FR-002, 0002-opentofu-dialect FR-003, 0002-opentofu-dialect FR-004, 0002-opentofu-dialect FR-005, 0002-opentofu-dialect FR-006 and 1 more

The dialect of Archon for cloud resources with OpenTofu: what it guarantees (as data), how it renders an order of cloud-resource requirements to one JSON configuration (OpenTofu's JSON syntax), and the steps that carry the plan out. It renders and says what to run; it runs nothing, and it needs no network.

What makes it safe to hand to a pipeline: every provider the order uses is named with an exact version (a provider the options do not name is refused, so nothing is fetched that nobody pinned); no credential is ever in the render, because a requirement or a provider setting that holds one is refused (the provider reads its credentials from the environment of the run, as every cloud's own tooling does); the state is kept outside the repository (a backend the options name, or a file in a folder the options name that is not in the render's folder), so the state, which holds the secrets of what it made, is never committed; the arguments that run code (provisioner, connection) are refused; and the steps plan to a saved plan and apply exactly that plan, so that what was shown is what is done (and the plan is checked against the order first: checkPlan).

import { opentofu, KINDS_CARRIED } from "./dialect.ts";
KINDS_CARRIED; // ["cloud-resource"]

Source: commons/archon-dialect-opentofu/src/dialect.ts

10 of 13 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

DIALECT_IDconst
const DIALECT_ID: "opentofu"

The id of the dialect.

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

PINNED_VERSIONconstno test imports it
const PINNED_VERSION: "1.9.0"

The version of OpenTofu the dialect pins. A fleet that pins another passes it.

KINDS_CARRIEDconst
const KINDS_CARRIED: readonly ["cloud-resource"]

The kinds of resource the dialect carries out.

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

ProviderPintypeno test imports it
type ProviderPin = {
  /** Where it comes from, as the registry names it: `hashicorp/aws`. */
  readonly source: string;
  /** Its exact version: a range is not a pin. */
  readonly version: string;
  /** Its settings (a region, a profile name, an endpoint): never a credential. */
  readonly config?: { readonly [key: string]: JsonValue };
};

A provider the order may use, pinned.

OpenTofuOptionstype
type OpenTofuOptions = { /** The providers the order may use, by the local name the requirements give (`aws`). */ re… (756 characters)
type OpenTofuOptions = {
  /** The providers the order may use, by the local name the requirements give (`aws`). */
  readonly providers: { readonly [name: string]: ProviderPin };
  /** The folder the state, the saved plan and the provider data are kept in: absolute, and outside the render. */
  readonly stateDir: string;
  /** Where the state lives where it is not a file of `stateDir`: a backend and its settings (never a credential). */
  readonly backend?: { readonly type: string; readonly config: { readonly [key: string]: JsonValue } };
  /** The version of OpenTofu the run must have. */
  readonly version?: string;
  /** The folder, below the working folder, the render is written in; `.archon` by default. */
  readonly renderRoot?: string;
};

What the dialect is made with.

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

optionProblemsfunction
function optionProblems(o: OpenTofuOptions): readonly string[]

The problems of the options, or none.

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

resourcesOffunction
function resourcesOf(order: Order, o: OpenTofuOptions): Result<readonly Resource[], readonly string[]>

The resources of an order, or every reason it cannot be rendered.

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

configurationOffunction
function configurationOf(resources: readonly Resource[], o: OpenTofuOptions): Obj

The configuration of an order, in OpenTofu's JSON syntax, as an object whose keys are in order.

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

opentofufunction
function opentofu(options: OpenTofuOptions): Dialect

The dialect, as the port of Archon takes it.

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

PlannedChangetypeno test imports it
type PlannedChange = { readonly address: string; readonly actions: readonly string[] };

What OpenTofu would do to one resource.

changesOffunction
function changesOf(showJson: string): Result<readonly PlannedChange[], string>

The changes of tofu show -json <plan>, or why the text is not that.

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

planDigestfunction
function planDigest(changes: readonly PlannedChange[]): Promise<string>

The digest of what a plan would do: the addresses and the actions, and nothing of the values (a plan holds the secrets of what it makes). It is the hash an approval names.

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

checkPlanfunction
function checkPlan(order: Order, changes: readonly PlannedChange[]): readonly string[]

What a plan does that the order did not ask for: a resource it would destroy or replace that no requirement asks to remove or replace, and a change to a resource no requirement states (which the state holds and the configuration no longer does).

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.