@contrail/cli 3.8.0 → 3.9.0-alpha.750305e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +244 -83
- package/dist/auth/login.js +3 -1
- package/dist/auth/login.spec.js +22 -0
- package/dist/baseFlags.d.ts +4 -0
- package/dist/baseFlags.js +9 -1
- package/dist/basecommand.d.ts +7 -0
- package/dist/basecommand.js +17 -2
- package/dist/basecommand.spec.d.ts +1 -0
- package/dist/basecommand.spec.js +97 -0
- package/dist/commands/app/create.d.ts +1 -0
- package/dist/commands/app/delete.d.ts +1 -0
- package/dist/commands/app/extension/deploy.d.ts +1 -0
- package/dist/commands/app/extension/deployment/list.d.ts +1 -0
- package/dist/commands/app/getApiKey.d.ts +1 -0
- package/dist/commands/app/init.d.ts +1 -0
- package/dist/commands/app/install.d.ts +1 -0
- package/dist/commands/app/publish.d.ts +1 -0
- package/dist/commands/app/uninstall.d.ts +1 -0
- package/dist/commands/app/upgrade.d.ts +1 -0
- package/dist/commands/app/version/major.d.ts +1 -0
- package/dist/commands/app/version/minor.d.ts +1 -0
- package/dist/commands/app/version/patch.d.ts +1 -0
- package/dist/commands/app/version/premajor.d.ts +1 -0
- package/dist/commands/app/version/preminor.d.ts +1 -0
- package/dist/commands/app/version/prepatch.d.ts +1 -0
- package/dist/commands/app/version/prerelease.d.ts +1 -0
- package/dist/commands/config/create.d.ts +3 -3
- package/dist/commands/config/create.js +2 -3
- package/dist/commands/config/describe.d.ts +3 -3
- package/dist/commands/config/describe.js +8 -7
- package/dist/commands/config/list.d.ts +3 -3
- package/dist/commands/config/list.js +10 -6
- package/dist/commands/config/set.d.ts +2 -3
- package/dist/commands/config/set.js +12 -9
- package/dist/commands/config/use.d.ts +3 -3
- package/dist/commands/config/use.js +5 -3
- package/dist/commands/entities/create.d.ts +1 -0
- package/dist/commands/entities/delete.d.ts +1 -0
- package/dist/commands/entities/get.d.ts +1 -0
- package/dist/commands/entities/update.d.ts +1 -0
- package/dist/commands/feature-flags/export.d.ts +1 -0
- package/dist/commands/feature-flags/import.d.ts +1 -0
- package/dist/commands/file/upload.d.ts +1 -0
- package/dist/commands/groups/export.d.ts +1 -0
- package/dist/commands/groups/import.d.ts +1 -0
- package/dist/commands/instance/export.d.ts +1 -0
- package/dist/commands/instance/import.d.ts +1 -0
- package/dist/commands/load/colors.d.ts +1 -0
- package/dist/commands/load/custom-entity.d.ts +1 -0
- package/dist/commands/load/line-sheet.d.ts +1 -0
- package/dist/commands/load/upload-and-load.d.ts +1 -0
- package/dist/commands/load-local/index.d.ts +1 -0
- package/dist/commands/login.d.ts +1 -0
- package/dist/commands/org-config/export.d.ts +1 -0
- package/dist/commands/org-config/import.d.ts +1 -0
- package/dist/commands/projects/export.d.ts +1 -0
- package/dist/commands/projects/list.d.ts +1 -0
- package/dist/commands/projects/load.d.ts +1 -0
- package/dist/commands/types/exportOptionSetHierarchies.d.ts +1 -0
- package/dist/commands/types/getAll.d.ts +1 -0
- package/dist/commands/types/getOptionSets.d.ts +1 -0
- package/dist/commands/types/loadAll.d.ts +1 -0
- package/dist/commands/types/mergeOptionSets.d.ts +1 -0
- package/dist/commands/types/mergeTypeProperties.d.ts +1 -0
- package/dist/commands/types/parseOptionSetsHierarchyLocalFile.d.ts +1 -0
- package/dist/commands/types/parseOptionSetsHierarchyValuesToKeysLocalFile.d.ts +1 -0
- package/dist/commands/types/parseOptionSetsLocalFiles.d.ts +1 -0
- package/dist/commands/types/parseOptionSetsToFolderStructure.d.ts +1 -0
- package/dist/commands/types/parseTypesFromFiles.d.ts +1 -0
- package/dist/commands/types/parseTypesFromLocalFiles.d.ts +1 -0
- package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.d.ts +1 -0
- package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.d.ts +1 -0
- package/dist/commands/types/uploadOptionSetHierarchies.d.ts +1 -0
- package/dist/commands/types/uploadOptionSets.d.ts +1 -0
- package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.d.ts +1 -0
- package/dist/commands/types/uploadRuleSets.d.ts +1 -0
- package/dist/commands/types/uploadTypeOverrides.d.ts +1 -0
- package/dist/commands/types/uploadTypePolicies.d.ts +1 -0
- package/dist/commands/types/uploadTypePropertyPolicies.d.ts +1 -0
- package/dist/commands/types/uploadTypes.d.ts +1 -0
- package/dist/commands/users/export.d.ts +1 -0
- package/dist/commands/users/import.d.ts +1 -0
- package/dist/commands/webhooks/create.d.ts +1 -0
- package/dist/commands/webhooks/delete.d.ts +1 -0
- package/dist/commands/webhooks/getWebhookTrigger.d.ts +1 -0
- package/dist/commands/webhooks/list.d.ts +1 -0
- package/dist/commands/workflow-template-definitions/install.d.ts +1 -0
- package/dist/commands/workflow-template-definitions/list.d.ts +1 -0
- package/dist/commands/workflow-templates/delete.d.ts +1 -0
- package/dist/commands/workflow-templates/export.d.ts +1 -0
- package/dist/commands/workflow-templates/list.d.ts +1 -0
- package/dist/commands/workflow-templates/load.d.ts +1 -0
- package/dist/helpers/config/config.d.ts +11 -2
- package/dist/helpers/config/config.js +73 -40
- package/dist/helpers/config/config.spec.d.ts +1 -0
- package/dist/helpers/config/config.spec.js +104 -0
- package/dist/helpers/config/redact-tokens.d.ts +1 -0
- package/dist/helpers/config/redact-tokens.js +14 -0
- package/dist/helpers/config/redact-tokens.spec.d.ts +1 -0
- package/dist/helpers/config/redact-tokens.spec.js +24 -0
- package/oclif.manifest.json +549 -9
- package/package.json +1 -1
package/dist/auth/login.js
CHANGED
|
@@ -171,7 +171,9 @@ async function authenticateWithApiKey(config, apiKey, orgSlug) {
|
|
|
171
171
|
};
|
|
172
172
|
(0, sdk_1.setConfig)(sdk_1.Auth.config);
|
|
173
173
|
await (0, sdk_1.getCurrentUser)();
|
|
174
|
-
|
|
174
|
+
await (0, config_1.storeConfig)({ orgSlug, apiGateway });
|
|
175
|
+
await (0, config_1.clearStoredApiKey)();
|
|
176
|
+
return Object.assign({}, sdk_1.Auth.config);
|
|
175
177
|
}
|
|
176
178
|
async function authenticateWithUsernamePassword(params) {
|
|
177
179
|
const cognitoConfig = COGNITO_CONFIGS[params.environment];
|
package/dist/auth/login.spec.js
CHANGED
|
@@ -23,6 +23,7 @@ jest.mock('../helpers/config/config', () => ({
|
|
|
23
23
|
...jest.requireActual('../helpers/config/config'),
|
|
24
24
|
getConfig: jest.fn(),
|
|
25
25
|
storeConfig: jest.fn(),
|
|
26
|
+
clearStoredApiKey: jest.fn(),
|
|
26
27
|
}));
|
|
27
28
|
jest.mock('../logger', () => ({
|
|
28
29
|
__esModule: true,
|
|
@@ -130,6 +131,27 @@ describe('authUser with email and password', () => {
|
|
|
130
131
|
expect(config_1.storeConfig).not.toHaveBeenCalled();
|
|
131
132
|
});
|
|
132
133
|
});
|
|
134
|
+
describe('authUser with an API key', () => {
|
|
135
|
+
const originalApiKey = process.env.CONTRAIL_CLI_API_KEY;
|
|
136
|
+
beforeEach(() => {
|
|
137
|
+
jest.clearAllMocks();
|
|
138
|
+
process.env.CONTRAIL_CLI_API_KEY = 'api-key-from-env';
|
|
139
|
+
config_1.getConfig.mockResolvedValue({ apiGateway: DEV_GATEWAY, orgSlug: 'adam-zone-1' });
|
|
140
|
+
sdk_1.getCurrentUser.mockResolvedValue({ id: 'user-1' });
|
|
141
|
+
});
|
|
142
|
+
afterEach(() => {
|
|
143
|
+
restoreEnv('CONTRAIL_CLI_API_KEY', originalApiKey);
|
|
144
|
+
});
|
|
145
|
+
it('should sign in with the key and save only the org and environment', async () => {
|
|
146
|
+
const context = await (0, login_1.authUser)();
|
|
147
|
+
expect(context).toMatchObject({ apiUserToken: 'api-key-from-env', orgSlug: 'adam-zone-1' });
|
|
148
|
+
expect(config_1.storeConfig).toHaveBeenCalledWith({ orgSlug: 'adam-zone-1', apiGateway: DEV_GATEWAY });
|
|
149
|
+
});
|
|
150
|
+
it('should clear an API key that an earlier version saved', async () => {
|
|
151
|
+
await (0, login_1.authUser)();
|
|
152
|
+
expect(config_1.clearStoredApiKey).toHaveBeenCalled();
|
|
153
|
+
});
|
|
154
|
+
});
|
|
133
155
|
describe('authUser with stored tokens', () => {
|
|
134
156
|
const originalFetch = global.fetch;
|
|
135
157
|
const originalEmail = process.env.CONTRAIL_CLI_EMAIL;
|
package/dist/baseFlags.d.ts
CHANGED
|
@@ -4,7 +4,11 @@ export declare const LogLevelFlag: {
|
|
|
4
4
|
export declare const AlwaysConfirmEnvFlag: {
|
|
5
5
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
6
|
};
|
|
7
|
+
export declare const ConfigFlag: {
|
|
8
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
};
|
|
7
10
|
export declare const baseFlags: {
|
|
11
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
12
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
13
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
14
|
};
|
package/dist/baseFlags.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.baseFlags = exports.AlwaysConfirmEnvFlag = exports.LogLevelFlag = void 0;
|
|
3
|
+
exports.baseFlags = exports.ConfigFlag = exports.AlwaysConfirmEnvFlag = exports.LogLevelFlag = void 0;
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
5
|
exports.LogLevelFlag = {
|
|
6
6
|
logLevel: core_1.Flags.string({
|
|
@@ -19,7 +19,15 @@ exports.AlwaysConfirmEnvFlag = {
|
|
|
19
19
|
options: ['true', 'false'],
|
|
20
20
|
}),
|
|
21
21
|
};
|
|
22
|
+
exports.ConfigFlag = {
|
|
23
|
+
config: core_1.Flags.string({
|
|
24
|
+
description: 'The config to use for this command. Defaults to the one chosen with `contrail config use`.',
|
|
25
|
+
required: false,
|
|
26
|
+
env: 'CONTRAIL_CLI_CONFIG',
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
22
29
|
exports.baseFlags = {
|
|
23
30
|
...exports.LogLevelFlag,
|
|
24
31
|
...exports.AlwaysConfirmEnvFlag,
|
|
32
|
+
...exports.ConfigFlag,
|
|
25
33
|
};
|
package/dist/basecommand.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ export declare abstract class BaseCommand extends Command {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
skipValidateEnv: boolean;
|
|
5
5
|
skipConfirmEnv: boolean;
|
|
6
|
+
shouldSelectConfigAtStart: boolean;
|
|
6
7
|
static baseFlags: {
|
|
8
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
9
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
10
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
11
|
};
|
|
@@ -16,3 +18,8 @@ export declare abstract class BaseCommand extends Command {
|
|
|
16
18
|
}): Promise<unknown>;
|
|
17
19
|
private confirmEnv;
|
|
18
20
|
}
|
|
21
|
+
export declare abstract class ConfigCommand extends BaseCommand {
|
|
22
|
+
skipConfirmEnv: boolean;
|
|
23
|
+
shouldSelectConfigAtStart: boolean;
|
|
24
|
+
protected getConfigNameFromFlag(): string | undefined;
|
|
25
|
+
}
|
package/dist/basecommand.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseCommand = void 0;
|
|
3
|
+
exports.ConfigCommand = exports.BaseCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const core_1 = require("@oclif/core");
|
|
6
6
|
const common_1 = require("./common");
|
|
@@ -14,6 +14,7 @@ class BaseCommand extends core_1.Command {
|
|
|
14
14
|
static description = 'Global Flags';
|
|
15
15
|
skipValidateEnv = true;
|
|
16
16
|
skipConfirmEnv = false;
|
|
17
|
+
shouldSelectConfigAtStart = true;
|
|
17
18
|
static baseFlags = {
|
|
18
19
|
...baseFlags_1.baseFlags,
|
|
19
20
|
};
|
|
@@ -32,6 +33,10 @@ class BaseCommand extends core_1.Command {
|
|
|
32
33
|
this.flags = flags;
|
|
33
34
|
this.args = args;
|
|
34
35
|
const config = await (0, config_1.readVibeIQConfig)();
|
|
36
|
+
(0, config_1.selectConfigForRun)({ requestedName: flags.config, nameInUse: config?.configInUse });
|
|
37
|
+
if (this.shouldSelectConfigAtStart) {
|
|
38
|
+
await (0, config_1.fetchConfigNameForRun)();
|
|
39
|
+
}
|
|
35
40
|
if (!this.skipValidateEnv) {
|
|
36
41
|
await (0, config_1.validateEnvironments)();
|
|
37
42
|
}
|
|
@@ -70,6 +75,7 @@ class BaseCommand extends core_1.Command {
|
|
|
70
75
|
env = (0, config_1.findEnvironmentName)(data.apiGateway);
|
|
71
76
|
}
|
|
72
77
|
data.environment = env;
|
|
78
|
+
data.config = await (0, config_1.fetchConfigNameForRun)();
|
|
73
79
|
delete data.apiGateway;
|
|
74
80
|
console.table(data);
|
|
75
81
|
const questions = [];
|
|
@@ -82,9 +88,18 @@ class BaseCommand extends core_1.Command {
|
|
|
82
88
|
});
|
|
83
89
|
const { confirm } = await (0, common_1.promptOnStderr)(questions);
|
|
84
90
|
if (confirm === 'no') {
|
|
85
|
-
logger_1.default.info('
|
|
91
|
+
logger_1.default.info('Pass --config <name> or set CONTRAIL_CLI_CONFIG to pick a configuration, or use `contrail config set --environment=prod` to set a different environment.');
|
|
86
92
|
this.exit(1);
|
|
87
93
|
}
|
|
88
94
|
}
|
|
89
95
|
}
|
|
90
96
|
exports.BaseCommand = BaseCommand;
|
|
97
|
+
class ConfigCommand extends BaseCommand {
|
|
98
|
+
skipConfirmEnv = true;
|
|
99
|
+
shouldSelectConfigAtStart = false;
|
|
100
|
+
getConfigNameFromFlag() {
|
|
101
|
+
const isConfigFlagPassed = this.argv.some((arg) => arg === '--config' || arg.startsWith('--config='));
|
|
102
|
+
return isConfigFlagPassed ? this.flags.config : undefined;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.ConfigCommand = ConfigCommand;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const os_1 = require("os");
|
|
6
|
+
const util_1 = require("util");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const basecommand_1 = require("./basecommand");
|
|
9
|
+
const list_1 = tslib_1.__importDefault(require("./commands/config/list"));
|
|
10
|
+
const describe_1 = tslib_1.__importDefault(require("./commands/config/describe"));
|
|
11
|
+
const set_1 = tslib_1.__importDefault(require("./commands/config/set"));
|
|
12
|
+
const config_1 = require("./helpers/config/config");
|
|
13
|
+
jest.mock('node:os', () => {
|
|
14
|
+
const actualOs = jest.requireActual('node:os');
|
|
15
|
+
return {
|
|
16
|
+
...actualOs,
|
|
17
|
+
homedir: () => `${actualOs.tmpdir()}/contrail-cli-basecommand-${process.pid}`,
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
jest.mock('./logger', () => ({
|
|
21
|
+
__esModule: true,
|
|
22
|
+
default: { debug: jest.fn(), info: jest.fn(), warn: jest.fn(), error: jest.fn() },
|
|
23
|
+
}));
|
|
24
|
+
class ConfigNameCommand extends basecommand_1.BaseCommand {
|
|
25
|
+
skipConfirmEnv = true;
|
|
26
|
+
static flags = { ...basecommand_1.BaseCommand.baseFlags };
|
|
27
|
+
async run() {
|
|
28
|
+
return (0, config_1.fetchConfigNameForRun)();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const PACKAGE_ROOT = (0, path_1.resolve)(__dirname, '..');
|
|
32
|
+
const home = (0, path_1.join)((0, os_1.tmpdir)(), `contrail-cli-basecommand-${process.pid}`);
|
|
33
|
+
describe('config selection on a command', () => {
|
|
34
|
+
const originalConfigEnv = process.env.CONTRAIL_CLI_CONFIG;
|
|
35
|
+
let configDir;
|
|
36
|
+
const writeJson = (name, content) => (0, fs_1.writeFileSync)((0, path_1.join)(configDir, `${name}.json`), JSON.stringify(content));
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
configDir = (0, path_1.join)(home, '.vibeiq', 'configs');
|
|
39
|
+
(0, fs_1.mkdirSync)(configDir, { recursive: true });
|
|
40
|
+
writeJson('config', { configInUse: 'pointer' });
|
|
41
|
+
for (const name of ['pointer', 'from-env', 'from-flag']) {
|
|
42
|
+
writeJson(name, { orgSlug: name });
|
|
43
|
+
}
|
|
44
|
+
delete process.env.CONTRAIL_CLI_CONFIG;
|
|
45
|
+
});
|
|
46
|
+
afterEach(() => {
|
|
47
|
+
if (originalConfigEnv === undefined) {
|
|
48
|
+
delete process.env.CONTRAIL_CLI_CONFIG;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
process.env.CONTRAIL_CLI_CONFIG = originalConfigEnv;
|
|
52
|
+
}
|
|
53
|
+
(0, fs_1.rmSync)(home, { recursive: true, force: true });
|
|
54
|
+
});
|
|
55
|
+
it('should use the config chosen with config use when no flag or env var is set', async () => {
|
|
56
|
+
expect(await ConfigNameCommand.run([], PACKAGE_ROOT)).toBe('pointer');
|
|
57
|
+
});
|
|
58
|
+
it('should use CONTRAIL_CLI_CONFIG over the config chosen with config use', async () => {
|
|
59
|
+
process.env.CONTRAIL_CLI_CONFIG = 'from-env';
|
|
60
|
+
expect(await ConfigNameCommand.run([], PACKAGE_ROOT)).toBe('from-env');
|
|
61
|
+
});
|
|
62
|
+
it('should use --config over CONTRAIL_CLI_CONFIG', async () => {
|
|
63
|
+
process.env.CONTRAIL_CLI_CONFIG = 'from-env';
|
|
64
|
+
expect(await ConfigNameCommand.run(['--config', 'from-flag'], PACKAGE_ROOT)).toBe('from-flag');
|
|
65
|
+
});
|
|
66
|
+
it('should create the named config when config set names one that does not exist', async () => {
|
|
67
|
+
await set_1.default.run(['--orgSlug', 'acme', '--config', 'new-config'], PACKAGE_ROOT);
|
|
68
|
+
expect(JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(configDir, 'new-config.json')).toString())).toEqual({
|
|
69
|
+
orgSlug: 'acme',
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
it('should fail without creating a config when CONTRAIL_CLI_CONFIG names one that does not exist', async () => {
|
|
73
|
+
process.env.CONTRAIL_CLI_CONFIG = 'misspelled';
|
|
74
|
+
await expect(set_1.default.run(['--orgSlug', 'acme'], PACKAGE_ROOT)).rejects.toThrow('No config named "misspelled"');
|
|
75
|
+
expect((0, fs_1.existsSync)((0, path_1.join)(configDir, 'misspelled.json'))).toBe(false);
|
|
76
|
+
});
|
|
77
|
+
it('should list configs when CONTRAIL_CLI_CONFIG names one that does not exist', async () => {
|
|
78
|
+
process.env.CONTRAIL_CLI_CONFIG = 'misspelled';
|
|
79
|
+
const table = jest.spyOn(console, 'table').mockImplementation(() => undefined);
|
|
80
|
+
await list_1.default.run([], PACKAGE_ROOT);
|
|
81
|
+
expect(table).toHaveBeenCalledWith(expect.arrayContaining([{ Name: 'pointer' }]), ['Name']);
|
|
82
|
+
table.mockRestore();
|
|
83
|
+
});
|
|
84
|
+
it('should describe the config named by --config', async () => {
|
|
85
|
+
const log = jest.spyOn(describe_1.default.prototype, 'log').mockImplementation(() => undefined);
|
|
86
|
+
await describe_1.default.run(['--config', 'from-flag'], PACKAGE_ROOT);
|
|
87
|
+
expect(log).toHaveBeenCalledWith((0, util_1.inspect)({ orgSlug: 'from-flag' }));
|
|
88
|
+
log.mockRestore();
|
|
89
|
+
});
|
|
90
|
+
it('should create the config when --config and CONTRAIL_CLI_CONFIG name the same new one', async () => {
|
|
91
|
+
process.env.CONTRAIL_CLI_CONFIG = 'new-config';
|
|
92
|
+
await set_1.default.run(['--orgSlug', 'acme', '--config', 'new-config'], PACKAGE_ROOT);
|
|
93
|
+
expect(JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(configDir, 'new-config.json')).toString())).toEqual({
|
|
94
|
+
orgSlug: 'acme',
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -3,6 +3,7 @@ export default class CreateApp extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
7
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
};
|
|
@@ -4,6 +4,7 @@ export default class DeleteApp extends BaseCommand {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static strict: boolean;
|
|
6
6
|
static flags: {
|
|
7
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
};
|
|
@@ -5,6 +5,7 @@ export default class DeployExtension extends BaseCommand {
|
|
|
5
5
|
static flags: {
|
|
6
6
|
identifier: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
7
|
debug: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
11
|
};
|
|
@@ -5,6 +5,7 @@ export default class ListExtensionDeployments extends BaseCommand {
|
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
7
7
|
all: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
11
|
};
|
|
@@ -4,6 +4,7 @@ export default class GetAPIKeyApp extends BaseCommand {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
appIdentifier: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
};
|
|
@@ -3,6 +3,7 @@ export default class InitApp extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
7
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
};
|
|
@@ -6,6 +6,7 @@ export default class InstallApp extends BaseCommand {
|
|
|
6
6
|
static flags: {
|
|
7
7
|
appIdentifier: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
8
|
installWorkflowTemplates: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
11
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
12
|
};
|
|
@@ -7,6 +7,7 @@ export default class PublishApp extends BaseCommand {
|
|
|
7
7
|
upgrade: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
8
|
verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
9
|
dryRun: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
11
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
12
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
13
|
};
|
|
@@ -5,6 +5,7 @@ export default class UninstallApp extends BaseCommand {
|
|
|
5
5
|
static strict: boolean;
|
|
6
6
|
static flags: {
|
|
7
7
|
appIdentifier: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
11
|
};
|
|
@@ -6,6 +6,7 @@ export default class UpgradeApp extends BaseCommand {
|
|
|
6
6
|
static flags: {
|
|
7
7
|
appIdentifier: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
8
|
latest: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
11
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
12
|
};
|
|
@@ -4,6 +4,7 @@ export default class AppMajorVersionUpgrade extends BaseCommand {
|
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
7
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
};
|
|
@@ -4,6 +4,7 @@ export default class AppMinorVersionUpgrade extends BaseCommand {
|
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
7
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
};
|
|
@@ -4,6 +4,7 @@ export default class AppPatchVersionUpgrade extends BaseCommand {
|
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
7
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
};
|
|
@@ -4,6 +4,7 @@ export default class AppPremajorVersionUpgrade extends BaseCommand {
|
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
7
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
};
|
|
@@ -4,6 +4,7 @@ export default class AppPreminorVersionUpgrade extends BaseCommand {
|
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
7
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
};
|
|
@@ -4,6 +4,7 @@ export default class AppPrepatchVersionUpgrade extends BaseCommand {
|
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
7
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
};
|
|
@@ -4,6 +4,7 @@ export default class AppPrereleaseVersionUpgrade extends BaseCommand {
|
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
7
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class CreateConfig extends
|
|
1
|
+
import { ConfigCommand } from '../../basecommand';
|
|
2
|
+
export default class CreateConfig extends ConfigCommand {
|
|
3
3
|
static description: string;
|
|
4
|
-
skipConfirmEnv: boolean;
|
|
5
4
|
static examples: string[];
|
|
6
5
|
static flags: {
|
|
7
6
|
name: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
8
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
9
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
10
|
};
|
|
@@ -5,12 +5,11 @@ const config_1 = require("../../helpers/config/config");
|
|
|
5
5
|
const basecommand_1 = require("../../basecommand");
|
|
6
6
|
const core_1 = require("@oclif/core");
|
|
7
7
|
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
8
|
-
class CreateConfig extends basecommand_1.
|
|
8
|
+
class CreateConfig extends basecommand_1.ConfigCommand {
|
|
9
9
|
static description = 'Create a new configuration file';
|
|
10
|
-
skipConfirmEnv = true;
|
|
11
10
|
static examples = ['$ contrail config create --name demo-org'];
|
|
12
11
|
static flags = {
|
|
13
|
-
...basecommand_1.
|
|
12
|
+
...basecommand_1.ConfigCommand.baseFlags,
|
|
14
13
|
name: core_1.Flags.string({ description: 'The config name', required: true }),
|
|
15
14
|
};
|
|
16
15
|
async run() {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class DescribeConfig extends
|
|
1
|
+
import { ConfigCommand } from '../../basecommand';
|
|
2
|
+
export default class DescribeConfig extends ConfigCommand {
|
|
3
3
|
static description: string;
|
|
4
|
-
skipConfirmEnv: boolean;
|
|
5
4
|
static examples: string[];
|
|
6
5
|
static args: {
|
|
7
6
|
name: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
8
7
|
};
|
|
9
8
|
static flags: {
|
|
9
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
10
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
11
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
12
|
};
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
const node_util_1 = require("node:util");
|
|
4
5
|
const config_1 = require("../../helpers/config/config");
|
|
6
|
+
const redact_tokens_1 = require("../../helpers/config/redact-tokens");
|
|
5
7
|
const basecommand_1 = require("../../basecommand");
|
|
6
8
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
7
9
|
const core_1 = require("@oclif/core");
|
|
8
10
|
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
9
|
-
class DescribeConfig extends basecommand_1.
|
|
11
|
+
class DescribeConfig extends basecommand_1.ConfigCommand {
|
|
10
12
|
static description = 'Display the contents of a configuration file';
|
|
11
|
-
skipConfirmEnv = true;
|
|
12
13
|
static examples = ['$ contrail config describe demo-org'];
|
|
13
14
|
static args = {
|
|
14
15
|
name: core_1.Args.string({ description: 'The config name', required: false }),
|
|
15
16
|
};
|
|
16
17
|
static flags = {
|
|
17
|
-
...basecommand_1.
|
|
18
|
+
...basecommand_1.ConfigCommand.baseFlags,
|
|
18
19
|
};
|
|
19
20
|
async run() {
|
|
20
|
-
let configName = this.args.name;
|
|
21
|
+
let configName = this.args.name ?? this.getConfigNameFromFlag();
|
|
21
22
|
const arrConfigFiles = await (0, config_1.getConfigFiles)();
|
|
22
|
-
if (
|
|
23
|
+
if (configName && !arrConfigFiles.includes(configName)) {
|
|
23
24
|
logger_1.default.error(`No config found with name ${configName}`);
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
26
|
-
if (!
|
|
27
|
+
if (!configName) {
|
|
27
28
|
const questions = [
|
|
28
29
|
{
|
|
29
30
|
type: 'list',
|
|
@@ -40,7 +41,7 @@ class DescribeConfig extends basecommand_1.BaseCommand {
|
|
|
40
41
|
const answers = await inquirer_1.default.prompt(questions);
|
|
41
42
|
configName = answers.configFile;
|
|
42
43
|
}
|
|
43
|
-
this.log(await (0, config_1.getConfigContent)(configName));
|
|
44
|
+
this.log((0, node_util_1.inspect)((0, redact_tokens_1.redactTokens)(await (0, config_1.getConfigContent)(configName))));
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
exports.default = DescribeConfig;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class ListConfig extends
|
|
1
|
+
import { ConfigCommand } from '../../basecommand';
|
|
2
|
+
export default class ListConfig extends ConfigCommand {
|
|
3
3
|
static description: string;
|
|
4
|
-
skipConfirmEnv: boolean;
|
|
5
4
|
static examples: string[];
|
|
6
5
|
static flags: {
|
|
6
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
7
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
8
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
9
|
};
|
|
@@ -4,22 +4,26 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const config_1 = require("../../helpers/config/config");
|
|
5
5
|
const basecommand_1 = require("../../basecommand");
|
|
6
6
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
-
|
|
7
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
8
|
+
class ListConfig extends basecommand_1.ConfigCommand {
|
|
8
9
|
static description = 'List the configurations';
|
|
9
|
-
skipConfirmEnv = true;
|
|
10
10
|
static examples = [
|
|
11
11
|
`$ contrail config list
|
|
12
12
|
`,
|
|
13
13
|
];
|
|
14
14
|
static flags = {
|
|
15
|
-
...basecommand_1.
|
|
15
|
+
...basecommand_1.ConfigCommand.baseFlags,
|
|
16
16
|
};
|
|
17
17
|
async run() {
|
|
18
18
|
// Get all available config files
|
|
19
19
|
const arrConfigFiles = await (0, config_1.getConfigFiles)();
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const activeConfig = await (0, config_1.fetchConfigNameForRun)().catch((error) => {
|
|
21
|
+
if (!(error instanceof config_1.ConfigSelectionError)) {
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
logger_1.default.warn(error.message);
|
|
25
|
+
return '';
|
|
26
|
+
});
|
|
23
27
|
// Create a simpler array of objects with just the names
|
|
24
28
|
const tableData = arrConfigFiles.map((config, index) => {
|
|
25
29
|
return {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class SetConfig extends
|
|
3
|
-
skipConfirmEnv: boolean;
|
|
1
|
+
import { ConfigCommand } from '../../basecommand';
|
|
2
|
+
export default class SetConfig extends ConfigCommand {
|
|
4
3
|
static description: string;
|
|
5
4
|
static examples: string[];
|
|
6
5
|
static flags: {
|
|
@@ -5,12 +5,14 @@ const core_1 = require("@oclif/core");
|
|
|
5
5
|
const config_1 = require("../../helpers/config/config");
|
|
6
6
|
const basecommand_1 = require("../../basecommand");
|
|
7
7
|
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
8
|
-
class SetConfig extends basecommand_1.
|
|
9
|
-
skipConfirmEnv = true;
|
|
8
|
+
class SetConfig extends basecommand_1.ConfigCommand {
|
|
10
9
|
static description = 'Set a variable in the configuration';
|
|
11
|
-
static examples = [
|
|
10
|
+
static examples = [
|
|
11
|
+
'$ contrail config set --orgSlug acme',
|
|
12
|
+
'$ contrail config set --orgSlug acme --config acme-dev',
|
|
13
|
+
];
|
|
12
14
|
static flags = {
|
|
13
|
-
...basecommand_1.
|
|
15
|
+
...basecommand_1.ConfigCommand.baseFlags,
|
|
14
16
|
orgSlug: core_1.Flags.string({ description: 'The org slug', required: false }),
|
|
15
17
|
environment: core_1.Flags.string({
|
|
16
18
|
description: 'The Environment',
|
|
@@ -21,14 +23,15 @@ class SetConfig extends basecommand_1.BaseCommand {
|
|
|
21
23
|
description: 'The API User Token',
|
|
22
24
|
required: false,
|
|
23
25
|
}),
|
|
24
|
-
config: core_1.Flags.string({
|
|
25
|
-
description: 'The config name',
|
|
26
|
-
required: false,
|
|
27
|
-
}),
|
|
28
26
|
};
|
|
29
27
|
static args = {};
|
|
30
28
|
async run() {
|
|
31
29
|
delete this.flags.alwaysConfirmEnv;
|
|
30
|
+
const configName = this.getConfigNameFromFlag();
|
|
31
|
+
delete this.flags.config;
|
|
32
|
+
if (configName && !(await (0, config_1.getConfigFiles)()).includes(configName)) {
|
|
33
|
+
await (0, config_1.createConfig)(configName);
|
|
34
|
+
}
|
|
32
35
|
const config = {};
|
|
33
36
|
for (const [label, obj] of Object.entries(this.flags)) {
|
|
34
37
|
if (label === 'environment') {
|
|
@@ -39,7 +42,7 @@ class SetConfig extends basecommand_1.BaseCommand {
|
|
|
39
42
|
}
|
|
40
43
|
logger_1.default.info(`label: ${label}, value: ${obj}`);
|
|
41
44
|
}
|
|
42
|
-
await (0, config_1.storeConfig)(config
|
|
45
|
+
await (0, config_1.storeConfig)(config);
|
|
43
46
|
logger_1.default.info(`Successfully added/updated configuration`);
|
|
44
47
|
}
|
|
45
48
|
}
|