Skip to content

Commit

Permalink
Add catalog source name and namespace to use external catalog source …
Browse files Browse the repository at this point in the history
…to install Eclipse Che. (#750)

Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
  • Loading branch information
AndrienkoAleksandr committed Jun 19, 2020
1 parent 63b76e8 commit 8e4de97
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ OPTIONS
command.
This parameter is used only when the installer is 'olm'.
--catalog-source-name=catalog-source-name
OLM catalog source to install Eclipse Che operator.
This parameter is used only when the installer is the 'olm'.
--catalog-source-namespace=catalog-source-namespace
Namespace for OLM catalog source to install Eclipse Che operator.
This parameter is used only when the installer is the 'olm'.
--catalog-source-yaml=catalog-source-yaml
Path to a yaml file that describes custom catalog source for installation Eclipse Che operator.
Catalog source will be applied to the namespace with Che operator.
Expand Down
28 changes: 25 additions & 3 deletions src/commands/server/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,25 @@ export default class Start extends Command {
description: `Olm channel to install Eclipse Che, f.e. stable.
If options was not set, will be used default version for package manifest.
This parameter is used only when the installer is the 'olm'.`,
dependsOn: ['catalog-source-yaml']
}),
'package-manifest-name': string({
description: `Package manifest name to subscribe to Eclipse Che OLM package manifest.
This parameter is used only when the installer is the 'olm'.`,
dependsOn: ['catalog-source-yaml']
}),
'catalog-source-yaml': string({
description: `Path to a yaml file that describes custom catalog source for installation Eclipse Che operator.
Catalog source will be applied to the namespace with Che operator.
Also you need define 'olm-channel' name and 'package-manifest-name'.
This parameter is used only when the installer is the 'olm'.`,
}),
'catalog-source-name': string({
description: `OLM catalog source to install Eclipse Che operator.
This parameter is used only when the installer is the 'olm'.`
}),
'catalog-source-namespace': string({
description: `Namespace for OLM catalog source to install Eclipse Che operator.
This parameter is used only when the installer is the 'olm'.`
}),
'skip-kubernetes-health-check': skipK8sHealthCheck
}

Expand Down Expand Up @@ -304,6 +310,15 @@ export default class Start extends Command {
if (flags.installer !== 'olm' && flags['package-manifest-name']) {
this.error('"package-manifest-name" flag should be used only with "olm" installer.')
}
if (flags.installer !== 'olm' && flags['catalog-source-name']) {
this.error('"catalog-source-name" flag should be used only with "olm" installer.')
}
if (flags.installer !== 'olm' && flags['catalog-source-namespace']) {
this.error('"package-manifest-name" flag should be used only with "olm" installer.')
}
if (flags['catalog-source-name'] && flags['catalog-source-yaml']) {
this.error('should be provided only one argument: "catalog-source-name" or "catalog-source-yaml"')
}

if (!flags['package-manifest-name'] && flags['catalog-source-yaml']) {
this.error('you need define "package-manifest-name" flag to use "catalog-source-yaml".')
Expand Down Expand Up @@ -415,7 +430,14 @@ export default class Start extends Command {
*/
async setDefaultInstaller(flags: any): Promise<void> {
const kubeHelper = new KubeHelper(flags)
if (flags.platform === 'openshift' && await kubeHelper.isOpenShift4() && isStableVersion(flags) && await kubeHelper.isPreInstalledOLM()) {

const olmIsPreinstalled = await kubeHelper.isPreInstalledOLM()
if ((flags['catalog-source-name'] || flags['catalog-source-yaml']) && olmIsPreinstalled) {
flags.installer = 'olm'
return
}

if (flags.platform === 'openshift' && await kubeHelper.isOpenShift4() && isStableVersion(flags) && olmIsPreinstalled) {
flags.installer = 'olm'
} else {
flags.installer = 'operator'
Expand Down
7 changes: 4 additions & 3 deletions src/tasks/installers/olm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class OLMTasks {

ctx.approvalStarategy = flags['auto-update'] ? 'Automatic' : 'Manual'

ctx.sourceName = CUSTOM_CATALOG_SOURCE_NAME
ctx.sourceName = flags['catalog-source-name'] || CUSTOM_CATALOG_SOURCE_NAME

task.title = `${task.title}...done.`
}
Expand Down Expand Up @@ -80,10 +80,11 @@ export class OLMTasks {
task.title = `${task.title}...It already exists.`
} else {
let subscription: Subscription
if (!flags['catalog-source-yaml']) {
if (!flags['catalog-source-yaml'] && !flags['catalog-source-name']) {
subscription = this.createSubscription(SUBSCRIPTION_NAME, DEFAULT_CHE_OLM_PACKAGE_NAME, flags.chenamespace, ctx.defaultCatalogSourceNamespace, OLM_STABLE_CHANNEL_NAME, ctx.catalogSourceNameStable, ctx.approvalStarategy, flags['starting-csv'])
} else {
subscription = this.createSubscription(SUBSCRIPTION_NAME, flags['package-manifest-name'], flags.chenamespace, flags.chenamespace, flags['olm-channel'], ctx.sourceName, ctx.approvalStarategy, flags['starting-csv'])
const catalogSourceNamespace = flags['catalog-source-namespace'] || flags.chenamespace
subscription = this.createSubscription(SUBSCRIPTION_NAME, flags['package-manifest-name'], flags.chenamespace, catalogSourceNamespace, flags['olm-channel'], ctx.sourceName, ctx.approvalStarategy, flags['starting-csv'])
}
await kube.createOperatorSubscription(subscription)
task.title = `${task.title}...created new one.`
Expand Down

0 comments on commit 8e4de97

Please sign in to comment.