Skip to content

Commit

Permalink
update cluster issuer type
Browse files Browse the repository at this point in the history
Signed-off-by: Jeromy Cannon <jeromy@swirldslabs.com>
  • Loading branch information
jeromy-cannon committed Jan 26, 2024
1 parent 55fb30e commit 91d163e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 22 deletions.
10 changes: 5 additions & 5 deletions fullstack-network-manager/src/commands/flags.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ export const operatorKey = {
}
}

export const tlsClusterIssuerName = { // tlsClusterIssuerType
name: 'tls-cluster-issuer-name',
definition: { // TODO fix
describe: 'The name of the TLS cluster issuer to use for gateway services, defaults to "self-signed-ca", another option for the acme-cluster-issuer is "letsencrypt-staging" and "letsencrypt-prod"',
export const tlsClusterIssuerType = {
name: 'tls-cluster-issuer-type',
definition: {
describe: 'The TLS cluster issuer type to use for hedera explorer, defaults to "self-signed", the available options are: "acme-staging", "acme-prod", or "self-signed"',
default: 'self-signed',
type: 'string'
}
Expand Down Expand Up @@ -285,7 +285,7 @@ export const allFlags = [
chainId,
operatorId,
operatorKey,
tlsClusterIssuerName,
tlsClusterIssuerType,
enableHederaExplorerTls,
deletePvcs
]
43 changes: 30 additions & 13 deletions fullstack-network-manager/src/commands/network.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,27 @@ import { constants, Templates } from '../core/index.mjs'
import * as prompts from './prompts.mjs'

export class NetworkCommand extends BaseCommand {
getTlsValueArguments (tlsClusterIssuerName, enableHederaExplorerTls) {
// TODO rebuild
getTlsValueArguments (tlsClusterIssuerType, enableHederaExplorerTls, namespace) {
let valuesArg = ''

if (enableHederaExplorerTls) {
if (!['acme-staging', 'acme-prod', 'self-signed'].includes(tlsClusterIssuerType)) {
throw new Error(`Invalid TLS cluster issuer type: ${tlsClusterIssuerType}, must be one of: "acme-staging", "acme-prod", or "self-signed"`)
}

// return valuesArg
valuesArg += ' --set hedera-explorer.ingress.enabled=true'
valuesArg += ' --set cloud.haproxyIngressController.enabled=true'
valuesArg += ` --set global.ingressClassName=${namespace}-hedera-explorer-ingress-class`

if (tlsClusterIssuerType === 'self-signed') {
valuesArg += ' --set cloud.selfSignedClusterIssuer.enabled=true'
} else {
valuesArg += ' --set cloud.acmeClusterIssuer.enabled=true'
valuesArg += ` --set hedera-explorer.certClusterIssuerType=${tlsClusterIssuerType}"`
}
}

return valuesArg
}

prepareValuesFiles (valuesFile) {
Expand All @@ -28,8 +45,8 @@ export class NetworkCommand extends BaseCommand {
return valuesArg
}

prepareValuesArg (chartDir, valuesFile, deployMirrorNode, deployHederaExplorer, tlsClusterIssuerName,
enableHederaExplorerTls) {
prepareValuesArg (chartDir, valuesFile, deployMirrorNode, deployHederaExplorer, tlsClusterIssuerType,
enableHederaExplorerTls, namespace) {
let valuesArg = ''
if (chartDir) {
valuesArg = `-f ${chartDir}/fullstack-deployment/values.yaml`
Expand All @@ -39,9 +56,9 @@ export class NetworkCommand extends BaseCommand {

valuesArg += ` --set hedera-mirror-node.enabled=${deployMirrorNode} --set hedera-explorer.enabled=${deployHederaExplorer}`

// if (enableTls) {
// valuesArg += this.getTlsValueArguments(enableTls, tlsClusterIssuerName, tlsClusterIssuerNamespace, enableHederaExplorerTls)
// }
if (enableHederaExplorerTls) {
valuesArg += this.getTlsValueArguments(tlsClusterIssuerType, enableHederaExplorerTls, namespace)
}

return valuesArg
}
Expand All @@ -54,7 +71,7 @@ export class NetworkCommand extends BaseCommand {
const valuesFile = this.configManager.getFlag(flags.valuesFile)
const deployMirrorNode = this.configManager.getFlag(flags.deployMirrorNode)
const deployExplorer = this.configManager.getFlag(flags.deployHederaExplorer)
const tlsClusterIssuerName = this.configManager.getFlag(flags.tlsClusterIssuerName)
const tlsClusterIssuerType = this.configManager.getFlag(flags.tlsClusterIssuerType)
const enableHederaExplorerTls = this.configManager.getFlag(flags.enableHederaExplorerTls)

// prompt if values are missing and create a config object
Expand All @@ -65,7 +82,7 @@ export class NetworkCommand extends BaseCommand {
valuesFile: await prompts.promptChartDir(task, valuesFile),
deployMirrorNode: await prompts.promptDeployMirrorNode(task, deployMirrorNode),
deployHederaExplorer: await prompts.promptDeployHederaExplorer(task, deployExplorer),
tlsClusterIssuerName: await prompts.promptTlsClusterIssuerName(task, tlsClusterIssuerName),
tlsClusterIssuerType: await prompts.promptTlsClusterIssuerType(task, tlsClusterIssuerType),
enableHederaExplorerTls: await prompts.promptEnableHederaExplorerTls(task, enableHederaExplorerTls),
version: this.configManager.getVersion()
}
Expand All @@ -76,7 +93,7 @@ export class NetworkCommand extends BaseCommand {

config.valuesArg = this.prepareValuesArg(config.chartDir,
config.valuesFile, config.deployMirrorNode, config.deployHederaExplorer,
config.tlsClusterIssuerName, config.enableHederaExplorerTls)
config.tlsClusterIssuerType, config.enableHederaExplorerTls, config.namespace)

return config
}
Expand Down Expand Up @@ -287,7 +304,7 @@ export class NetworkCommand extends BaseCommand {
flags.deployJsonRpcRelay,
flags.valuesFile,
flags.chartDirectory,
flags.tlsClusterIssuerName,
flags.tlsClusterIssuerType,
flags.enableHederaExplorerTls
)
},
Expand Down Expand Up @@ -336,7 +353,7 @@ export class NetworkCommand extends BaseCommand {
flags.deployHederaExplorer,
flags.valuesFile,
flags.chartDirectory,
flags.tlsClusterIssuerName,
flags.tlsClusterIssuerType,
flags.enableHederaExplorerTls
),
handler: argv => {
Expand Down
12 changes: 8 additions & 4 deletions fullstack-network-manager/src/commands/prompts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -335,19 +335,23 @@ export async function promptDeployHederaExplorer (task, input) {
}
}

export async function promptTlsClusterIssuerName (task, input) {
export async function promptTlsClusterIssuerType (task, input) {
try {
if (!input) {
input = await task.prompt(ListrEnquirerPromptAdapter).run({
type: 'text',
default: flags.tlsClusterIssuerName.definition.default,
message: 'Enter TLS cluster issuer name:'
default: flags.tlsClusterIssuerType.definition.default,
message: 'Enter TLS cluster issuer type, available options are: "acme-staging", "acme-prod", or "self-signed":'
})
}

if (!input || !['acme-staging', 'acme-prod', 'self-signed'].includes(input)) {
throw new FullstackTestingError('must be one of: "acme-staging", "acme-prod", or "self-signed"')
}

return input
} catch (e) {
throw new FullstackTestingError(`input failed: ${flags.tlsClusterIssuerName.name}`, e)
throw new FullstackTestingError(`input failed: ${flags.tlsClusterIssuerType.name}`, e)
}
}

Expand Down

0 comments on commit 91d163e

Please sign in to comment.