Commit Graph

2953 Commits

Author SHA1 Message Date
Wolfgang Bumiller
78c29b33ef compression: add flush_window to DeflateEncoder
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-09-05 14:15:11 +02:00
Wolfgang Bumiller
b22de1864a router: add stream helpers to async-decode json-seq
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-09-05 14:15:11 +02:00
Wolfgang Bumiller
04923dd601 client: expose body, add generic request methods and streaming
The get/put/post/put_without_body/... methods now have a default
implementation forwarding to a generic `request` method as all our
implementations do the same already anyway.

Additionally, in order to allow easy access to a "streaming body", the
Body type is now exposed.

In the future, this crate may also require a wrapper to standardize
the handling of `application/json-seq` streams if we end up using
them, but for now, a simple way to expose the body is enough to get
going.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-09-05 14:15:11 +02:00
Wolfgang Bumiller
8021f0a7f6 api-macro: support new streaming api methods
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-09-05 14:15:11 +02:00
Wolfgang Bumiller
17bd32e90e router, rest-server: add StreamSync and StreamAsync API handlers
These are Iterators or Streams which continuously produce output. They
can either be formatted, in which they are serialized like the as
usually, or, if the client caccepts `application/json-seq` via an
`Accept` header, it will be streamed as a sequence directly.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-09-05 14:15:11 +02:00
Wolfgang Bumiller
c31eaf0018 router, rest-server, api-macro: rename Streaming api to Serializing
This does not "stream", but rather skips the intermediate step to
serialize the entire output into a local json string.

We now reserve the "Stream*" prefix for actual *streaming*, that is,
producing an API response which gets streamed continuously as it is
asynchronously produced.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-09-05 14:15:11 +02:00
Wolfgang Bumiller
e8b8060b17 log: bump to 0.2.4-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-09-05 13:58:56 +02:00
Gabriel Goller
5933c2f47b log: write to stderr when using init_cli_logger, export tracing::Level
Previously when using `env_logger` all of our cli-tools logged to
stderr, make tracing do the same. Export `tracing::Level` so that we can
use the `tracing::enabled!` macro.

Tested-by: Christian Ebner <c.ebner@proxmox.com>
Reviewed-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2024-09-05 13:45:43 +02:00
Wolfgang Bumiller
a46dd1a60a router: bump to 2.2.4-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-30 13:53:03 +02:00
Wolfgang Bumiller
9a17ff15f7 log: bump to 0.2.3-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-30 13:50:24 +02:00
Gabriel Goller
021bab9304 add tracing init_cli_logger and deprecate old one
Deprecate the proxmox-router init_cli_logger function used in client
binaries such as `proxmox-backup-client`, `proxmox-backup-manager`,
'pxar', etc... Add a new init_cli_logger function that uses tracing
instead of env_logger. It checks if the task is in a workertask and
prints the message either to stdout or to the tasklog (this is
neccessary for commands in proxmox-backup-manager that call api handlers
that start workerthreads from the client).

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2024-08-30 13:47:55 +02:00
Dominik Csapak
237b317678 router: sort cli properties in usage output
If we don't do this, then properties from a serde flattened struct will
be positioned at the end of the list, rather than properly sorted with
the other properties.

Since the tests also feature non-sorted properties, we have to adapt
them too.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-08-30 13:26:13 +02:00
Wolfgang Bumiller
d72ea40c80 schema: bump to 3.1.4-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-28 14:51:23 +02:00
Wolfgang Bumiller
5704cb43b9 schema: add Schema::unwrap_any_object_schema
so we have a version we can use in const fns and const{} expressions

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-28 14:50:21 +02:00
Wolfgang Bumiller
00ca04698d schema: seal ObjectSchemaType and assert Send + Sync
While this is technically a breaking API change since the trait is
public, we don't implement it anywhere and it isn't meant to be
implemented from the outside.

Also, encode that these types are all Send + Sync via a super trait
notation.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-28 14:43:42 +02:00
Wolfgang Bumiller
e750bce69b schema: make Schema::any_object a const fn
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-28 14:32:39 +02:00
Wolfgang Bumiller
d166dcff0a schema: rustfmt
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-28 14:32:21 +02:00
Wolfgang Bumiller
3d044a5acf systemd: bump d/control to add missing dependencies
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-28 14:18:58 +02:00
Maximiliano Sandoval
a41da1f371 systemd: debcargo: add libsystemd-dev to dependencies
`Build-Depends` and `Depends` in d/control are missing `libsystemd-dev`,
resulting in mk-build-deps not being able to install all dependencies
needed by `make deb`.

After running `make deb` the control file looks:

```diff
modified   proxmox-systemd/debian/control
@@ -6,7 +6,8 @@ Build-Depends: debhelper (>= 12),
  cargo:native <!nocheck>,
  rustc:native <!nocheck>,
  libstd-rust-dev <!nocheck>,
- librust-libc-0.2+default-dev (>= 0.2.107-~~) <!nocheck>
+ librust-libc-0.2+default-dev (>= 0.2.107-~~) <!nocheck>,
+ libsystemd-dev <!nocheck>
 Maintainer: Proxmox Support Team <support@proxmox.com>
 Standards-Version: 4.6.2
 Vcs-Git: git://git.proxmox.com/git/proxmox.git
@@ -19,7 +20,8 @@ Architecture: any
 Multi-Arch: same
 Depends:
  ${misc:Depends},
- librust-libc-0.2+default-dev (>= 0.2.107-~~)
+ librust-libc-0.2+default-dev (>= 0.2.107-~~),
+ libsystemd-dev
 Provides:
  librust-proxmox-systemd+default-dev (= ${binary:Version}),
  librust-proxmox-systemd-0-dev (= ${binary:Version}),
```

Suggested-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-28 14:18:22 +02:00
Maximiliano Sandoval
de004f736d section-config: fix link to SectionConfigData
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-28 13:09:15 +02:00
Maximiliano Sandoval
ec3e8e05e4 section-config: fix link to section_config
Fixes:

warning: unresolved link to `seccfg`
  --> proxmox-section-config/src/typed.rs:18:71
   |
18 |     /// If the [`SectionConfig`] returned by the [`section_config()`][seccfg] method includes the
   |                                                                       ^^^^^^ no item named `seccfg` in scope
   |
   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
   = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default

warning: unresolved link to `seccfg`
  --> proxmox-section-config/src/typed.rs:22:10
   |
22 |     /// [seccfg] ApiSectionDataEntry::section_config()
   |          ^^^^^^ no item named `seccfg` in scope
   |
   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-28 13:09:15 +02:00
Maximiliano Sandoval
0157b6fdea access-control: acl: add indentation to docs
Fixes:

warning: doc list item missing indentation
   --> proxmox-access-control/src/acl.rs:518:9
    |
518 |     /// -- user/token is more specific than group at each level
    |         ^
    |
    = help: if this is supposed to be its own paragraph, add a blank line
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation
    = note: `#[warn(clippy::doc_lazy_continuation)]` on by default
help: indent this line
    |
518 |     ///   -- user/token is more specific than group at each level
    |         ++

warning: doc list item missing indentation
   --> proxmox-access-control/src/acl.rs:519:9
    |
519 |     /// -- roles lower in the tree are more specific than those higher up along the path
    |         ^
    |
    = help: if this is supposed to be its own paragraph, add a blank line
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation
help: indent this line
    |
519 |     ///   -- roles lower in the tree are more specific than those higher up along the path
    |         ++

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-28 13:09:15 +02:00
Maximiliano Sandoval
e60a53d80b apt: sources_parser: remove needless borrow
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-28 13:09:15 +02:00
Maximiliano Sandoval
f8f57540c6 apt: cache_api: simplify match with unwrap_or_default
Fixes:

warning: match can be simplified with `.unwrap_or_default()`
  --> proxmox-apt/src/cache_api.rs:77:28
   |
77 |           let mut notified = match cache.notified {
   |  ____________________________^
78 | |             Some(notified) => notified,
79 | |             None => std::collections::HashMap::new(),
80 | |         };
   | |_________^ help: replace it with: `cache.notified.unwrap_or_default()`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default
   = note: `#[warn(clippy::manual_unwrap_or_default)]` on by default

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-28 13:09:15 +02:00
Maximiliano Sandoval
a2e5973982 router: completion: remove needles borrow
Fixes:

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> proxmox-router/src/cli/completion.rs:154:25
    |
154 |                         &completion_functions,
    |                         ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `completion_functions`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
    = note: `#[warn(clippy::needless_borrow)]` on by default

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> proxmox-router/src/cli/completion.rs:201:21
    |
201 |                     &completion_functions,
    |                     ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `completion_functions`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-28 13:09:15 +02:00
Maximiliano Sandoval
b7100ecc1e rrd_map: remove unnecessary use of get().is_some()
Fixes:

warning: unnecessary use of `get(rel_path).is_some()`
   --> proxmox-rrd/src/cache/rrd_map.rs:107:21
    |
107 |         if self.map.get(rel_path).is_some() {
    |                     ^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key(rel_path)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-28 13:09:15 +02:00
Maximiliano Sandoval
5586eeaba8 rrd_map: remove unneded return statement
Fixes:

warning: unneeded `return` statement
   --> proxmox-rrd/src/cache/rrd_map.rs:117:13
    |
117 |             return Ok(true);
    |             ^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
    = note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
    |
117 -             return Ok(true);
117 +             Ok(true)
    |

warning: unneeded `return` statement
   --> proxmox-rrd/src/cache/rrd_map.rs:119:13
    |
119 |             return Ok(false);
    |             ^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
    |
119 -             return Ok(false);
119 +             Ok(false)

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-28 13:09:15 +02:00
Wolfgang Bumiller
2da3121492 sys: crypt: style + drop unnecessary length check
These are statically sized arrays, not slices, they cannot be empty.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-28 13:04:43 +02:00
Wolfgang Bumiller
3129752da9 router: bump to 2.2.3-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-14 12:02:13 +02:00
Wolfgang Bumiller
c1a947c998 openid: bump to 0.10.3-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-14 12:00:58 +02:00
Wolfgang Bumiller
9ae3df424e product-config: bump to 0.2.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-14 12:00:02 +02:00
Wolfgang Bumiller
5544c17ede log: bump to 0.2.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-14 11:52:03 +02:00
Wolfgang Bumiller
ca04e129e4 client: bump to 0.4.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-14 11:51:22 +02:00
Wolfgang Bumiller
11e6173097 apt: bump to 0.11.3-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-14 11:48:32 +02:00
Wolfgang Bumiller
256bcfb0f1 rrd: bump to 0.3.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-14 11:47:35 +02:00
Wolfgang Bumiller
c1709d994e simple-config: bump to 0.1.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-14 11:44:26 +02:00
Wolfgang Bumiller
fc7a4be4eb uuid: bump to 1.0.3-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-14 11:43:11 +02:00
Wolfgang Bumiller
2c1d5fd741 daemon: bump to 0.1.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-14 11:42:00 +02:00
Maximiliano Sandoval
af9aa40d8b router: remove unused deps
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-14 11:38:48 +02:00
Maximiliano Sandoval
89df077104 openid: remove unused dependencies
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-14 11:38:48 +02:00
Maximiliano Sandoval
c33cc9e350 product-config: remove unused dependencies
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-14 11:38:48 +02:00
Maximiliano Sandoval
d44ceba86d log: remove unused log dependency
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-14 11:38:48 +02:00
Maximiliano Sandoval
5e2179cf0a client: remove unused dependencies
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-14 11:38:48 +02:00
Maximiliano Sandoval
b01230f70c apt: remove unused dependencies
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-14 11:38:48 +02:00
Maximiliano Sandoval
9031fc88e1 rrd: remove unused libc dependency
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-14 11:38:48 +02:00
Maximiliano Sandoval
b6c6834d1f simple-config: remove unused log dependency
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-14 11:38:48 +02:00
Maximiliano Sandoval
c594d847b5 uuid: remove unused libc dependency
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-14 11:38:48 +02:00
Maximiliano Sandoval
709c237ebc daemon: Remove unused once_cell dependency
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-14 11:38:48 +02:00
Wolfgang Bumiller
f36d0e5137 dns-api: bump to 0.1.4-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-08-14 11:38:45 +02:00
Maximiliano Sandoval
58e2fa5983 dns-api: remove unused dependencies
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-08-14 11:36:49 +02:00