Documentation
¶
Overview ¶
Package envnet maps a tile to its environment's isolated Docker network and slug-based naming. Each environment holds one attachable overlay out of a pool (infra/netpool), the name says nothing, the env row is the mapping. Traefik is attached to every one so it can route HTTP to any tile, while tiles themselves can only reach their own environment (and a shared instance over its own network, repo.Tile.SharedNet).
Every docker object name is built here and nowhere else. Names are made of slugs joined by "_": Slugify emits only [a-z0-9-], so no slug can contain an underscore and the segments cannot be confused. A "-" separator would be ambiguous (stack "a-b" + env "c" reads the same as "a" + "b-c"), which is the collision this scheme exists to remove. Names are never parsed back; anything that needs the rows goes to the rows.
Nothing resolves a tile by container name, tiles get explicit DNS aliases (the tile slug and TileAlias), so the separator is operator-facing only.
Index ¶
- Constants
- func Net(ctx context.Context, store repo.Store, envID string) (string, error)
- func RecordProxyAddr(ctx context.Context, store repo.Store, c *cluster.Cluster, ...)
- func ServiceFor(ctx context.Context, store repo.Store, t *repo.Tile) string
- func TearDown(ctx context.Context, store repo.Store, c *cluster.Cluster, t *repo.Tile)
- func TileAlias(tileID string) string
- func UpperEnv(ctx context.Context, store repo.Store, t *repo.Tile) bool
- type Scope
Constants ¶
const ( Prefix = "stkr_" ImagePrefix = "stkr/" )
Prefix opens every docker object stackr owns: networks, containers and the panel's own traefik/registry/relay containers. Images use ImagePrefix. Volumes are the exception, they keep the older "stackr-" prefix, because docker cannot rename a volume and a prefix change would detach live data (repo.StorageVolume).
Variables ¶
This section is empty.
Functions ¶
func Net ¶
Net is the overlay an environment sits on, without claiming one. Empty means nothing has deployed into the env yet.
func RecordProxyAddr ¶
func RecordProxyAddr(ctx context.Context, store repo.Store, c *cluster.Cluster, envID, netName string)
RecordProxyAddr stores where Traefik sits on one environment network, feeding ${{ stackr.PROXY_IP }} / ${{ stackr.PROXY_CIDR }}. Call it after attaching.
Best-effort throughout: this is a convenience for config files, and no failure here should stop a deploy or stop Traefik serving. A missed write leaves the previous value standing until the next attach.
func ServiceFor ¶
ServiceFor resolves the swarm service name for a tile ("" if its stack or environment is already gone, which teardown treats as nothing to remove).
func TearDown ¶
TearDown removes everything docker holds for one tile: its service, and any container left under the tile's labels. Both halves are needed, removing a task's container only makes swarm start another, and a box that deployed before the swarm move still has plain containers under the same labels.
Best-effort throughout: a tile whose objects are already gone must not strand its rows.
func TileAlias ¶
TileAlias is the tile's globally-unique DNS alias, used by Traefik which sits on every environment network (plain slugs would collide across envs).
Types ¶
type Scope ¶
Scope is the resolved naming context for one tile.
func Ensure ¶
func Ensure(ctx context.Context, store repo.Store, c *cluster.Cluster, t *repo.Tile) (Scope, string, error)
Ensure resolves the tile's scope and claims the environment's overlay out of the pool if it has none yet. Returns the scope and the network name; nothing may derive the network from the scope.
Traefik is deliberately not attached here. It is a service now, and a service joining a network rolls every one of its tasks, an environment create would take 80 and 443 down. Traefik holds the whole pool from the moment it starts (infra/proxy), so the network this claims is already one of its own.
func ForStack ¶
ForStack builds the scope for one environment of a stack, loading the org for its slug. Callers that hold the rows already use this over Resolve.
func (Scope) ContainerName ¶
ContainerName is the operator-facing container name for a tile; suffix distinguishes coexisting containers (e.g. deployment id) and may be empty. The suffix joins on the same separator: a slug can never contain one, so a tile named "site" with suffix "abc" cannot collide with a tile named "site_abc", no such slug exists.
func (Scope) ImageRepo ¶
ImageRepo is the local image repository for a tile's builds. No env in it: an image is a property of (stack, tile, commit), and baking the env in would make promoting a built image between environments impossible.
func (Scope) ServiceName ¶
ServiceName is the swarm service for a tile: the scoped name with no suffix. Stable for the life of the tile, a deploy updates the service in place and swarm rolls the tasks, so unlike the old per-deployment container name there is nothing to disambiguate.