Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: (Un)install DevWorkspaceRouting CRD during during (un)installation using operator. #1393

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ export class DevWorkspaceTasks {

protected devWorkspaceTemplatesCrdName = 'devworkspacetemplates.workspace.devfile.io'

protected workspaceRoutingsCrdName = 'devworkspaceroutings.controller.devfile.io'

protected webhooksName = 'controller.devfile.io'

// Web Terminal Operator constants
Expand Down Expand Up @@ -260,7 +258,6 @@ export class DevWorkspaceTasks {
task: async (_ctx: any, task: any) => {
await this.kubeHelper.deleteCrd(this.devWorkspacesCrdName)
await this.kubeHelper.deleteCrd(this.devWorkspaceTemplatesCrdName)
await this.kubeHelper.deleteCrd(this.workspaceRoutingsCrdName)

task.title = await `${task.title}...OK`
},
Expand Down
28 changes: 28 additions & 0 deletions src/tasks/installers/operator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export class OperatorTasks {

devworkspaceCheNamePrefix = 'devworkspace-che'

devWorkspaceRoutingCrd = 'devworkspaceroutings.controller.devfile.io'

private getReadRolesAndBindingsTask(kube: KubeHelper): Listr.ListrTask {
return {
title: 'Read Roles and Bindings',
Expand Down Expand Up @@ -233,6 +235,23 @@ export class OperatorTasks {
}
},
},
{
title: 'Create DevWorkspaceRouting CRD',
task: async (ctx: any, task: any) => {
const crdPath = await this.getDevWorkspaceRoutingCRDPath(ctx, kube)
if (crdPath) {
const existingCRD = await kube.getCrd(this.devWorkspaceRoutingCrd)
if (existingCRD) {
task.title = `${task.title}...It already exists.`
} else {
await kube.createCrdFromFile(crdPath)
task.title = `${task.title}...done.`
}
} else {
task.title = `${task.title}...skipped.`
}
},
},
{
title: 'Waiting 5 seconds for the new Kubernetes resources to get flushed',
task: async (_ctx: any, task: any) => {
Expand Down Expand Up @@ -505,6 +524,7 @@ export class OperatorTasks {
await kh.deleteCrd(this.cheClusterBackupCrd)
await kh.deleteCrd(this.cheClusterRestoreCrd)
await kh.deleteCrd(this.cheBackupServerConfigCrd)
await kh.deleteCrd(this.devWorkspaceRoutingCrd)
task.title = `${task.title}...OK`
}
},
Expand Down Expand Up @@ -616,6 +636,14 @@ export class OperatorTasks {
return [backupServerConfigFileName, backupCrdFileName, restoreCrdFileName]
}

private async getDevWorkspaceRoutingCRDPath(ctx: any, kube: KubeHelper): Promise<string | null> {
if (await kube.IsAPIExtensionSupported('v1')) {
return path.join(ctx.resourcesPath, 'crds', 'devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml')
} else {
return null
}
}

/**
* Reads and patch 'che-operator' deployment:
* - sets operator image
Expand Down