Skip to content

Commit

Permalink
chore: Use new templates locations. (#1248)
Browse files Browse the repository at this point in the history
* chore: Use new templates locations after moving to a new operator-sdk v1.7.1

Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
  • Loading branch information
AndrienkoAleksandr committed Jul 20, 2021
1 parent a38ed85 commit 452ca93
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 5 deletions.
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"
},

]
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@
"/lib",
"/installers",
"/npm-shrinkwrap.json",
"/oclif.manifest.json"
"/oclif.manifest.json",
"/prepare-che-operator-templates.js"
],
"homepage": "https://github.com/che-incubator/chectl",
"keywords": [
Expand Down Expand Up @@ -155,7 +156,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()
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2611,15 +2611,15 @@ ecc-jsbn@~0.1.1:

"eclipse-che-devfile-workspace-operator@git://github.com/devfile/devworkspace-operator#main":
version "0.0.0"
resolved "git://github.com/devfile/devworkspace-operator#fdc3ad4b732c88182539e708a77a639e00a8647e"
resolved "git://github.com/devfile/devworkspace-operator#ecec8b97c0ce749e1aa2ec89793cf7d862ab0f77"

"eclipse-che-operator@git://github.com/eclipse-che/che-operator#main":
version "0.0.0"
resolved "git://github.com/eclipse-che/che-operator#e29484fd4579bebee1acfa34b0696b73d357c85e"
resolved "git://github.com/eclipse-che/che-operator#f555494a7d5764cbed3e057b5bc092d411970610"

"eclipse-che-server@git://github.com/eclipse-che/che-server#main":
version "0.0.0"
resolved "git://github.com/eclipse-che/che-server#7fbc22bb6cb5a739b91328c70dc463aa5061c8ed"
resolved "git://github.com/eclipse-che/che-server#94353639e46fa2cb3139a3651706282b8a702e7e"

editorconfig@^0.15.0:
version "0.15.3"
Expand Down

0 comments on commit 452ca93

Please sign in to comment.