Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allows to override default values #508

Merged
merged 4 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ OPTIONS
-t, --templates=templates
[default: templates] Path to the templates folder

--che-operator-cr-patch-yaml=che-operator-cr-patch-yaml
Path to a yaml file that overrides the default values in CheCluster CR used by the operator. This parameter is used
only when the installer is the operator.

--che-operator-cr-yaml=che-operator-cr-yaml
Path to a yaml file that defines a CheCluster used by the operator. This parameter is used only when the installer
is the operator.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"fs-extra": "^8.1.0",
"listr": "^0.14.3",
"listr-verbose-renderer": "^0.6.0",
"lodash": "^4.17.13",
"mkdirp": "^0.5.1",
"node-notifier": "^6.0.0",
"tslib": "^1"
Expand Down
14 changes: 13 additions & 1 deletion src/api/kube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { cli } from 'cli-ux'
import * as fs from 'fs'
import https = require('https')
import * as yaml from 'js-yaml'
import { merge } from 'lodash'
import * as net from 'net'
import { Writable } from 'stream'

Expand Down Expand Up @@ -949,9 +950,11 @@ export class KubeHelper {

async createCheClusterFromFile(filePath: string, flags: any, useDefaultCR: boolean) {
let yamlCr = this.safeLoadFromYamlFile(filePath)
yamlCr = this.overrideDefaultValues(yamlCr, flags['che-operator-cr-patch-yaml'])

const cheNamespace = flags.chenamespace
if (useDefaultCR) {
// If we don't use an explicitely provided CheCluster CR,
// If we don't use an explicitly provided CheCluster CR,
// then let's modify the default example CR with values
// derived from the other parameters
const cheImage = flags.cheimage
Expand Down Expand Up @@ -1001,6 +1004,15 @@ export class KubeHelper {
}
}

overrideDefaultValues(yamlCr: any, filePath: string): any {
if (filePath) {
const patchCr = this.safeLoadFromYamlFile(filePath)
return merge(yamlCr, patchCr)
} else {
return yamlCr
}
}

async cheClusterExist(name = '', namespace = ''): Promise<boolean> {
const customObjectsApi = this.kc.makeApiClient(CustomObjectsApi)
try {
Expand Down
6 changes: 5 additions & 1 deletion src/commands/server/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ export default class Start extends Command {
description: 'Path to a yaml file that defines a CheCluster used by the operator. This parameter is used only when the installer is the operator.',
default: ''
}),
'che-operator-cr-patch-yaml': string({
description: 'Path to a yaml file that overrides the default values in CheCluster CR used by the operator. This parameter is used only when the installer is the operator.',
default: ''
}),
directory: string({
char: 'd',
description: 'Directory to store logs into',
Expand All @@ -131,7 +135,7 @@ export default class Start extends Command {
'skip-version-check': flags.boolean({
description: 'Skip minimal versions check.',
default: false
}),
})
}

static getTemplatesDir(): string {
Expand Down