rdeploy 0.5.3__tar.gz → 0.5.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rdeploy-0.5.3/rdeploy.egg-info → rdeploy-0.5.4}/PKG-INFO +5 -1
- {rdeploy-0.5.3 → rdeploy-0.5.4}/README.md +4 -0
- rdeploy-0.5.4/VERSION +1 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/rdeploy/gke_auth.py +30 -3
- {rdeploy-0.5.3 → rdeploy-0.5.4}/rdeploy/helm_chart.py +11 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4/rdeploy.egg-info}/PKG-INFO +5 -1
- {rdeploy-0.5.3 → rdeploy-0.5.4}/tests/test_gke_auth.py +63 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/tests/test_helm_chart.py +28 -0
- rdeploy-0.5.3/VERSION +0 -1
- {rdeploy-0.5.3 → rdeploy-0.5.4}/LICENSE +0 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/pyproject.toml +0 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/rdeploy/__init__.py +0 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/rdeploy/exceptions.py +0 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/rdeploy/main.py +0 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/rdeploy/tasks.py +0 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/rdeploy/utils.py +0 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/rdeploy.egg-info/SOURCES.txt +0 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/rdeploy.egg-info/dependency_links.txt +0 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/rdeploy.egg-info/entry_points.txt +0 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/rdeploy.egg-info/requires.txt +0 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/rdeploy.egg-info/top_level.txt +0 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/setup.cfg +0 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/tests/test_exceptions.py +0 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/tests/test_main.py +0 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/tests/test_tasks.py +0 -0
- {rdeploy-0.5.3 → rdeploy-0.5.4}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rdeploy
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.4
|
|
4
4
|
Summary: CLI that makes it easy to build and deploy an application to k8s.
|
|
5
5
|
Author-email: Rehive <info@rehive.com>
|
|
6
6
|
License: MIT
|
|
@@ -296,6 +296,10 @@ organization requires certificate-based access, where Artifact Registry
|
|
|
296
296
|
rejects Helm's own login. You need read access to the repository
|
|
297
297
|
(`roles/artifactregistry.reader`).
|
|
298
298
|
|
|
299
|
+
If gcloud's login has expired, rdeploy asks before running `gcloud auth
|
|
300
|
+
login`. Without a terminal, such as in a script, it stops and tells you to
|
|
301
|
+
run it.
|
|
302
|
+
|
|
299
303
|
## Versioning
|
|
300
304
|
|
|
301
305
|
rdeploy uses semantic versioning for releases. The `git-release` command automates tagging:
|
|
@@ -259,6 +259,10 @@ organization requires certificate-based access, where Artifact Registry
|
|
|
259
259
|
rejects Helm's own login. You need read access to the repository
|
|
260
260
|
(`roles/artifactregistry.reader`).
|
|
261
261
|
|
|
262
|
+
If gcloud's login has expired, rdeploy asks before running `gcloud auth
|
|
263
|
+
login`. Without a terminal, such as in a script, it stops and tells you to
|
|
264
|
+
run it.
|
|
265
|
+
|
|
262
266
|
## Versioning
|
|
263
267
|
|
|
264
268
|
rdeploy uses semantic versioning for releases. The `git-release` command automates tagging:
|
rdeploy-0.5.4/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.5.4
|
|
@@ -58,6 +58,10 @@ class KubectlLoginError(Exception):
|
|
|
58
58
|
pass
|
|
59
59
|
|
|
60
60
|
|
|
61
|
+
class GcloudLoginError(KubectlLoginError):
|
|
62
|
+
"""gcloud is not signed in and rdeploy did not sign it in."""
|
|
63
|
+
|
|
64
|
+
|
|
61
65
|
# Paths and saved settings
|
|
62
66
|
##########################
|
|
63
67
|
|
|
@@ -179,7 +183,16 @@ def run_gcloud(cmd):
|
|
|
179
183
|
return subprocess.run(cmd, stdout=subprocess.PIPE, text=True)
|
|
180
184
|
|
|
181
185
|
|
|
182
|
-
def
|
|
186
|
+
def ask_yes_no(question):
|
|
187
|
+
"""Ask in the terminal; only an explicit yes counts, so Enter means no."""
|
|
188
|
+
try:
|
|
189
|
+
answer = input(question + ' [y/N] ')
|
|
190
|
+
except EOFError:
|
|
191
|
+
return False
|
|
192
|
+
return answer.strip().lower() in ('y', 'yes')
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def ensure_gcloud_login(account=None, ask=False):
|
|
183
196
|
"""
|
|
184
197
|
Make sure gcloud can get a token for `account` (default: the active
|
|
185
198
|
account) before rdeploy uses it, signing gcloud in again if needed.
|
|
@@ -187,6 +200,10 @@ def ensure_gcloud_login(account=None):
|
|
|
187
200
|
A password or security-key reauthentication is left to gcloud, which
|
|
188
201
|
prompts for it in the terminal. When gcloud's login has expired, or there
|
|
189
202
|
is none, run `gcloud auth login`, which signs in through the browser.
|
|
203
|
+
|
|
204
|
+
With `ask`, rdeploy asks before opening the browser, and without a
|
|
205
|
+
terminal to ask in it stops instead. Commands that are not themselves a
|
|
206
|
+
sign-in, such as a deploy, use this.
|
|
190
207
|
"""
|
|
191
208
|
account_flag = [f'--account={account}'] if account else []
|
|
192
209
|
# The token itself is never needed: it goes to /dev/null, so rdeploy never
|
|
@@ -199,10 +216,20 @@ def ensure_gcloud_login(account=None):
|
|
|
199
216
|
if ('reauth' in check.stderr.lower()
|
|
200
217
|
and subprocess.run(token_cmd, stdout=subprocess.DEVNULL).returncode == 0):
|
|
201
218
|
return
|
|
202
|
-
print('gcloud needs you to sign in again. Opening your browser for gcloud first.', flush=True)
|
|
203
219
|
login_cmd = ['gcloud', 'auth', 'login'] + ([account] if account else [])
|
|
220
|
+
if ask:
|
|
221
|
+
who = account or gcloud_account()
|
|
222
|
+
expired = 'Your gcloud login{who} has expired or is missing.'.format(
|
|
223
|
+
who=' for {0}'.format(who) if who else '')
|
|
224
|
+
if not (sys.stdin.isatty() and ask_yes_no(
|
|
225
|
+
expired + ' Sign in again now with `gcloud auth login`?')):
|
|
226
|
+
raise GcloudLoginError(
|
|
227
|
+
'{expired} Run `{cmd}`, then run this command again.'.format(
|
|
228
|
+
expired=expired, cmd=' '.join(login_cmd)))
|
|
229
|
+
else:
|
|
230
|
+
print('gcloud needs you to sign in again. Opening your browser for gcloud first.', flush=True)
|
|
204
231
|
if subprocess.run(login_cmd).returncode != 0:
|
|
205
|
-
raise
|
|
232
|
+
raise GcloudLoginError('gcloud sign-in failed; gcloud\'s error is above.')
|
|
206
233
|
|
|
207
234
|
|
|
208
235
|
def load_client(project, secret, account=None, client_json=None):
|
|
@@ -19,6 +19,8 @@ import shutil
|
|
|
19
19
|
import subprocess
|
|
20
20
|
import tempfile
|
|
21
21
|
|
|
22
|
+
from rdeploy.gke_auth import GcloudLoginError, ensure_gcloud_login
|
|
23
|
+
|
|
22
24
|
CHART_LAYER_MEDIA_TYPE = 'application/vnd.cncf.helm.chart.content.v1.tar+gzip'
|
|
23
25
|
REGISTRY_HOST = re.compile(r'^(?:https?://)?(?P<location>[a-z0-9-]+)-docker\.pkg\.dev/?$')
|
|
24
26
|
|
|
@@ -88,6 +90,8 @@ def download_file(project, location, repository, name, destination, filename):
|
|
|
88
90
|
'--destination={0}'.format(destination),
|
|
89
91
|
'--local-filename={0}'.format(filename),
|
|
90
92
|
'--allow-overwrite',
|
|
93
|
+
# No progress boxes; gcloud's errors still print.
|
|
94
|
+
'--no-user-output-enabled',
|
|
91
95
|
])
|
|
92
96
|
return os.path.join(destination, filename)
|
|
93
97
|
|
|
@@ -129,6 +133,13 @@ def fetch_chart(helm_registry, project, helm_chart, chart_version, destination=N
|
|
|
129
133
|
destination = tempfile.mkdtemp(prefix='rdeploy-chart-')
|
|
130
134
|
atexit.register(shutil.rmtree, destination, True)
|
|
131
135
|
|
|
136
|
+
# Before anything else, so an expired login is caught while nothing has
|
|
137
|
+
# happened yet, and the user is asked before a browser opens.
|
|
138
|
+
try:
|
|
139
|
+
ensure_gcloud_login(ask=True)
|
|
140
|
+
except GcloudLoginError as err:
|
|
141
|
+
raise ChartFetchError(str(err))
|
|
142
|
+
|
|
132
143
|
print('Downloading chart {chart} {version} with gcloud'.format(
|
|
133
144
|
chart=helm_chart, version=chart_version), flush=True)
|
|
134
145
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rdeploy
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.4
|
|
4
4
|
Summary: CLI that makes it easy to build and deploy an application to k8s.
|
|
5
5
|
Author-email: Rehive <info@rehive.com>
|
|
6
6
|
License: MIT
|
|
@@ -296,6 +296,10 @@ organization requires certificate-based access, where Artifact Registry
|
|
|
296
296
|
rejects Helm's own login. You need read access to the repository
|
|
297
297
|
(`roles/artifactregistry.reader`).
|
|
298
298
|
|
|
299
|
+
If gcloud's login has expired, rdeploy asks before running `gcloud auth
|
|
300
|
+
login`. Without a terminal, such as in a script, it stops and tells you to
|
|
301
|
+
run it.
|
|
302
|
+
|
|
299
303
|
## Versioning
|
|
300
304
|
|
|
301
305
|
rdeploy uses semantic versioning for releases. The `git-release` command automates tagging:
|
|
@@ -470,6 +470,69 @@ class TestEnsureGcloudLogin:
|
|
|
470
470
|
assert mock_run.call_args_list[0][0][0] == ['gcloud', 'auth', 'print-access-token']
|
|
471
471
|
assert mock_run.call_args_list[2][0][0] == ['gcloud', 'auth', 'login']
|
|
472
472
|
|
|
473
|
+
EXPIRED = 'There was a problem refreshing your current auth tokens. Please run: gcloud auth login'
|
|
474
|
+
|
|
475
|
+
@patch('rdeploy.gke_auth.sys.stdin')
|
|
476
|
+
@patch('rdeploy.gke_auth.input', create=True, return_value='y')
|
|
477
|
+
@patch('rdeploy.gke_auth.subprocess.run')
|
|
478
|
+
def test_ask_yes_runs_login(self, mock_run, mock_input, mock_stdin):
|
|
479
|
+
mock_stdin.isatty.return_value = True
|
|
480
|
+
mock_run.side_effect = [completed(returncode=1, stderr=self.EXPIRED), completed()]
|
|
481
|
+
gke_auth.ensure_gcloud_login('me@example.test', ask=True)
|
|
482
|
+
assert 'me@example.test' in mock_input.call_args[0][0]
|
|
483
|
+
assert '[y/N]' in mock_input.call_args[0][0]
|
|
484
|
+
assert mock_run.call_args_list[1][0][0] == ['gcloud', 'auth', 'login', 'me@example.test']
|
|
485
|
+
|
|
486
|
+
@pytest.mark.parametrize('answer', ['', 'n', 'no', 'maybe'])
|
|
487
|
+
@patch('rdeploy.gke_auth.sys.stdin')
|
|
488
|
+
@patch('rdeploy.gke_auth.subprocess.run')
|
|
489
|
+
def test_ask_anything_but_yes_stops(self, mock_run, mock_stdin, answer):
|
|
490
|
+
mock_stdin.isatty.return_value = True
|
|
491
|
+
mock_run.side_effect = [completed(returncode=1, stderr=self.EXPIRED)]
|
|
492
|
+
with patch('rdeploy.gke_auth.input', create=True, return_value=answer):
|
|
493
|
+
with pytest.raises(gke_auth.GcloudLoginError,
|
|
494
|
+
match='Run `gcloud auth login me@example.test`, then run this command again'):
|
|
495
|
+
gke_auth.ensure_gcloud_login('me@example.test', ask=True)
|
|
496
|
+
assert mock_run.call_count == 1 # no browser
|
|
497
|
+
|
|
498
|
+
@patch('rdeploy.gke_auth.gcloud_account', return_value='')
|
|
499
|
+
@patch('rdeploy.gke_auth.sys.stdin')
|
|
500
|
+
@patch('rdeploy.gke_auth.subprocess.run')
|
|
501
|
+
def test_ask_without_terminal_stops_without_asking(self, mock_run, mock_stdin, _account):
|
|
502
|
+
mock_stdin.isatty.return_value = False
|
|
503
|
+
mock_run.side_effect = [completed(returncode=1, stderr=self.EXPIRED)]
|
|
504
|
+
with patch('rdeploy.gke_auth.input', create=True) as mock_input:
|
|
505
|
+
with pytest.raises(gke_auth.GcloudLoginError, match='expired'):
|
|
506
|
+
gke_auth.ensure_gcloud_login(ask=True)
|
|
507
|
+
mock_input.assert_not_called()
|
|
508
|
+
assert mock_run.call_count == 1
|
|
509
|
+
|
|
510
|
+
@patch('rdeploy.gke_auth.gcloud_account', return_value='active@example.test')
|
|
511
|
+
@patch('rdeploy.gke_auth.sys.stdin')
|
|
512
|
+
@patch('rdeploy.gke_auth.subprocess.run')
|
|
513
|
+
def test_ask_names_the_active_account(self, mock_run, mock_stdin, _account):
|
|
514
|
+
mock_stdin.isatty.return_value = True
|
|
515
|
+
mock_run.side_effect = [completed(returncode=1, stderr=self.EXPIRED)]
|
|
516
|
+
with patch('rdeploy.gke_auth.input', create=True, return_value='') as mock_input:
|
|
517
|
+
with pytest.raises(gke_auth.GcloudLoginError):
|
|
518
|
+
gke_auth.ensure_gcloud_login(ask=True)
|
|
519
|
+
assert 'active@example.test' in mock_input.call_args[0][0]
|
|
520
|
+
|
|
521
|
+
@patch('rdeploy.gke_auth.sys.stdin')
|
|
522
|
+
@patch('rdeploy.gke_auth.subprocess.run')
|
|
523
|
+
def test_ask_signed_in_asks_nothing(self, mock_run, mock_stdin):
|
|
524
|
+
mock_run.return_value = completed('token')
|
|
525
|
+
with patch('rdeploy.gke_auth.input', create=True) as mock_input:
|
|
526
|
+
gke_auth.ensure_gcloud_login(ask=True)
|
|
527
|
+
mock_input.assert_not_called()
|
|
528
|
+
|
|
529
|
+
def test_ask_yes_no_eof_is_no(self):
|
|
530
|
+
with patch('rdeploy.gke_auth.input', create=True, side_effect=EOFError):
|
|
531
|
+
assert gke_auth.ask_yes_no('?') is False
|
|
532
|
+
|
|
533
|
+
def test_login_error_is_a_kubectl_login_error(self):
|
|
534
|
+
assert issubclass(gke_auth.GcloudLoginError, KubectlLoginError)
|
|
535
|
+
|
|
473
536
|
@patch('rdeploy.gke_auth.subprocess.run')
|
|
474
537
|
def test_login_fails(self, mock_run):
|
|
475
538
|
mock_run.side_effect = [completed(returncode=1, stderr='no credentialed accounts'), completed(returncode=1)]
|
|
@@ -15,6 +15,7 @@ from rdeploy.helm_chart import (
|
|
|
15
15
|
registry_location,
|
|
16
16
|
split_chart,
|
|
17
17
|
)
|
|
18
|
+
from rdeploy.gke_auth import GcloudLoginError
|
|
18
19
|
from rdeploy.tasks import install, resolve_helm_chart, upgrade
|
|
19
20
|
|
|
20
21
|
CHART = b'fake chart archive'
|
|
@@ -101,6 +102,13 @@ class TestParsing:
|
|
|
101
102
|
chart_layer_digest(str(path))
|
|
102
103
|
|
|
103
104
|
|
|
105
|
+
@pytest.fixture
|
|
106
|
+
def gcloud_signed_in():
|
|
107
|
+
with patch('rdeploy.helm_chart.ensure_gcloud_login') as ensure:
|
|
108
|
+
yield ensure
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@pytest.mark.usefixtures('gcloud_signed_in')
|
|
104
112
|
class TestFetchChart:
|
|
105
113
|
def test_downloads_and_verifies_chart(self, tmp_path):
|
|
106
114
|
gcloud = FakeGcloud()
|
|
@@ -134,6 +142,26 @@ class TestFetchChart:
|
|
|
134
142
|
assert 'stderr' not in call.kwargs
|
|
135
143
|
assert 'stdin' not in call.kwargs
|
|
136
144
|
|
|
145
|
+
def test_downloads_are_quiet(self, tmp_path):
|
|
146
|
+
gcloud = FakeGcloud()
|
|
147
|
+
fetch(tmp_path, gcloud)
|
|
148
|
+
for call in gcloud.calls[1:]:
|
|
149
|
+
assert '--no-user-output-enabled' in call
|
|
150
|
+
|
|
151
|
+
def test_checks_gcloud_login_first_and_asks(self, tmp_path, gcloud_signed_in):
|
|
152
|
+
gcloud = FakeGcloud()
|
|
153
|
+
gcloud_signed_in.side_effect = lambda **kwargs: gcloud.calls.append('login check')
|
|
154
|
+
fetch(tmp_path, gcloud)
|
|
155
|
+
gcloud_signed_in.assert_called_once_with(ask=True)
|
|
156
|
+
assert gcloud.calls[0] == 'login check'
|
|
157
|
+
|
|
158
|
+
def test_declined_login_stops_before_downloading(self, tmp_path, gcloud_signed_in):
|
|
159
|
+
gcloud = FakeGcloud()
|
|
160
|
+
gcloud_signed_in.side_effect = GcloudLoginError('Run `gcloud auth login`, then run this command again.')
|
|
161
|
+
with pytest.raises(ChartFetchError, match='gcloud auth login'):
|
|
162
|
+
fetch(tmp_path, gcloud)
|
|
163
|
+
assert gcloud.calls == []
|
|
164
|
+
|
|
137
165
|
def test_rejects_tampered_chart(self, tmp_path):
|
|
138
166
|
gcloud = FakeGcloud()
|
|
139
167
|
gcloud.files[CHART_DIGEST] = b'something else'
|
rdeploy-0.5.3/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.5.3
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|