Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Flavius Lacatusu <flacatus@redhat.com>
  • Loading branch information
flacatus committed Feb 17, 2021
1 parent 3cdef7b commit 40ffd83
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 25 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/e2e-minikube-devworkspace.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 8 additions & 10 deletions src/api/kube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ export class KubeHelper {
}
}

async mutatingWebhookConfigurationExist(name: string): Promise<boolean> {
async isMutatingWebhookConfigurationExists(name: string): Promise<boolean> {
const k8sAdmissionApi = KubeHelper.KUBE_CONFIG.makeApiClient(AdmissionregistrationV1Api)
try {
const { body } = await k8sAdmissionApi.readMutatingWebhookConfiguration(name)
Expand All @@ -446,7 +446,7 @@ export class KubeHelper {
}
}

async validatingWebhookConfigurationExist(name: string): Promise<boolean> {
async isValidatingWebhookConfigurationExists(name: string): Promise<boolean> {
const k8sAdmissionApi = KubeHelper.KUBE_CONFIG.makeApiClient(AdmissionregistrationV1Api)
try {
const { body } = await k8sAdmissionApi.readValidatingWebhookConfiguration(name)
Expand Down Expand Up @@ -978,7 +978,7 @@ export class KubeHelper {
}
}

async configMapExist(name: string, namespace: string): Promise<boolean> {
async isConfigMapExists(name: string, namespace: string): Promise<boolean> {
const k8sApi = KubeHelper.KUBE_CONFIG.makeApiClient(CoreV1Api)
try {
const { body } = await k8sApi.readNamespacedConfigMap(name, namespace)
Expand Down Expand Up @@ -1437,7 +1437,7 @@ export class KubeHelper {
}
}

async CRDV1Exist(name: string): Promise<boolean> {
async isCRDV1Exists(name: string): Promise<boolean> {
const k8sApiextensionsApi = KubeHelper.KUBE_CONFIG.makeApiClient(ApiextensionsV1Api)
try {
const { body } = await k8sApiextensionsApi.readCustomResourceDefinition(name)
Expand Down Expand Up @@ -2060,7 +2060,7 @@ export class KubeHelper {
}
}

async namespacedCertificateExists(name: string, version: string, namespace: string): Promise<boolean> {
async isNamespacedCertificateExists(name: string, version: string, namespace: string): Promise<boolean> {
const customObjectsApi = KubeHelper.KUBE_CONFIG.makeApiClient(CustomObjectsApi)

try {
Expand All @@ -2076,25 +2076,23 @@ export class KubeHelper {
}
}

async deleteNamespacedCertificate(name: string, version: string, namespace: string): Promise<boolean> {
async deleteNamespacedCertificate(name: string, version: string, namespace: string): Promise<void> {
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<boolean> {
async deleteNamespacedIssuer(name: string, version: string, namespace: string): Promise<void> {
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)
}
Expand Down Expand Up @@ -2140,7 +2138,7 @@ export class KubeHelper {
}
}

async certificateIssuerExists(name: string, version: string, namespace: string): Promise<boolean> {
async isCertificateIssuerExists(name: string, version: string, namespace: string): Promise<boolean> {
const customObjectsApi = KubeHelper.KUBE_CONFIG.makeApiClient(CustomObjectsApi)

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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`
Expand All @@ -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`
Expand All @@ -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`
Expand Down

0 comments on commit 40ffd83

Please sign in to comment.