Skip to content

Commit

Permalink
Remove not actual openshift oAuth auto detection. (#1038)
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
  • Loading branch information
AndrienkoAleksandr committed Dec 21, 2020
1 parent d1fe7e6 commit 06243fa
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 52 deletions.
3 changes: 0 additions & 3 deletions src/api/kube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1374,9 +1374,6 @@ export class KubeHelper {
merge(cheClusterCR, ctx.crPatch)
}

// Back off some configuration properties(chectl estimated them like not working or not desired)
merge(cheClusterCR, ctx.CROverrides)

const customObjectsApi = KubeHelper.KUBE_CONFIG.makeApiClient(CustomObjectsApi)
try {
const { body } = await customObjectsApi.createNamespacedCustomObject('org.eclipse.che', 'v1', cheNamespace, 'checlusters', cheClusterCR)
Expand Down
2 changes: 0 additions & 2 deletions src/commands/server/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { DevWorkspaceTasks } from '../../tasks/component-installers/devfile-work
import { getPrintHighlightedMessagesTask, getRetrieveKeycloakCredentialsTask, retrieveCheCaCertificateTask } from '../../tasks/installers/common-tasks'
import { InstallerTasks } from '../../tasks/installers/installer'
import { ApiTasks } from '../../tasks/platforms/api'
import { CommonPlatformTasks } from '../../tasks/platforms/common-platform-tasks'
import { PlatformTasks } from '../../tasks/platforms/platform'
import { getCommandErrorMessage, getCommandSuccessMessage, isOpenshiftPlatformFamily, notifyCommandCompletedSuccessfully } from '../../util'

Expand Down Expand Up @@ -346,7 +345,6 @@ export default class Deploy extends Command {

// Platform Checks
let platformCheckTasks = new Listr(platformTasks.preflightCheckTasks(flags, this), ctx.listrOptions)
platformCheckTasks.add(CommonPlatformTasks.oAuthProvidersExists(flags))

// Checks if Eclipse Che is already deployed
let preInstallTasks = new Listr(undefined, ctx.listrOptions)
Expand Down
2 changes: 0 additions & 2 deletions src/commands/server/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { DEFAULT_CHE_OPERATOR_IMAGE, SUBSCRIPTION_NAME } from '../../constants'
import { getPrintHighlightedMessagesTask } from '../../tasks/installers/common-tasks'
import { InstallerTasks } from '../../tasks/installers/installer'
import { ApiTasks } from '../../tasks/platforms/api'
import { CommonPlatformTasks } from '../../tasks/platforms/common-platform-tasks'
import { getCommandErrorMessage, getCommandSuccessMessage, getCurrentChectlName, getCurrentChectlVersion, getImageTag, getLatestChectlVersion, notifyCommandCompletedSuccessfully } from '../../util'

export default class Update extends Command {
Expand Down Expand Up @@ -104,7 +103,6 @@ export default class Update extends Command {
const apiTasks = new ApiTasks()
const preUpdateTasks = new Listr([], ctx.listrOptions)
preUpdateTasks.add(apiTasks.testApiTasks(flags, this))
preUpdateTasks.add(CommonPlatformTasks.oAuthProvidersExists(flags))
preUpdateTasks.add(installerTasks.preUpdateTasks(flags, this))

// update tasks
Expand Down
45 changes: 0 additions & 45 deletions src/tasks/platforms/common-platform-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/

import ansi = require('ansi-colors')
import * as http from 'http'
import * as https from 'https'
import * as Listr from 'listr'

import { KubeHelper } from '../../api/kube'
import { DOCS_LINK_HOW_TO_ADD_IDENTITY_PROVIDER_OS4, DOCS_LINK_HOW_TO_CREATE_USER_OS3 } from '../../constants'

export namespace CommonPlatformTasks {
/**
* Checks whether cluster on which Che is being deployed accessible.
Expand Down Expand Up @@ -75,45 +71,4 @@ export namespace CommonPlatformTasks {
})
})
}

export function oAuthProvidersExists(flags: any): Listr.ListrTask {
let kube = new KubeHelper(flags)
return {
title: 'Verify Openshift oauth.',
enabled: (ctx: any) => ctx.isOpenShift && isOAuthEnabled(ctx),
task: async (ctx: any, task: any) => {
if (ctx.isOpenShift4) {
const providers = await kube.getOpenshiftAuthProviders()
if (!providers || providers.length === 0) {
ctx.highlightedMessages.push(`❗ ${ansi.yellow('[WARNING]')} OpenShift OAuth is turned off, because there is no any identity providers configured. ${DOCS_LINK_HOW_TO_ADD_IDENTITY_PROVIDER_OS4}`)
ctx.CROverrides = { spec: { auth: { openShiftoAuth: false } } }
}
} else {
if (await kube.getUsersNumber() === 0) {
ctx.highlightedMessages.push(`❗ ${ansi.yellow('[WARNING]')} OpenShift OAuth is turned off, because there are no any users added. See: "${DOCS_LINK_HOW_TO_CREATE_USER_OS3}"`)
ctx.CROverrides = { spec: { auth: { openShiftoAuth: false } } }
}
}
task.title = `${task.title}...done.`
}
}
}

/**
* Checks if Openshift oAuth enabled in Che configuration.
* Returns true if Openshift oAuth is enabled (or omitted) and false if it is explicitly disabled.
*/
function isOAuthEnabled(ctx: any): boolean {
const crPatch = ctx.crPatch
if (crPatch && crPatch.spec && crPatch.spec.auth && typeof crPatch.spec.auth.openShiftoAuth === 'boolean') {
return crPatch.spec.auth.openShiftoAuth
}

const customCR = ctx.customCR
if (customCR && customCR.spec && customCR.spec.auth && typeof customCR.spec.auth.openShiftoAuth === 'boolean') {
return customCR.spec.auth.openShiftoAuth
}

return true
}
}

0 comments on commit 06243fa

Please sign in to comment.