uffizzi-cli 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +61 -115
- data/config/uffizzi.rb +2 -1
- data/lib/uffizzi/auth_helper.rb +5 -6
- data/lib/uffizzi/cli/common.rb +1 -1
- data/lib/uffizzi/cli/config.rb +40 -8
- data/lib/uffizzi/cli/connect.rb +8 -8
- data/lib/uffizzi/cli/disconnect.rb +1 -1
- data/lib/uffizzi/cli/login.rb +29 -10
- data/lib/uffizzi/cli/logout.rb +2 -2
- data/lib/uffizzi/cli/preview/service.rb +6 -6
- data/lib/uffizzi/cli/preview.rb +11 -11
- data/lib/uffizzi/cli/project/compose.rb +12 -14
- data/lib/uffizzi/cli/project/secret.rb +6 -6
- data/lib/uffizzi/cli/project.rb +2 -2
- data/lib/uffizzi/cli.rb +8 -3
- data/lib/uffizzi/clients/api/api_client.rb +44 -42
- data/lib/uffizzi/clients/api/api_routes.rb +30 -30
- data/lib/uffizzi/clients/api/http_client.rb +2 -4
- data/lib/uffizzi/config_file.rb +36 -20
- data/lib/uffizzi/shell.rb +13 -4
- data/lib/uffizzi/version.rb +1 -1
- data/lib/uffizzi.rb +4 -0
- data/man/uffizzi-config +65 -0
- data/man/uffizzi-config.html +144 -0
- data/man/uffizzi-config.ronn +55 -0
- data/man/uffizzi-login +1 -1
- data/man/uffizzi-login.ronn +1 -1
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de1f8c92c08b2d323c6c379bd5521aa394db91d85ed02ebc73f8c8457bb083d9
|
4
|
+
data.tar.gz: 5c19dc240896c322b27d7dcf42499d6c5a67ce911ef3df625caf78fc71c259c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b653f34930cd546941d9646f7b5e2fccb854a784ed375e7da0b51f2a0cd9d9642b2463598ed6092e2d86be2de6ba804c9ae4c474290e5bdcee12123ad04fcd96
|
7
|
+
data.tar.gz: 7f4c915af4bebe54b1ae2e96b2661d08374ce4d71a9fed04388b815bf3c6c6e02039bed214d8e6da678dc427d6753ac17869473a172df5c81bc5f2dca9c0c7c3
|
data/README.md
CHANGED
@@ -4,22 +4,20 @@ A command-line interace (CLI) for [Uffizzi App](https://github.com/UffizziCloud/
|
|
4
4
|
|
5
5
|
## Uffizzi Overview
|
6
6
|
|
7
|
-
Uffizzi is
|
7
|
+
Uffizzi is an open-source engine for creating lightweight, ephemeral test environments for APIs and full-stack applications. Uffizzi enables teams to preview new features before merging and to mitigate the risk of introducing regressions into a codebase. Each preview gets a shareable URL that's updated when you push new commits or image tags, so teams can provide continual feedback during the development/QA process. Previews can be configured to expire or be destroyed when a pull request is closed, so environments exist only as long as they are needed. Uffizzi also helps deconflict shared development environments since previews are deployed as isolated namespaces—there is no risk of clobbering another developer's preview.
|
8
8
|
|
9
|
-
|
9
|
+
While Uffizzi depends on Kubernetes, it does not require end-users to interface with Kubernetes directly. Instead, Uffizzi leverages Docker Compose as its configuration file format, so developers do not need modify Kubernetes manifests or even know about Kubernetes.
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
Alternatively, you can self-host Uffizzi via the open-source repositories available here on GitHub. The remainder of this README is intended for users interested in self-hosting Uffizzi or for those who are just curious about how Uffizzi works.
|
11
|
+
Uffizzi is designed to integrate with any CI/CD system.
|
14
12
|
|
15
13
|
## Uffizzi Architecture
|
14
|
+
<img src="https://github.com/UffizziCloud/uffizzi_app/blob/main/docs/images/uffizzi-architecture.png" description="Uffizzi Architecture" width="320"/>
|
16
15
|
|
17
16
|
Uffizzi consists of the following components:
|
18
17
|
|
19
18
|
- [Uffizzi App](https://github.com/UffizziCloud/uffizzi_app) - The primary REST API for creating and managing Previews
|
20
19
|
- [Uffizzi Controller](https://github.com/UffizziCloud/uffizzi_controller) - A smart proxy service that handles requests from Uffizzi App to the Kubernetes API
|
21
20
|
- Uffizzi CLI (this repository) - A command-line interface for Uffizzi App
|
22
|
-
- [Uffizzi Dashboard](https://app.uffizzi.com) - A graphical user interface for Uffizzi App, available as a paid service at https://uffizzi.com
|
23
21
|
|
24
22
|
To host Uffizzi yourself, you will also need the following external dependencies:
|
25
23
|
|
@@ -29,197 +27,145 @@ To host Uffizzi yourself, you will also need the following external dependencies
|
|
29
27
|
|
30
28
|
## Installation
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
```ruby
|
35
|
-
gem 'uffizzi-cli'
|
36
|
-
```
|
37
|
-
|
38
|
-
And then execute:
|
39
|
-
|
40
|
-
$ bundle install
|
41
|
-
|
42
|
-
Or install it yourself as:
|
43
|
-
|
44
|
-
$ gem install uffizzi-cli
|
30
|
+
The Uffizzi CLI can be used interactively or as part of an automated workflow (e.g. GitHub Actions). Both options use the `uffizzi/cli` container image available on Docker Hub.
|
45
31
|
|
46
|
-
###
|
32
|
+
### Interactive mode
|
47
33
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
docker run -it --rm uffizzi/cli project list
|
34
|
+
Run the CLI as a Docker container in interactive mode:
|
35
|
+
```
|
36
|
+
docker run --interactive --rm --tty --entrypoint=sh uffizzi/cli
|
52
37
|
```
|
53
38
|
|
54
39
|
If you specify the following environment variables, the Docker image's
|
55
40
|
entrypoint script can log you into Uffizzi before executing your command.
|
56
41
|
|
57
42
|
- `UFFIZZI_USER`
|
58
|
-
- `
|
43
|
+
- `UFFIZZI_SERVER`
|
59
44
|
- `UFFIZZI_PASSWORD`
|
60
45
|
- `UFFIZZI_PROJECT` (optional)
|
61
46
|
|
62
|
-
|
63
|
-
|
64
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
65
|
-
|
66
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
67
|
-
|
68
|
-
Run rubocop:
|
69
|
-
`bundle exec rubocop -A`
|
70
|
-
|
71
|
-
## Testing
|
47
|
+
### Automated mode
|
72
48
|
|
73
|
-
|
74
|
-
`bundle exec rake test`
|
75
|
-
|
76
|
-
Run tests from a file:
|
77
|
-
`bundle exec rake test TEST=test/uffizzi/cli/preview_test.rb`
|
78
|
-
|
79
|
-
Run single test
|
80
|
-
`bundle exec rake test TEST=test/uffizzi/cli/preview_test.rb TESTOPTS="--name=test_name"`
|
81
|
-
|
82
|
-
## Commands
|
83
|
-
|
84
|
-
### login
|
49
|
+
If you want to use Uffizzi as part of an automated workflow, you can pass the Uffizzi commands to the Docker run command. For example:
|
85
50
|
|
86
51
|
```
|
87
|
-
|
52
|
+
docker run -it --rm uffizzi/cli project list
|
88
53
|
```
|
89
54
|
|
90
|
-
|
91
|
-
|
92
|
-
### login options
|
55
|
+
## Sample commands and examples
|
93
56
|
|
94
|
-
|
95
|
-
| ------------ | ------ | ------------------------- |
|
96
|
-
| `--user` | `-u` | Your email for logging in |
|
97
|
-
| `--hostname` | | Adress of your app |
|
57
|
+
### help
|
98
58
|
|
99
|
-
|
59
|
+
The `help` subcommand can be used to see more information about a particular command.
|
100
60
|
|
101
|
-
|
61
|
+
Examples:
|
102
62
|
|
103
63
|
```
|
104
|
-
|
64
|
+
uffizzi help
|
105
65
|
```
|
106
66
|
|
107
|
-
Use this command to configure your projects. This command has 2 subcommands `list` and `compose`.
|
108
|
-
|
109
67
|
```
|
110
|
-
|
68
|
+
uffizzi preview help
|
111
69
|
```
|
112
70
|
|
113
|
-
Shows all your projects' slugs
|
114
|
-
|
115
|
-
If you have only one project it will be added to your config file automatically, if there's more than one project you need to set up your project manually with the command `uffizzi config set YOUR_PROJECT_SLUG`
|
116
|
-
|
117
|
-
### compose
|
118
|
-
|
119
71
|
```
|
120
|
-
|
72
|
+
uffizzi project compose help
|
121
73
|
```
|
122
74
|
|
123
|
-
|
75
|
+
### login
|
124
76
|
|
125
77
|
```
|
126
|
-
|
78
|
+
uffizzi login --server=localhost:8080 --username=your@email.com
|
127
79
|
```
|
128
80
|
|
129
|
-
|
81
|
+
Log in to the app with the specified server.
|
130
82
|
|
131
|
-
|
132
|
-
$ uffizzi project compose describe
|
133
|
-
```
|
83
|
+
#### login options
|
134
84
|
|
135
|
-
|
85
|
+
| Option | Aliase | Description |
|
86
|
+
| ------------ | ------ | ------------------------- |
|
87
|
+
| `--username` | `-u` | Your email for logging in |
|
88
|
+
| `--server` | | The URL of the Uffizzi installation |
|
136
89
|
|
137
|
-
|
138
|
-
$ uffizzi project compose unset
|
139
|
-
```
|
90
|
+
If server uses basic authentication you can specify options for it by setting `basic_auth_user` and `basic_auth_password` via `config set` command.
|
140
91
|
|
141
|
-
|
92
|
+
### config
|
142
93
|
|
143
|
-
|
94
|
+
Use this command to configure your cli app.
|
144
95
|
|
145
|
-
|
96
|
+
```
|
97
|
+
$ uffizzi config
|
98
|
+
```
|
146
99
|
|
147
|
-
|
148
|
-
| -------- | ------ | ------------------------- |
|
149
|
-
| `--file` | `-f` | Path to your compose file |
|
100
|
+
Launching interactive setup guide that sets the values for `server`, `username` and `project`
|
150
101
|
|
151
|
-
### config
|
102
|
+
### config subcommands
|
152
103
|
|
153
|
-
|
104
|
+
This command has 4 subcommands `list`, `get`, `set`, and `delete`.
|
154
105
|
|
155
106
|
```
|
156
|
-
|
107
|
+
uffizzi config list
|
157
108
|
```
|
158
109
|
|
159
110
|
Shows all options and their values from the config file.
|
160
111
|
|
161
112
|
```
|
162
|
-
|
113
|
+
uffizzi config get-value OPTION
|
163
114
|
```
|
164
115
|
|
165
116
|
Shows the value of the specified option.
|
166
117
|
|
167
118
|
```
|
168
|
-
|
119
|
+
uffizzi config set OPTION VALUE
|
169
120
|
```
|
170
121
|
|
171
122
|
Sets specified value for specified option. If a specified option already exists and has value it will be overwritten.
|
172
123
|
|
173
124
|
```
|
174
|
-
|
125
|
+
uffizzi config unset OPTION
|
175
126
|
```
|
176
127
|
|
177
|
-
|
128
|
+
Unsets specified option.
|
178
129
|
|
179
|
-
###
|
130
|
+
### project
|
180
131
|
|
181
132
|
```
|
182
|
-
|
133
|
+
uffizzi project
|
183
134
|
```
|
184
135
|
|
185
|
-
|
136
|
+
Use this command to configure your projects. This command has 2 subcommands `list` and `compose`.
|
186
137
|
|
187
|
-
|
138
|
+
```
|
139
|
+
uffizzi project list
|
140
|
+
```
|
188
141
|
|
189
|
-
|
142
|
+
Shows all your projects' slugs
|
190
143
|
|
191
|
-
|
144
|
+
If you have only one project it will be added to your config file automatically, if there's more than one project you need to set up your project manually with the command `uffizzi config set YOUR_PROJECT_SLUG`
|
192
145
|
|
193
|
-
|
146
|
+
### preview
|
194
147
|
|
195
|
-
|
148
|
+
Create and manage previews
|
196
149
|
|
197
|
-
2. Pull repository to ensure you have the latest changes
|
198
150
|
```
|
199
|
-
|
151
|
+
uffizzi preview create docker-compose.uffizzi.yml
|
200
152
|
```
|
153
|
+
Create a preview from a compose file.
|
201
154
|
|
202
|
-
3. Start new branch from `develop`
|
203
155
|
```
|
204
|
-
|
156
|
+
uffizzi preview delete deployment-21
|
205
157
|
```
|
158
|
+
Delete a preview with preview ID `deployment-21`.
|
159
|
+
|
160
|
+
### disconnect
|
206
161
|
|
207
|
-
4. Make changes you need for the feature, commit them to the repo
|
208
162
|
```
|
209
|
-
|
210
|
-
git commit -m 'short commit description' (e.g. git commit -m 'added domain settings')
|
211
|
-
git push origin BRANCH_NAME
|
163
|
+
uffizzi disconnect CREDENTIAL_TYPE
|
212
164
|
```
|
213
165
|
|
214
|
-
|
166
|
+
Deletes credential of specified type
|
215
167
|
|
216
|
-
|
217
|
-
```
|
218
|
-
git checkout qa
|
219
|
-
git pull --rebase qa
|
220
|
-
git merge --no-ff BRANCH_NAME
|
221
|
-
git push origin qa
|
222
|
-
```
|
168
|
+
Supported credential types - `docker-hub`, `acr`, `ecr`, `gcr`
|
223
169
|
|
224
170
|
## Contributing
|
225
171
|
|
data/config/uffizzi.rb
CHANGED
@@ -12,7 +12,7 @@ module Uffizzi
|
|
12
12
|
end
|
13
13
|
|
14
14
|
configure do |config|
|
15
|
-
config.
|
15
|
+
config.server = 'http://web:7000'
|
16
16
|
config.credential_types = {
|
17
17
|
dockerhub: 'UffizziCore::Credential::DockerHub',
|
18
18
|
azure: 'UffizziCore::Credential::Azure',
|
@@ -20,5 +20,6 @@ module Uffizzi
|
|
20
20
|
amazon: 'UffizziCore::Credential::Amazon',
|
21
21
|
github_container_registry: 'UffizziCore::Credential::GithubContainerRegistry',
|
22
22
|
}
|
23
|
+
config.default_server = 'app.uffizzi.com'
|
23
24
|
end
|
24
25
|
end
|
data/lib/uffizzi/auth_helper.rb
CHANGED
@@ -5,14 +5,13 @@ module Uffizzi
|
|
5
5
|
class << self
|
6
6
|
def signed_in?
|
7
7
|
ConfigFile.exists? &&
|
8
|
-
ConfigFile.
|
9
|
-
ConfigFile.
|
10
|
-
ConfigFile.
|
8
|
+
ConfigFile.option_has_value?(:account_id) &&
|
9
|
+
ConfigFile.option_has_value?(:cookie) &&
|
10
|
+
ConfigFile.option_has_value?(:server)
|
11
11
|
end
|
12
12
|
|
13
|
-
def project_set?
|
14
|
-
ConfigFile.exists? &&
|
15
|
-
ConfigFile.option_exists?(:project)
|
13
|
+
def project_set?(options)
|
14
|
+
!options[:project].nil? || (ConfigFile.exists? && ConfigFile.option_has_value?(:project))
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
data/lib/uffizzi/cli/common.rb
CHANGED
data/lib/uffizzi/cli/config.rb
CHANGED
@@ -7,13 +7,19 @@ module Uffizzi
|
|
7
7
|
class CLI::Config < Thor
|
8
8
|
include ApiClient
|
9
9
|
|
10
|
+
class << self
|
11
|
+
def help(_shell, _subcommand)
|
12
|
+
Cli::Common.show_manual(:config)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
10
16
|
desc 'list', 'list'
|
11
17
|
def list
|
12
18
|
run('list')
|
13
19
|
end
|
14
20
|
|
15
21
|
desc 'get [PROPERTY]', 'get'
|
16
|
-
def
|
22
|
+
def get_value(property)
|
17
23
|
run('get', property)
|
18
24
|
end
|
19
25
|
|
@@ -22,11 +28,20 @@ module Uffizzi
|
|
22
28
|
run('set', property, value)
|
23
29
|
end
|
24
30
|
|
25
|
-
desc '
|
26
|
-
def
|
27
|
-
run('
|
31
|
+
desc 'unset [PROPERTY]', 'unset'
|
32
|
+
def unset(property)
|
33
|
+
run('unset', property)
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'setup', 'setup'
|
37
|
+
def setup
|
38
|
+
run('setup')
|
28
39
|
end
|
29
40
|
|
41
|
+
map('get-value' => :get_value)
|
42
|
+
|
43
|
+
default_task :setup
|
44
|
+
|
30
45
|
private
|
31
46
|
|
32
47
|
def run(command, property = nil, value = nil)
|
@@ -37,11 +52,26 @@ module Uffizzi
|
|
37
52
|
handle_get_command(property)
|
38
53
|
when 'set'
|
39
54
|
handle_set_command(property, value)
|
40
|
-
when '
|
41
|
-
|
55
|
+
when 'unset'
|
56
|
+
handle_unset_command(property)
|
57
|
+
when 'setup'
|
58
|
+
handle_setup_command
|
42
59
|
end
|
43
60
|
end
|
44
61
|
|
62
|
+
def handle_setup_command
|
63
|
+
Uffizzi.ui.say("Configure the default properties that will be used to authenticate with your \
|
64
|
+
\nUffizzi API service and manage previews.\n")
|
65
|
+
server = Uffizzi.ui.ask('Server: ', default: Uffizzi.configuration.default_server.to_s)
|
66
|
+
username = Uffizzi.ui.ask('Username: ')
|
67
|
+
project = Uffizzi.ui.ask('Project: ')
|
68
|
+
ConfigFile.delete
|
69
|
+
ConfigFile.write_option(:server, server)
|
70
|
+
ConfigFile.write_option(:username, username)
|
71
|
+
ConfigFile.write_option(:project, project)
|
72
|
+
Uffizzi.ui.say('To login, run: uffizzi login')
|
73
|
+
end
|
74
|
+
|
45
75
|
def handle_list_command
|
46
76
|
ConfigFile.list
|
47
77
|
end
|
@@ -55,10 +85,12 @@ module Uffizzi
|
|
55
85
|
|
56
86
|
def handle_set_command(property, value)
|
57
87
|
ConfigFile.write_option(property.to_sym, value)
|
88
|
+
Uffizzi.ui.say("Updated property [#{property}]")
|
58
89
|
end
|
59
90
|
|
60
|
-
def
|
61
|
-
ConfigFile.
|
91
|
+
def handle_unset_command(property)
|
92
|
+
ConfigFile.unset_option(property.to_sym)
|
93
|
+
Uffizzi.ui.say("Unset property [#{property}]")
|
62
94
|
end
|
63
95
|
end
|
64
96
|
end
|
data/lib/uffizzi/cli/connect.rb
CHANGED
@@ -35,8 +35,8 @@ module Uffizzi
|
|
35
35
|
type: Uffizzi.configuration.credential_types[:dockerhub],
|
36
36
|
}
|
37
37
|
|
38
|
-
|
39
|
-
response = create_credential(
|
38
|
+
server = ConfigFile.read_option(:server)
|
39
|
+
response = create_credential(server, params)
|
40
40
|
|
41
41
|
if ResponseHelper.created?(response)
|
42
42
|
print_success_message('DockerHub')
|
@@ -57,8 +57,8 @@ module Uffizzi
|
|
57
57
|
type: Uffizzi.configuration.credential_types[:azure],
|
58
58
|
}
|
59
59
|
|
60
|
-
|
61
|
-
response = create_credential(
|
60
|
+
server = ConfigFile.read_option(:server)
|
61
|
+
response = create_credential(server, params)
|
62
62
|
|
63
63
|
if ResponseHelper.created?(response)
|
64
64
|
print_success_message('ACR')
|
@@ -79,8 +79,8 @@ module Uffizzi
|
|
79
79
|
type: Uffizzi.configuration.credential_types[:amazon],
|
80
80
|
}
|
81
81
|
|
82
|
-
|
83
|
-
response = create_credential(
|
82
|
+
server = ConfigFile.read_option(:server)
|
83
|
+
response = create_credential(server, params)
|
84
84
|
|
85
85
|
if ResponseHelper.created?(response)
|
86
86
|
print_success_message('ECR')
|
@@ -103,8 +103,8 @@ module Uffizzi
|
|
103
103
|
type: Uffizzi.configuration.credential_types[:google],
|
104
104
|
}
|
105
105
|
|
106
|
-
|
107
|
-
response = create_credential(
|
106
|
+
server = ConfigFile.read_option(:server)
|
107
|
+
response = create_credential(server, params)
|
108
108
|
|
109
109
|
if ResponseHelper.created?(response)
|
110
110
|
print_success_message('GCR')
|
@@ -22,7 +22,7 @@ module Uffizzi
|
|
22
22
|
raise Uffizzi::Error.new('Unsupported credential type.')
|
23
23
|
end
|
24
24
|
|
25
|
-
response = delete_credential(ConfigFile.read_option(:
|
25
|
+
response = delete_credential(ConfigFile.read_option(:server), connection_type)
|
26
26
|
|
27
27
|
if ResponseHelper.no_content?(response)
|
28
28
|
Uffizzi.ui.say("Successfully disconnected #{connection_name(credential_type)} connection")
|
data/lib/uffizzi/cli/login.rb
CHANGED
@@ -13,13 +13,15 @@ module Uffizzi
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def run
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
Uffizzi.ui.say('Login to Uffizzi to your previews.')
|
17
|
+
server = set_server
|
18
|
+
username = set_username
|
19
|
+
password = set_password
|
20
|
+
params = prepare_request_params(username, password)
|
21
|
+
response = create_session(server, params)
|
20
22
|
|
21
23
|
if ResponseHelper.created?(response)
|
22
|
-
handle_succeed_response(response)
|
24
|
+
handle_succeed_response(response, server, username)
|
23
25
|
else
|
24
26
|
ResponseHelper.handle_failed_response(response)
|
25
27
|
end
|
@@ -27,20 +29,37 @@ module Uffizzi
|
|
27
29
|
|
28
30
|
private
|
29
31
|
|
30
|
-
def
|
32
|
+
def set_server
|
33
|
+
config_server = ConfigFile.exists? && ConfigFile.option_has_value?(:server) ? ConfigFile.read_option(:server) : nil
|
34
|
+
@options[:server] || config_server || Uffizzi.ui.ask('Server: ')
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_username
|
38
|
+
config_username = ConfigFile.exists? && ConfigFile.option_has_value?(:username) ? ConfigFile.read_option(:username) : nil
|
39
|
+
@options[:username] || config_username || Uffizzi.ui.ask('Username: ')
|
40
|
+
end
|
41
|
+
|
42
|
+
def set_password
|
43
|
+
ENV['UFFIZZI_PASSWORD'] || Uffizzi.ui.ask('Password: ', echo: false)
|
44
|
+
end
|
45
|
+
|
46
|
+
def prepare_request_params(username, password)
|
31
47
|
{
|
32
48
|
user: {
|
33
|
-
email:
|
34
|
-
password: password
|
49
|
+
email: username,
|
50
|
+
password: password,
|
35
51
|
},
|
36
52
|
}
|
37
53
|
end
|
38
54
|
|
39
|
-
def handle_succeed_response(response)
|
55
|
+
def handle_succeed_response(response, server, username)
|
40
56
|
account = response[:body][:user][:accounts].first
|
41
57
|
return Uffizzi.ui.say('No account related to this email') unless account_valid?(account)
|
42
58
|
|
43
|
-
ConfigFile.
|
59
|
+
ConfigFile.write_option(:server, server)
|
60
|
+
ConfigFile.write_option(:username, username)
|
61
|
+
ConfigFile.write_option(:cookie, response[:headers])
|
62
|
+
ConfigFile.write_option(:account_id, account[:id])
|
44
63
|
end
|
45
64
|
|
46
65
|
def account_valid?(account)
|
data/lib/uffizzi/cli/logout.rb
CHANGED
@@ -14,8 +14,8 @@ module Uffizzi
|
|
14
14
|
def run
|
15
15
|
return Uffizzi.ui.say('You are not logged in') unless Uffizzi::AuthHelper.signed_in?
|
16
16
|
|
17
|
-
|
18
|
-
destroy_session(
|
17
|
+
server = ConfigFile.read_option(:server)
|
18
|
+
destroy_session(server)
|
19
19
|
|
20
20
|
ConfigFile.delete
|
21
21
|
Uffizzi.ui.say('You have been successfully logged out')
|
@@ -12,7 +12,7 @@ module Uffizzi
|
|
12
12
|
desc 'logs [LOGS_TYPE] [DEPLOYMENT_ID] [CONTAINER_NAME]', 'logs'
|
13
13
|
def logs(logs_type, deployment_name, container_name = args)
|
14
14
|
return Uffizzi.ui.say('You are not logged in.') unless Uffizzi::AuthHelper.signed_in?
|
15
|
-
return Uffizzi.ui.say('This command needs project to be set in config file') unless Uffizzi::AuthHelper.project_set?
|
15
|
+
return Uffizzi.ui.say('This command needs project to be set in config file') unless Uffizzi::AuthHelper.project_set?(options)
|
16
16
|
|
17
17
|
deployment_id = PreviewService.read_deployment_id(deployment_name)
|
18
18
|
response = service_logs_response(logs_type, deployment_id, container_name)
|
@@ -28,12 +28,12 @@ module Uffizzi
|
|
28
28
|
desc 'logs [DEPLOYMENT_ID]', 'list'
|
29
29
|
def list(deployment_name)
|
30
30
|
return Uffizzi.ui.say('You are not logged in.') unless Uffizzi::AuthHelper.signed_in?
|
31
|
-
return Uffizzi.ui.say('This command needs project to be set in config file') unless Uffizzi::AuthHelper.project_set?
|
31
|
+
return Uffizzi.ui.say('This command needs project to be set in config file') unless Uffizzi::AuthHelper.project_set?(options)
|
32
32
|
|
33
33
|
project_slug = ConfigFile.read_option(:project)
|
34
|
-
|
34
|
+
server = ConfigFile.read_option(:server)
|
35
35
|
deployment_id = PreviewService.read_deployment_id(deployment_name)
|
36
|
-
response = fetch_deployment_services(
|
36
|
+
response = fetch_deployment_services(server, project_slug, deployment_id)
|
37
37
|
|
38
38
|
if ResponseHelper.ok?(response)
|
39
39
|
handle_succeed_list_response(response, deployment_name)
|
@@ -46,11 +46,11 @@ module Uffizzi
|
|
46
46
|
|
47
47
|
def service_logs_response(logs_type, deployment_id, container_name)
|
48
48
|
project_slug = ConfigFile.read_option(:project)
|
49
|
-
|
49
|
+
server = ConfigFile.read_option(:server)
|
50
50
|
|
51
51
|
case logs_type
|
52
52
|
when 'container'
|
53
|
-
fetch_deployment_service_logs(
|
53
|
+
fetch_deployment_service_logs(server, project_slug, deployment_id, container_name)
|
54
54
|
else
|
55
55
|
raise Uffizzi::Error.new('Unknown log type')
|
56
56
|
end
|