UNPKG

@adpt/cloud

Version:
77 lines 2.91 kB
import { InspectReport } from "./cli"; /** * Representation of a Docker network name<->ID mapping. * @internal */ export interface NetworkInfo { name: string; id?: string; } /** * Representation of the differences between two sets of Docker networks, in * the form of what changes would need to be made to make them equivalent. * @internal */ export interface NetworkDiff { toAdd: string[]; toDelete: string[]; } export declare type NetworkResolver = (names: string[]) => Promise<Required<NetworkInfo>[]>; /** * Data structure that represents a set of networks connected to a container, * Structured to minimize network inspect requests to the Docker daemon. * @remarks * Notes: * - Under load, Docker network inspect requests via CLI can take a second * or more each. * - In many typical cases, such as when a container is already connected * to the correct networks, the container's InspectReport contains both the * network name and ID for all networks we care about comparing, so no * network inspect requests at all are needed. * - Most of the complexity in this implementation comes from the corner * cases. * - Corner case 1: sometimes the NetworkID field is blank in the container * InspectReport. * - Corner case 2: it's possible for the Element's props to have both the * network name and the network ID for the same network, so simple length * comparisons are not possible. * @internal */ export declare class NetworkSet { byName: Map<string, NetworkInfo>; byId: Map<string, NetworkInfo>; unresolved: Set<string>; constructor(nets?: NetworkInfo[]); readonly size: number; /** * Returns true if all networks we know have both a name and ID. */ readonly allResolved: boolean; add(items: NetworkInfo | NetworkInfo[]): void; equals(namesOrIds: string[], resolver: NetworkResolver): Promise<boolean>; diff(namesOrIds: string[], resolver: NetworkResolver): Promise<NetworkDiff>; _diff(namesOrIds: string[]): NetworkDiff | false; _addOne(item: NetworkInfo): void; _get(nameOrId: string): NetworkInfo | undefined; } /** * Returns a `NetworkSet` that represents the networks currently attached * to the container. * @internal */ export declare function containerNetworks(info: InspectReport): NetworkSet; /** * Returns true if there's a possibility this could reference a Docker * network ID. * @remarks * The Docker daemon will accept any portion of a partial network ID, as * long as it is not ambiguous **at that moment**, based on all existing * network IDs. * That means that lots of things can be a network ID, even a single character. * It could be an ID if it's: * - Made up of (only) lower case letters a-f and digits * - Length 1-64 characters * @internal */ export declare function mightBeId(name: string): boolean; //# sourceMappingURL=network_set.d.ts.map