IF Commons GitHub

governance/model

Written to: 3 requirements: 3 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-estate-iac-model FR-001, 0002-estate-iac-model FR-002, 0002-estate-iac-model FR-003

What an importer gives: assets and links of the estate, each asset with where it came from. An importer reads a file (or the text of one) and runs no tool; it copies only the attributes the estate's catalog names (never the values of a resource, which hold secrets in state), and says in problems what it could not read, so that nothing is dropped without a word.

import { slug } from "./model.ts";
slug("tf", "aws_instance.web[0]"); // "tf-aws-instance-web-0"

Source: commons/estate-iac/src/governance/model.ts

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

governance.TOOLSconstno test imports it
const TOOLS: readonly ["opentofu", "terraform", "cloudformation", "kubernetes", "compose", "pulumi"]

The tools whose files are read.

governance.Tooltypeno test imports it
type Tool = (typeof TOOLS)[number];

A tool whose files are read.

governance.Importedtypeno test imports it
type Imported = { readonly id: string; readonly kind: string; readonly attributes: Readonly<Record<string, AttributeValue>> };

An asset an importer found: its identity, kind and attributes (with provenance among them). The state of the asset is discovered: reading code adopts nothing.

governance.ImportedLinktypeno test imports it
type ImportedLink = { readonly from: string; readonly to: string; readonly kind: string };

A link an importer found, between the identities of two imported assets.

governance.Importstypeno test imports it
type Imports = { readonly tool: Tool; readonly source: string; readonly assets: readonly Imported[]; readonly links: readonly ImportedLink[]; readonly problems: readonly string[] };

What an importer gives for one file.

governance.provenanceOffunctionno test imports it
function provenanceOf(tool: "cloudformation" | "compose" | "kubernetes" | "opentofu" | "pulumi" | "terraform", source: string, address: string): string

Where an asset was read from, as tool:file#address.

governance.slugfunctionno test imports it
function slug(...parts: readonly string[]): string

An asset identity from words: lower case, letters and digits joined by hyphens, starting with the first word (a prefix that begins with a letter), at most 100 characters.

governance.IdPoolclassno test imports it
class IdPool

A set of identities in use, that gives the first free one: the identity, then it with -2, -3 and so on.

MemberTypeWhat it is
take(base: string) => string
governance.linkForfunctionno test imports it
function linkFor(needs: Imported, needed: Imported): ImportedLink

The link between two imported assets where the first needs the second, named by the kinds of both: an endpoint that needs a resource is exposed by it, an endpoint that needs a certificate is secured by it, a name that needs an asset resolves to it, and any other is a dependency.

governance.presentfunctionno test imports it
function present(a: Readonly<Record<string, AttributeValue | undefined>>): Readonly<Record<string, AttributeValue>>

The attributes without the ones that have no value.

governance.distinctLinksfunctionno test imports it
function distinctLinks(links: readonly ImportedLink[]): readonly ImportedLink[]

Links without the ones that repeat or join an asset to itself, in order.

TOOLSconstno test imports it
const TOOLS: readonly ["opentofu", "terraform", "cloudformation", "kubernetes", "compose", "pulumi"]

The tools whose files are read.

Tooltypeno test imports it
type Tool = (typeof TOOLS)[number];

A tool whose files are read.

Importedtype
type Imported = { readonly id: string; readonly kind: string; readonly attributes: Readonly<Record<string, AttributeValue>> };

An asset an importer found: its identity, kind and attributes (with provenance among them). The state of the asset is discovered: reading code adopts nothing.

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

ImportedLinktypeno test imports it
type ImportedLink = { readonly from: string; readonly to: string; readonly kind: string };

A link an importer found, between the identities of two imported assets.

Importstype
type Imports = { readonly tool: Tool; readonly source: string; readonly assets: readonly Imported[]; readonly links: readonly ImportedLink[]; readonly problems: readonly string[] };

What an importer gives for one file.

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

provenanceOffunction
function provenanceOf(tool: "cloudformation" | "compose" | "kubernetes" | "opentofu" | "pulumi" | "terraform", source: string, address: string): string

Where an asset was read from, as tool:file#address.

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

slugfunction
function slug(...parts: readonly string[]): string

An asset identity from words: lower case, letters and digits joined by hyphens, starting with the first word (a prefix that begins with a letter), at most 100 characters.

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

IdPoolclass
class IdPool

A set of identities in use, that gives the first free one: the identity, then it with -2, -3 and so on.

MemberTypeWhat it is
take(base: string) => string

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

linkForfunction
function linkFor(needs: Imported, needed: Imported): ImportedLink

The link between two imported assets where the first needs the second, named by the kinds of both: an endpoint that needs a resource is exposed by it, an endpoint that needs a certificate is secured by it, a name that needs an asset resolves to it, and any other is a dependency.

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

presentfunctionno test imports it
function present(a: Readonly<Record<string, AttributeValue | undefined>>): Readonly<Record<string, AttributeValue>>

The attributes without the ones that have no value.

distinctLinksfunction
function distinctLinks(links: readonly ImportedLink[]): readonly ImportedLink[]

Links without the ones that repeat or join an asset to itself, in order.

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

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