const VERSION="1.13";
const SRC=src;
const DEST=dest;
const DOIT=config.apply;
const sourcesDir=`https://github.com/rook/rook/raw/release-${VERSION}/deploy/examples`;
const sources=[
    "crds.yaml"
];
const crdFiles=[
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephblockpoolradosnamespaces.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephblockpools.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephbucketnotifications.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephbuckettopics.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephclients.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephclusters.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephcosidrivers.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephfilesystemmirrors.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephfilesystems.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephfilesystemsubvolumegroups.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephnfses.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephobjectrealms.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephobjectstores.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephobjectstoreusers.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephobjectzonegroups.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephobjectzones.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_cephrbdmirrors.ceph.rook.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_objectbucketclaims.objectbucket.io.yaml",
    "apiextensions.k8s.io_v1_CustomResourceDefinition_objectbuckets.objectbucket.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}`);
    }
}
