From dda11217cb5feb6ee6c4bbef76234841bca746b4 Mon Sep 17 00:00:00 2001 From: Lidia Mokevnina Date: Mon, 19 Feb 2024 13:00:52 +0100 Subject: [PATCH 1/3] [401] added install/uninstall help pages --- CONTRIBUTING.md | 2 +- man/uffizzi-install.ronn | 73 ++++++++++++++++++++------------------ man/uffizzi-uninstall.ronn | 23 ++++++++++++ man/uffizzi.ronn | 11 ++++-- 4 files changed, 71 insertions(+), 38 deletions(-) create mode 100644 man/uffizzi-uninstall.ronn diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d721e826..fc71facd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -91,5 +91,5 @@ Uffizzi supports a [Homebrew tap package] (https://github.com/UffizziCloud/homeb 4. Copy over the contents of the existing [Formula](https://github.com/UffizziCloud/homebrew-tap/blob/main/Formula/uffizzi.rb) from the master, replacing the sha and the url for the ones from the newly created Formula. 5. Update the `resource "uffizzi-cli"` to the latest gem and add new dependencies if needed. 6. Run `HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source --verbose --debug uffizzi` and manually test the new uffizzi version (make sure that all other homebrew uffizzi versions are uninstalled). -7. Run `brew audit --strict --online` to check if the Formula adheres to the Homebrew style. +7. Run `brew audit --strict --online uffizzi` to check if the Formula adheres to the Homebrew style. 8. If tests and audit pass, create a PR into master in the UffizziCloud/homebrew-tap [repository] (https://github.com/UffizziCloud/homebrew-tap) with the new Formula. diff --git a/man/uffizzi-install.ronn b/man/uffizzi-install.ronn index f87822a4..ba8b05e7 100644 --- a/man/uffizzi-install.ronn +++ b/man/uffizzi-install.ronn @@ -1,52 +1,55 @@ -$ uffizzi -h -uffizzi - manage Uffizzi resources +$ uffizzi install help +uffizzi-install - install the uffizzi platform ================================================================ ## SYNOPSIS - uffizzi GROUP | COMMAND + uffizzi install [HOSTNAME] --email=[EMAIL] ## DESCRIPTION - The uffizzi CLI manages authentication, configuration, and - interaction with Uffizzi APIs. + Install the Uffizzi platform data plane (controller and operator) on a host cluster. + + If you want to self-host the Uffizzi platform data and control planes, you should + use Uffizzi Enterprise instead. Contact sales@uffizzi.com to get started. - For more information on the uffizzi CLI, see: - https://docs.uffizzi.com/references/cli/ + For more information on the Uffizzi installation process, see: + https://docs.uffizzi.com/install/platform -## GROUP - GROUP is one of the following: - cluster - Manage virtual clusters +## POSITIONAL ARGUMENTS - config - Configure the uffizzi CLI + HOSTNAME + The hostname where your installation will be publicly available. E.g. uffizzi.example.com + The output of the `install` command is an IP address or hostname where your instance + of the Uffizzi controller service is available. Uffizzi expects this service to be publicly + available at the specified HOSTNAME. Before you can create Uffizzi environments + on your installation, be sure to configure your DNS to point HOSTNAME to the IP + or hostname output by this command. - connect - Grant a Uffizzi user account access to external services + EMAIL + A business email, required for letsencrypt certificate authority. - compose - Manage Uffizzi compose environments (previews) and view logs +## FLAGS - dev - Creates a Uffizzi cluster preconfigured for development workflows + --email + A business email required for letsencrypt - install - Install the Uffizzi platform data plane on a host cluster. + --context + The name of the kubeconfig context to use. If no context is specified, your + kubeconfig current context is used. - project - Manage Uffizzi project resources including compose files for - specifying compose environment (preview) configurations and secrets + --namespace + The namespace where Uffizzi platform will be installed. If no namespace is + specified, the 'default' namespace is used. -## COMMAND - COMMAND is one of the following: + --help + Display this help page and exit - help - Show uffizzi documentation +## EXAMPLES - login - Log in to a Uffizzi user account + To install Uffizzi using the current context at hostname 'uffizzi.example.com', run: - logout - Log out of a Uffizzi user account - - version - Print version information for uffizzi CLI + $ uffizzi install uffizzi.example.com --email="jdoe@example.com" + + To install Uffizzi using context 'foo' and namespace 'bar', run: + + $ uffizzi install uffizzi.example.com --email="jdoe@example.com" \ + --context='foo' --namespace='bar' diff --git a/man/uffizzi-uninstall.ronn b/man/uffizzi-uninstall.ronn new file mode 100644 index 00000000..01245659 --- /dev/null +++ b/man/uffizzi-uninstall.ronn @@ -0,0 +1,23 @@ +$ uffizzi uninstall help +uffizzi-uninstall - uninstall the uffizzi platform +================================================================ + +## SYNOPSIS + uffizzi uninstall + +## DESCRIPTION + Uninstall the Uffizzi platform data plane (controller and operator) from a host cluster. + + For more information on the Uffizzi installation process, see: + https://docs.uffizzi.com/install/platform + +## FLAGS + + --help + Display this help page and exit + +## EXAMPLES + + To uninstall Uffizzi, run: + + $ uffizzi uninstall diff --git a/man/uffizzi.ronn b/man/uffizzi.ronn index 15f19305..aa3b0b5c 100644 --- a/man/uffizzi.ronn +++ b/man/uffizzi.ronn @@ -25,12 +25,19 @@ uffizzi - manage Uffizzi resources compose Manage Uffizzi compose environments (previews) and view logs + dev + Creates a Uffizzi cluster preconfigured for development workflows + + install + Install the Uffizzi platform data plane on a host cluster. + project Manage Uffizzi project resources including compose files for specifying compose environment (preview) configurations and secrets - dev - Creates a Uffizzi cluster preconfigured for development workflows + uninstall + Uninstall the Uffizzi platform data plane from a host cluster. Updates CLI + to use Uffizzi Cloud as the default API. ## COMMAND COMMAND is one of the following: From 7b022c1e38298c046c4be127e03834a1413542ee Mon Sep 17 00:00:00 2001 From: Lidia Mokevnina Date: Mon, 19 Feb 2024 21:04:35 +0100 Subject: [PATCH 2/3] [397] added check for controller installation and a dynamic installation message --- lib/uffizzi/cli/account.rb | 2 +- lib/uffizzi/cli/login.rb | 41 +++++++++++++++++-- lib/uffizzi/cli/login_by_identity_token.rb | 2 +- lib/uffizzi/cli/project.rb | 5 ++- lib/uffizzi/helpers/config_helper.rb | 8 +++- .../uffizzi/uffizzi_accounts_success.json | 7 +++- test/uffizzi/cli/login_test.rb | 1 - 7 files changed, 53 insertions(+), 13 deletions(-) diff --git a/lib/uffizzi/cli/account.rb b/lib/uffizzi/cli/account.rb index 1a8702cf..530c82bd 100644 --- a/lib/uffizzi/cli/account.rb +++ b/lib/uffizzi/cli/account.rb @@ -76,7 +76,7 @@ def handle_succeed_set_default_response(response) account = response[:body][:account] account_id = account[:id] account_name = account[:name] - ConfigFile.write_option(:account, Uffizzi::ConfigHelper.account_config(account_id, account_name)) + ConfigFile.write_option(:account, Uffizzi::ConfigHelper.account_config(id: account_id, name: account_name)) Uffizzi.ui.say("The account with name '#{account_name}' was set as default.") projects = account[:projects] diff --git a/lib/uffizzi/cli/login.rb b/lib/uffizzi/cli/login.rb index 5bc0074b..bad916bd 100644 --- a/lib/uffizzi/cli/login.rb +++ b/lib/uffizzi/cli/login.rb @@ -71,6 +71,7 @@ def handle_token_success(response) Uffizzi.ui.say('Login successful') set_current_account_and_project + Uffizzi.ui.say(installation_message) end def open_browser(url) @@ -88,7 +89,7 @@ def handle_succeed_response(response, username) if ENV.fetch('CI_PIPELINE_RUN', false) account = response[:body][:user][:default_account] - return ConfigFile.write_option(:account, Uffizzi::ConfigHelper.account_config(account[:id])) + return ConfigFile.write_option(:account, Uffizzi::ConfigHelper.account_config(id: account[:id])) end set_current_account_and_project @@ -123,7 +124,7 @@ def set_account accounts = accounts_response[:body][:accounts] if accounts.length == 1 current_account = accounts.first - ConfigFile.write_option(:account, Uffizzi::ConfigHelper.account_config(current_account[:id], current_account[:name])) + ConfigFile.write_option(:account, account_config(current_account)) return current_account[:id] end question = 'Select an account:' @@ -131,9 +132,9 @@ def set_account { name: account[:name], value: account[:id] } end account_id = Uffizzi.prompt.select(question, choices) - account_name = accounts.detect { |account| account[:id] == account_id }[:name] + selected_account = accounts.detect { |account| account[:id] == account_id } - ConfigFile.write_option(:account, Uffizzi::ConfigHelper.account_config(account_id, account_name)) + ConfigFile.write_option(:account, account_config(selected_account)) account_id end @@ -211,5 +212,37 @@ def handle_create_project_succeess(response) Uffizzi.ui.say("Project #{project[:name]} was successfully created") end + + def installation_message + account_config = ConfigHelper.read_account_config + if account_config[:has_installation] + "\r\n\r\n"\ + '####################################################################' \ + "\r\n\r\n"\ + "Your CLI is configured to use '#{account_config[:vclusters_controller_url]}'." \ + "\r\n\r\n"\ + 'Run `uffizzi config -h` to see CLI configuration options.'\ + "\r\n\r\n" + else + "\r\n\r\n"\ + '####################################################################'\ + "\r\n\r\n"\ + 'Your CLI is configured to use https://app.uffizzi.com (Uffizzi Cloud).'\ + "\r\n\r\n"\ + 'Run `uffizzi config -h` to see CLI configuration options.'\ + "\r\n"\ + 'Run `uffizzi install -h` to see self-hosted installation options.'\ + "\r\n\r\n" + end + end + + def account_config(account_data) + Uffizzi::ConfigHelper.account_config( + id: account_data[:id], + name: account_data[:name], + has_installation: account_data[:has_installation], + vclusters_controller_url: account_data[:vclusters_controller_url], + ) + end end end diff --git a/lib/uffizzi/cli/login_by_identity_token.rb b/lib/uffizzi/cli/login_by_identity_token.rb index e803197b..f0e4df5a 100644 --- a/lib/uffizzi/cli/login_by_identity_token.rb +++ b/lib/uffizzi/cli/login_by_identity_token.rb @@ -41,7 +41,7 @@ def prepare_request_params(oidc_token, github_access_token) def handle_succeed_response(response, server, oidc_token) ConfigFile.write_option(:server, server) ConfigFile.write_option(:cookie, response[:headers]) - ConfigFile.write_option(:account, Uffizzi::ConfigHelper.account_config(response[:body][:account_id])) + ConfigFile.write_option(:account, Uffizzi::ConfigHelper.account_config(id: response[:body][:account_id])) ConfigFile.write_option(:project, response[:body][:project_slug]) ConfigFile.write_option(:oidc_token, oidc_token) diff --git a/lib/uffizzi/cli/project.rb b/lib/uffizzi/cli/project.rb index 6a684a40..da12bb60 100644 --- a/lib/uffizzi/cli/project.rb +++ b/lib/uffizzi/cli/project.rb @@ -171,10 +171,11 @@ def print_projects(projects) def set_default_project(project) ConfigFile.write_option(:project, project[:slug]) account = project[:account] - return ConfigFile.write_option(:account, Uffizzi::ConfigHelper.account_config(account[:id], account[:name])) if account + account_config = Uffizzi::ConfigHelper.account_config(id: account[:id], name: account[:name]) + return ConfigFile.write_option(:account, account_config) if account # For core versions < core_v2.2.3 - ConfigFile.write_option(:account, Uffizzi::ConfigHelper.account_config(project[:account_id])) + ConfigFile.write_option(:account, Uffizzi::ConfigHelper.account_config(id: project[:account_id])) end end end diff --git a/lib/uffizzi/helpers/config_helper.rb b/lib/uffizzi/helpers/config_helper.rb index 4788a5bb..cf1ee167 100644 --- a/lib/uffizzi/helpers/config_helper.rb +++ b/lib/uffizzi/helpers/config_helper.rb @@ -17,8 +17,8 @@ def read_option_from_config(option) ConfigFile.option_has_value?(option) ? ConfigFile.read_option(option) : nil end - def account_config(id, name = nil) - { id: id, name: name } + def account_config(id:, name: nil, has_installation: false, vclusters_controller_url: nil) + { id: id, name: name, has_installation: has_installation, vclusters_controller_url: vclusters_controller_url } end def update_clusters_config_by_id(id, params) @@ -60,6 +60,10 @@ def dev_environment read_option_from_config(:dev_environment) || {} end + def read_account_config + read_option_from_config(:account) + end + private def clusters diff --git a/test/fixtures/files/uffizzi/uffizzi_accounts_success.json b/test/fixtures/files/uffizzi/uffizzi_accounts_success.json index 444d0aae..66d2131b 100644 --- a/test/fixtures/files/uffizzi/uffizzi_accounts_success.json +++ b/test/fixtures/files/uffizzi/uffizzi_accounts_success.json @@ -2,11 +2,14 @@ "accounts": [ { "id": 1, - "name": "uffizzi" + "name": "uffizzi", + "has_installation": false, + "vclusters_controller_url": "https://controller.uclusters.app.uffizzi.com" }, { "id": 2, - "name": "hello-world" + "name": "hello-world", + "vclusters_controller_url": "https://controller.uclusters.app.uffizzi.com" } ] } diff --git a/test/uffizzi/cli/login_test.rb b/test/uffizzi/cli/login_test.rb index 732da2a1..473d3f59 100644 --- a/test/uffizzi/cli/login_test.rb +++ b/test/uffizzi/cli/login_test.rb @@ -139,7 +139,6 @@ def test_browser_login_with_new_project_creation_success assert_requested(stubbed_uffizzi_projects) assert_requested(stubbed_uffizzi_project) assert_requested(stubbed_uffizzi_accounts) - assert_match('was successfully created', Uffizzi.ui.last_message) end def test_browser_login_with_new_project_creation_when_project_already_exists_and_abort_repeat From 413c5e05e45a7266b4f401638388154cc145f34a Mon Sep 17 00:00:00 2001 From: Lidia Mokevnina Date: Tue, 20 Feb 2024 13:20:53 +0100 Subject: [PATCH 3/3] Change version to 2.4.6 --- Gemfile.lock | 2 +- lib/uffizzi/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8ba561ba..c1c76660 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - uffizzi-cli (2.4.5) + uffizzi-cli (2.4.6) activesupport awesome_print faker diff --git a/lib/uffizzi/version.rb b/lib/uffizzi/version.rb index 675d5897..da9267e6 100644 --- a/lib/uffizzi/version.rb +++ b/lib/uffizzi/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Uffizzi - VERSION = '2.4.5' + VERSION = '2.4.6' end