Skip to content

Commit b06cee3

Browse files
authored
feat: Update default cli output configuration (#1184)
Adapt default cli configuration for the resources output. Add some documentation on how this can be used.
1 parent 7594204 commit b06cee3

File tree

21 files changed

+261
-135
lines changed

21 files changed

+261
-135
lines changed

.github/workflows/mdbook.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
build:
3030
runs-on: ubuntu-latest
3131
env:
32-
MDBOOK_VERSION: 0.4.40
32+
MDBOOK_VERSION: 0.4.48
3333
steps:
3434
- name: Harden Runner
3535
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0

README.md

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,60 @@ Current focus of the project is at introducing Rust as a programming language
2525
into the ecosystem of OpenStack user facing tooling and provides SDK as well as
2626
CLI and TUI.
2727

28+
## Components
29+
30+
- `openstack_sdk` - SDK
31+
- `openstack_cli` - The new and shiny CLI for OpenStack
32+
- `openstack_tui` - Text (Terminal) User Interface
33+
- `openstack_types` - Type definitions for the API responses.
34+
- `doc` - Project documentation
35+
36+
## OpenStackClient (NG)
37+
38+
New approach for having a CLI for OpenStack using complied language offering
39+
blazing fast UX (it is the cloud to blame for being slow from now on, not the
40+
client).
41+
42+
- Advanced authentication caching built-in and enabled by default
43+
44+
- Status based resource coloring (resource list table rows are colored by the
45+
resource state)
46+
47+
- Output configuration (using `$XDG_CONFIG_DIR/osc/config.yaml` it is possible
48+
to configure which fields should be returned when listing resources to enable
49+
customization).
50+
51+
- Strict microversion binding for resource modification requests (instead of
52+
`openstack server create ...` which will not work with all microversions you
53+
use `osc compute server create290` which will only work if server supports it.
54+
It is similar to `openstack --os-compute-api-version X.Y`). It behaves the same
55+
on every cloud independent of which microversion this cloud supports (as long
56+
as it supports required microversion).
57+
58+
- Can be wonderfully combined with jq for ultimate control of the necessary
59+
data (`osc server list -o json | jq -r ".[].flavor.original_name"`)
60+
61+
- Output everything what cloud sent (`osc compute server list -o json` to
62+
return fields that we never even knew about, but the cloud sent us).
63+
64+
- `osc api` command as an API wrapper allowing user to perform any direct API
65+
call specifying service type, url, method and payload. This can be used for
66+
example when certain resource is not currently implemented natively.
67+
68+
69+
## Terminal User Interface (TUI)
70+
71+
Exploring the cloud resources using CLI is not something very comfortable. A
72+
terminal user interface imroves user experience when a quick look at currently
73+
present resources is required.
74+
75+
openstack_tui (`ostui` as a binary name) is such TUI built upon
76+
[Ratatui](https://ratatui.rs) and inspired in functionality by
77+
[k9s](https://k9scli.io) that provides TUI for Kubernetes.
78+
79+
![](doc/src/images/tui/ostui.gif)
80+
81+
2882
## Design principles
2983

3084
After long time maintaining OpenStack client facing tools it became clear that
@@ -74,16 +128,6 @@ normalization.
74128
- User is in full control of input and output. Microversion X.Y has a concrete
75129
body schema and with no faulty merges between different versions.
76130

77-
## Components
78-
79-
- `openstack_sdk` - SDK
80-
- `openstack_cli` - The new and shiny CLI for OpenStack
81-
- `openstack_tui` - Text (Terminal) User Interface
82-
- `structable_derive` - Helper crate for having Output in some way similar to
83-
old OpenStackClient
84-
- `xtask` - Workflow helper
85-
- `doc` - Project documentation
86-
87131
## Trying out
88132

89133
Any software is created to be used.
@@ -104,7 +148,6 @@ TUI can be installed similarly:
104148
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/gtema/openstack/releases/latest/download/openstack_tui-installer.sh | sh
105149
```
106150

107-
108151
### Build locally
109152
Alternatively it is possible to compile project from sources. Since the project
110153
is a pure `Rust` it requires having a Rust compile suite.
@@ -160,18 +203,6 @@ and token caching enabled. Benchmarking is performed using
160203
API response. High amount of long API requests causes smaller performance
161204
difference.
162205

163-
## Terminal User Interface (TUI)
164-
165-
Exploring the cloud resources using CLI is not something very comfortable. A
166-
terminal user interface imroves user experience when a quick look at currently
167-
present resources is required.
168-
169-
openstack_tui (`ostui` as a binary name) is such TUI built upon
170-
[Ratatui](https://ratatui.rs) and inspired in functionality by
171-
[k9s](https://k9scli.io) that provides TUI for Kubernetes.
172-
173-
![](doc/src/images/tui/ostui.gif)
174-
175206
## Software security
176207

177208
Security is being taken seriously. Every step of the development and release

doc/book.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ multilingual = false
55
src = "src"
66
title = "OpenStack Client Tools"
77

8+
[rust]
9+
edition = "2024"
10+
811
[build]
912
build-dir = "html"
1013
create-missing = false
1114

1215
[output.html.fold]
1316
enable = true
14-
level = 1
17+
level = 2
1518

1619
[preprocessor.osc-cli]
1720
command = "cargo run -p xtask --bin osc-cli-md"

doc/src/SUMMARY.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@
1010
# Components
1111

1212
- [Rust SDK](./sdk.md)
13+
14+
---
15+
1316
- [OpenStackClient (OSC)](./cli.md)
14-
- [Text User Interface (TUI)](./tui.md)
17+
- [Interface](cli/interface.md)
18+
- [Configuration](cli/config.md)
19+
20+
---
21+
22+
- [Text User Interface (TUI)](tui.md)
1523
- [Connection](./tui/cloud-connect.md)
1624
- [Resource Selection](./tui/resource-select.md)
1725
- [Header](./tui/header.md)

doc/src/cli.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
11
{{#include ../../openstack_cli/README.md}}
2-
3-
# Command interface
4-
5-
{{#cmd osc}}

doc/src/cli/config.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# CLI configuration
2+
3+
It is possible to configure different aspects of the OpenStackClient (not the
4+
clouds connection credentials) using the configuration file
5+
(`$XDG_CONFIG_DIR/osc/config.yaml`). This enables user to configurate which
6+
columns should be returned when no corresponding run time arguments on a
7+
resource base.
8+
9+
```yaml
10+
views:
11+
compute.server:
12+
# Listing compute servers will only return ID, NAME and IMAGE columns unless `-o wide` or
13+
`-f XXX` parameters are being passed
14+
fields: [id, name, image]
15+
dns.zone/recordset:
16+
# DNS zone recordsets are listed in the wide mode by default.
17+
wide: true
18+
```
19+
20+
The key of the `views` map is a resource key shared among all
21+
`openstack_rust`tools and is built in the following form:
22+
`<SERVICE-TYPE>.<RESOURCE_NAME>[/<SUBRESOURCE_NAME>]` where
23+
`<RESOURCE_NAME>[/<SUBRESOURCE_NAME>` is a url based naming (for designate
24+
`/zone/<ID>/recordset/<RS_ID>` would be names as zone.recordset and
25+
`/volumes/{volume_id}/metadata`would become volume.metadata. Please consult
26+
[Codegenerator
27+
metadata](https://opendev.org/openstack/codegenerator/src/branch/master/metadata)
28+
for known resource keys.

doc/src/cli/interface.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Command interface
2+
3+
{{#cmd osc}}

0 commit comments

Comments
 (0)