const VERSION="0.27.0";
const SRC=src;
const DEST=dest;
const DOIT=config.apply;
const PURGE=config.purge;
const sourcesDir=`https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v${VERSION}`;
const sources=[
    "crds.yaml"
];
const crdFiles=[
    "apiextensions.k8s.io_v1_CustomResourceDefinition_catalogsources.operators.coreos.com.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_clusterserviceversions.operators.coreos.com.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_installplans.operators.coreos.com.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_olmconfigs.operators.coreos.com.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_operatorconditions.operators.coreos.com.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_operatorgroups.operators.coreos.com.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_operators.operators.coreos.com.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_subscriptions.operators.coreos.com.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::PURGE {
        return;
    }
    for file in global::crdFiles {
        shell(`kubectl delete -f ${global::SRC}/${file}`);
    }
}
