Skip to content

Commit

Permalink
feat: Update CheCluster V2 templates (#2139)
Browse files Browse the repository at this point in the history
* feat: Update CheCluster V2 templates

Signed-off-by: Anatolii Bazko <[email protected]>
  • Loading branch information
tolusha authored Jun 9, 2022
1 parent f13336a commit 0e53337
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 76 deletions.
110 changes: 35 additions & 75 deletions prepare-che-operator-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 0e53337

Please sign in to comment.