Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
lidiamokevnina committed Feb 20, 2024
2 parents bf5b408 + 413c5e0 commit a090404
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 53 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
uffizzi-cli (2.4.5)
uffizzi-cli (2.4.6)
activesupport
awesome_print
faker
Expand Down
2 changes: 1 addition & 1 deletion lib/uffizzi/cli/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
41 changes: 37 additions & 4 deletions lib/uffizzi/cli/login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -123,17 +124,17 @@ 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:'
choices = accounts.map do |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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/uffizzi/cli/login_by_identity_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 3 additions & 2 deletions lib/uffizzi/cli/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 6 additions & 2 deletions lib/uffizzi/helpers/config_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/uffizzi/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Uffizzi
VERSION = '2.4.5'
VERSION = '2.4.6'
end
73 changes: 38 additions & 35 deletions man/uffizzi-install.ronn
Original file line number Diff line number Diff line change
@@ -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 [email protected] 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="[email protected]"

To install Uffizzi using context 'foo' and namespace 'bar', run:

$ uffizzi install uffizzi.example.com --email="[email protected]" \
--context='foo' --namespace='bar'
23 changes: 23 additions & 0 deletions man/uffizzi-uninstall.ronn
Original file line number Diff line number Diff line change
@@ -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
11 changes: 9 additions & 2 deletions man/uffizzi.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 5 additions & 2 deletions test/fixtures/files/uffizzi/uffizzi_accounts_success.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
1 change: 0 additions & 1 deletion test/uffizzi/cli/login_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a090404

Please sign in to comment.