Skip to content

Commit

Permalink
add hederaExplorerTlsLoadBalancerIp and hederaExplorerTlsHostName
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 91d163e commit b5a8fd0
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 6 deletions.
20 changes: 20 additions & 0 deletions fullstack-network-manager/src/commands/flags.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,24 @@ export const enableHederaExplorerTls = { // KEEP
}
}

export const hederaExplorerTlsLoadBalancerIp = {
name: 'hedera-explorer-tls-load-balancer-ip',
definition: {
describe: 'The static IP address to use for the Hedera Explorer TLS load balancer, defaults to ""',
default: '',
type: 'string'
}
}

export const hederaExplorerTlsHostName = {
name: 'hedera-explorer-tls-host-name',
definition: {
describe: 'The host name to use for the Hedera Explorer TLS, defaults to "explorer.fst.local"',
default: 'explorer.fst.local',
type: 'string'
}
}

export const deletePvcs = {
name: 'delete-pvcs',
definition: {
Expand Down Expand Up @@ -287,5 +305,7 @@ export const allFlags = [
operatorKey,
tlsClusterIssuerType,
enableHederaExplorerTls,
hederaExplorerTlsLoadBalancerIp,
hederaExplorerTlsHostName,
deletePvcs
]
28 changes: 22 additions & 6 deletions fullstack-network-manager/src/commands/network.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { constants, Templates } from '../core/index.mjs'
import * as prompts from './prompts.mjs'

export class NetworkCommand extends BaseCommand {
getTlsValueArguments (tlsClusterIssuerType, enableHederaExplorerTls, namespace) {
getTlsValueArguments (tlsClusterIssuerType, enableHederaExplorerTls, namespace,
hederaExplorerTlsLoadBalancerIp, hederaExplorerTlsHostName) {
let valuesArg = ''

if (enableHederaExplorerTls) {
Expand All @@ -20,6 +21,11 @@ export class NetworkCommand extends BaseCommand {
valuesArg += ' --set hedera-explorer.ingress.enabled=true'
valuesArg += ' --set cloud.haproxyIngressController.enabled=true'
valuesArg += ` --set global.ingressClassName=${namespace}-hedera-explorer-ingress-class`
valuesArg += ` --set-json hedera-explorer.ingress.hosts[0]={"host":"${hederaExplorerTlsHostName}","paths":[{"path":"/","pathType":"Prefix"}]}`

if (hederaExplorerTlsLoadBalancerIp !== '') {
valuesArg += ` --set haproxy-ingress.controller.service.loadBalancerIP=${hederaExplorerTlsLoadBalancerIp}`
}

if (tlsClusterIssuerType === 'self-signed') {
valuesArg += ' --set cloud.selfSignedClusterIssuer.enabled=true'
Expand All @@ -46,7 +52,7 @@ export class NetworkCommand extends BaseCommand {
}

prepareValuesArg (chartDir, valuesFile, deployMirrorNode, deployHederaExplorer, tlsClusterIssuerType,
enableHederaExplorerTls, namespace) {
enableHederaExplorerTls, namespace, hederaExplorerTlsLoadBalancerIp, hederaExplorerTlsHostName) {
let valuesArg = ''
if (chartDir) {
valuesArg = `-f ${chartDir}/fullstack-deployment/values.yaml`
Expand All @@ -57,7 +63,8 @@ export class NetworkCommand extends BaseCommand {
valuesArg += ` --set hedera-mirror-node.enabled=${deployMirrorNode} --set hedera-explorer.enabled=${deployHederaExplorer}`

if (enableHederaExplorerTls) {
valuesArg += this.getTlsValueArguments(tlsClusterIssuerType, enableHederaExplorerTls, namespace)
valuesArg += this.getTlsValueArguments(tlsClusterIssuerType, enableHederaExplorerTls, namespace,
hederaExplorerTlsLoadBalancerIp, hederaExplorerTlsHostName)
}

return valuesArg
Expand All @@ -73,6 +80,8 @@ export class NetworkCommand extends BaseCommand {
const deployExplorer = this.configManager.getFlag(flags.deployHederaExplorer)
const tlsClusterIssuerType = this.configManager.getFlag(flags.tlsClusterIssuerType)
const enableHederaExplorerTls = this.configManager.getFlag(flags.enableHederaExplorerTls)
const hederaExplorerTlsLoadBalancerIp = this.configManager.getFlag(flags.hederaExplorerTlsLoadBalancerIp)
const hederaExplorerTlsHostName = this.configManager.getFlag(flags.hederaExplorerTlsHostName)

// prompt if values are missing and create a config object
const config = {
Expand All @@ -84,6 +93,8 @@ export class NetworkCommand extends BaseCommand {
deployHederaExplorer: await prompts.promptDeployHederaExplorer(task, deployExplorer),
tlsClusterIssuerType: await prompts.promptTlsClusterIssuerType(task, tlsClusterIssuerType),
enableHederaExplorerTls: await prompts.promptEnableHederaExplorerTls(task, enableHederaExplorerTls),
hederaExplorerTlsLoadBalancerIp: await prompts.promptHederaExplorerTlsLoadBalancerIp(task, hederaExplorerTlsLoadBalancerIp),
hederaExplorerTlsHostName: await prompts.promptHederaExplorerTlsHostName(task, hederaExplorerTlsHostName),
version: this.configManager.getVersion()
}

Expand All @@ -93,7 +104,8 @@ export class NetworkCommand extends BaseCommand {

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

return config
}
Expand Down Expand Up @@ -305,7 +317,9 @@ export class NetworkCommand extends BaseCommand {
flags.valuesFile,
flags.chartDirectory,
flags.tlsClusterIssuerType,
flags.enableHederaExplorerTls
flags.enableHederaExplorerTls,
flags.hederaExplorerTlsLoadBalancerIp,
flags.hederaExplorerTlsHostName
)
},
handler: argv => {
Expand Down Expand Up @@ -354,7 +368,9 @@ export class NetworkCommand extends BaseCommand {
flags.valuesFile,
flags.chartDirectory,
flags.tlsClusterIssuerType,
flags.enableHederaExplorerTls
flags.enableHederaExplorerTls,
flags.hederaExplorerTlsLoadBalancerIp,
flags.hederaExplorerTlsHostName
),
handler: argv => {
networkCmd.logger.debug("==== Running 'chart upgrade' ===")
Expand Down
32 changes: 32 additions & 0 deletions fullstack-network-manager/src/commands/prompts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,38 @@ export async function promptEnableHederaExplorerTls (task, input) {
}
}

export async function promptHederaExplorerTlsLoadBalancerIp (task, input) {
try {
if (!input) {
input = await task.prompt(ListrEnquirerPromptAdapter).run({
type: 'text',
default: flags.hederaExplorerTlsLoadBalancerIp.definition.default,
message: 'Enter the static IP address to use for the Hedera Explorer TLS load balancer or leave empty:'
})
}

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

export async function promptHederaExplorerTlsHostName (task, input) {
try {
if (!input) {
input = await task.prompt(ListrEnquirerPromptAdapter).run({
type: 'text',
default: flags.hederaExplorerTlsHostName.definition.default,
message: 'Enter the host name to use for the Hedera Explorer TLS:'
})
}

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

export async function promptOperatorId (task, input) {
try {
if (!input) {
Expand Down

0 comments on commit b5a8fd0

Please sign in to comment.