Skip to content

Commit

Permalink
Add '--mirror-node-version' flag to override default mirror node version
Browse files Browse the repository at this point in the history
Signed-off-by: instamenta <[email protected]>
  • Loading branch information
instamenta committed Sep 19, 2024
1 parent 11880c5 commit 1c59ff1
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 13 deletions.
13 changes: 12 additions & 1 deletion src/commands/flags.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,16 @@ export const adminKey = {
}
}

/** @type {CommandFlag} **/
export const mirrorNodeVersion = {
constName: 'mirrorNodeVersion',
name: 'mirror-node-version',
definition: {
describe: 'Mirror node chart version',
defaultValue: '',
type: 'string'
}
}
/** @type {CommandFlag[]} **/
export const allFlags = [
accountId,
Expand Down Expand Up @@ -815,7 +825,8 @@ export const allFlags = [
tlsPrivateKey,
tlsPublicKey,
updateAccountKeys,
valuesFile
valuesFile,
mirrorNodeVersion
]

/**
Expand Down
11 changes: 9 additions & 2 deletions src/commands/mirror_node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export class MirrorNodeCommand extends BaseCommand {
flags.profileFile,
flags.profileName,
flags.tlsClusterIssuerType,
flags.valuesFile
flags.valuesFile,
flags.mirrorNodeVersion
]
}

Expand Down Expand Up @@ -121,6 +122,10 @@ export class MirrorNodeCommand extends BaseCommand {
config.hederaExplorerTlsLoadBalancerIp, config.hederaExplorerTlsHostName)
}

if (config.mirrorNodeVersion) {
valuesArg += ` --set global.image.tag=${config.mirrorNodeVersion}`

Check warning on line 126 in src/commands/mirror_node.mjs

View check run for this annotation

Codecov / codecov/patch

src/commands/mirror_node.mjs#L126

Added line #L126 was not covered by tests
}

valuesArg += ` --set hedera-mirror-node.enabled=true --set hedera-explorer.enabled=${config.deployHederaExplorer}`
return valuesArg
}
Expand All @@ -147,7 +152,8 @@ export class MirrorNodeCommand extends BaseCommand {
flags.hederaExplorerTlsHostName,
flags.hederaExplorerTlsLoadBalancerIp,
flags.tlsClusterIssuerType,
flags.valuesFile
flags.valuesFile,
flags.mirrorNodeVersion
])

await prompts.execute(task, self.configManager, MirrorNodeCommand.DEPLOY_FLAGS_LIST)
Expand All @@ -169,6 +175,7 @@ export class MirrorNodeCommand extends BaseCommand {
* -- extra args --
* @property {string} chartPath
* @property {string} valuesArg
* @property {string} mirrorNodeVersion
* -- methods --
* @property {getUnusedConfigs} getUnusedConfigs
*/
Expand Down
9 changes: 9 additions & 0 deletions src/commands/prompts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,14 @@ export async function promptPersistentVolumeClaims (task, input) {
flags.persistentVolumeClaims.name)
}

export async function promptMirrorNodeVersion (task, input) {
return await promptToggle(task, input,

Check warning on line 425 in src/commands/prompts.mjs

View check run for this annotation

Codecov / codecov/patch

src/commands/prompts.mjs#L424-L425

Added lines #L424 - L425 were not covered by tests
flags.mirrorNodeVersion.definition.defaultValue,
'Would you like to choose mirror node version? ',
null,
flags.mirrorNodeVersion.name)
}

/**
* @returns {Map<string, Function>}
*/
Expand Down Expand Up @@ -464,6 +472,7 @@ export function getPromptMap () {
.set(flags.gossipEndpoints.name, promptGossipEndpoints)
.set(flags.grpcEndpoints.name, promptGrpcEndpoints)
.set(flags.endpointType.name, promptEndpointType)
.set(flags.mirrorNodeVersion.name, promptMirrorNodeVersion)
}

// build the prompt registry
Expand Down
28 changes: 18 additions & 10 deletions src/core/chart_manager.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,36 @@ export class ChartManager {
*
* @param {Map<string, string>} repoURLs - a map of name and chart repository URLs
* @param {boolean} force - whether or not to update the repo
* @returns {Promise<string[]>}
* @returns {Promise<string[]>} - returns the urls
*/
async setup (repoURLs = constants.DEFAULT_CHART_REPO, force = true) {
try {
let forceUpdateArg = ''
if (force) {
forceUpdateArg = '--force-update'
}
const forceUpdateArg = force ? '--force-update' : ''

const urls = []
/** @type {Array<Promise<string>>} */
const promises = []
for (const [name, url] of repoURLs.entries()) {
this.logger.debug(`Adding repo ${name} -> ${url}`, { repoName: name, repoURL: url })
await this.helm.repo('add', name, url, forceUpdateArg)
urls.push(url)
promises.push(this.addRepo(name, url, forceUpdateArg))
}

return urls
return await Promise.all(promises) // urls
} catch (e) {
throw new FullstackTestingError(`failed to setup chart repositories: ${e.message}`, e)
}
}

/**
* @param {string} name
* @param {string} url
* @param {string} forceUpdateArg
* @returns {Promise<string>}
*/
async addRepo (name, url, forceUpdateArg) {
this.logger.debug(`Adding repo ${name} -> ${url}`, { repoName: name, repoURL: url })
await this.helm.repo('add', name, url, forceUpdateArg)
return url
}

/**
* List available clusters
* @param {string} namespaceName
Expand Down

0 comments on commit 1c59ff1

Please sign in to comment.