From 0e533373ed9dc226604f10849170bda57bc17fef Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Thu, 9 Jun 2022 15:05:42 +0300 Subject: [PATCH] feat: Update CheCluster V2 templates (#2139) * feat: Update CheCluster V2 templates Signed-off-by: Anatolii Bazko --- prepare-che-operator-templates.js | 110 ++++++++++-------------------- yarn.lock | 2 +- 2 files changed, 36 insertions(+), 76 deletions(-) diff --git a/prepare-che-operator-templates.js b/prepare-che-operator-templates.js index 4bbec6246..0adb7eb2d 100644 --- a/prepare-che-operator-templates.js +++ b/prepare-che-operator-templates.js @@ -13,85 +13,45 @@ const fs = require('fs-extra') const path = require('path') const deployFolder = path.join(__dirname, 'node_modules', 'eclipse-che-operator', 'deploy/deployment'); -const configFolder = path.join(__dirname, 'node_modules', 'eclipse-che-operator', 'config'); const cheOperatorTemplates = path.join(__dirname, 'templates', 'che-operator'); function prepareTemplates() { - if (fs.existsSync(deployFolder)) { - for (const platform in ['kubernetes', 'openshift']) { - fs.copySync( - path.join(deployFolder, platform, 'org_v2_checluster.yaml'), - path.join(cheOperatorTemplates, platform, 'crds', 'org_checluster_cr.yaml')) - fs.copySync( - path.join(deployFolder, platform, 'objects', 'checlusters.org.eclipse.che.CustomResourceDefinition.yaml'), - path.join(cheOperatorTemplates, platform, 'crds', 'org.eclipse.che_checlusters.yaml')) - fs.copySync( - path.join(deployFolder, platform, 'objects', 'che-operator.Deployment.yaml'), - path.join(cheOperatorTemplates, 'platform,operator.yaml')) - fs.copySync( - path.join(deployFolder, platform, 'objects', 'che-operator.ServiceAccount.yaml'), - path.join(cheOperatorTemplates, platform, 'service_account.yaml')) - fs.copySync( - path.join(deployFolder, platform, 'objects', 'che-operator.ClusterRoleBinding.yaml'), - path.join(cheOperatorTemplates, platform, 'cluster_rolebinding.yaml')) - fs.copySync( - path.join(deployFolder, platform, 'objects', 'che-operator.ClusterRole.yaml'), - path.join(cheOperatorTemplates, platform, 'cluster_role.yaml')) - fs.copySync( - path.join(deployFolder, platform, 'objects', 'che-operator.RoleBinding.yaml'), - path.join(cheOperatorTemplates, platform, 'role_binding.yaml')) - fs.copySync( - path.join(deployFolder, platform, 'objects', 'che-operator.Role.yaml'), - path.join(cheOperatorTemplates, platform, 'role.yaml')) - fs.copySync( - path.join(deployFolder, platform, 'objects', 'che-operator-serving-cert.Certificate.yaml'), - path.join(cheOperatorTemplates, platform, 'serving-cert.yaml')) - fs.copySync( - path.join(deployFolder, platform, 'objects', 'selfsigned-issuer.Issuer.yaml'), - path.join(cheOperatorTemplates, platform, 'selfsigned-issuer.yaml')) - fs.copySync( - path.join(deployFolder, platform, 'objects', 'webhook-service.Service.yaml'), - path.join(cheOperatorTemplates, platform, 'webhook-service.yaml')) - fs.copySync( - path.join(deployFolder, platform, 'objects', 'manager-config.ConfigMap.yaml'), - path.join(cheOperatorTemplates, platform, 'manager-config.yaml')) - } - } else if (fs.existsSync(configFolder)) { - const filterFunc = (src) => { - const isFile = fs.statSync(src).isFile(); - if (isFile) { - const filePath = path.basename(src); - if (filePath === 'role.yaml' || - filePath === 'role_binding.yaml' || - filePath === 'cluster_role.yaml' || - filePath === 'cluster_rolebinding.yaml' || - filePath === 'service_account.yaml') { - return true - } - } else { - const dirName = path.basename(src); - if (dirName === 'rbac') { - return true - } - } - } - - fs.copySync(path.join(configFolder, 'rbac'), cheOperatorTemplates, filterFunc) - fs.copySync(path.join(configFolder, 'manager', 'manager.yaml'), path.join(cheOperatorTemplates, 'operator.yaml')) - fs.copySync(path.join(configFolder, 'crd', 'bases'), path.join(cheOperatorTemplates, 'crds')) - - // CheCluster API v2 - let cheClusterCR = path.join(configFolder, 'samples', 'org_v2_checluster.yaml') - if (!fs.existsSync(cheClusterCR)) { - // CheCluster API v1 - cheClusterCR = path.join(configFolder, 'samples', 'org.eclipse.che_v1_checluster.yaml') - } - - // Common file name for both versions - fs.copySync(cheClusterCR, path.join(cheOperatorTemplates, 'crds', 'org_checluster_cr.yaml')) - } else { - throw new Error("Unable to prepare che-operator templates") + for (const platform of ['kubernetes', 'openshift']) { + fs.copySync( + path.join(deployFolder, platform, 'org_v2_checluster.yaml'), + path.join(cheOperatorTemplates, platform, 'crds', 'org_checluster_cr.yaml')) + fs.copySync( + path.join(deployFolder, platform, 'objects', 'checlusters.org.eclipse.che.CustomResourceDefinition.yaml'), + path.join(cheOperatorTemplates, platform, 'crds', 'org.eclipse.che_checlusters.yaml')) + fs.copySync( + path.join(deployFolder, platform, 'objects', 'che-operator.Deployment.yaml'), + path.join(cheOperatorTemplates, platform, 'operator.yaml')) + fs.copySync( + path.join(deployFolder, platform, 'objects', 'che-operator.ServiceAccount.yaml'), + path.join(cheOperatorTemplates, platform, 'service_account.yaml')) + fs.copySync( + path.join(deployFolder, platform, 'objects', 'che-operator.ClusterRoleBinding.yaml'), + path.join(cheOperatorTemplates, platform, 'cluster_rolebinding.yaml')) + fs.copySync( + path.join(deployFolder, platform, 'objects', 'che-operator.ClusterRole.yaml'), + path.join(cheOperatorTemplates, platform, 'cluster_role.yaml')) + fs.copySync( + path.join(deployFolder, platform, 'objects', 'che-operator.RoleBinding.yaml'), + path.join(cheOperatorTemplates, platform, 'role_binding.yaml')) + fs.copySync( + path.join(deployFolder, platform, 'objects', 'che-operator.Role.yaml'), + path.join(cheOperatorTemplates, platform, 'role.yaml')) + fs.copySync( + path.join(deployFolder, platform, 'objects', 'che-operator-service.Service.yaml'), + path.join(cheOperatorTemplates, platform, 'webhook-service.yaml')) } + + fs.copySync( + path.join(deployFolder, 'kubernetes', 'objects', 'che-operator-serving-cert.Certificate.yaml'), + path.join(cheOperatorTemplates, 'kubernetes', 'serving-cert.yaml')) + fs.copySync( + path.join(deployFolder, 'kubernetes', 'objects', 'che-operator-selfsigned-issuer.Issuer.yaml'), + path.join(cheOperatorTemplates, 'kubernetes', 'selfsigned-issuer.yaml')) } fs.removeSync(cheOperatorTemplates) diff --git a/yarn.lock b/yarn.lock index 6b99fda0a..c1d121ab9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2524,7 +2524,7 @@ ecc-jsbn@~0.1.1: "eclipse-che-operator@https://github.com/eclipse-che/che-operator#main": version "0.0.0" - resolved "https://github.com/eclipse-che/che-operator#16c92ec513a6a49b91e162d0fde91549c2147aa1" + resolved "https://github.com/eclipse-che/che-operator#0bc10490177c5d90867459e52ee7e1686cb97ff2" editorconfig@^0.15.0: version "0.15.3"