diff --git a/.github/workflows/e2e-minikube-devworkspace.yml b/.github/workflows/e2e-minikube-devworkspace.yml new file mode 100644 index 000000000..336dac4d2 --- /dev/null +++ b/.github/workflows/e2e-minikube-devworkspace.yml @@ -0,0 +1,26 @@ +# +# Copyright (c) 2012-2020 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 +# +# Contributors: +# Red Hat, Inc. - initial API and implementation +name: Minikube E2E +on: pull_request +jobs: + minikube-e2e: + name: DevWorkspace Engine Deployment + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v1 + - name: Install minikube kubernetes cluster + run: minikube start --memory=6000 + - name: Install chectl dependencies + run: yarn + - name: Run workspace-engine tests in minikube + run: | + minikube addons enable ingress + ./bin/run server:deploy --workspace-engine=dev-workspace -p minikube diff --git a/src/api/kube.ts b/src/api/kube.ts index ca29860b6..c6d361ddd 100644 --- a/src/api/kube.ts +++ b/src/api/kube.ts @@ -436,7 +436,7 @@ export class KubeHelper { } } - async mutatingWebhookConfigurationExist(name: string): Promise { + async isMutatingWebhookConfigurationExists(name: string): Promise { const k8sAdmissionApi = KubeHelper.KUBE_CONFIG.makeApiClient(AdmissionregistrationV1Api) try { const { body } = await k8sAdmissionApi.readMutatingWebhookConfiguration(name) @@ -446,7 +446,7 @@ export class KubeHelper { } } - async validatingWebhookConfigurationExist(name: string): Promise { + async isValidatingWebhookConfigurationExists(name: string): Promise { const k8sAdmissionApi = KubeHelper.KUBE_CONFIG.makeApiClient(AdmissionregistrationV1Api) try { const { body } = await k8sAdmissionApi.readValidatingWebhookConfiguration(name) @@ -978,7 +978,7 @@ export class KubeHelper { } } - async configMapExist(name: string, namespace: string): Promise { + async isConfigMapExists(name: string, namespace: string): Promise { const k8sApi = KubeHelper.KUBE_CONFIG.makeApiClient(CoreV1Api) try { const { body } = await k8sApi.readNamespacedConfigMap(name, namespace) @@ -1437,7 +1437,7 @@ export class KubeHelper { } } - async CRDV1Exist(name: string): Promise { + async isCRDV1Exists(name: string): Promise { const k8sApiextensionsApi = KubeHelper.KUBE_CONFIG.makeApiClient(ApiextensionsV1Api) try { const { body } = await k8sApiextensionsApi.readCustomResourceDefinition(name) @@ -2060,7 +2060,7 @@ export class KubeHelper { } } - async namespacedCertificateExists(name: string, version: string, namespace: string): Promise { + async isNamespacedCertificateExists(name: string, version: string, namespace: string): Promise { const customObjectsApi = KubeHelper.KUBE_CONFIG.makeApiClient(CustomObjectsApi) try { @@ -2076,25 +2076,23 @@ export class KubeHelper { } } - async deleteNamespacedCertificate(name: string, version: string, namespace: string): Promise { + async deleteNamespacedCertificate(name: string, version: string, namespace: string): Promise { const customObjectsApi = KubeHelper.KUBE_CONFIG.makeApiClient(CustomObjectsApi) try { // If cluster issuers doesn't exist an exception will be thrown await customObjectsApi.deleteNamespacedCustomObject('cert-manager.io', version, namespace, 'certificates', name) - return true } catch (e) { throw this.wrapK8sClientError(e) } } - async deleteNamespacedIssuer(name: string, version: string, namespace: string): Promise { + async deleteNamespacedIssuer(name: string, version: string, namespace: string): Promise { const customObjectsApi = KubeHelper.KUBE_CONFIG.makeApiClient(CustomObjectsApi) try { // If cluster issuers doesn't exist an exception will be thrown await customObjectsApi.deleteNamespacedCustomObject('cert-manager.io', version, namespace, 'issuers', name) - return true } catch (e) { throw this.wrapK8sClientError(e) } @@ -2140,7 +2138,7 @@ export class KubeHelper { } } - async certificateIssuerExists(name: string, version: string, namespace: string): Promise { + async isCertificateIssuerExists(name: string, version: string, namespace: string): Promise { const customObjectsApi = KubeHelper.KUBE_CONFIG.makeApiClient(CustomObjectsApi) try { diff --git a/src/tasks/component-installers/devfile-workspace-operator-installer.ts b/src/tasks/component-installers/devfile-workspace-operator-installer.ts index a8830a8e1..ff063162f 100644 --- a/src/tasks/component-installers/devfile-workspace-operator-installer.ts +++ b/src/tasks/component-installers/devfile-workspace-operator-installer.ts @@ -217,22 +217,22 @@ export class DevWorkspaceTasks { { title: 'Create DevWorkspace Custom Resource Definitions', task: async (ctx: any, task: any) => { - if (!await this.kubeHelper.CRDV1Exist(this.devworkspacesCRDName)) { + if (!await this.kubeHelper.isCRDV1Exists(this.devworkspacesCRDName)) { const devworkspaceWorkspaceCRDfile = path.join(this.getTemplatePath(ctx), 'devworkspaces.workspace.devfile.io.CustomResourceDefinition.yaml') await this.kubeHelper.createCRDV1FromFile(devworkspaceWorkspaceCRDfile) } - if (!await this.kubeHelper.CRDV1Exist(this.componentsCRDName)) { + if (!await this.kubeHelper.isCRDV1Exists(this.componentsCRDName)) { const devworkspaceWorkspaceCRDfile = path.join(this.getTemplatePath(ctx), 'components.controller.devfile.io.CustomResourceDefinition.yaml') await this.kubeHelper.createCRDV1FromFile(devworkspaceWorkspaceCRDfile) } - if (!await this.kubeHelper.CRDV1Exist(this.devworkspacetemplatesCRDName)) { + if (!await this.kubeHelper.isCRDV1Exists(this.devworkspacetemplatesCRDName)) { const devworkspaceWorkspaceCRDfile = path.join(this.getTemplatePath(ctx), 'devworkspacetemplates.workspace.devfile.io.CustomResourceDefinition.yaml') await this.kubeHelper.createCRDV1FromFile(devworkspaceWorkspaceCRDfile) } - if (!await this.kubeHelper.CRDV1Exist(this.workspaceroutingsCRDName)) { + if (!await this.kubeHelper.isCRDV1Exists(this.workspaceroutingsCRDName)) { const devworkspaceWorkspaceCRDfile = path.join(this.getTemplatePath(ctx), 'workspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml') await this.kubeHelper.createCRDV1FromFile(devworkspaceWorkspaceCRDfile) } @@ -243,7 +243,7 @@ export class DevWorkspaceTasks { { title: `Create configMap ${this.devworkspaceConfigMap}`, task: async (ctx: any, task: any) => { - const exists = await this.kubeHelper.configMapExist(this.devworkspaceConfigMap, this.getNamespace()) + const exists = await this.kubeHelper.isConfigMapExists(this.devworkspaceConfigMap, this.getNamespace()) if (exists) { task.title = `${task.title}...It already exists.` return @@ -306,7 +306,7 @@ export class DevWorkspaceTasks { title: `Create certificate issuer ${this.devworkspaceCertIssuer}`, enabled: (ctx: any) => !ctx.isOpenShift, task: async (ctx: any, task: any) => { - const certIssuerExist = await this.kubeHelper.certificateIssuerExists(this.devworkspaceCertIssuer, ctx.certManagerK8sApiVersion, this.getNamespace()) + const certIssuerExist = await this.kubeHelper.isCertificateIssuerExists(this.devworkspaceCertIssuer, ctx.certManagerK8sApiVersion, this.getNamespace()) if (certIssuerExist) { task.title = `${task.title}...It already exists.` return @@ -321,7 +321,7 @@ export class DevWorkspaceTasks { title: `Create self-signed certificate ${this.devworkspaceCertificate}`, enabled: (ctx: any) => !ctx.isOpenShift, task: async (ctx: any, task: any) => { - const certExists = await this.kubeHelper.namespacedCertificateExists(this.devworkspaceCertificate, ctx.certManagerK8sApiVersion, this.getNamespace()) + const certExists = await this.kubeHelper.isNamespacedCertificateExists(this.devworkspaceCertificate, ctx.certManagerK8sApiVersion, this.getNamespace()) if (certExists) { task.title = `${task.title}...It already exists.` return @@ -444,10 +444,10 @@ export class DevWorkspaceTasks { title: 'Delete DevWorkspace self-signed certificates', enabled: async (ctx: any) => !ctx.IsOpenshift, task: async (_ctx: any, task: any) => { - if (await this.kubeHelper.namespacedCertificateExists(this.devworkspaceCertificate, 'v1', this.getNamespace())) { + if (await this.kubeHelper.isNamespacedCertificateExists(this.devworkspaceCertificate, 'v1', this.getNamespace())) { await this.kubeHelper.deleteNamespacedCertificate(this.devworkspaceCertificate, 'v1', this.getNamespace()) } - if (await this.kubeHelper.certificateIssuerExists(this.devworkspaceCertIssuer, 'v1', this.getNamespace())) { + if (await this.kubeHelper.isCertificateIssuerExists(this.devworkspaceCertIssuer, 'v1', this.getNamespace())) { await this.kubeHelper.deleteNamespacedIssuer(this.devworkspaceCertIssuer, 'v1', this.getNamespace()) } task.title = await `${task.title}...OK` @@ -456,10 +456,10 @@ export class DevWorkspaceTasks { { title: 'Delete Devworkspace webhooks', task: async (_ctx: any, task: any) => { - if (await this.kubeHelper.mutatingWebhookConfigurationExist(this.webhooksName)) { + if (await this.kubeHelper.isMutatingWebhookConfigurationExists(this.webhooksName)) { await this.kubeHelper.deleteMutatingWebhookConfiguration(this.webhooksName) } - if (await this.kubeHelper.validatingWebhookConfigurationExist(this.webhooksName)) { + if (await this.kubeHelper.isValidatingWebhookConfigurationExists(this.webhooksName)) { await this.kubeHelper.deleteValidatingWebhookConfiguration(this.webhooksName) } task.title = await `${task.title} ...OK` @@ -468,16 +468,16 @@ export class DevWorkspaceTasks { { title: 'Delete DevWorkspace controller CRDs', task: async (_ctx: any, task: any) => { - if (await this.kubeHelper.CRDV1Exist(this.componentsCRDName)) { + if (await this.kubeHelper.isCRDV1Exists(this.componentsCRDName)) { await this.kubeHelper.deleteCRDV1(this.componentsCRDName) } - if (await this.kubeHelper.CRDV1Exist(this.devworkspacesCRDName)) { + if (await this.kubeHelper.isCRDV1Exists(this.devworkspacesCRDName)) { await this.kubeHelper.deleteCRDV1(this.devworkspacesCRDName) } - if (await this.kubeHelper.CRDV1Exist(this.devworkspacetemplatesCRDName)) { + if (await this.kubeHelper.isCRDV1Exists(this.devworkspacetemplatesCRDName)) { await this.kubeHelper.deleteCRDV1(this.devworkspacetemplatesCRDName) } - if (await this.kubeHelper.CRDV1Exist(this.workspaceroutingsCRDName)) { + if (await this.kubeHelper.isCRDV1Exists(this.workspaceroutingsCRDName)) { await this.kubeHelper.deleteCRDV1(this.workspaceroutingsCRDName) } task.title = await `${task.title}...OK`