uffizzi-cli 0.11.2 → 0.11.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c1515d3dbc2f3e8cdf08d18602248f6059aede5e63c702600f0cca97efa19d8
4
- data.tar.gz: 7945ef89453d07a194f61102ab72484a24b5b4a44ebc834cb7bbfac06393e1bb
3
+ metadata.gz: a81fa2bb6f00491f6c59e4c10ea3ce067da1b75b26ff8543e1a08558893058c0
4
+ data.tar.gz: fec82e0d04c499515f0221740a1a40b51bd5593a35223c0a7723648f20b25a5e
5
5
  SHA512:
6
- metadata.gz: 0deb98fdefb88dd09a65f1991c7980fe253eea34325f0cc044433823fe4ef2408d3dd2002078a141e94830ea8e3db4aa938dda9bfcf17b51f9526900ac04ba75
7
- data.tar.gz: bc4b3deeae31d244aa8d2b76e3ab00ca671af015df70f328c9a843ffd27270275d098bdbe20fa5421db242e9311c93e2854be04063863086207180dae2a1fd4d
6
+ metadata.gz: 82610a6fe745521646e7d7e7c5e0f65a39263ea53987f1e431d0a0d0b69033d015a67bcd48b07e30c5d044f2167c752f307525438ca232044e90c5b60eb0f602
7
+ data.tar.gz: 67d5b6c3947e01e72c3ec678b6b14a1ccc6b78583d34f46274cdfa1f7692c9632b98728f43bf1ab5e0b3e984313db98e536c5231ddb9d2a07cc8156b8334ca2e
@@ -20,24 +20,26 @@ module Uffizzi
20
20
  desc 'docker-hub', 'Connect to Docker Hub (hub.docker.com)'
21
21
  method_option :skip_raise_existence_error, type: :boolean, default: false,
22
22
  desc: 'Skip raising an error within check the credential'
23
+ method_option :update_credential_if_exists, type: :boolean, default: false
23
24
  def docker_hub
24
25
  type = Uffizzi.configuration.credential_types[:dockerhub]
25
- check_credential_existence(type, 'docker-hub')
26
+ credential_exists = credential_exists?(type)
27
+ handle_existing_credential_options('docker-hub') if credential_exists
26
28
 
27
- username = ENV['DOCKERHUB_USERNAME'] || Uffizzi.ui.ask('Username: ')
28
- password = ENV['DOCKERHUB_PASSWORD'] || Uffizzi.ui.ask('Password: ', echo: false)
29
+ username = ENV['DOCKERHUB_USERNAME'] || Uffizzi.ui.ask('Username:')
30
+ password = ENV['DOCKERHUB_PASSWORD'] || Uffizzi.ui.ask('Password:', echo: false)
29
31
 
30
32
  params = {
31
33
  username: username,
32
34
  password: password,
33
- type: Uffizzi.configuration.credential_types[:dockerhub],
35
+ type: type,
34
36
  }
35
37
 
36
38
  server = ConfigFile.read_option(:server)
37
- response = create_credential(server, params)
39
+ response = create_or_update_credential(server, params, create: !credential_exists)
38
40
 
39
- if ResponseHelper.created?(response)
40
- print_success_message('DockerHub')
41
+ if successful?(response)
42
+ print_success_message('Docker Hub')
41
43
  else
42
44
  ResponseHelper.handle_failed_response(response)
43
45
  end
@@ -46,13 +48,15 @@ module Uffizzi
46
48
  desc 'acr', 'Connect to Azure Container Registry (azurecr.io)'
47
49
  method_option :skip_raise_existence_error, type: :boolean, default: false,
48
50
  desc: 'Skip raising an error within check the credential'
51
+ method_option :update_credential_if_exists, type: :boolean, default: false
49
52
  def acr
50
53
  type = Uffizzi.configuration.credential_types[:azure]
51
- check_credential_existence(type, 'acr')
54
+ credential_exists = credential_exists?(type)
55
+ handle_existing_credential_options('acr') if credential_exists
52
56
 
53
- registry_url = ENV['ACR_REGISTRY_URL'] || Uffizzi.ui.ask('Registry Domain: ')
54
- username = ENV['ACR_USERNAME'] || Uffizzi.ui.ask('Docker ID: ')
55
- password = ENV['ACR_PASSWORD'] || Uffizzi.ui.ask('Password/Access Token: ', echo: false)
57
+ registry_url = ENV['ACR_REGISTRY_URL'] || Uffizzi.ui.ask('Registry Domain:')
58
+ username = ENV['ACR_USERNAME'] || Uffizzi.ui.ask('Docker ID:')
59
+ password = ENV['ACR_PASSWORD'] || Uffizzi.ui.ask('Password/Access Token:', echo: false)
56
60
 
57
61
  params = {
58
62
  username: username,
@@ -62,9 +66,9 @@ module Uffizzi
62
66
  }
63
67
 
64
68
  server = ConfigFile.read_option(:server)
65
- response = create_credential(server, params)
69
+ response = create_or_update_credential(server, params, create: !credential_exists)
66
70
 
67
- if ResponseHelper.created?(response)
71
+ if successful?(response)
68
72
  print_success_message('ACR')
69
73
  else
70
74
  ResponseHelper.handle_failed_response(response)
@@ -74,13 +78,15 @@ module Uffizzi
74
78
  desc 'ecr', 'Connect to Amazon Elastic Container Registry'
75
79
  method_option :skip_raise_existence_error, type: :boolean, default: false,
76
80
  desc: 'Skip raising an error within check the credential'
81
+ method_option :update_credential_if_exists, type: :boolean, default: false
77
82
  def ecr
78
83
  type = Uffizzi.configuration.credential_types[:amazon]
79
- check_credential_existence(type, 'ecr')
84
+ credential_exists = credential_exists?(type)
85
+ handle_existing_credential_options('ecr') if credential_exists
80
86
 
81
- registry_url = ENV['AWS_REGISTRY_URL'] || Uffizzi.ui.ask('Registry Domain: ')
82
- access_key = ENV['AWS_ACCESS_KEY_ID'] || Uffizzi.ui.ask('Access key ID: ')
83
- secret_access_key = ENV['AWS_SECRET_ACCESS_KEY'] || Uffizzi.ui.ask('Secret access key: ', echo: false)
87
+ registry_url = ENV['AWS_REGISTRY_URL'] || Uffizzi.ui.ask('Registry Domain:')
88
+ access_key = ENV['AWS_ACCESS_KEY_ID'] || Uffizzi.ui.ask('Access key ID:')
89
+ secret_access_key = ENV['AWS_SECRET_ACCESS_KEY'] || Uffizzi.ui.ask('Secret access key:', echo: false)
84
90
 
85
91
  params = {
86
92
  username: access_key,
@@ -90,9 +96,9 @@ module Uffizzi
90
96
  }
91
97
 
92
98
  server = ConfigFile.read_option(:server)
93
- response = create_credential(server, params)
99
+ response = create_or_update_credential(server, params, create: !credential_exists)
94
100
 
95
- if ResponseHelper.created?(response)
101
+ if successful?(response)
96
102
  print_success_message('ECR')
97
103
  else
98
104
  ResponseHelper.handle_failed_response(response)
@@ -102,9 +108,11 @@ module Uffizzi
102
108
  desc 'gcr', 'Connect to Google Container Registry (gcr.io)'
103
109
  method_option :skip_raise_existence_error, type: :boolean, default: false,
104
110
  desc: 'Skip raising an error within check the credential'
111
+ method_option :update_credential_if_exists, type: :boolean, default: false
105
112
  def gcr(credential_file_path = nil)
106
113
  type = Uffizzi.configuration.credential_types[:google]
107
- check_credential_existence(type, 'gcr')
114
+ credential_exists = credential_exists?(type)
115
+ handle_existing_credential_options('gcr') if credential_exists
108
116
 
109
117
  credential_content = google_service_account_content(credential_file_path)
110
118
 
@@ -114,9 +122,9 @@ module Uffizzi
114
122
  }
115
123
 
116
124
  server = ConfigFile.read_option(:server)
117
- response = create_credential(server, params)
125
+ response = create_or_update_credential(server, params, create: !credential_exists)
118
126
 
119
- if ResponseHelper.created?(response)
127
+ if successful?(response)
120
128
  print_success_message('GCR')
121
129
  else
122
130
  ResponseHelper.handle_failed_response(response)
@@ -126,12 +134,16 @@ module Uffizzi
126
134
  desc 'ghcr', 'Connect to GitHub Container Registry (ghcr.io)'
127
135
  method_option :skip_raise_existence_error, type: :boolean, default: false,
128
136
  desc: 'Skip raising an error within check the credential'
137
+ method_option :update_credential_if_exists, type: :boolean, default: false
138
+ method_option :username, type: :string, aliases: :u
139
+ method_option :token, type: :string, aliases: :t
129
140
  def ghcr
130
141
  type = Uffizzi.configuration.credential_types[:github_registry]
131
- check_credential_existence(type, 'ghcr')
142
+ credential_exists = credential_exists?(type)
143
+ handle_existing_credential_options('ghcr') if credential_exists
132
144
 
133
- username = ENV['GITHUB_USERNAME'] || Uffizzi.ui.ask('Github Username: ')
134
- password = ENV['GITHUB_ACCESS_TOKEN'] || Uffizzi.ui.ask('Access Token: ', echo: false)
145
+ username = options[:username] || ENV['GITHUB_USERNAME'] || Uffizzi.ui.ask('Github Username:')
146
+ password = options[:token] || ENV['GITHUB_ACCESS_TOKEN'] || Uffizzi.ui.ask('Access Token:', echo: false)
135
147
 
136
148
  params = {
137
149
  username: username,
@@ -140,9 +152,9 @@ module Uffizzi
140
152
  }
141
153
 
142
154
  server = ConfigFile.read_option(:server)
143
- response = create_credential(server, params)
155
+ response = create_or_update_credential(server, params, create: !credential_exists)
144
156
 
145
- if ResponseHelper.created?(response)
157
+ if successful?(response)
146
158
  print_success_message('GHCR')
147
159
  else
148
160
  ResponseHelper.handle_failed_response(response)
@@ -154,31 +166,46 @@ module Uffizzi
154
166
 
155
167
  private
156
168
 
169
+ def successful?(response)
170
+ ResponseHelper.created?(response) || ResponseHelper.ok?(response)
171
+ end
172
+
157
173
  def prepare_registry_url(registry_url)
158
174
  return registry_url if registry_url.match?(/^(?:http(s)?:\/\/)/)
159
175
 
160
176
  "https://#{registry_url}"
161
177
  end
162
178
 
163
- def print_success_message(connection_name)
164
- Uffizzi.ui.say("Successfully connected to #{connection_name}")
179
+ def print_success_message(credential_type_slug)
180
+ Uffizzi.ui.say("Successfully connected to #{credential_type_slug}.")
165
181
  end
166
182
 
167
- def check_credential_existence(type, connection_name)
183
+ def credential_exists?(type)
168
184
  server = ConfigFile.read_option(:server)
169
185
  response = check_credential(server, type)
170
- return if ResponseHelper.ok?(response)
186
+ !ResponseHelper.ok?(response)
187
+ end
188
+
189
+ def handle_existing_credential_options(credential_type_slug)
190
+ if options.update_credential_if_exists?
191
+ Uffizzi.ui.say('Updating existing credential.')
192
+ return
193
+ end
171
194
 
172
195
  if options.skip_raise_existence_error?
173
- Uffizzi.ui.say("Credentials of type #{connection_name} already exist for this account.")
196
+ Uffizzi.ui.say("Credential of type #{credential_type_slug} already exists for this account.")
174
197
  exit(true)
175
198
  else
176
- message = "Credentials of type #{connection_name} already exist for this account. " \
177
- "To remove them, run $ uffizzi disconnect #{connection_name}."
199
+ message = "Credential of type #{credential_type_slug} already exists for this account.\n" \
200
+ "To remove them, run uffizzi disconnect #{credential_type_slug}."
178
201
  raise Uffizzi::Error.new(message)
179
202
  end
180
203
  end
181
204
 
205
+ def create_or_update_credential(server, params, create: true)
206
+ create ? create_credential(server, params) : update_credential(server, params, params[:type])
207
+ end
208
+
182
209
  def handle_list_credentials_success(response)
183
210
  credentials = response[:body][:credentials]
184
211
  credentials.each do |credential|
@@ -202,7 +229,7 @@ module Uffizzi
202
229
  def google_service_account_content(credential_file_path = nil)
203
230
  return ENV['GCLOUD_SERVICE_KEY'] if ENV['GCLOUD_SERVICE_KEY']
204
231
 
205
- return Uffizzi.ui.say('Path to google service account key file wasn\'t specified.') if credential_file_path.nil?
232
+ raise Uffizzi::Error.new("Path to a google service account key file wasn't specified.") if credential_file_path.nil?
206
233
 
207
234
  begin
208
235
  credential_content = File.read(credential_file_path)
@@ -70,6 +70,13 @@ module ApiClient
70
70
  build_response(response)
71
71
  end
72
72
 
73
+ def update_credential(server, params, type)
74
+ uri = credential_uri(server, type)
75
+ response = http_client.make_put_request(uri, params)
76
+
77
+ build_response(response)
78
+ end
79
+
73
80
  def fetch_deployment_services(server, project_slug, deployment_id)
74
81
  uri = preview_services_uri(server, project_slug, deployment_id)
75
82
  response = http_client.make_get_request(uri)
@@ -78,7 +85,7 @@ module ApiClient
78
85
  end
79
86
 
80
87
  def delete_credential(server, credential_type)
81
- uri = delete_credential_uri(server, credential_type)
88
+ uri = credential_uri(server, credential_type)
82
89
  response = http_client.make_delete_request(uri)
83
90
 
84
91
  build_response(response)
@@ -64,7 +64,7 @@ module ApiRoutes
64
64
  "#{server}/api/cli/v1/projects/#{project_slug}/deployments/#{deployment_id}/containers"
65
65
  end
66
66
 
67
- def delete_credential_uri(server, credential_type)
67
+ def credential_uri(server, credential_type)
68
68
  "#{server}/api/cli/v1/account/credentials/#{credential_type}"
69
69
  end
70
70
 
@@ -92,7 +92,7 @@ class ComposeFileService
92
92
 
93
93
  def parse_compose_content_to_object(compose_content)
94
94
  begin
95
- compose_data = Psych.safe_load(compose_content)
95
+ compose_data = Psych.safe_load(compose_content, aliases: true)
96
96
  rescue Psych::SyntaxError
97
97
  Uffizzi.ui.say('Invalid compose file')
98
98
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uffizzi
4
- VERSION = '0.11.2'
4
+ VERSION = '0.11.5'
5
5
  end
data/man/uffizzi-connect CHANGED
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.9.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.9.1
3
- .TH "UFFIZZI\-CONNECT" "" "May 2022" ""
3
+ .TH "UFFIZZI\-CONNECT" "" "July 2022" ""
4
4
  .SH "NAME"
5
5
  \fBuffizzi\-connect\fR \- grant a Uffizzi user account access to external services
6
6
  .SH "SYNOPSIS"
@@ -30,8 +30,14 @@ ecr
30
30
  gcr
31
31
  Connect to Google Container Registry (gcr\.io)\.
32
32
 
33
- gchr
33
+ ghcr
34
34
  Connect to GitHub Container Registry (ghcr\.io)\.
35
35
  .fi
36
+ .SH "FLAGS"
37
+ .nf
38
+ \-\-skip\-raise\-existence\-error If credential exist, do not raise an exception, just print a message
39
+
40
+ \-\-update\-credential\-if\-exists Update credential if it exists
41
+ .fi
36
42
  .P
37
43
  Run \'uffizzi connect COMMAND \-\-help\' for more information on a command\.
@@ -1,16 +1,20 @@
1
1
  .\" generated with Ronn-NG/v0.9.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.9.1
3
- .TH "UFFIZZI\-CONNECT\-ECR" "" "May 2022" ""
3
+ .TH "UFFIZZI\-CONNECT\-GHCR" "" "July 2022" ""
4
4
  .SH "NAME"
5
- \fBuffizzi\-connect\-ecr\fR \- grant a Uffizzi user account access to a private GitHub Container Registry (GHCR)
5
+ \fBuffizzi\-connect\-ghcr\fR \- grant a Uffizzi user account access to a private GitHub Container Registry (GHCR)
6
6
  .SH "SYNOPSIS"
7
7
  .nf
8
- uffizzi connect ecr
8
+ uffizzi connect ghcr [OPTION]\|\.\|\.\|\.
9
9
  .fi
10
10
  .SH "DESCRIPTION"
11
11
  .nf
12
12
  Given valid credentials, grants a Uffizzi user account access
13
- to a private GitHub Container Registry
13
+ to a private GitHub Container Registry\.
14
+
15
+ Credentials can be provided interactively or non\-interactively
16
+ via command options or environment variables:
17
+ GITHUB_USERNAME, GITHUB_ACCESS_TOKEN
14
18
 
15
19
  This command can fail for the following reasons:
16
20
  \- The active user does not have permission to connect
@@ -24,12 +28,17 @@ For detailed instructions on configuring webhooks to send push
24
28
  notifications to Uffizzi, see
25
29
  https://docs\.uffizzi\.com/guides/container\-registry\-integrations
26
30
  .fi
31
+ .SH "OPTIONS"
32
+ .nf
33
+ \-u, \-\-username GitHub username
34
+ \-t, \-\-token Personal access token from GitHub
35
+ .fi
27
36
  .SH "EXAMPLES"
28
37
  .nf
29
38
  The following command will prompt the user to enter GHCR
30
39
  credentials, including GitHub account name and
31
- personal access key (PAT):
40
+ personal access token (PAT):
32
41
 
33
- $ uffizzi connect ecr
42
+ uffizzi connect ghcr
34
43
  .fi
35
44
 
@@ -1,15 +1,19 @@
1
- uffizzi-connect-ecr - grant a Uffizzi user account access to a private GitHub Container Registry (GHCR)
1
+ uffizzi-connect-ghcr - grant a Uffizzi user account access to a private GitHub Container Registry (GHCR)
2
2
  ================================================================
3
3
 
4
4
  ## SYNOPSIS
5
- uffizzi connect ecr
5
+ uffizzi connect ghcr [OPTION]...
6
6
 
7
7
  ## DESCRIPTION
8
- Given valid credentials, grants a Uffizzi user account access
9
- to a private GitHub Container Registry
8
+ Given valid credentials, grants a Uffizzi user account access
9
+ to a private GitHub Container Registry.
10
+
11
+ Credentials can be provided interactively or non-interactively
12
+ via command options or environment variables:
13
+ GITHUB_USERNAME, GITHUB_ACCESS_TOKEN
10
14
 
11
15
  This command can fail for the following reasons:
12
- - The active user does not have permission to connect
16
+ - The active user does not have permission to connect
13
17
  external services.
14
18
  - The given credentials are invalid.
15
19
 
@@ -17,12 +21,16 @@ uffizzi-connect-ecr - grant a Uffizzi user account access to a private GitHub Co
17
21
  https://github.com/UffizziCloud/uffizzi_cli
18
22
 
19
23
  For detailed instructions on configuring webhooks to send push
20
- notifications to Uffizzi, see
24
+ notifications to Uffizzi, see
21
25
  https://docs.uffizzi.com/guides/container-registry-integrations
22
26
 
27
+ ## OPTIONS
28
+ -u, --username GitHub username
29
+ -t, --token Personal access token from GitHub
30
+
23
31
  ## EXAMPLES
24
- The following command will prompt the user to enter GHCR
25
- credentials, including GitHub account name and
26
- personal access key (PAT):
27
-
28
- $ uffizzi connect ecr
32
+ The following command will prompt the user to enter GHCR
33
+ credentials, including GitHub account name and
34
+ personal access token (PAT):
35
+
36
+ uffizzi connect ghcr
@@ -24,8 +24,14 @@ uffizzi-connect - grant a Uffizzi user account access to external services
24
24
 
25
25
  gcr
26
26
  Connect to Google Container Registry (gcr.io).
27
-
28
- gchr
27
+
28
+ ghcr
29
29
  Connect to GitHub Container Registry (ghcr.io).
30
30
 
31
+
32
+ ## FLAGS
33
+ --skip-raise-existence-error If credential exist, do not raise an exception, just print a message
34
+
35
+ --update-credential-if-exists Update credential if it exists
36
+
31
37
  Run 'uffizzi connect COMMAND --help' for more information on a command.
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.9.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.9.1
3
- .TH "UFFIZZI\-DISCONNECT" "" "May 2022" ""
3
+ .TH "UFFIZZI\-DISCONNECT" "" "July 2022" ""
4
4
  .SH "NAME"
5
5
  \fBuffizzi\-disconnect\fR \- revoke a Uffizzi user account access to external services
6
6
  .SH "SYNOPSIS"
@@ -30,7 +30,7 @@ ecr
30
30
  gcr
31
31
  Disonnect from Google Container Registry (gcr\.io)\.
32
32
 
33
- gchr
33
+ ghcr
34
34
  Disonnect from GitHub Container Registry (ghcr\.io)\.
35
35
  .fi
36
36
  .P
@@ -24,8 +24,8 @@ uffizzi-disconnect - revoke a Uffizzi user account access to external services
24
24
 
25
25
  gcr
26
26
  Disonnect from Google Container Registry (gcr.io).
27
-
28
- gchr
27
+
28
+ ghcr
29
29
  Disonnect from GitHub Container Registry (ghcr.io).
30
30
 
31
31
  Run 'uffizzi disconnect COMMAND --help' for more information on a command.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uffizzi-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.11.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Thurman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-07-12 00:00:00.000000000 Z
12
+ date: 2022-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: awesome_print