Skip to content

Commit

Permalink
EVEREST-1815 Replase AlecAivazis/survey lib with charmbracelet/bubble…
Browse files Browse the repository at this point in the history
…tea (#1062)

* EVEREST-1815 Replase AlecAivazis/survey lib with charmbracelet/bubbletea

* EVEREST-1815 Adjust styles

* EVEREST-1815 Test

* EVEREST-1815 Logger test

* EVEREST-1815 Logger test

* TEST

* TEST 2

* Fix Helm config

* EVEREST-1815 Fix running actions in case of tty absence

* Fix go.mod

* Fix tests

* Fix tests

* Fix tests

* Fix password validation regexp

* Fix password validation regexp

* Add tmate to minikube

* Adjust docker daemon config for GH workflowswq

* Adjust docker daemon config for GH workflowswq

* Adjust docker daemon config for GH workflowswq

* Adjust docker config for FE GH e2e workflow

* Fix comments for account CLI commands

* Fix comments

* Fix formatting

* Replace Unicode digits in post-install message

* Add mark for current cursor position

* Update configure.go

* Update go.mod

---------

Co-authored-by: Percona Platform Robot <61465387+percona-robot@users.noreply.github.com>
  • Loading branch information
maxkondr and percona-robot authored Feb 10, 2025
1 parent c4b71ce commit 48bbf84
Show file tree
Hide file tree
Showing 54 changed files with 2,909 additions and 1,157 deletions.
26 changes: 20 additions & 6 deletions .github/workflows/dev-be-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ jobs:
${{ matrix.os }}-go-${{ matrix.go-version }}-build-${{ github.ref }}-
${{ matrix.os }}-go-${{ matrix.go-version }}-build-
# Switch docker data directory to /mnt to have more space for the local Kubernetes cluster
- name: Switch docker-daemon data directory to /mnt
run: |
sudo systemctl stop docker
echo '{ "exec-opts": ["native.cgroupdriver=cgroupfs"], "cgroup-parent": "/actions_job", "data-root": "/mnt/docker-data" }' | sudo tee /etc/docker/daemon.json
sudo mkdir /mnt/docker-data
sudo systemctl start docker
- name: Start local Kubernetes cluster with the local registry
uses: medyagh/setup-minikube@latest
id: minikube
Expand All @@ -262,6 +270,11 @@ jobs:
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make build-debug
- name: Build Everest CLI
shell: bash
run: |
make build-cli
- name: Build Everest docker container
uses: docker/metadata-action@v5
id: meta
Expand Down Expand Up @@ -319,8 +332,8 @@ jobs:
- name: Provision Everest using CLI
shell: bash
run: |
make build-cli
./bin/everestctl install -v \
--disable-telemetry \
--version 0.0.0 \
--version-metadata-url https://check-dev.percona.com \
--operator.mongodb \
Expand All @@ -346,10 +359,14 @@ jobs:
kubectl patch configmap everest-rbac -n everest-system --patch "$(kubectl get configmap everest-rbac -n everest-system -o json | jq '.data["policy.csv"] += "\ng, everest_ci, role:admin"' | jq '{data: { "policy.csv": .data["policy.csv"] } }')"
kubectl get configmap everest-rbac -n everest-system -ojsonpath='{.data.policy\.csv}'
- name: Run integration tests
- name: Init integration tests
run: |
cd api-tests
make init
- name: Run integration tests
run: |
cd api-tests
make test
- name: Run debug commands on failure
Expand All @@ -360,9 +377,6 @@ jobs:
kubectl -n everest describe pods
kubectl -n everest-system logs deploy/everest-server
integration_tests_cli:
name: CLI Integration Tests
strategy:
Expand Down Expand Up @@ -418,9 +432,9 @@ jobs:
uses: helm/kind-action@v1.12.0

- name: Run integration tests
working-directory: cli-tests
id: cli-tests
run: |
cd cli-tests
make init
make install-operators
make test-cli
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/dev-fe-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [1.23.x]
may-fail: [false]
go-version: [ 1.23.x ]
may-fail: [ false ]
runs-on: ubuntu-latest
steps:
# Setup Go
Expand Down Expand Up @@ -139,6 +139,7 @@ jobs:
shell: bash
run: |
./bin/everestctl install -v \
--disable-telemetry \
--version 0.0.0 \
--version-metadata-url https://check-dev.percona.com \
--skip-wizard \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ run-debug: build-debug ## Run binary
bin/everest

run-cli-install: build-cli
bin/everestctl install --skip-wizard --namespaces=everest
bin/everestctl install --disable-telemetry --skip-wizard --namespaces=everest

cert: ## Install dev TLS certificates
mkcert -install
Expand Down
1 change: 1 addition & 0 deletions cli-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ init: ## Install dependencies

install-operators: ## Install operators to k8s
../bin/everestctl install -v \
--disable-telemetry \
--version 0.0.0 \
--version-metadata-url https://check-dev.percona.com \
--namespaces percona-everest-operators \
Expand Down
4 changes: 2 additions & 2 deletions cli-tests/helpers/cliHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ export class CliHelper {
async everestExecSkipWizard(command: string) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return test.step(`Run "${command}" command with --skip-wizard`, async () => {
return this.execute(`${this.pathToBinary} ${command} --skip-wizard --version 0.0.0 --version-metadata-url https://check-dev.percona.com`);
return this.execute(`${this.pathToBinary} ${command} --disable-telemetry --skip-wizard --version 0.0.0 --version-metadata-url https://check-dev.percona.com`);
});
}

async everestExecSkipWizardWithEnv(command, env: string) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return test.step(`Run "${command}" command with env variables`, async () => {
return this.execute(`${env} ${this.pathToBinary} ${command} --skip-wizard --version 0.0.0 --version-metadata-url https://check-dev.percona.com`);
return this.execute(`${env} ${this.pathToBinary} ${command} --disable-telemetry --skip-wizard --version 0.0.0 --version-metadata-url https://check-dev.percona.com`);
});
}

Expand Down
14 changes: 7 additions & 7 deletions cli-tests/tests/flow/all-operators.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ test.describe('Everest CLI install', async () => {

await out.assertSuccess();
await out.outContainsNormalizedMany([
' Installing Everest Helm chart',
' Ensuring Everest API deployment is ready',
' Ensuring Everest operator deployment is ready',
' Ensuring OLM components are ready',
' Ensuring Everest CatalogSource is ready',
' Ensuring monitoring stack is ready',
' Provisioning database namespaces (everest-all)',
' Installing Everest Helm chart',
' Ensuring Everest API deployment is ready',
' Ensuring Everest operator deployment is ready',
' Ensuring OLM components are ready',
' Ensuring Everest CatalogSource is ready',
' Ensuring monitoring stack is ready',
' Provisioning database namespace \'everest-all\'',
'Thank you for installing Everest',
]);
});
Expand Down
14 changes: 7 additions & 7 deletions cli-tests/tests/flow/mongodb-operator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ test.describe('Everest CLI install', async () => {

await out.assertSuccess();
await out.outContainsNormalizedMany([
' Installing Everest Helm chart',
' Ensuring Everest API deployment is ready',
' Ensuring Everest operator deployment is ready',
' Ensuring OLM components are ready',
' Ensuring Everest CatalogSource is ready',
' Ensuring monitoring stack is ready',
' Provisioning database namespaces (everest-operators)',
' Installing Everest Helm chart',
' Ensuring Everest API deployment is ready',
' Ensuring Everest operator deployment is ready',
' Ensuring OLM components are ready',
' Ensuring Everest CatalogSource is ready',
' Ensuring monitoring stack is ready',
' Provisioning database namespace \'everest-operators\'',
'Thank you for installing Everest',
]);
});
Expand Down
38 changes: 19 additions & 19 deletions cli-tests/tests/flow/namespaces.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ test.describe('Everest CLI install', async () => {

await out.assertSuccess();
await out.outContainsNormalizedMany([
' Installing Everest Helm chart',
' Ensuring Everest API deployment is ready',
' Ensuring Everest operator deployment is ready',
' Ensuring OLM components are ready',
' Ensuring Everest CatalogSource is ready',
' Ensuring monitoring stack is ready',
' Installing Everest Helm chart',
' Ensuring Everest API deployment is ready',
' Ensuring Everest operator deployment is ready',
' Ensuring OLM components are ready',
' Ensuring Everest CatalogSource is ready',
' Ensuring monitoring stack is ready',
'Thank you for installing Everest',
]);
});
Expand All @@ -65,7 +65,7 @@ test.describe('Everest CLI install', async () => {
`install`,
);
await out.outErrContainsNormalizedMany([
'× everest is already installed',
' everest is already installed',
]);
});
await page.waitForTimeout(10_000);
Expand All @@ -77,7 +77,7 @@ test.describe('Everest CLI install', async () => {
);
await out.assertSuccess();
await out.outContainsNormalizedMany([
'✓ Installing namespace \'everest\'',
'✅ Provisioning database namespace \'everest\'',
]);
});
await page.waitForTimeout(10_000);
Expand All @@ -89,7 +89,7 @@ test.describe('Everest CLI install', async () => {
`add everest --operator.mongodb=false --operator.postgresql=false --operator.xtradb-cluster=true`,
);
await out.outErrContainsNormalizedMany([
'× invalid namespace (everest): namespace already exists. HINT: set \'--take-ownership\' flag to use existing namespaces',
'❌ \'everest\': namespace already exists and is managed by Everest',
]);
});
await page.waitForTimeout(10_000);
Expand All @@ -102,7 +102,7 @@ test.describe('Everest CLI install', async () => {
);
await out.assertSuccess();
await out.outContainsNormalizedMany([
' Updating namespace \'everest\'',
' Updating database namespace \'everest\'',
]);
});
await page.waitForTimeout(10_000);
Expand All @@ -119,10 +119,10 @@ test.describe('Everest CLI install', async () => {
);
await out.assertSuccess();
await out.outContainsNormalizedMany([
' Deleting database clusters in namespace \'everest\'',
' Deleting backup storages in namespace \'everest\'',
' Deleting monitoring instances in namespace \'everest\'',
' Deleting namespace \'everest\'',
' Deleting database clusters in namespace \'everest\'',
' Deleting backup storages in namespace \'everest\'',
' Deleting monitoring instances in namespace \'everest\'',
' Deleting database namespace \'everest\'',
]);

out = await cli.exec(`kubectl get namespace everest`);
Expand All @@ -142,7 +142,7 @@ test.describe('Everest CLI install', async () => {
);
await out.assertSuccess();
await out.outContainsNormalizedMany([
'✓ Installing namespace \'existing-ns\'',
'✅ Provisioning database namespace \'existing-ns\'',
]);
});
await page.waitForTimeout(10_000);
Expand All @@ -154,10 +154,10 @@ test.describe('Everest CLI install', async () => {
);
await out.assertSuccess();
await out.outContainsNormalizedMany([
' Deleting database clusters in namespace \'existing-ns\'',
' Deleting backup storages in namespace \'existing-ns\'',
' Deleting monitoring instances in namespace \'existing-ns\'',
' Deleting resources from namespace \'existing-ns\'',
' Deleting database clusters in namespace \'existing-ns\'',
' Deleting backup storages in namespace \'existing-ns\'',
' Deleting monitoring instances in namespace \'existing-ns\'',
' Deleting resources from namespace \'existing-ns\'',
]);

out = await cli.exec(`kubectl get namespace existing-ns`);
Expand Down
14 changes: 7 additions & 7 deletions cli-tests/tests/flow/pg-operator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ test.describe('Everest CLI install', async () => {

await out.assertSuccess();
await out.outContainsNormalizedMany([
' Installing Everest Helm chart',
' Ensuring Everest API deployment is ready',
' Ensuring Everest operator deployment is ready',
' Ensuring OLM components are ready',
' Ensuring Everest CatalogSource is ready',
' Ensuring monitoring stack is ready',
' Provisioning database namespaces (everest-operators)',
' Installing Everest Helm chart',
' Ensuring Everest API deployment is ready',
' Ensuring Everest operator deployment is ready',
' Ensuring OLM components are ready',
' Ensuring Everest CatalogSource is ready',
' Ensuring monitoring stack is ready',
' Provisioning database namespace \'everest-operators\'',
'Thank you for installing Everest',
]);
});
Expand Down
14 changes: 7 additions & 7 deletions cli-tests/tests/flow/pxc-operator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ test.describe('Everest CLI install', async () => {

await out.assertSuccess();
await out.outContainsNormalizedMany([
' Installing Everest Helm chart',
' Ensuring Everest API deployment is ready',
' Ensuring Everest operator deployment is ready',
' Ensuring OLM components are ready',
' Ensuring Everest CatalogSource is ready',
' Ensuring monitoring stack is ready',
' Provisioning database namespaces (everest-operators)',
' Installing Everest Helm chart',
' Ensuring Everest API deployment is ready',
' Ensuring Everest operator deployment is ready',
' Ensuring OLM components are ready',
' Ensuring Everest CatalogSource is ready',
' Ensuring monitoring stack is ready',
' Provisioning database namespace \'everest-operators\'',
'Thank you for installing Everest',
]);
});
Expand Down
39 changes: 37 additions & 2 deletions commands/accounts/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
accountscli "github.com/percona/everest/pkg/accounts/cli"
"github.com/percona/everest/pkg/cli"
"github.com/percona/everest/pkg/logger"
"github.com/percona/everest/pkg/output"
)

var (
Expand Down Expand Up @@ -53,17 +54,51 @@ func accountsCreatePreRun(cmd *cobra.Command, _ []string) { //nolint:revive
// Copy global flags to config
accountsCreateCfg.Pretty = !(cmd.Flag(cli.FlagVerbose).Changed || cmd.Flag(cli.FlagJSON).Changed)
accountsCreateCfg.KubeconfigPath = cmd.Flag(cli.FlagKubeconfig).Value.String()

// Check username
if accountsCreateOpts.Username != "" {
// Validate provided username for new account.
if err := accountscli.ValidateUsername(accountsCreateOpts.Username); err != nil {
output.PrintError(err, logger.GetLogger(), accountsCreateCfg.Pretty)
os.Exit(1)
}
} else {
// Ask user in interactive mode to provide username for new account.
if username, err := accountscli.PopulateUsername(cmd.Context()); err != nil {
output.PrintError(err, logger.GetLogger(), accountsCreateCfg.Pretty)
os.Exit(1)
} else {
accountsCreateOpts.Username = username
}
}

// Check password
if accountsCreateOpts.Password != "" {
// Validate provided password for new account.
if err := accountscli.ValidatePassword(accountsCreateOpts.Password); err != nil {
output.PrintError(err, logger.GetLogger(), accountsCreateCfg.Pretty)
os.Exit(1)
}
} else {
// Ask user in interactive mode to provide password for new account.
if password, err := accountscli.PopulatePassword(cmd.Context()); err != nil {
output.PrintError(err, logger.GetLogger(), accountsCreateCfg.Pretty)
os.Exit(1)
} else {
accountsCreateOpts.Password = password
}
}
}

func accountsCreateRun(cmd *cobra.Command, _ []string) { //nolint:revive
cliA, err := accountscli.NewAccounts(*accountsCreateCfg, logger.GetLogger())
if err != nil {
logger.GetLogger().Error(err)
output.PrintError(err, logger.GetLogger(), accountsCreateCfg.Pretty)
os.Exit(1)
}

if err := cliA.Create(cmd.Context(), *accountsCreateOpts); err != nil {
logger.GetLogger().Error(err)
output.PrintError(err, logger.GetLogger(), accountsCreateCfg.Pretty)
os.Exit(1)
}
}
Expand Down
Loading

0 comments on commit 48bbf84

Please sign in to comment.