# k8s.yaml

> A module of k8s's API.

Just enough YAML to read a kubeconfig: block mappings and sequences of scalars, read into a flat map from paths to strings.

```mojo
var y = read_yaml(text)
y.get("current-context")                  # "kind-orca"
y.get("clusters/0/cluster/server")        # "https://127.0.0.1:6443"
y.count("users")                          # 1
```

A path is the keys and sequence indices from the top, joined by `/`. A
scalar may be plain, single-quoted or double-quoted; `~`, `null` and an
empty value are the empty string, as are the empty flow collections `{}`
and `[]`. That covers what `kubectl` and `kind` write. Anything else,
such as a block scalar (`|`), a flow collection with something in it, an
anchor or a tab used to indent, raises rather than being read wrong.

## Structs

### `Yaml`

```mojo
struct Yaml
```

Implements: `Movable`

Fields:

- `values: Dict[String, String]`: Each scalar, by its path.
- `counts: Dict[String, Int]`: Each sequence's length, by its path.
- `maps: Dict[String, Bool]`: The path of each mapping below the top.

#### `get`

```mojo
def get(self, path: String, default: String = "") -> String
```

#### `has`

```mojo
def has(self, path: String) -> Bool
```

#### `count`

```mojo
def count(self, path: String) -> Int
```

The length of the sequence at `path`, or 0.

## Functions

### `read_yaml`

```mojo
def read_yaml(text: String) -> Yaml
```
