Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
  • Loading branch information
tolusha committed Dec 10, 2020
1 parent 57c0e9e commit 23f0bd4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/api/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export namespace ChectlContext {
ctx[COMMAND_ID] = command.id
ctx[LOGS_DIRECTORY] = path.resolve(flags[LOG_DIRECTORY_KEY] ? flags[LOG_DIRECTORY_KEY] : path.resolve(os.tmpdir(), 'chectl-logs', Date.now().toString()))

ctx[CUSTOM_CR] = readCRFile(flags, CHE_OPERATOR_CR_YAML_KEY)
ctx[CR_PATCH] = readCRFile(flags, CHE_OPERATOR_CR_PATCH_YAML_KEY)
ctx[CUSTOM_CR] = readCRFile(flags, CHE_OPERATOR_CR_YAML_KEY) || {}
ctx[CR_PATCH] = readCRFile(flags, CHE_OPERATOR_CR_PATCH_YAML_KEY) || {}
}

export async function initAndGet(flags: any, command: Command): Promise<any> {
Expand Down
32 changes: 17 additions & 15 deletions src/commands/server/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,23 @@ export default class Update extends Command {
if (projectName === 'chectl' && latestChectlVersion) {
// suggest update chectl first
if (currentChectlVersion !== latestChectlVersion) {
cli.warn(`'chectl' tool is not up to date.
Update 'chectl' first: 'chectl update ${chectlChannel}' and then try again.`)
} else if (chectlChannel === 'stable' && !flags[CHE_OPERATOR_CR_PATCH_YAML_KEY]) {
cli.warn(`It is not possible to update Eclipse Che to a newer version
using the current '${currentChectlVersion}' version of chectl. Please, update 'chectl'
to a newer version '${latestChectlVersion}' with the command 'chectl update ${chectlChannel}'
and then try again.`)
} else if (!flags[CHE_OPERATOR_CR_PATCH_YAML_KEY]) {
// same version, no patch then nothing to update
cli.info('Eclipse Che is already up to date.')
this.exit(0)
}
} else if (projectName !== 'chectl') {
} else {
// unknown project, no patch file then suggest to update
if (!flags[CHE_OPERATOR_CR_PATCH_YAML_KEY]) {
cli.info(`Update '${getCurrentChectlName()}' first and then try again.`)
cli.warn(`It is not possible to update Eclipse Che to a newer version
using the current '${currentChectlVersion}' version of '${getCurrentChectlName()}'.
Please, update '${getCurrentChectlName()}' and then try again.`)
this.exit(0)
}
} else {
cli.warn('')
}
// custom operator image is used
} else if (newOperatorImage !== DEFAULT_CHE_OPERATOR_IMAGE) {
Expand All @@ -181,43 +183,43 @@ Consider removing '--che-operator-image' to update Eclipse Che operator to the s
const crPatch = ctx[ChectlContext.CR_PATCH]
if (cheCluster.spec.server.pluginRegistryImage
&& (!crPatch.spec || !crPatch.spec.server || !crPatch.spec.server.pluginRegistryImage)) {
imagesListMsg += `- Plugin registry image: ${cheCluster.spec.server.pluginRegistryImage}\n`
imagesListMsg += `\n - Plugin registry image: ${cheCluster.spec.server.pluginRegistryImage}`
merge(ctx[ChectlContext.CR_PATCH], { spec: { server: { pluginRegistryImage: '' } } })
}

if (cheCluster.spec.server.devfileRegistryImage
&& (!crPatch.spec || !crPatch.spec.server || !crPatch.spec.server.devfileRegistryImage)) {
imagesListMsg += `- Devfile registry image: ${cheCluster.spec.server.devfileRegistryImage}\n`
imagesListMsg += `\n - Devfile registry image: ${cheCluster.spec.server.devfileRegistryImage}`
merge(ctx[ChectlContext.CR_PATCH], { spec: { server: { devfileRegistryImage: '' } } })
}

if (cheCluster.spec.server.postgresImage
&& (!crPatch.spec || !crPatch.spec.database || !crPatch.spec.database.postgresImage)) {
imagesListMsg += `- Postgres image: ${cheCluster.spec.database.postgresImage}\n`
imagesListMsg += `\n - Postgres image: ${cheCluster.spec.database.postgresImage}`
merge(ctx[ChectlContext.CR_PATCH], { spec: { database: { postgresImage: '' } } })
}

if (cheCluster.spec.server.identityProviderImage
&& (!crPatch.spec || !crPatch.spec.auth || !crPatch.spec.auth.identityProviderImage)) {
imagesListMsg += `- Identity provider image: ${cheCluster.spec.auth.identityProviderImage}\n`
imagesListMsg += `\n - Identity provider image: ${cheCluster.spec.auth.identityProviderImage}`
merge(ctx[ChectlContext.CR_PATCH], { spec: { auth: { identityProviderImage: '' } } })
}

if (cheCluster.spec.server.cheImage
&& (!crPatch.spec || !crPatch.spec.server || !crPatch.spec.server.cheImage)) {
imagesListMsg += `- Eclipse Che server image name: ${cheCluster.spec.server.cheImage}\n`
imagesListMsg += `\n - Eclipse Che server image name: ${cheCluster.spec.server.cheImage}`
merge(ctx[ChectlContext.CR_PATCH], { spec: { server: { cheImage: '' } } })
}

if (cheCluster.spec.server.cheImageTag
&& (!crPatch.spec || !crPatch.spec.server || !crPatch.spec.server.cheImageTag)) {
imagesListMsg += `- Eclipse Che server image tag: ${cheCluster.spec.server.cheImageTag}\n`
imagesListMsg += `\n - Eclipse Che server image tag: ${cheCluster.spec.server.cheImageTag}`
merge(ctx[ChectlContext.CR_PATCH], { spec: { server: { cheImageTag: '' } } })
}

if (imagesListMsg) {
cli.warn(`In order to update Eclipse Che to a new version the fields defining the images in the '${cheCluster.metadata.name}'
Custom Resource of the namespace '${flags.chenamespace}' will be cleaned up.\n${imagesListMsg}`)
cli.warn(`In order to update Eclipse Che to a newer version the fields defining the images in the '${cheCluster.metadata.name}'
Custom Resource in the '${flags.chenamespace}' namespace will be cleaned up:${imagesListMsg}`)
if (!flags.yes && !await cli.confirm('If you want to continue - press Y')) {
this.exit(0)
}
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2126,19 +2126,19 @@ ecc-jsbn@~0.1.1:

"eclipse-che-devfile-workspace-operator@git://github.com/devfile/devworkspace-operator#master":
version "0.0.0"
resolved "git://github.com/devfile/devworkspace-operator#b1fd56a21bdbb9865163cf46e72569262a5397b7"
resolved "git://github.com/devfile/devworkspace-operator#55769df6e901c37b38384dc231e4abc5fbcdb96e"

"eclipse-che-minishift@git://github.com/minishift/minishift#master":
version "0.0.0"
resolved "git://github.com/minishift/minishift#4b58f8954421fcbb7996ca67cba7ed8c58092a88"

"eclipse-che-operator@git://github.com/eclipse/che-operator#master":
version "0.0.0"
resolved "git://github.com/eclipse/che-operator#f917b982818c46485d2027d531c30067ac2c45e8"
resolved "git://github.com/eclipse/che-operator#ed3df35359b648d19a5a775f3a2e140f5da96933"

"eclipse-che@git://github.com/eclipse/che#master":
version "0.0.0"
resolved "git://github.com/eclipse/che#f817a510e463d4f536fd2a97ca88942f17b31ead"
resolved "git://github.com/eclipse/che#55f29d64afc073125c7c623fe6d5f9ddf09e1100"

editorconfig@^0.15.0:
version "0.15.3"
Expand Down

0 comments on commit 23f0bd4

Please sign in to comment.