Skip to content

Commit

Permalink
Move resources folder into templates
Browse files Browse the repository at this point in the history
Signed-off-by: Mykola Morhun <mmorhun@redhat.com>
  • Loading branch information
mmorhun committed Jan 31, 2020
1 parent 56a4bfc commit c532cce
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 24 deletions.
17 changes: 0 additions & 17 deletions src/commands/server/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ export default class Start extends Command {
default: Start.getTemplatesDir(),
env: 'CHE_TEMPLATES_FOLDER'
}),
resources: string({
description: 'Path to the resources folder',
env: 'CHE_RESOURCES_FOLDER',
default: Start.getResourcesDir()
}),
'devfile-registry-url': string({
description: 'The URL of the external Devfile registry.',
env: 'CHE_WORKSPACE_DEVFILE__REGISTRY__URL'
Expand Down Expand Up @@ -143,18 +138,6 @@ export default class Start extends Command {
return path.join(__dirname, '../../../templates')
}

static getResourcesDir(): string {
// return local resources folder if present
const RESOURCES_DIR_NAME = 'resources'
const resourcesDirPath = path.resolve(RESOURCES_DIR_NAME)
const exists = fs.existsSync(RESOURCES_DIR_NAME)
if (exists) {
return resourcesDirPath
}
// else use the location from node modules
return path.join(__dirname, '../../../', RESOURCES_DIR_NAME)
}

static setPlaformDefaults(flags: any) {
if (flags.platform === 'minishift') {
if (!flags.multiuser && flags.installer === '') {
Expand Down
12 changes: 5 additions & 7 deletions src/tasks/component-installers/cert-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import * as path from 'path'
import { KubeHelper } from '../../api/kube'
import { CERT_MANAGER_NAMESPACE_NAME, CHE_TLS_SECRET_NAME } from '../../constants'

const RESOURCES_FOLDER_PATH = path.resolve(__dirname, '..', '..', '..', 'resources')

export const CERT_MANAGER_CA_SECRET_NAME = 'ca'

export class CertManagerTasks {
Expand Down Expand Up @@ -47,7 +45,7 @@ export class CertManagerTasks {
{
title: 'Deploy cert-manager',
task: async (ctx: any, task: any) => {
const yamlPath = path.join(flags.resources, '/cert-manager/cert-manager.yml')
const yamlPath = path.join(flags.templates, 'cert-manager', 'cert-manager.yml')
await this.kubeHelper.applyResource(yamlPath)
ctx.certManagerInstalled = true

Expand Down Expand Up @@ -91,8 +89,8 @@ export class CertManagerTasks {
try {
// Configure permissions for CA key pair generation job
await this.kubeHelper.createServiceAccount(CA_CERT_GENERATION_SERVICE_ACCOUNT_NAME, CERT_MANAGER_NAMESPACE_NAME)
await this.kubeHelper.createRoleFromFile(path.join(RESOURCES_FOLDER_PATH, 'cert-manager', 'ca-cert-generator-role.yml'), CERT_MANAGER_NAMESPACE_NAME)
await this.kubeHelper.createRoleBindingFromFile(path.join(RESOURCES_FOLDER_PATH, 'cert-manager', 'ca-cert-generator-role-binding.yml'), CERT_MANAGER_NAMESPACE_NAME)
await this.kubeHelper.createRoleFromFile(path.join(flags.templates, 'cert-manager', 'ca-cert-generator-role.yml'), CERT_MANAGER_NAMESPACE_NAME)
await this.kubeHelper.createRoleBindingFromFile(path.join(flags.templates, 'cert-manager', 'ca-cert-generator-role-binding.yml'), CERT_MANAGER_NAMESPACE_NAME)

// Await created resources to be available
await this.kubeHelper.waitServiceAccount(CA_CERT_GENERATION_SERVICE_ACCOUNT_NAME, CERT_MANAGER_NAMESPACE_NAME)
Expand Down Expand Up @@ -132,7 +130,7 @@ export class CertManagerTasks {
task: async (_ctx: any, task: any) => {
const cheClusterIssuerExists = await this.kubeHelper.clusterIssuerExists('che-cluster-issuer')
if (!cheClusterIssuerExists) {
const cheCertificateClusterIssuerTemplatePath = path.join(flags.resources, '/cert-manager/che-cluster-issuer.yml')
const cheCertificateClusterIssuerTemplatePath = path.join(flags.templates, '/cert-manager/che-cluster-issuer.yml')
await this.kubeHelper.createCheClusterIssuer(cheCertificateClusterIssuerTemplatePath)

task.title = `${task.title}...done`
Expand All @@ -148,7 +146,7 @@ export class CertManagerTasks {
throw new Error('Che certificate already exists.')
}

const certificateTemplatePath = path.join(flags.resources, '/cert-manager/che-certificate.yml')
const certificateTemplatePath = path.join(flags.templates, '/cert-manager/che-certificate.yml')
await this.kubeHelper.createCheClusterCertificate(certificateTemplatePath, flags.domain, flags.chenamespace)
ctx.cheCertificateExists = true

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit c532cce

Please sign in to comment.