cloudsmith-cli 0.28.0__tar.gz → 1.8.2__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.
- cloudsmith_cli-1.8.2/MANIFEST.in +2 -0
- cloudsmith_cli-1.8.2/PKG-INFO +311 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/README.md +33 -5
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/__init__.py +4 -1
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/__main__.py +0 -2
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/__init__.py +0 -1
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/command.py +9 -13
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/commands/__init__.py +27 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/commands/auth.py +112 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/check.py +10 -24
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/copy.py +0 -2
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/delete.py +0 -2
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/commands/dependencies.py +108 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/docs.py +0 -2
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/entitlements.py +14 -13
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/help_.py +0 -2
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/list_.py +56 -7
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/commands/login.py +91 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/main.py +1 -2
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/commands/metrics/__init__.py +2 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/metrics/command.py +0 -1
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/metrics/entitlements.py +10 -13
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/metrics/packages.py +10 -13
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/move.py +0 -2
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/commands/policy/__init__.py +2 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/commands/policy/command.py +20 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/commands/policy/license.py +326 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/commands/policy/vulnerability.py +311 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/push.py +130 -63
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/commands/quarantine.py +145 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/commands/quota/__init__.py +2 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/quota/command.py +1 -2
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/quota/history.py +15 -14
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/quota/quota.py +12 -13
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/repos.py +7 -8
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/resync.py +0 -2
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/status.py +3 -8
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/tags.py +1 -3
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/commands/tokens.py +84 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/commands/upstream.py +456 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/commands/whoami.py +30 -8
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/config.py +28 -24
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/decorators.py +0 -2
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/exceptions.py +14 -14
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/saml.py +111 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/table.py +4 -7
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/tests/commands/__init__.py +0 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/tests/commands/policy/__init__.py +0 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/tests/commands/policy/test_licence.py +172 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/tests/commands/policy/test_vulnerability.py +178 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/tests/commands/test_check.py +73 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/tests/commands/test_login.py +30 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/tests/commands/test_main.py +26 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/tests/commands/test_package_commands.py +165 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/tests/commands/test_repos.py +177 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/tests/commands/test_tokens.py +123 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/tests/commands/test_upstream.py +131 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/tests/conftest.py +75 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/tests/test_push.py +245 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/tests/test_saml.py +164 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/tests/test_utils.py +35 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/tests/utils.py +12 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/types.py +1 -3
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/utils.py +45 -20
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/cli/validators.py +42 -9
- cloudsmith_cli-1.8.2/cloudsmith_cli/cli/webserver.py +204 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/__init__.py +0 -1
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/api/__init__.py +0 -1
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/api/distros.py +0 -2
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/api/entitlements.py +0 -2
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/api/exceptions.py +10 -10
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/api/files.py +50 -6
- cloudsmith_cli-1.8.2/cloudsmith_cli/core/api/init.py +145 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/api/metrics.py +2 -4
- cloudsmith_cli-1.8.2/cloudsmith_cli/core/api/orgs.py +121 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/api/packages.py +57 -11
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/api/quota.py +0 -2
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/api/rates.py +1 -4
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/api/repos.py +6 -6
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/api/status.py +0 -2
- cloudsmith_cli-1.8.2/cloudsmith_cli/core/api/upstreams.py +72 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/core/api/user.py +99 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/api/version.py +3 -5
- cloudsmith-cli-0.28.0/cloudsmith_cli/cli/commands/login.py → cloudsmith_cli-1.8.2/cloudsmith_cli/core/config.py +4 -56
- cloudsmith_cli-1.8.2/cloudsmith_cli/core/keyring.py +89 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/pagination.py +1 -6
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/ratelimits.py +1 -6
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/rest.py +13 -15
- cloudsmith_cli-1.8.2/cloudsmith_cli/core/tests/__init__.py +0 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/core/tests/test_init.py +186 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/core/tests/test_keyring.py +202 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/core/tests/test_rest.py +39 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/tests/test_version.py +1 -4
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/utils.py +12 -3
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/core/version.py +0 -2
- cloudsmith_cli-1.8.2/cloudsmith_cli/data/VERSION +1 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/templates/__init__.py +3 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/templates/auth_error.html +45 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli/templates/auth_success.html +37 -0
- cloudsmith_cli-1.8.2/cloudsmith_cli.egg-info/PKG-INFO +311 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli.egg-info/SOURCES.txt +39 -2
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli.egg-info/entry_points.txt +0 -1
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli.egg-info/requires.txt +4 -6
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/setup.cfg +1 -6
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/setup.py +17 -19
- cloudsmith-cli-0.28.0/MANIFEST.in +0 -1
- cloudsmith-cli-0.28.0/PKG-INFO +0 -23
- cloudsmith-cli-0.28.0/cloudsmith_cli/cli/commands/__init__.py +0 -21
- cloudsmith-cli-0.28.0/cloudsmith_cli/cli/commands/metrics/__init__.py +0 -3
- cloudsmith-cli-0.28.0/cloudsmith_cli/cli/commands/quota/__init__.py +0 -3
- cloudsmith-cli-0.28.0/cloudsmith_cli/core/api/init.py +0 -82
- cloudsmith-cli-0.28.0/cloudsmith_cli/core/api/user.py +0 -42
- cloudsmith-cli-0.28.0/cloudsmith_cli/data/VERSION +0 -1
- cloudsmith-cli-0.28.0/cloudsmith_cli.egg-info/PKG-INFO +0 -23
- cloudsmith-cli-0.28.0/pyproject.toml +0 -3
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/LICENSE +0 -0
- {cloudsmith-cli-0.28.0/cloudsmith_cli/core → cloudsmith_cli-1.8.2/cloudsmith_cli/cli}/tests/__init__.py +0 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/data/config.ini +0 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli/data/credentials.ini +0 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli.egg-info/dependency_links.txt +0 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli.egg-info/not-zip-safe +0 -0
- {cloudsmith-cli-0.28.0 → cloudsmith_cli-1.8.2}/cloudsmith_cli.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cloudsmith-cli
|
|
3
|
+
Version: 1.8.2
|
|
4
|
+
Summary: Cloudsmith Command-Line Interface (CLI)
|
|
5
|
+
Home-page: https://github.com/cloudsmith-io/cloudsmith-cli
|
|
6
|
+
Author: Cloudsmith Ltd
|
|
7
|
+
Author-email: support@cloudsmith.io
|
|
8
|
+
License: Apache License 2.0
|
|
9
|
+
Keywords: cloudsmith,cli,devops
|
|
10
|
+
Platform: any
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Internet
|
|
24
|
+
Classifier: Topic :: System :: Systems Administration
|
|
25
|
+
Classifier: Topic :: Utilities
|
|
26
|
+
Requires-Python: >=3.9.0
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: click!=8.0.2,>=7.0
|
|
30
|
+
Requires-Dist: click-configfile>=0.2.3
|
|
31
|
+
Requires-Dist: click-didyoumean>=0.0.3
|
|
32
|
+
Requires-Dist: click-spinner>=0.1.7
|
|
33
|
+
Requires-Dist: cloudsmith-api<3.0,>=2.0.18
|
|
34
|
+
Requires-Dist: keyring>=25.4.1
|
|
35
|
+
Requires-Dist: requests>=2.18.4
|
|
36
|
+
Requires-Dist: requests_toolbelt>=0.8.0
|
|
37
|
+
Requires-Dist: semver>=2.7.9
|
|
38
|
+
Requires-Dist: urllib3<2.0
|
|
39
|
+
Dynamic: author
|
|
40
|
+
Dynamic: author-email
|
|
41
|
+
Dynamic: classifier
|
|
42
|
+
Dynamic: description
|
|
43
|
+
Dynamic: description-content-type
|
|
44
|
+
Dynamic: home-page
|
|
45
|
+
Dynamic: keywords
|
|
46
|
+
Dynamic: license
|
|
47
|
+
Dynamic: license-file
|
|
48
|
+
Dynamic: platform
|
|
49
|
+
Dynamic: requires-dist
|
|
50
|
+
Dynamic: requires-python
|
|
51
|
+
Dynamic: summary
|
|
52
|
+
|
|
53
|
+
# Cloudsmith Command Line Interface (CLI)
|
|
54
|
+
|
|
55
|
+
[](https://cloudsmith.io/~cloudsmith/repos/cli/packages/detail/python/cloudsmith-cli/latest/xf=bdist_wheel;xn=cloudsmith-cli;xv=py2.py3/)
|
|
56
|
+
[](https://pypi.python.org/pypi/cloudsmith-cli)
|
|
57
|
+
[](https://pypi.python.org/pypi/cloudsmith-cli)
|
|
58
|
+
[](https://circleci.com/gh/cloudsmith-io/cloudsmith-cli)
|
|
59
|
+
[](https://codeclimate.com/github/cloudsmith-io/cloudsmith-cli/maintainability)
|
|
60
|
+
[](https://codeclimate.com/github/cloudsmith-io/cloudsmith-cli/test_coverage)
|
|
61
|
+
[](https://github.com/ambv/black)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
The [Cloudsmith](https://cloudsmith.io) Command Line Interface (CLI) is a Python 3 text-based interface to the [API](https://api.cloudsmith.io). This allows users, machines and other services to access and integrate smoothly with Cloudsmith without requiring explicit plugins or tools. [Be awesome. Automate Everything](https://cloudsmith.com/company/the-tao-of-cloudsmith/).
|
|
65
|
+
|
|
66
|
+
The following asciinema video demonstrates some of the CLI commands:
|
|
67
|
+
[](https://asciinema.org/a/DkNXQWQGBjWkfGPAkDAPNz7xe)
|
|
68
|
+
|
|
69
|
+
We also have a [demo video on YouTube](https://youtu.be/R-g8ZhDwTKk):
|
|
70
|
+
|
|
71
|
+
You can also read our [blog article](https://blog.cloudsmith.io/2017/11/25/automation-as-simple-as-a-b-cli/) that introduced the first version of the CLI and the Cloudsmith RESTful API.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## Changelog
|
|
75
|
+
|
|
76
|
+
Please see the [changelog](https://github.com/cloudsmith-io/cloudsmith-cli/blob/master/CHANGELOG.md) for the list of changes by version. The current version is displayed in the PyPi badge at the top.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
## Features
|
|
80
|
+
|
|
81
|
+
The CLI currently supports the following commands (and sub-commands):
|
|
82
|
+
|
|
83
|
+
- `auth`: Authenticate the CLI against an organization's SAML configuration.
|
|
84
|
+
- `check`: Check rate limits and service status.
|
|
85
|
+
- `copy`|`cp`: Copy a package to another repository.
|
|
86
|
+
- `delete`|`rm`: Delete a package from a repository.
|
|
87
|
+
- `dependencies`|`deps`: List direct (non-transitive) dependencies for a package.
|
|
88
|
+
- `docs`: Launch the help website in your browser.
|
|
89
|
+
- `entitlements`|`ents`: Manage the entitlements for a repository.
|
|
90
|
+
- `create`|`new`: Create a new entitlement in a repository.
|
|
91
|
+
- `delete`|`rm`: Delete an entitlement from a repository.
|
|
92
|
+
- `list`|`ls`: List entitlements for a repository.
|
|
93
|
+
- `refresh`: Refresh an entitlement in a repository.
|
|
94
|
+
- `sync`: Sync entitlements from another repository.
|
|
95
|
+
- `update`|`set`: Update (patch) a entitlement in a repository.
|
|
96
|
+
- `help`: Display the delightful help message and exit.
|
|
97
|
+
- `list`|`ls`: List distros, packages, repos and entitlements.
|
|
98
|
+
- `dependencies`|`deps` List direct (non-transitive) dependencies for a package.
|
|
99
|
+
- `distros`: List available distributions.
|
|
100
|
+
- `entitlements`|`ents`: List entitlements for a repository.
|
|
101
|
+
- `packages`: List packages for a repository. (Aliases `repos list`)
|
|
102
|
+
- `repos`: List repositories for a namespace (owner).
|
|
103
|
+
- `login`|`token`: Retrieve your API authentication token/key via login.
|
|
104
|
+
- `metrics`: Metrics and statistics for a repository.
|
|
105
|
+
- `tokens`: Retrieve bandwidth usage for entitlement tokens.
|
|
106
|
+
- `packages`: Retrieve package usage for repository.
|
|
107
|
+
- `move`|`mv`: Move (promote) a package to another repo.
|
|
108
|
+
- `push`|`upload`: Push (upload) a new package to a repository.
|
|
109
|
+
- `alpine`: Push (upload) a new Alpine package upstream.
|
|
110
|
+
- `cargo`: Push (upload) a new Cargo package upstream.
|
|
111
|
+
- `composer`: Push (upload) a new Composer package upstream.
|
|
112
|
+
- `cocoapods`: Push (upload) a new CocoaPods package upstream.
|
|
113
|
+
- `conan`: Push (upload) a new Conan (C++) package upstream.
|
|
114
|
+
- `cran`: Push (upload) a new R/CRAN package upstream.
|
|
115
|
+
- `deb`: Push (upload) a new Debian package upstream.
|
|
116
|
+
- `docker`: Push (upload) a new Docker image upstream.
|
|
117
|
+
- `go`: Push (upload) a new Go module upstream.
|
|
118
|
+
- `helm`: Push (upload) a new Helm package upstream.
|
|
119
|
+
- `luarocks`: Push (upload) a new Lua module upstream.
|
|
120
|
+
- `maven`: Push (upload) a new Maven package upstream.
|
|
121
|
+
- `npm`: Push (upload) a new Npm package upstream.
|
|
122
|
+
- `nuget`: Push (upload) a new NuGet package upstream.
|
|
123
|
+
- `python`: Push (upload) a new Python package upstream.
|
|
124
|
+
- `raw`: Push (upload) a new Raw package upstream.
|
|
125
|
+
- `rpm`: Push (upload) a new RedHat package upstream.
|
|
126
|
+
- `ruby`: Push (upload) a new Ruby package upstream.
|
|
127
|
+
- `terraform`: Push (upload) a new Terraform package upstream.
|
|
128
|
+
- `vagrant`: Push (upload) a new Vagrant package upstream.
|
|
129
|
+
- `quarantine`|`block`: Manage quarantined packages in a repository.
|
|
130
|
+
- `add`: Add a package to quarantine.
|
|
131
|
+
- `remove`|`rm`|`restore`: Add a package to quarantine.
|
|
132
|
+
- `quota`: Quota limits and history for a organisation.
|
|
133
|
+
- `limits`: Display the Quota (bandwidth & storage usage/limits) for a specific organisation.
|
|
134
|
+
- `history`: Display the Quota History (upload, download, and storage usage/limits) for a specific organisation.
|
|
135
|
+
- `repositories`|`repos`: Manage repositories.
|
|
136
|
+
- `create`|`new`: Create a new repository in a namespace.
|
|
137
|
+
- `get`|`list`|`ls`: List repositories for a user, in a namespace or get details for a specific repository.
|
|
138
|
+
- `update`: Update a repository in a namespace.
|
|
139
|
+
- `delete`|`rm`: Delete a repository from a namespace.
|
|
140
|
+
- `resync`: Resynchronise a package in a repository.
|
|
141
|
+
- `status`: Get the synchronisation status for a package.
|
|
142
|
+
- `tags`: Manage the tags for a package in a repository.
|
|
143
|
+
- `add`: Add tags to a package in a repository.
|
|
144
|
+
- `clear`: Clear all existing (non-immutable) tags from a package in a repository.
|
|
145
|
+
- `list`|`ls`: List tags for a package in a repository.
|
|
146
|
+
- `remove`|`rm`: Remove tags from a package in a repository.
|
|
147
|
+
- `replace`: Replace all existing (non-immutable) tags on a package in a repository.
|
|
148
|
+
- `whoami`: Retrieve your current authentication status.
|
|
149
|
+
- `tokens`: Manage API tokens.
|
|
150
|
+
- `list`|`ls`: List API tokens.
|
|
151
|
+
- `refresh`: Refresh an API token.
|
|
152
|
+
|
|
153
|
+
## Installation
|
|
154
|
+
|
|
155
|
+
You can install the latest CLI application from:
|
|
156
|
+
|
|
157
|
+
- [Official CLI Repository @ PyPi](https://pypi.python.org/pypi/cloudsmith-cli)
|
|
158
|
+
- [Official CLI Repository @ Cloudsmith](https://cloudsmith.io/~cloudsmith/repos/cli/packages/)
|
|
159
|
+
|
|
160
|
+
The simplest way is to use `pip`, such as:
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
pip install --upgrade cloudsmith-cli
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Or you can get the latest pre-release version from Cloudsmith:
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
pip install --upgrade cloudsmith-cli --extra-index-url=https://dl.cloudsmith.io/public/cloudsmith/cli/python/index/
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Configuration
|
|
173
|
+
|
|
174
|
+
There are two configuration files used by the CLI:
|
|
175
|
+
|
|
176
|
+
- `config.ini`: For non-credentials configuration.
|
|
177
|
+
- `credentials.ini`: For credentials (authentication) configuration.
|
|
178
|
+
|
|
179
|
+
By default, the CLI will look for these in the following locations:
|
|
180
|
+
|
|
181
|
+
- The current working directory.
|
|
182
|
+
- A directory called `cloudsmith` in the OS-defined application directory. For example:
|
|
183
|
+
- Linux:
|
|
184
|
+
- `$HOME/.config/cloudsmith`
|
|
185
|
+
- `$HOME/.cloudsmith`
|
|
186
|
+
- Mac OS:
|
|
187
|
+
- `$HOME/Library/Application Support/cloudsmith`
|
|
188
|
+
- `$HOME/.cloudsmith`
|
|
189
|
+
- Windows:
|
|
190
|
+
- `C:\Users\<user>\AppData\Local\cloudsmith` (Win7+, not roaming)
|
|
191
|
+
- `C:\Users\<user>\AppData\Roaming\cloudsmith` (Win7+, roaming)
|
|
192
|
+
- `C:\Documents and Settings\<user>\Application Data\cloudsmith` (WinXP, not roaming)
|
|
193
|
+
- `C:\Documents and Settings\<user>\Local Settings\Application Data\cloudsmith` (WinXP, roaming)
|
|
194
|
+
- `C:\Documents and Settings\<user>\.cloudsmith`
|
|
195
|
+
|
|
196
|
+
Both configuration files use the simple INI format, such as:
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
[default]
|
|
200
|
+
api_key=1234567890abcdef1234567890abcdef
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Additionally, the CLI will store SSO access and refresh tokens in the system keyring
|
|
204
|
+
using the [`keyring`](https://github.com/jaraco/keyring) library.
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
### Non-Credentials (config.ini)
|
|
208
|
+
|
|
209
|
+
See the [default config](https://raw.githubusercontent.com/cloudsmith-io/cloudsmith-cli/master/cloudsmith_cli/data/config.ini) in GitHub:
|
|
210
|
+
|
|
211
|
+
You can specify the following configuration options:
|
|
212
|
+
|
|
213
|
+
- `api_host`: The API host to connect to.
|
|
214
|
+
- `api_proxy`: The API proxy to connect through.
|
|
215
|
+
- `api_ssl_verify`: Whether or not to use SSL verification for requests.
|
|
216
|
+
- `api_user_agent`: The user agent to use for requests.
|
|
217
|
+
|
|
218
|
+
### Credentials (credentials.ini)
|
|
219
|
+
|
|
220
|
+
See the [default config](https://raw.githubusercontent.com/cloudsmith-io/cloudsmith-cli/master/cloudsmith_cli/data/credentials.ini) in GitHub:
|
|
221
|
+
|
|
222
|
+
You can specify the following configuration options:
|
|
223
|
+
|
|
224
|
+
- `api_key`: The API key for authenticating with the API.
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
### Authenticating
|
|
228
|
+
|
|
229
|
+
You'll need to provide authentication to Cloudsmith for any CLI actions that result in accessing private data or making changes to resources (such as pushing a new package to a repository)..
|
|
230
|
+
|
|
231
|
+
#### SAML authentication
|
|
232
|
+
|
|
233
|
+
You can authenticate using your organization's SAML provider, if configured, with the `cloudsmith auth` command:
|
|
234
|
+
```
|
|
235
|
+
cloudsmith auth --owner example
|
|
236
|
+
Beginning authentication for the example org ...
|
|
237
|
+
Opening your organization's SAML IDP URL in your browser: https://example.com/some-saml-idp
|
|
238
|
+
|
|
239
|
+
Starting webserver to begin authentication ...
|
|
240
|
+
|
|
241
|
+
Authentication complete
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
#### Getting Your API Key
|
|
245
|
+
|
|
246
|
+
You can retrieve your API key using the `cloudsmith login` command:
|
|
247
|
+
|
|
248
|
+
```
|
|
249
|
+
cloudsmith login
|
|
250
|
+
Login: you@example.com
|
|
251
|
+
Password:
|
|
252
|
+
Repeat for confirmation:
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
*Note:* Please ensure you use your email for the 'Login' prompt and not your user slug/identifier.
|
|
256
|
+
|
|
257
|
+
The resulting output looks something like:
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
Retrieving API token for 'you@example.com' ... OK
|
|
261
|
+
Your API token is: 1234567890abcdef1234567890abcdef
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Once you have your API key you can then put this into your `credentials.ini`, use it as an environment variable `export CLOUDSMITH_API_KEY=your_key_here` or pass it to the CLI using the `-k your_key_here` flag.
|
|
265
|
+
|
|
266
|
+
For convenience the CLI will ask you if you want to install the default configuration files, complete with your API key, if they don't already exist. Say 'y' or 'yes' to create the configuration files.
|
|
267
|
+
|
|
268
|
+
If the configuration files already exist, you'll have to manually put the API key into the configuration files, but the CLI will print out their locations.
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
## Uploading Packages
|
|
272
|
+
|
|
273
|
+
Although native uploads, i.e. those supported by the native ecosystem of a package format, are often preferred; it's easy to publish with the Cloudsmith CLI too!
|
|
274
|
+
|
|
275
|
+
For example, if you wanted to upload a Debian package, you can do it in one-step. Assuming you have a package filename **libxml2-2.9.4-2.x86_64.deb**, representing **libxml 2.9.4**, for the **Ubuntu 16.04** distribution (which has a cloudsmith identifier of **ubuntu/xenial**):
|
|
276
|
+
|
|
277
|
+
```
|
|
278
|
+
cloudsmith push deb your-account/your-repo/ubuntu/xenial libxml2-2.9.4-2.x86_64.deb
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Want to know how to do it with another packaging format? Easy, just ask for help:
|
|
282
|
+
|
|
283
|
+
```
|
|
284
|
+
cloudsmith push rpm --help
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
## Contributing
|
|
289
|
+
|
|
290
|
+
Yes! Please do contribute, this is why we love open source. Please see [CONTRIBUTING](https://github.com/cloudsmith-io/cloudsmith-cli/blob/master/CONTRIBUTING.md) for contribution guidelines when making code changes or raising issues for bug reports, ideas, discussions and/or questions (i.e. help required).
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
## License
|
|
294
|
+
|
|
295
|
+
Copyright 2018 Cloudsmith Ltd
|
|
296
|
+
|
|
297
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
298
|
+
you may not use this file except in compliance with the License.
|
|
299
|
+
|
|
300
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
301
|
+
|
|
302
|
+
Unless required by applicable law or agreed to in writing, software
|
|
303
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
304
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
305
|
+
See the License for the specific language governing permissions and
|
|
306
|
+
limitations under the License.
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
## EOF
|
|
310
|
+
|
|
311
|
+
This quality product was brought to you by [Cloudsmith](https://cloudsmith.io) and the [fine folks who have contributed](https://github.com/cloudsmith-io/cloudsmith-cli/blob/master/CONTRIBUTORS.md).
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
[](https://github.com/ambv/black)
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
The [Cloudsmith](https://cloudsmith.io) Command Line Interface (CLI) is a
|
|
12
|
+
The [Cloudsmith](https://cloudsmith.io) Command Line Interface (CLI) is a Python 3 text-based interface to the [API](https://api.cloudsmith.io). This allows users, machines and other services to access and integrate smoothly with Cloudsmith without requiring explicit plugins or tools. [Be awesome. Automate Everything](https://cloudsmith.com/company/the-tao-of-cloudsmith/).
|
|
13
13
|
|
|
14
14
|
The following asciinema video demonstrates some of the CLI commands:
|
|
15
15
|
[](https://asciinema.org/a/DkNXQWQGBjWkfGPAkDAPNz7xe)
|
|
@@ -28,9 +28,11 @@ Please see the [changelog](https://github.com/cloudsmith-io/cloudsmith-cli/blob/
|
|
|
28
28
|
|
|
29
29
|
The CLI currently supports the following commands (and sub-commands):
|
|
30
30
|
|
|
31
|
+
- `auth`: Authenticate the CLI against an organization's SAML configuration.
|
|
31
32
|
- `check`: Check rate limits and service status.
|
|
32
33
|
- `copy`|`cp`: Copy a package to another repository.
|
|
33
34
|
- `delete`|`rm`: Delete a package from a repository.
|
|
35
|
+
- `dependencies`|`deps`: List direct (non-transitive) dependencies for a package.
|
|
34
36
|
- `docs`: Launch the help website in your browser.
|
|
35
37
|
- `entitlements`|`ents`: Manage the entitlements for a repository.
|
|
36
38
|
- `create`|`new`: Create a new entitlement in a repository.
|
|
@@ -41,8 +43,9 @@ The CLI currently supports the following commands (and sub-commands):
|
|
|
41
43
|
- `update`|`set`: Update (patch) a entitlement in a repository.
|
|
42
44
|
- `help`: Display the delightful help message and exit.
|
|
43
45
|
- `list`|`ls`: List distros, packages, repos and entitlements.
|
|
46
|
+
- `dependencies`|`deps` List direct (non-transitive) dependencies for a package.
|
|
44
47
|
- `distros`: List available distributions.
|
|
45
|
-
- `entitlements`:
|
|
48
|
+
- `entitlements`|`ents`: List entitlements for a repository.
|
|
46
49
|
- `packages`: List packages for a repository. (Aliases `repos list`)
|
|
47
50
|
- `repos`: List repositories for a namespace (owner).
|
|
48
51
|
- `login`|`token`: Retrieve your API authentication token/key via login.
|
|
@@ -71,6 +74,9 @@ The CLI currently supports the following commands (and sub-commands):
|
|
|
71
74
|
- `ruby`: Push (upload) a new Ruby package upstream.
|
|
72
75
|
- `terraform`: Push (upload) a new Terraform package upstream.
|
|
73
76
|
- `vagrant`: Push (upload) a new Vagrant package upstream.
|
|
77
|
+
- `quarantine`|`block`: Manage quarantined packages in a repository.
|
|
78
|
+
- `add`: Add a package to quarantine.
|
|
79
|
+
- `remove`|`rm`|`restore`: Add a package to quarantine.
|
|
74
80
|
- `quota`: Quota limits and history for a organisation.
|
|
75
81
|
- `limits`: Display the Quota (bandwidth & storage usage/limits) for a specific organisation.
|
|
76
82
|
- `history`: Display the Quota History (upload, download, and storage usage/limits) for a specific organisation.
|
|
@@ -88,7 +94,9 @@ The CLI currently supports the following commands (and sub-commands):
|
|
|
88
94
|
- `remove`|`rm`: Remove tags from a package in a repository.
|
|
89
95
|
- `replace`: Replace all existing (non-immutable) tags on a package in a repository.
|
|
90
96
|
- `whoami`: Retrieve your current authentication status.
|
|
91
|
-
|
|
97
|
+
- `tokens`: Manage API tokens.
|
|
98
|
+
- `list`|`ls`: List API tokens.
|
|
99
|
+
- `refresh`: Refresh an API token.
|
|
92
100
|
|
|
93
101
|
## Installation
|
|
94
102
|
|
|
@@ -131,6 +139,7 @@ By default, the CLI will look for these in the following locations:
|
|
|
131
139
|
- `C:\Users\<user>\AppData\Roaming\cloudsmith` (Win7+, roaming)
|
|
132
140
|
- `C:\Documents and Settings\<user>\Application Data\cloudsmith` (WinXP, not roaming)
|
|
133
141
|
- `C:\Documents and Settings\<user>\Local Settings\Application Data\cloudsmith` (WinXP, roaming)
|
|
142
|
+
- `C:\Documents and Settings\<user>\.cloudsmith`
|
|
134
143
|
|
|
135
144
|
Both configuration files use the simple INI format, such as:
|
|
136
145
|
|
|
@@ -139,6 +148,10 @@ Both configuration files use the simple INI format, such as:
|
|
|
139
148
|
api_key=1234567890abcdef1234567890abcdef
|
|
140
149
|
```
|
|
141
150
|
|
|
151
|
+
Additionally, the CLI will store SSO access and refresh tokens in the system keyring
|
|
152
|
+
using the [`keyring`](https://github.com/jaraco/keyring) library.
|
|
153
|
+
|
|
154
|
+
|
|
142
155
|
### Non-Credentials (config.ini)
|
|
143
156
|
|
|
144
157
|
See the [default config](https://raw.githubusercontent.com/cloudsmith-io/cloudsmith-cli/master/cloudsmith_cli/data/config.ini) in GitHub:
|
|
@@ -159,11 +172,26 @@ You can specify the following configuration options:
|
|
|
159
172
|
- `api_key`: The API key for authenticating with the API.
|
|
160
173
|
|
|
161
174
|
|
|
162
|
-
###
|
|
175
|
+
### Authenticating
|
|
163
176
|
|
|
164
177
|
You'll need to provide authentication to Cloudsmith for any CLI actions that result in accessing private data or making changes to resources (such as pushing a new package to a repository)..
|
|
165
178
|
|
|
166
|
-
|
|
179
|
+
#### SAML authentication
|
|
180
|
+
|
|
181
|
+
You can authenticate using your organization's SAML provider, if configured, with the `cloudsmith auth` command:
|
|
182
|
+
```
|
|
183
|
+
cloudsmith auth --owner example
|
|
184
|
+
Beginning authentication for the example org ...
|
|
185
|
+
Opening your organization's SAML IDP URL in your browser: https://example.com/some-saml-idp
|
|
186
|
+
|
|
187
|
+
Starting webserver to begin authentication ...
|
|
188
|
+
|
|
189
|
+
Authentication complete
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
#### Getting Your API Key
|
|
193
|
+
|
|
194
|
+
You can retrieve your API key using the `cloudsmith login` command:
|
|
167
195
|
|
|
168
196
|
```
|
|
169
197
|
cloudsmith login
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
"""Cloudsmith CLI."""
|
|
2
|
+
|
|
3
|
+
import warnings
|
|
4
|
+
|
|
3
5
|
import click
|
|
4
6
|
import urllib3
|
|
5
7
|
|
|
6
8
|
click.disable_unicode_literals_warning = True
|
|
7
9
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
10
|
+
warnings.filterwarnings("ignore", category=ResourceWarning)
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
"""CLI - Group/Command classes."""
|
|
3
|
-
from __future__ import absolute_import, print_function, unicode_literals
|
|
4
2
|
|
|
5
|
-
import sys
|
|
6
3
|
from collections import OrderedDict
|
|
7
4
|
|
|
8
5
|
import click.exceptions
|
|
9
|
-
import six
|
|
10
6
|
from click_didyoumean import DYMGroup
|
|
11
7
|
|
|
12
8
|
|
|
@@ -14,13 +10,13 @@ class AliasGroup(DYMGroup):
|
|
|
14
10
|
"""A command group with DYM and alias support."""
|
|
15
11
|
|
|
16
12
|
def __init__(self, *args, **kwargs):
|
|
17
|
-
super(
|
|
13
|
+
super().__init__(*args, **kwargs)
|
|
18
14
|
self.aliases = OrderedDict()
|
|
19
15
|
self.inverse = {}
|
|
20
16
|
|
|
21
17
|
def resolve_command(self, ctx, args):
|
|
22
18
|
try:
|
|
23
|
-
return super(
|
|
19
|
+
return super().resolve_command(ctx, args)
|
|
24
20
|
except click.exceptions.UsageError:
|
|
25
21
|
# Before DYM kicks in, check to see if the command prefix matches
|
|
26
22
|
# exactly one command, then use that instead.
|
|
@@ -30,23 +26,23 @@ class AliasGroup(DYMGroup):
|
|
|
30
26
|
matched = [cmd for cmd in cmds if cmd.startswith(cmd_name)]
|
|
31
27
|
if len(matched) == 1 and len(cmd_name) > 1:
|
|
32
28
|
args[0] = matched[0]
|
|
33
|
-
return super(
|
|
29
|
+
return super().resolve_command(ctx, args)
|
|
34
30
|
|
|
35
|
-
|
|
31
|
+
raise
|
|
36
32
|
|
|
37
33
|
def list_commands(self, ctx):
|
|
38
|
-
commands = super(
|
|
34
|
+
commands = super().list_commands(ctx)
|
|
39
35
|
|
|
40
36
|
if getattr(ctx, "showing_help", False):
|
|
41
37
|
for k, v in enumerate(commands):
|
|
42
38
|
try:
|
|
43
|
-
commands[k] = "
|
|
39
|
+
commands[k] = f"{v}|{'|'.join(self.aliases[v])}"
|
|
44
40
|
except KeyError:
|
|
45
41
|
pass
|
|
46
42
|
|
|
47
43
|
return commands
|
|
48
44
|
|
|
49
|
-
for k in
|
|
45
|
+
for k in self.inverse:
|
|
50
46
|
commands.append(k)
|
|
51
47
|
|
|
52
48
|
return commands
|
|
@@ -61,7 +57,7 @@ class AliasGroup(DYMGroup):
|
|
|
61
57
|
except KeyError:
|
|
62
58
|
pass
|
|
63
59
|
|
|
64
|
-
return super(
|
|
60
|
+
return super().get_command(ctx, cmd_name)
|
|
65
61
|
|
|
66
62
|
def command(self, *args, **kwargs):
|
|
67
63
|
def decorator(f):
|
|
@@ -95,4 +91,4 @@ class AliasGroup(DYMGroup):
|
|
|
95
91
|
|
|
96
92
|
def format_commands(self, ctx, formatter):
|
|
97
93
|
ctx.showing_help = True
|
|
98
|
-
return super(
|
|
94
|
+
return super().format_commands(ctx, formatter)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""CLI/Commands - Import all commands."""
|
|
2
|
+
|
|
3
|
+
from . import (
|
|
4
|
+
auth,
|
|
5
|
+
check,
|
|
6
|
+
copy,
|
|
7
|
+
delete,
|
|
8
|
+
dependencies,
|
|
9
|
+
docs,
|
|
10
|
+
entitlements,
|
|
11
|
+
help_,
|
|
12
|
+
list_,
|
|
13
|
+
login,
|
|
14
|
+
metrics,
|
|
15
|
+
move,
|
|
16
|
+
policy,
|
|
17
|
+
push,
|
|
18
|
+
quarantine,
|
|
19
|
+
quota,
|
|
20
|
+
repos,
|
|
21
|
+
resync,
|
|
22
|
+
status,
|
|
23
|
+
tags,
|
|
24
|
+
tokens,
|
|
25
|
+
upstream,
|
|
26
|
+
whoami,
|
|
27
|
+
)
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""CLI/Commands - Authenticate the user."""
|
|
2
|
+
|
|
3
|
+
import webbrowser
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from ...core.api import exceptions, user
|
|
8
|
+
from ...core.config import create_config_files, new_config_messaging
|
|
9
|
+
from .. import decorators, validators
|
|
10
|
+
from ..exceptions import handle_api_exceptions
|
|
11
|
+
from ..saml import create_configured_session, get_idp_url
|
|
12
|
+
from ..utils import maybe_spinner
|
|
13
|
+
from ..webserver import AuthenticationWebRequestHandler, AuthenticationWebServer
|
|
14
|
+
from .main import main
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@main.command(aliases=["auth"])
|
|
18
|
+
@click.option(
|
|
19
|
+
"-o",
|
|
20
|
+
"--owner",
|
|
21
|
+
metavar="OWNER",
|
|
22
|
+
required=True,
|
|
23
|
+
callback=validators.validate_owner,
|
|
24
|
+
prompt=True,
|
|
25
|
+
help="The name of the Cloudsmith organization to authenticate with.",
|
|
26
|
+
)
|
|
27
|
+
@click.option(
|
|
28
|
+
"-t",
|
|
29
|
+
"--token",
|
|
30
|
+
default=False,
|
|
31
|
+
is_flag=True,
|
|
32
|
+
help="Retrieve a user API token after successful authentication.",
|
|
33
|
+
)
|
|
34
|
+
@decorators.common_cli_config_options
|
|
35
|
+
@decorators.common_cli_output_options
|
|
36
|
+
@decorators.initialise_api
|
|
37
|
+
@click.pass_context
|
|
38
|
+
def authenticate(ctx, opts, owner, token):
|
|
39
|
+
"""Authenticate to Cloudsmith using the org's SAML setup."""
|
|
40
|
+
owner = owner[0].strip("'[]'")
|
|
41
|
+
api_host = opts.api_config.host
|
|
42
|
+
|
|
43
|
+
click.echo(
|
|
44
|
+
"Beginning authentication for the {owner} org ... ".format(
|
|
45
|
+
owner=click.style(owner, bold=True)
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
session = create_configured_session(opts)
|
|
50
|
+
|
|
51
|
+
context_message = "Failed to authenticate via SSO!"
|
|
52
|
+
with handle_api_exceptions(ctx, opts=opts, context_msg=context_message):
|
|
53
|
+
idp_url = get_idp_url(api_host, owner, session=session)
|
|
54
|
+
click.echo(
|
|
55
|
+
"Opening your organization's SAML IDP URL in your browser: %(idp_url)s"
|
|
56
|
+
% {"idp_url": click.style(idp_url, bold=True)}
|
|
57
|
+
)
|
|
58
|
+
click.echo()
|
|
59
|
+
webbrowser.open(idp_url)
|
|
60
|
+
click.echo("Starting webserver to begin authentication ... ")
|
|
61
|
+
|
|
62
|
+
auth_server = AuthenticationWebServer(
|
|
63
|
+
("127.0.0.1", 12400),
|
|
64
|
+
AuthenticationWebRequestHandler,
|
|
65
|
+
api_host=api_host,
|
|
66
|
+
owner=owner,
|
|
67
|
+
session=session,
|
|
68
|
+
debug=opts.debug,
|
|
69
|
+
)
|
|
70
|
+
auth_server.handle_request()
|
|
71
|
+
|
|
72
|
+
if not token:
|
|
73
|
+
return
|
|
74
|
+
|
|
75
|
+
try:
|
|
76
|
+
api_token = user.create_user_token_saml()
|
|
77
|
+
click.echo(f"New token value: {click.style(api_token.key, fg='magenta')}")
|
|
78
|
+
create, has_errors = create_config_files(ctx, opts, api_key=api_token.key)
|
|
79
|
+
new_config_messaging(has_errors, opts, create, api_key=api_token.key)
|
|
80
|
+
return
|
|
81
|
+
except exceptions.ApiException as exc:
|
|
82
|
+
if exc.status == 400:
|
|
83
|
+
if "User has already created an API key" in exc.detail:
|
|
84
|
+
click.confirm(
|
|
85
|
+
"User already has a token. Would you like to recreate it?",
|
|
86
|
+
abort=True,
|
|
87
|
+
)
|
|
88
|
+
else:
|
|
89
|
+
raise
|
|
90
|
+
|
|
91
|
+
context_msg = "Failed to refresh the token!"
|
|
92
|
+
with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg):
|
|
93
|
+
api_tokens = user.list_user_tokens()
|
|
94
|
+
for t in api_tokens:
|
|
95
|
+
click.echo("Current tokens:")
|
|
96
|
+
click.echo(
|
|
97
|
+
f"Token: {click.style(t.key, fg='magenta')}, "
|
|
98
|
+
f"Created: {click.style(t.created, fg='green')}, "
|
|
99
|
+
f"slug_perm: {click.style(t.slug_perm, fg='cyan')}"
|
|
100
|
+
)
|
|
101
|
+
token_slug = click.prompt(
|
|
102
|
+
"Please enter the slug_perm of the token you would like to refresh"
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
click.echo(f"Refreshing token {token_slug}... ", nl=False)
|
|
106
|
+
with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg):
|
|
107
|
+
with maybe_spinner(opts):
|
|
108
|
+
new_token = user.refresh_user_token(token_slug)
|
|
109
|
+
click.secho("OK", fg="green")
|
|
110
|
+
click.echo(f"New token value: {click.style(new_token.key, fg='magenta')}")
|
|
111
|
+
create, has_errors = create_config_files(ctx, opts, api_key=new_token.key)
|
|
112
|
+
new_config_messaging(has_errors, opts, create, api_key=new_token.key)
|