const VERSION="0.6.3";
const SRC=src;
const DEST=dest;
const DOIT=config.apply;
const sourcesDir=`https://github.com/k8snetworkplumbingwg/whereabouts/raw/v${VERSION}/doc/crds`;
const sources=[
    "whereabouts.cni.cncf.io_ippools.yaml",
    "whereabouts.cni.cncf.io_overlappingrangeipreservations.yaml"
];
const crdFiles=[
    "apiextensions.k8s.io_v1_CustomResourceDefinition_ippools.whereabouts.cni.cncf.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_overlappingrangeipreservations.whereabouts.cni.cncf.io.yaml",
];
fn pre_pack() {
    for file in global::sources {
        shell(`curl -sL ${global::sourcesDir}/${file} > ${global::SRC}/${file}`);
    }
}
fn pre_install() {
    if ! global::DOIT {
        return;
    }
    for file in global::crdFiles {
        shell(`kubectl replace -f ${global::SRC}/${file} || kubectl create -f ${global::SRC}/${file}`);
    }
}
fn post_destroy() {
    if ! global::DOIT {
        return;
    }
    for file in global::crdFiles {
        shell(`kubectl delete -f ${global::SRC}/${file}`);
    }
}
