Skip to content

Commit

Permalink
Use new templates locations.
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
  • Loading branch information
AndrienkoAleksandr committed Jul 16, 2021
1 parent 4771039 commit 5b9dcfa
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
}
},
{
"type": "node",
"request": "launch",
"name": "Debug prepare-che-operator.js script",
"program": "${workspaceFolder}/prepare-che-operator-templates.js"
},

]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"postinstall-helm": "rimraf templates/kubernetes && cpx 'node_modules/eclipse-che-server/deploy/kubernetes/**' 'templates/kubernetes'",
"postinstall-cert-manager": "rimraf templates/cert-manager && cpx 'node_modules/eclipse-che-server/deploy/cert-manager/**' 'templates/cert-manager'",
"postinstall-dev-workspace": "rimraf templates/devworkspace && cpx 'node_modules/eclipse-che-devfile-workspace-operator/deploy/**' 'templates/devworkspace'",
"postinstall-operator": "rimraf templates/che-operator && cpx 'node_modules/eclipse-che-operator/deploy/**' 'templates/che-operator'",
"postinstall-operator": "node prepare-che-operator-templates.js",
"postinstall-repositories": "yarn upgrade eclipse-che-server eclipse-che-operator eclipse-che-devfile-workspace-operator",
"postinstall-cleanup": "rimraf node_modules/eclipse-che-server && rimraf node_modules/eclipse-che-operator",
"test": "jest --collect-coverage",
Expand Down
55 changes: 55 additions & 0 deletions prepare-che-operator-templates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*********************************************************************
* Copyright (c) 2021 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/

'use strict'

const fs = require('fs-extra')
const path = require('path')
var deployFolder = path.join(__dirname, 'node_modules', 'eclipse-che-operator', 'deploy')
var configFolder = path.join(__dirname, 'node_modules', 'eclipse-che-operator', 'config')
var cheOperatorTemplates = path.join(__dirname, 'templates', 'che-operator')

function prepareTemplates() {
if (fs.existsSync(deployFolder)) {
fs.copySync(deployFolder, cheOperatorTemplates)
} else if (fs.existsSync(configFolder)) {
const filterFunc = (src) => {
var isFile = fs.statSync(src).isFile()
if (isFile) {
var 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 {
var 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'))
fs.copySync(path.join(configFolder, 'samples', 'org.eclipse.che_v1_checluster.yaml'), path.join(cheOperatorTemplates, 'crds', 'org_v1_che_cr.yaml'))
fs.copySync(path.join(configFolder, 'samples', 'org_v1_chebackupserverconfiguration.yaml'), path.join(cheOperatorTemplates, 'crds', 'org.eclipse.che_v1_chebackupserverconfiguration_cr.yaml'))
fs.copySync(path.join(configFolder, 'samples', 'org_v1_checlusterbackup.yaml'), path.join(cheOperatorTemplates, 'crds', 'org.eclipse.che_v1_checlusterbackup_cr.yaml'))
fs.copySync(path.join(configFolder, 'samples', 'org_v1_checlusterrestore.yaml'), path.join(cheOperatorTemplates, 'crds', 'org.eclipse.che_v1_checlusterrestore_cr.yaml'))
} else {
throw new Error("Unable to prepare che-operator templates")
}
}

fs.removeSync(cheOperatorTemplates)
prepareTemplates()

0 comments on commit 5b9dcfa

Please sign in to comment.