UNPKG

@atomist/sdm

Version:

Atomist Software Delivery Machine SDK

66 lines 2.84 kB
import * as k8s from "@kubernetes/client-node"; import { KubernetesResourceRequest } from "./request"; /** * Remove objectionable characters from a Kubernetes label value. * The validation regular expression for a label value is * /^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$/. * * @param value The label value * @return A valid label value based on the input */ export declare function safeLabelValue(value: string): string; /** Input type for matchLabels function. */ export declare type MatchLabelInput = Pick<KubernetesResourceRequest, "name" | "workspaceId">; /** * Returns the subset of the default set of labels for that should be * used in a matchLabels to match a resource. * * @param req A Kubernetes request object containing at least the "name" and "workspaceId" properties * @return Kubernetes object metadata labels object */ export declare function matchLabels(req: MatchLabelInput): { [key: string]: string; }; /** * Provide label selector string suitable for passing to a Kubernetes * API call for the provided `req` object. * * @param req A Kubernetes request object containing at least the "name" and "workspaceId" properties * @return Kubernetes label selector string */ export declare function labelSelector(req: MatchLabelInput): string; export declare type KubernetesApplicationLabelInput = Pick<KubernetesResourceRequest, "name" | "sdmFulfiller" | "workspaceId">; /** * Support for the Kubernetes recommended set of labels, * https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/ */ export interface KubernetesLabelInput { /** The component within the application architecture. */ component?: string; /** A unique name identifying the instance of an application */ instance?: string; /** Version of this application. */ version?: string; } /** Input type for the labels function. */ export declare type ApplicationLabelInput = KubernetesApplicationLabelInput & KubernetesLabelInput; /** * Create a default set of labels for a resource. The returned set * satisfy the recommendations from * https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/ */ export declare function applicationLabels(req: ApplicationLabelInput): { [key: string]: string; }; /** * Determine if labels match selector. If the selector contains no * label selector, it is considered a match. If the the matchLabels * contain no properties, it is considered matching. If the * matchExpressions array is empty, it is considered matching. * * @param spec Kubernetes object spec * @param selector Kubernetes label selector * @return Return `true` if it is a match, `false` otherwise */ export declare function labelMatch(spec: k8s.KubernetesObject, selector?: k8s.V1LabelSelector): boolean; //# sourceMappingURL=labels.d.ts.map