Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Create a local config for storing configurations on the users machine #803

Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
fdc8678
feat: add LocalCOnfiguration class
Ivo-Yankov Oct 30, 2024
0eda60f
feat: finalize LocalConfig class and tests
Ivo-Yankov Nov 1, 2024
a5e0812
chore: code cleanup
Ivo-Yankov Nov 1, 2024
dac5104
chore: rename class
Ivo-Yankov Nov 1, 2024
dd07de0
wip: LocalConfig prompting
Ivo-Yankov Nov 4, 2024
cf9bada
Merge branch 'main' into 00590-create-a-local-config-for-storing-conf…
Ivo-Yankov Nov 4, 2024
7116e6e
feat: LocalConfig prompts
Ivo-Yankov Nov 5, 2024
baa94b3
test: add yaml file for e2e tests
Ivo-Yankov Nov 6, 2024
584032b
Merge branch 'main' into 00590-create-a-local-config-for-storing-conf…
Ivo-Yankov Nov 6, 2024
3905f5d
debug: e2e tests
Ivo-Yankov Nov 6, 2024
2601d5a
debug: e2e tests
Ivo-Yankov Nov 6, 2024
658775a
feat: inject config into BaseCommand
Ivo-Yankov Nov 7, 2024
4ba7b58
chore: rename types
Ivo-Yankov Nov 7, 2024
55a1202
chore: refactor LocalConfig class
Ivo-Yankov Nov 8, 2024
f50cfb7
chore: eslint
Ivo-Yankov Nov 8, 2024
03d7c06
Merge branch 'main' into 00590-create-a-local-config-for-storing-conf…
Ivo-Yankov Nov 8, 2024
4b6cad1
fix: circular dependency
Ivo-Yankov Nov 8, 2024
6838f6d
chore: eslint
Ivo-Yankov Nov 8, 2024
18255cc
nit: cleanup
Ivo-Yankov Nov 8, 2024
ba50a7b
Merge branch 'main' into 00590-create-a-local-config-for-storing-conf…
Ivo-Yankov Nov 8, 2024
c74f2e7
nit: cleanup
Ivo-Yankov Nov 8, 2024
e049a36
fix: comment out injectable code in BaseCommand
Ivo-Yankov Nov 8, 2024
cddf073
removed inversifyjs
Ivo-Yankov Nov 11, 2024
e9f4c6b
Merge branch 'main' into 00590-create-a-local-config-for-storing-conf…
Ivo-Yankov Nov 12, 2024
428e81d
chore: fix formatting
Ivo-Yankov Nov 12, 2024
a3fb43b
fix: integration test
Ivo-Yankov Nov 12, 2024
4a1dc81
feat: add LocalCOnfiguration class
Ivo-Yankov Oct 30, 2024
4e247ee
feat: finalize LocalConfig class and tests
Ivo-Yankov Nov 1, 2024
d5f08b2
chore: code cleanup
Ivo-Yankov Nov 1, 2024
76bee22
chore: rename class
Ivo-Yankov Nov 1, 2024
b6f3395
wip: LocalConfig prompting
Ivo-Yankov Nov 4, 2024
1a9face
feat: LocalConfig prompts
Ivo-Yankov Nov 5, 2024
b77c55e
test: add yaml file for e2e tests
Ivo-Yankov Nov 6, 2024
ad3195f
debug: e2e tests
Ivo-Yankov Nov 6, 2024
ef45975
debug: e2e tests
Ivo-Yankov Nov 6, 2024
329b6a6
feat: inject config into BaseCommand
Ivo-Yankov Nov 7, 2024
a6381df
chore: rename types
Ivo-Yankov Nov 7, 2024
ac314f0
chore: refactor LocalConfig class
Ivo-Yankov Nov 8, 2024
b0d1d5d
chore: eslint
Ivo-Yankov Nov 8, 2024
de4be41
fix: circular dependency
Ivo-Yankov Nov 8, 2024
e8a37dd
chore: eslint
Ivo-Yankov Nov 8, 2024
fb3a294
nit: cleanup
Ivo-Yankov Nov 8, 2024
767984c
nit: cleanup
Ivo-Yankov Nov 8, 2024
ec3d535
fix: comment out injectable code in BaseCommand
Ivo-Yankov Nov 8, 2024
a00e908
removed inversifyjs
Ivo-Yankov Nov 11, 2024
3845d15
chore: fix formatting
Ivo-Yankov Nov 12, 2024
d7db2cb
fix: integration test
Ivo-Yankov Nov 12, 2024
b227e2f
update package.json
jeromy-cannon Nov 19, 2024
325ad06
Merge remote-tracking branch 'origin/00590-create-a-local-config-for-…
Ivo-Yankov Nov 21, 2024
2307c38
chore: renamed files
Ivo-Yankov Nov 21, 2024
18a1a03
Merge branch 'main' into 00590-create-a-local-config-for-storing-conf…
Ivo-Yankov Nov 21, 2024
2068797
chore: import js files
Ivo-Yankov Nov 21, 2024
4acdece
chore: regenerate package-lock.json
Ivo-Yankov Nov 21, 2024
bb58abc
nit: addressing comments
Ivo-Yankov Nov 21, 2024
a536e9d
chore: fix path building
Ivo-Yankov Nov 21, 2024
d655d08
chore: remove clusterMappings
Ivo-Yankov Nov 22, 2024
00c5800
chore: remove custom deployments validation
Ivo-Yankov Nov 22, 2024
30ac6ad
add isDeployments decorator
Ivo-Yankov Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .swcrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"parser": {
"syntax": "typescript",
"tsx": false,
"decorators": false,
"decorators": true,
"dynamicImport": true
},
"target": "es2022",
Expand Down
125 changes: 101 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"solo-test": "node --no-deprecation --no-warnings --loader ts-node/esm solo.ts",
"solo": "node --no-deprecation --no-warnings dist/solo.js",
"check": "remark . --quiet --frail && eslint . --ignore-pattern 'docs/*' --ignore-pattern 'dist/*'; cd docs; jsdoc -c jsdoc.conf.json && tsc",
"format": "remark . --quiet --frail --output && eslint --fix . --ignore-pattern 'docs/*' --ignore-pattern 'dist/*'",
"format": "remark . --quiet --frail --output && eslint --fix . --ignore-pattern 'docs/*' --ignore-pattern 'dist/*' && tsc",
"test-setup": "./test/e2e/setup-e2e.sh",
"build": "swc src version.ts solo.ts -d dist && node resources/post-build-script.js"
"build": "swc src version.ts solo.ts -d dist && node resources/post-build-script.js && tsc"
},
"keywords": [
"solo",
Expand All @@ -52,6 +52,8 @@
"@peculiar/x509": "^1.12.3",
"adm-zip": "^0.5.16",
"chalk": "^5.3.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"dot-object": "^2.1.5",
"dotenv": "^16.4.5",
"enquirer": "^2.4.1",
Expand Down
4 changes: 4 additions & 0 deletions src/commands/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { MissingArgumentError } from '../core/errors.ts'
import { ShellRunner } from '../core/shell_runner.ts'
import type { ChartManager, ConfigManager, Helm, K8, DependencyManager, LeaseManager } from '../core/index.ts'
import type { CommandFlag, Opts } from '../types/index.ts'
import { type LocalConfig } from './../core/config/LocalConfig.ts'

export class BaseCommand extends ShellRunner {
protected readonly helm: Helm
Expand All @@ -29,6 +30,7 @@ export class BaseCommand extends ShellRunner {
protected readonly depManager: DependencyManager
protected readonly leaseManager: LeaseManager
protected readonly _configMaps = new Map<string, any>()
protected readonly localConfig: LocalConfig

constructor (opts: Opts) {
if (!opts || !opts.logger) throw new Error('An instance of core/SoloLogger is required')
Expand All @@ -37,6 +39,7 @@ export class BaseCommand extends ShellRunner {
if (!opts || !opts.chartManager) throw new Error('An instance of core/ChartManager is required')
if (!opts || !opts.configManager) throw new Error('An instance of core/ConfigManager is required')
if (!opts || !opts.depManager) throw new Error('An instance of core/DependencyManager is required')
if (!opts || !opts.localConfig) throw new Error('An instance of core/LocalConfig is required')

super(opts.logger)

Expand All @@ -46,6 +49,7 @@ export class BaseCommand extends ShellRunner {
this.configManager = opts.configManager
this.depManager = opts.depManager
this.leaseManager = opts.leaseManager
this.localConfig = opts.localConfig
}

async prepareChartPath (chartDir: string, chartRepo: string, chartReleaseName: string) {
Expand Down
33 changes: 33 additions & 0 deletions src/commands/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,36 @@ export const hederaExplorerVersion: CommandFlag = {
}
}

export const userEmailAddress: CommandFlag = {
constName: 'userEmailAddress',
name: 'email',
definition: {
describe: 'User email address used for local configuration',
defaultValue: '',
type: 'string'
}
}

export const deploymentName: CommandFlag = {
constName: 'deploymentName',
name: 'deployment-name',
definition: {
describe: 'Solo deployment name',
defaultValue: '',
type: 'string'
}
}

export const deploymentClusters: CommandFlag = {
constName: 'deploymentClusters',
name: 'deployment-clusters',
definition: {
describe: 'Solo deployment cluster list (comma separated)',
defaultValue: '',
type: 'string'
}
}

//* ------------- Node Proxy Certificates ------------- !//

export const grpcTlsCertificatePath: CommandFlag = {
Expand Down Expand Up @@ -782,6 +812,8 @@ export const allFlags: CommandFlag[] = [
deployCertManagerCrds,
deployHederaExplorer,
deployJsonRpcRelay,
deploymentClusters,
deploymentName,
deployMinio,
deployPrometheusStack,
devMode,
Expand Down Expand Up @@ -823,6 +855,7 @@ export const allFlags: CommandFlag[] = [
tlsPrivateKey,
tlsPublicKey,
updateAccountKeys,
userEmailAddress,
valuesFile,
mirrorNodeVersion,
hederaExplorerVersion,
Expand Down
34 changes: 34 additions & 0 deletions src/commands/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import { hederaExplorerVersion, resetDisabledPrompts } from './flags.ts'
import type { ListrTaskWrapper } from 'listr2'
import { type CommandFlag } from '../types/index.ts'
import validator from 'validator'

async function prompt (type: string, task: ListrTaskWrapper<any, any, any>, input: any, defaultValue: any, promptMessage: string, emptyCheckMessage: string | null, flagName: string) {
try {
Expand Down Expand Up @@ -366,6 +367,38 @@
flags.updateAccountKeys.name)
}

export async function promptUserEmailAddress (task: ListrTaskWrapper<any, any, any>, input: any) {
const promptForInput = async () => {
return await task.prompt(ListrEnquirerPromptAdapter).run({
type: 'text',
message: 'Please enter your email address:'
})
}

input = await promptForInput()
while (!validator.isEmail(input)) {
input = await promptForInput()
}

return input
}

Check warning on line 384 in src/commands/prompts.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/prompts.ts#L371-L384

Added lines #L371 - L384 were not covered by tests

export async function promptDeploymentName (task: ListrTaskWrapper<any, any, any>, input: any) {
return await promptText(task, input,
flags.deploymentName.definition.defaultValue,
'Enter the Solo deployment name: ',
null,
flags.deploymentName.name)
}

Check warning on line 392 in src/commands/prompts.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/prompts.ts#L387-L392

Added lines #L387 - L392 were not covered by tests

export async function promptDeploymentClusters (task: ListrTaskWrapper<any, any, any>, input: any) {
return await promptText(task, input,
flags.deploymentClusters.definition.defaultValue,
'Enter the Solo deployment cluster names (comma separated): ',
null,
flags.deploymentClusters.name)
}

Check warning on line 400 in src/commands/prompts.ts

View check run for this annotation

Codecov / codecov/patch

src/commands/prompts.ts#L395-L400

Added lines #L395 - L400 were not covered by tests

export async function promptPrivateKey (task: ListrTaskWrapper<any, any, any>, input: any) {
return await promptText(task, input,
flags.ed25519PrivateKey.definition.defaultValue,
Expand Down Expand Up @@ -531,6 +564,7 @@
.set(flags.replicaCount.name, promptReplicaCount)
.set(flags.tlsClusterIssuerType.name, promptTlsClusterIssuerType)
.set(flags.updateAccountKeys.name, promptUpdateAccountKeys)
.set(flags.userEmailAddress.name, promptUserEmailAddress)
.set(flags.valuesFile.name, promptValuesFile)
.set(flags.nodeAlias.name, promptNewNodeAlias)
.set(flags.gossipEndpoints.name, promptGossipEndpoints)
Expand Down
Loading
Loading