oks-cli 1.14__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.
oks_cli-1.14/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2025, Outscale SAS
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
oks_cli-1.14/PKG-INFO ADDED
@@ -0,0 +1,270 @@
1
+ Metadata-Version: 2.4
2
+ Name: oks-cli
3
+ Version: 1.14
4
+ Author: Outscale SAS
5
+ Author-email: opensource@outscale.com
6
+ License: BSD
7
+ Classifier: License :: OSI Approved :: BSD License
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.6
10
+ Classifier: Programming Language :: Python :: 3.7
11
+ Classifier: Programming Language :: Python :: 3.8
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Operating System :: OS Independent
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: certifi>=2024.8.30
19
+ Requires-Dist: charset-normalizer>=3.3.2
20
+ Requires-Dist: click>=8.1.7
21
+ Requires-Dist: colorama>=0.4.6
22
+ Requires-Dist: idna>=3.10
23
+ Requires-Dist: pyyaml>=6.0.2
24
+ Requires-Dist: requests>=2.32.3
25
+ Requires-Dist: urllib3>=2.2.3
26
+ Requires-Dist: human-readable
27
+ Requires-Dist: prettytable
28
+ Requires-Dist: python-dateutil
29
+ Requires-Dist: altgraph>=0.17.4
30
+ Requires-Dist: pynacl>=1.5.0
31
+ Requires-Dist: pyOpenSSL>=25.0.0
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest>=8.4.1; extra == "dev"
34
+ Dynamic: author
35
+ Dynamic: author-email
36
+ Dynamic: classifier
37
+ Dynamic: description
38
+ Dynamic: description-content-type
39
+ Dynamic: license
40
+ Dynamic: license-file
41
+ Dynamic: provides-extra
42
+ Dynamic: requires-dist
43
+
44
+ # OKS-CLI
45
+
46
+ [![Project Incubating](https://docs.outscale.com/fr/userguide/_images/Project-Incubating-blue.svg)](https://docs.outscale.com/en/userguide/Open-Source-Projects.html)
47
+ [![](https://dcbadge.limes.pink/api/server/HUVtY5gT6s?style=flat&theme=default-inverted)](https://discord.gg/HUVtY5gT6s)
48
+
49
+ <p align="center">
50
+ <img alt="Kubernetes" src="https://upload.wikimedia.org/wikipedia/commons/3/39/Kubernetes_logo_without_workmark.svg" width="120px">
51
+ </p>
52
+
53
+ ---
54
+
55
+ ## 🌐 Links
56
+
57
+ * 📘 [OKS-CLI Documentation](https://docs.outscale.com/fr/userguide/Installer-et-configurer-OKS-CLI.html)
58
+ * 📘 [OKS API Reference](https://docs.outscale.com/oks.html)
59
+ * 🐛 [GitHub Issues](https://github.com/outscale/oks-cli/issues)
60
+
61
+ ---
62
+
63
+ ## 📄 Table of Contents
64
+
65
+ * [Overview](#-overview)
66
+ * [Requirements](#-requirements)
67
+ * [Installation](#-installation)
68
+
69
+ * [Standard Installation](#standard-installation)
70
+ * [User Installation](#user-installation)
71
+ * [Usage](#-usage)
72
+
73
+ * [Commands](#commands)
74
+ * [Examples](#examples)
75
+ * [Development](#-development)
76
+
77
+ * [Editable Mode](#editable-mode)
78
+ * [Project Structure](#project-structure)
79
+ * [Dependencies](#dependencies)
80
+ * [Contributing](#-contributing)
81
+ * [License](#-license)
82
+ * [Support](#-support)
83
+
84
+ ---
85
+
86
+ ## 🧭 Overview
87
+
88
+ **OKS-CLI** is a command-line interface that allows you to deploy and manage Kubernetes clusters on top of OUTSCALE infrastructure.
89
+
90
+ ---
91
+
92
+ ## ✅ Requirements
93
+
94
+ * Python 3.11 or later
95
+ * `pip` (Python package manager)
96
+ * `kubectl` (required for commands that interact with the Kubernetes API)
97
+
98
+ ---
99
+
100
+ ## 📦 Installation
101
+
102
+ ### Standard Installation
103
+
104
+ ```bash
105
+ # Clone the repository
106
+ git clone https://github.com/outscale/oks-cli.git
107
+ cd oks-cli
108
+
109
+ # Create and activate a virtual environment
110
+ python -m venv venv
111
+ source venv/bin/activate
112
+
113
+ # Install dependencies
114
+ pip install -r requirements.txt
115
+
116
+ # Install the CLI in editable mode
117
+ pip install -e .
118
+ ```
119
+
120
+ ### User Installation
121
+
122
+ Install globally without a virtual environment (Python 3.11):
123
+
124
+ ```bash
125
+ pip3.11 install -e --user .
126
+ ```
127
+
128
+ > **Note:** Ensure `~/Library/Python/3.11/bin` (macOS) or the equivalent path is in your `PATH`.
129
+
130
+ ---
131
+
132
+ ## 🚀 Usage
133
+
134
+ Display all available commands:
135
+
136
+ ```bash
137
+ oks-cli fullhelp
138
+ ```
139
+
140
+ ### Commands
141
+
142
+ | Command | Description |
143
+ |--------------------------------------|---------------------------------------------------------------|
144
+ | profile list | List existing profiles |
145
+ | profile add | Add AK/SK or username/password new profile |
146
+ | profile delete | Delete a profile by name |
147
+ | profile update | Update an existing profile |
148
+ | project list | List all projects |
149
+ | project create | Create a new project |
150
+ | project get | Get default project or the project by name |
151
+ | project update | Update a project by name |
152
+ | project delete | Delete a project by name |
153
+ | project login | Set a default project by name |
154
+ | project logout | Unset default project |
155
+ | project quotas | Get project quotas |
156
+ | project snapshots | Get project snapshots |
157
+ | project publicips | Get project public ips |
158
+ | cluster list | List all clusters |
159
+ | cluster create | Create a new cluster |
160
+ | cluster get | Get a cluster by name |
161
+ | cluster update | Update a cluster by name |
162
+ | cluster upgrade | Upgrade a cluster by name |
163
+ | cluster delete | Delete a cluster by name |
164
+ | cluster login | Set a default cluster |
165
+ | cluster logout | Unset default cluster |
166
+ | cluster kubeconfig | Fetch the kubeconfig for a cluster |
167
+ | cluster kubectl | Fetch kubeconfig and run kubectl against it |
168
+ | cluster nodepool list | List nodepools in the specified cluster |
169
+ | cluster nodepool create | Create a new nodepool in the cluster |
170
+ | cluster nodepool delete | Delete a nodepool by name from the cluster |
171
+ | cache clear | Clear cache |
172
+ | cache kubeconfigs | List cached kubeconfigs |
173
+ | quotas | Get quotas |
174
+ | fullhelp | Display detailed help information for all commands |
175
+ | version | Show the current CLI version |
176
+ | install-completion | Install shell completion scripts |
177
+
178
+ ---
179
+
180
+ ### Examples
181
+
182
+ ```bash
183
+ # List all projects
184
+ oks-cli project list
185
+
186
+ # Dry run project creation
187
+ oks-cli project create --project-name my-project --description "Test project" --dry-run
188
+
189
+ # Dry run cluster creation
190
+ oks-cli cluster create \
191
+ --cluster-name my-cluster \
192
+ --project-name my-project \
193
+ --description "My test cluster" \
194
+ --version "1.32" \
195
+ --dry-run
196
+
197
+ # Set a default project profile
198
+ oks-cli project login --project-name my-project
199
+ ```
200
+
201
+ ---
202
+
203
+ ## 🛠 Development
204
+
205
+ ### Editable Mode
206
+
207
+ Install the CLI in editable mode with development dependencies
208
+
209
+ ```bash
210
+ pip install -e ".[dev]"
211
+ ```
212
+
213
+ Changes in the `oks_cli/` directory will be immediately reflected without reinstalling.
214
+
215
+ ### Tests
216
+
217
+ Run the test suite using `pytest` to ensure code correctness and stability:
218
+
219
+ ```bash
220
+ pytest
221
+ ```
222
+
223
+ ### Project Structure
224
+
225
+ ```
226
+ oks-cli/
227
+ ├── oks_cli/ # Source code
228
+ │ ├── cache.py
229
+ │ ├── cluster.py
230
+ │ ├── main.py
231
+ │ ├── profile.py
232
+ │ ├── project.py
233
+ │ ├── quotas.py
234
+ │ └── utils.py
235
+ ├── setup.py # Packaging configuration
236
+ ├── requirements.txt # Dependencies
237
+ └── README.md # Project documentation
238
+ ```
239
+
240
+ ### Dependencies
241
+
242
+ Dependencies are managed via `setup.py` and `requirements.txt`.
243
+
244
+ To reinstall or update:
245
+
246
+ ```bash
247
+ pip install -e .
248
+ ```
249
+
250
+ ---
251
+
252
+ ## 🤝 Contributing
253
+
254
+ OKS-CLI is open source software licensed under BSD-3-Clause.
255
+
256
+ We welcome contributions! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines and instructions.
257
+
258
+ ---
259
+
260
+ ## 📜 License
261
+
262
+ **BSD-3-Clause**
263
+ © Outscale SAS
264
+
265
+ ---
266
+
267
+ ## 🆘 Support
268
+
269
+ * [Official Documentation](https://docs.outscale.com/fr/userguide/Installer-et-configurer-OKS-CLI.html)
270
+ * [GitHub Issues](https://github.com/outscale/oks-cli/issues)
oks_cli-1.14/README.md ADDED
@@ -0,0 +1,227 @@
1
+ # OKS-CLI
2
+
3
+ [![Project Incubating](https://docs.outscale.com/fr/userguide/_images/Project-Incubating-blue.svg)](https://docs.outscale.com/en/userguide/Open-Source-Projects.html)
4
+ [![](https://dcbadge.limes.pink/api/server/HUVtY5gT6s?style=flat&theme=default-inverted)](https://discord.gg/HUVtY5gT6s)
5
+
6
+ <p align="center">
7
+ <img alt="Kubernetes" src="https://upload.wikimedia.org/wikipedia/commons/3/39/Kubernetes_logo_without_workmark.svg" width="120px">
8
+ </p>
9
+
10
+ ---
11
+
12
+ ## 🌐 Links
13
+
14
+ * 📘 [OKS-CLI Documentation](https://docs.outscale.com/fr/userguide/Installer-et-configurer-OKS-CLI.html)
15
+ * 📘 [OKS API Reference](https://docs.outscale.com/oks.html)
16
+ * 🐛 [GitHub Issues](https://github.com/outscale/oks-cli/issues)
17
+
18
+ ---
19
+
20
+ ## 📄 Table of Contents
21
+
22
+ * [Overview](#-overview)
23
+ * [Requirements](#-requirements)
24
+ * [Installation](#-installation)
25
+
26
+ * [Standard Installation](#standard-installation)
27
+ * [User Installation](#user-installation)
28
+ * [Usage](#-usage)
29
+
30
+ * [Commands](#commands)
31
+ * [Examples](#examples)
32
+ * [Development](#-development)
33
+
34
+ * [Editable Mode](#editable-mode)
35
+ * [Project Structure](#project-structure)
36
+ * [Dependencies](#dependencies)
37
+ * [Contributing](#-contributing)
38
+ * [License](#-license)
39
+ * [Support](#-support)
40
+
41
+ ---
42
+
43
+ ## 🧭 Overview
44
+
45
+ **OKS-CLI** is a command-line interface that allows you to deploy and manage Kubernetes clusters on top of OUTSCALE infrastructure.
46
+
47
+ ---
48
+
49
+ ## ✅ Requirements
50
+
51
+ * Python 3.11 or later
52
+ * `pip` (Python package manager)
53
+ * `kubectl` (required for commands that interact with the Kubernetes API)
54
+
55
+ ---
56
+
57
+ ## 📦 Installation
58
+
59
+ ### Standard Installation
60
+
61
+ ```bash
62
+ # Clone the repository
63
+ git clone https://github.com/outscale/oks-cli.git
64
+ cd oks-cli
65
+
66
+ # Create and activate a virtual environment
67
+ python -m venv venv
68
+ source venv/bin/activate
69
+
70
+ # Install dependencies
71
+ pip install -r requirements.txt
72
+
73
+ # Install the CLI in editable mode
74
+ pip install -e .
75
+ ```
76
+
77
+ ### User Installation
78
+
79
+ Install globally without a virtual environment (Python 3.11):
80
+
81
+ ```bash
82
+ pip3.11 install -e --user .
83
+ ```
84
+
85
+ > **Note:** Ensure `~/Library/Python/3.11/bin` (macOS) or the equivalent path is in your `PATH`.
86
+
87
+ ---
88
+
89
+ ## 🚀 Usage
90
+
91
+ Display all available commands:
92
+
93
+ ```bash
94
+ oks-cli fullhelp
95
+ ```
96
+
97
+ ### Commands
98
+
99
+ | Command | Description |
100
+ |--------------------------------------|---------------------------------------------------------------|
101
+ | profile list | List existing profiles |
102
+ | profile add | Add AK/SK or username/password new profile |
103
+ | profile delete | Delete a profile by name |
104
+ | profile update | Update an existing profile |
105
+ | project list | List all projects |
106
+ | project create | Create a new project |
107
+ | project get | Get default project or the project by name |
108
+ | project update | Update a project by name |
109
+ | project delete | Delete a project by name |
110
+ | project login | Set a default project by name |
111
+ | project logout | Unset default project |
112
+ | project quotas | Get project quotas |
113
+ | project snapshots | Get project snapshots |
114
+ | project publicips | Get project public ips |
115
+ | cluster list | List all clusters |
116
+ | cluster create | Create a new cluster |
117
+ | cluster get | Get a cluster by name |
118
+ | cluster update | Update a cluster by name |
119
+ | cluster upgrade | Upgrade a cluster by name |
120
+ | cluster delete | Delete a cluster by name |
121
+ | cluster login | Set a default cluster |
122
+ | cluster logout | Unset default cluster |
123
+ | cluster kubeconfig | Fetch the kubeconfig for a cluster |
124
+ | cluster kubectl | Fetch kubeconfig and run kubectl against it |
125
+ | cluster nodepool list | List nodepools in the specified cluster |
126
+ | cluster nodepool create | Create a new nodepool in the cluster |
127
+ | cluster nodepool delete | Delete a nodepool by name from the cluster |
128
+ | cache clear | Clear cache |
129
+ | cache kubeconfigs | List cached kubeconfigs |
130
+ | quotas | Get quotas |
131
+ | fullhelp | Display detailed help information for all commands |
132
+ | version | Show the current CLI version |
133
+ | install-completion | Install shell completion scripts |
134
+
135
+ ---
136
+
137
+ ### Examples
138
+
139
+ ```bash
140
+ # List all projects
141
+ oks-cli project list
142
+
143
+ # Dry run project creation
144
+ oks-cli project create --project-name my-project --description "Test project" --dry-run
145
+
146
+ # Dry run cluster creation
147
+ oks-cli cluster create \
148
+ --cluster-name my-cluster \
149
+ --project-name my-project \
150
+ --description "My test cluster" \
151
+ --version "1.32" \
152
+ --dry-run
153
+
154
+ # Set a default project profile
155
+ oks-cli project login --project-name my-project
156
+ ```
157
+
158
+ ---
159
+
160
+ ## 🛠 Development
161
+
162
+ ### Editable Mode
163
+
164
+ Install the CLI in editable mode with development dependencies
165
+
166
+ ```bash
167
+ pip install -e ".[dev]"
168
+ ```
169
+
170
+ Changes in the `oks_cli/` directory will be immediately reflected without reinstalling.
171
+
172
+ ### Tests
173
+
174
+ Run the test suite using `pytest` to ensure code correctness and stability:
175
+
176
+ ```bash
177
+ pytest
178
+ ```
179
+
180
+ ### Project Structure
181
+
182
+ ```
183
+ oks-cli/
184
+ ├── oks_cli/ # Source code
185
+ │ ├── cache.py
186
+ │ ├── cluster.py
187
+ │ ├── main.py
188
+ │ ├── profile.py
189
+ │ ├── project.py
190
+ │ ├── quotas.py
191
+ │ └── utils.py
192
+ ├── setup.py # Packaging configuration
193
+ ├── requirements.txt # Dependencies
194
+ └── README.md # Project documentation
195
+ ```
196
+
197
+ ### Dependencies
198
+
199
+ Dependencies are managed via `setup.py` and `requirements.txt`.
200
+
201
+ To reinstall or update:
202
+
203
+ ```bash
204
+ pip install -e .
205
+ ```
206
+
207
+ ---
208
+
209
+ ## 🤝 Contributing
210
+
211
+ OKS-CLI is open source software licensed under BSD-3-Clause.
212
+
213
+ We welcome contributions! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines and instructions.
214
+
215
+ ---
216
+
217
+ ## 📜 License
218
+
219
+ **BSD-3-Clause**
220
+ © Outscale SAS
221
+
222
+ ---
223
+
224
+ ## 🆘 Support
225
+
226
+ * [Official Documentation](https://docs.outscale.com/fr/userguide/Installer-et-configurer-OKS-CLI.html)
227
+ * [GitHub Issues](https://github.com/outscale/oks-cli/issues)
File without changes
@@ -0,0 +1,63 @@
1
+ import click
2
+ from .utils import clear_cache, find_project_id_by_name, find_cluster_id_by_name, get_all_cache, get_expiration_date, ctx_update, login_profile, profile_completer
3
+ import prettytable
4
+
5
+ # DEFINE THE CACHE COMMAND GROUP
6
+ @click.group(help="Cache related commands.")
7
+ @click.option('--project-name', '-p', required = False, help="Project Name")
8
+ @click.option('--cluster-name', '-c', required = False, help="Cluster Name")
9
+ @click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer)
10
+ @click.pass_context
11
+ def cache(ctx, project_name, cluster_name, profile):
12
+ """CLI command group for cache-related operations."""
13
+ ctx_update(ctx, project_name, cluster_name, profile)
14
+
15
+ @cache.command('clear', help="Clear cache")
16
+ @click.option('--force', is_flag=True, help="Force deletion without confirmation")
17
+ def delete_cache(force):
18
+ """Clear all cached data, optionally without confirmation."""
19
+ if force or click.confirm("Are you sure you want to clear all cache?", abort=True):
20
+ clear_cache()
21
+
22
+ @cache.command('kubeconfigs', help="List cached kubeconfigs")
23
+ @click.option('--project-name', '-p', required=False, help="Project Name")
24
+ @click.option('--cluster-name', '-c', required=False, help="Cluster Name")
25
+ @click.option('--plain', is_flag=True, help="Plain table format")
26
+ @click.option('--msword', is_flag=True, help="Microsoft Word table format")
27
+ @click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer)
28
+ @click.pass_context
29
+ def list_kubeconfigs(ctx, project_name, cluster_name, plain, msword, profile):
30
+ """Display cached kubeconfigs with expiration dates in table format."""
31
+ project_name, cluster_name, profile = ctx_update(ctx, project_name, cluster_name, profile)
32
+ login_profile(profile)
33
+
34
+ project_id = find_project_id_by_name(project_name)
35
+ cluster_id = find_cluster_id_by_name(project_id, cluster_name)
36
+
37
+ result = get_all_cache(project_id, cluster_id, "kubeconfig")
38
+
39
+ table = prettytable.PrettyTable()
40
+ table.field_names = ["user", "group", "expiration date"]
41
+
42
+ if plain:
43
+ table.set_style(prettytable.PLAIN_COLUMNS)
44
+
45
+ if msword:
46
+ table.set_style(prettytable.MSWORD_FRIENDLY)
47
+
48
+ for element in result:
49
+ kubeconfig = None
50
+ user = click.style(element['user'], bold=True)
51
+ group = click.style(element['group'], bold=True)
52
+
53
+ if element.get("cache_path"):
54
+ with open(element.get("cache_path")) as f:
55
+ kubeconfig = f.read()
56
+
57
+ if kubeconfig:
58
+ exp = get_expiration_date(kubeconfig)
59
+ row = user, group, exp
60
+
61
+ table.add_row(row)
62
+
63
+ click.echo(table)