@atomist/sdm
Version:
Atomist Software Delivery Machine SDK
58 lines • 2.67 kB
TypeScript
import { GitProject } from "@atomist/automation-client/lib/project/git/GitProject";
import * as k8s from "@kubernetes/client-node";
import { PushDiff } from "./diff";
/** Whether a spec should be applied or deleted. */
export declare type ChangeType = "apply" | "delete";
/**
* Delete/apply resources in change. The spec file provided by the
* change.path may contain multiple specs. The requested change is
* applied to each.
*/
export declare function changeResource(p: GitProject, change: PushDiff): Promise<void>;
/** Return type from [[calculateChanges]]. */
export interface SyncChanges {
/** "apply", "delete" or "ignore" */
change: ChangeType;
/** Spec to apply/delete. */
spec: k8s.KubernetesObject;
}
/**
* Inspect before and after specs to determine actions.
*
* If the action is "delete", return delete actions for all specs in
* `before` that do not have an ignore annotation for the current SDM,
* as the "delete" action implies there are no `after` specs.
*
* If the action is "apply", return apply actions for all specs in
* `after` and delete actions for all specs in `before` that are not
* in `after` that do not have an ignore annotation for the current
* SDM. If a `before` spec contains a sync ignore annotation for the
* current SDM and the `after` annotation does not, the `after` spec
* with an "apply" action is included in the returned changes. If an
* `after` spec contains a sync ignore annotation for the current SDM,
* then it is omitted from the returned changes, regardless of whether
* it appears in the `before` specs or not.
*
* @param before The specs before the change
* @param after The specs after the change
* @param change The type of change
* @return Array containing the type of change for each spec
*/
export declare function calculateChanges(before: k8s.KubernetesObject[], after: k8s.KubernetesObject[] | undefined, change: ChangeType): SyncChanges[];
/**
* Returned array of specs with those that should be ignored filtered
* out.
*
* @param specs Array of specs to check
* @return Array of not ignored specs.
*/
export declare function filterIgnoredSpecs(specs: k8s.KubernetesObject[] | undefined): k8s.KubernetesObject[];
/**
* Check if the Kubernetes Object has an annotation that is relevant to the current SDM
* @param spec the spec to inspect
* @param annotationKey the key to validate for
* @param annotationValue the value validate for
* @returns the result of the annotation inspection
*/
export declare function hasMetadataAnnotation(spec: k8s.KubernetesObject, annotationKey: string, annotationValue: string): boolean;
//# sourceMappingURL=change.d.ts.map