Skip to content

Commit

Permalink
fix: allow namespace to be created during chart install
Browse files Browse the repository at this point in the history
Signed-off-by: Lenin Mehedy <lenin.mehedy@swirldslabs.com>
  • Loading branch information
leninmehedy committed Jan 24, 2024
1 parent 6956df2 commit e9555a2
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
8 changes: 4 additions & 4 deletions fullstack-network-manager/src/commands/chart.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion fullstack-network-manager/src/core/chart_manager.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand Down
3 changes: 0 additions & 3 deletions fullstack-network-manager/src/core/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
1 change: 1 addition & 0 deletions fullstack-network-manager/src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 0 additions & 2 deletions fullstack-network-manager/test/e2e/core/k8_e2e.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand Down

0 comments on commit e9555a2

Please sign in to comment.