From e9555a2427e33a3f0e2a430134666f8445938713 Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Thu, 25 Jan 2024 08:00:20 +1100 Subject: [PATCH] fix: allow namespace to be created during chart install Signed-off-by: Lenin Mehedy --- fullstack-network-manager/src/commands/chart.mjs | 8 ++++---- fullstack-network-manager/src/core/chart_manager.mjs | 2 +- fullstack-network-manager/src/core/constants.mjs | 3 --- fullstack-network-manager/src/index.mjs | 1 + fullstack-network-manager/test/e2e/core/k8_e2e.test.mjs | 2 -- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/fullstack-network-manager/src/commands/chart.mjs b/fullstack-network-manager/src/commands/chart.mjs index 42044f009..7864eef24 100644 --- a/fullstack-network-manager/src/commands/chart.mjs +++ b/fullstack-network-manager/src/commands/chart.mjs @@ -99,10 +99,6 @@ export class ChartCommand extends BaseCommand { config.enableTls, config.tlsClusterIssuerName, config.tlsClusterIssuerNamespace, config.enableHederaExplorerTls, config.acmeClusterIssuer, config.selfSignedClusterIssuer) - if (!await this.k8.hasNamespace(config.namespace)) { - throw new FullstackTestingError(`namespace ${config.namespace} does not exist`) - } - return config } @@ -119,6 +115,10 @@ export class ChartCommand extends BaseCommand { { title: `Install chart '${constants.CHART_FST_DEPLOYMENT_NAME}'`, task: async (ctx, _) => { + if (await self.chartManager.isChartInstalled(ctx.config.namespace, constants.CHART_FST_DEPLOYMENT_NAME)) { + await self.chartManager.uninstall(ctx.config.namespace, constants.CHART_FST_DEPLOYMENT_NAME) + } + await this.chartManager.install( ctx.config.namespace, constants.CHART_FST_DEPLOYMENT_NAME, diff --git a/fullstack-network-manager/src/core/chart_manager.mjs b/fullstack-network-manager/src/core/chart_manager.mjs index 1e8f0b3d8..fd64f98e5 100644 --- a/fullstack-network-manager/src/core/chart_manager.mjs +++ b/fullstack-network-manager/src/core/chart_manager.mjs @@ -65,7 +65,7 @@ export class ChartManager { let namespaceArg = '' if (namespaceName) { - namespaceArg = `-n ${namespaceName}` + namespaceArg = `-n ${namespaceName} --create-namespace` } this.logger.debug(`> installing chart:${chartPath}`) diff --git a/fullstack-network-manager/src/core/constants.mjs b/fullstack-network-manager/src/core/constants.mjs index aa125bc51..2b6b4c00d 100644 --- a/fullstack-network-manager/src/core/constants.mjs +++ b/fullstack-network-manager/src/core/constants.mjs @@ -12,9 +12,6 @@ export const FST_HOME_DIR = `${process.env.HOME}/.fsnetman` export const FST_LOGS_DIR = `${FST_HOME_DIR}/logs` export const FST_CACHE_DIR = `${FST_HOME_DIR}/cache` export const DEFAULT_NAMESPACE = 'default' -export const RELEASE_NAME = 'fst' -export const NAMESPACE_NAME = `fst-${USER_SANITIZED}` - export const HELM = 'helm' export const CWD = process.cwd() export const FST_CONFIG_FILE = `${FST_HOME_DIR}/fsnetman.config` diff --git a/fullstack-network-manager/src/index.mjs b/fullstack-network-manager/src/index.mjs index b6c385027..b9b255f95 100644 --- a/fullstack-network-manager/src/index.mjs +++ b/fullstack-network-manager/src/index.mjs @@ -43,6 +43,7 @@ export function main (argv) { logger.showUser(chalk.cyan('Version\t\t\t:'), chalk.yellow(configManager.getVersion())) logger.showUser(chalk.cyan('Kubernetes Context\t:'), chalk.yellow(context.name)) logger.showUser(chalk.cyan('Kubernetes Cluster\t:'), chalk.yellow(configManager.getFlag(flags.clusterName))) + logger.showUser(chalk.cyan('Kubernetes Namespace\t:'), chalk.yellow(configManager.getFlag(flags.namespace))) logger.showUser(chalk.green('-------------------------------------------------------------------------------\n')) const opts = { diff --git a/fullstack-network-manager/test/e2e/core/k8_e2e.test.mjs b/fullstack-network-manager/test/e2e/core/k8_e2e.test.mjs index 8833d5ffa..c4e63667a 100644 --- a/fullstack-network-manager/test/e2e/core/k8_e2e.test.mjs +++ b/fullstack-network-manager/test/e2e/core/k8_e2e.test.mjs @@ -17,7 +17,6 @@ describe('K8', () => { it('should be able to list clusters', async () => { const clusters = await k8.getClusters() expect(clusters).not.toHaveLength(0) - expect(clusters).toContain('default') }) it('should be able to list namespaces', async () => { @@ -29,7 +28,6 @@ describe('K8', () => { it('should be able to list contexts', async () => { const contexts = await k8.getContexts() expect(contexts).not.toHaveLength(0) - expect(contexts).not.toHaveLength(0) }) it('should be able to create and delete a namespaces', async () => {