Commit Graph

3389 Commits

Author SHA1 Message Date
Lukas Wagner
0f1b84e93c sys: fs: derive Copy for CreateOptions
Pretty much all functions accepting `CreateOptions` take a value and not
a reference, so I've found myself using `.clone()` quite often in code
I've written recently.
The struct is only 24 bytes large (verified by a
`std::mem::size_of::<CreateOptions>()`), so it should be absolutely fine
to just derive Copy for it.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2025-01-29 18:09:24 +01:00
Thomas Lamprecht
31ae72ba6a schema: property ReST docs: correctly separate nested list from parent
This fixes the reStructuredText (ReST) output for more complex formats
where we got, for example, a definition list of all properties of a
(section) configuration with one or more properties then having a
sub-format that is also rendered as a list.

Such nested lists are possible in ReST but need to be separated by a
blank line [0].

Without this we got quite a few warnings/errors from the Sphinx/ReST
buildsystem looking like:

> config/datastore/config.rst:19: ERROR: Unexpected indentation.
> config/datastore/config.rst:20: WARNING: Block quote ends without a blank line; unexpected unindent.

[0]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#lists-and-quote-like-blocks

Reported-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-01-28 14:25:21 +01:00
Thomas Lamprecht
c0641c6e13 schema: use inline named params in format macro calls
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-01-28 14:25:21 +01:00
Wolfgang Bumiller
703c2dee04 api-macro: mark parameter defaults as #[allow(dead_code)]
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-28 10:56:28 +01:00
Laurențiu Leahu-Vlăducu
922c605d69 rest-server: Improved panic errors with formatted strings
Improved errors when panics occur and the panic message is a
formatted (not static) string. This worked already for &str literals,
but not for Strings.

Downcasting to both &str and String is also done by the Rust Standard
Library in the default panic handler. See:
b605c65b6e/library/std/src/panicking.rs (L777)

Signed-off-by: Laurențiu Leahu-Vlăducu <l.leahu-vladucu@proxmox.com>
2025-01-27 15:12:59 +01:00
Dietmar Maurer
f639695c87 pbs-api-types: add debian/control to git repository
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2025-01-22 12:33:33 +01:00
Dietmar Maurer
57b0477657 pbs-api-type: add as workspace member with correct debian files
Also changed the version to 0.2.0

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2025-01-22 11:57:00 +01:00
Thomas Lamprecht
b7b00b5205 Merge remote-tracking branch 'prepare-pbs-api-types-for-move/prepare-pbs-api-types-for-move'
Move over the whole history of pbs-api-types from the proxmox-backup
git repo to the common workspace as we want to re-use that in PDM and
the yew UI components, and thus require a real source-code package for
this crate.

Choose this repo over proxmox-api-types to avoid the need to copy this
build-system over there, rather we want to also merge pve-api-types
from that repo into ours here in the future.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-01-22 11:55:09 +01:00
Thomas Lamprecht
0477adaf88 client: fix code-style issue when formatting error
Fixes a style issue introduced by b31ab119 ("client: improve api error
message (avoid duplicate status code)"), as one always should use
inline variables for format template strings even if there are some
that cannot be used, e.g. as some method needs to be called on them
like here. The reason for this is to reduce the amount of
free-standing "{}" and parameters as that reduces the need to manually
match what "{}" resolves to which expression. While it is not that bad
for only two format variables it's still not winning us anything if we
don't do it and breaks consistency with newer code style.

Noticed as that commit made the line overly long, causing rustfmt
changing the line.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-01-21 09:22:08 +01:00
Thomas Lamprecht
daff73bdd6 sys: use correct pointer type for mkdtemp return value
The libc function mkdtemp takes a C char pointer while we previously
cast our OSString buffer as i8 pointer, but that's not valid on
platforms like AArch64 (ARM), where char is equivalent with a u8.

Fix that by using the c_char type that was explicitly made to always
get the correct, platform-independent type for C chars when doing FFI.

This was reported by OJaksch on our Arch Linux User Repo (AUR) package
[0].

https://aur.archlinux.org/packages/proxmox-backup-client#comment-1006851

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-01-21 09:14:43 +01:00
Wolfgang Bumiller
5a7993beb0 update to proxmox-schema 4
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 13:03:42 +01:00
Wolfgang Bumiller
4be2392d59 time-api: bump to 0.1.4-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:54:28 +01:00
Wolfgang Bumiller
e0bdcda6e6 syslog-api: bump to 0.1.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:53:28 +01:00
Wolfgang Bumiller
27c50bd037 rrd-api-types: bump to 1.0.3-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:52:15 +01:00
Wolfgang Bumiller
975f29bd7f network-api: bump to 0.1.4-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:51:19 +01:00
Wolfgang Bumiller
ce206f0a96 dns-api: bump to 0.1.5-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:50:26 +01:00
Wolfgang Bumiller
891413ffb7 access-control: bump to 0.2.4-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:49:23 +01:00
Wolfgang Bumiller
f01f934963 auth-api: bump to 0.4.7-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:47:08 +01:00
Wolfgang Bumiller
0807248c15 acme-api: bump to 0.1.7-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:46:13 +01:00
Wolfgang Bumiller
7e25958623 tfa: bump to 5.0.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:43:41 +01:00
Wolfgang Bumiller
40f0a0bdd3 subscription: bump to 0.5.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:42:10 +01:00
Wolfgang Bumiller
c84376e2c8 apt: bump to 0.11.7-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:40:14 +01:00
Wolfgang Bumiller
5382b8ce13 apt-api-types: bump to 1.0.3-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:38:33 +01:00
Wolfgang Bumiller
ca92328569 api-macro: bump to 1.3.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:36:57 +01:00
Wolfgang Bumiller
59d1ca87e5 rrd: bump to 0.4.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:36:56 +01:00
Wolfgang Bumiller
106aa95ced rest-server: bump to 0.8.6-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:35:43 +01:00
Wolfgang Bumiller
698b6782cd router: bump to 3.0.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:35:43 +01:00
Wolfgang Bumiller
69298c8d20 acme: bump to 0.5.4-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:28:06 +01:00
Wolfgang Bumiller
ed74a6a8a2 simple-config: bump to 0.1.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:26:42 +01:00
Wolfgang Bumiller
2782c72747 config-digest: bump to 0.1.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:25:33 +01:00
Wolfgang Bumiller
94b9f8db60 notify: bump to 0.5.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:25:31 +01:00
Wolfgang Bumiller
f2fefb7ffd section-config: bump to 2.1.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:20:00 +01:00
Wolfgang Bumiller
c7f4afb3fc human-byte: bump to 0.1.4-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:20:00 +01:00
Wolfgang Bumiller
e4f5179ae6 schema: bump to 4.0.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:07:49 +01:00
Wolfgang Bumiller
2e2edcf833 schema: add Schema::unwrap_*_schema_cloned
This way we can copy and modify a schema.

Eg. via the following ways:

    const FOO_SCHEMA: Schema = SOME_SCHEMA
        .unwrap_integer_schema_cloned()
        .description("Foo")
        .schema();

Note that for example there is currently no builder to set a
`default_key` for an `ObjectSchema` back to None, so one could do:

    const FOO_SCHEMA: Schema = const {
        let mut schema = SOME_SCHEMA.unwrap_object_schema_cloned();
        schema.default_key = None;
        schema.schema()
    };

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 11:56:57 +01:00
Wolfgang Bumiller
c040054827 schema: add 'description' builder methods to schema types
To cover the use case where we want to change only the description of
an existing type.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 11:07:08 +01:00
Wolfgang Bumiller
72c95c35bb schema: make schema types #[non_exhaustive]
This way extending them is not a breaking change anymore.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 10:56:58 +01:00
Wolfgang Bumiller
c794c42919 schema: drop deprecated code
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 10:56:58 +01:00
Wolfgang Bumiller
8d9cf97611 schema: doc: replace use of deprecated methods
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 10:56:58 +01:00
Wolfgang Bumiller
dc232f8bd4 schema: support PVE's "keyAlias" legacy property strings
Because the UI kept producing them...
And still does...

This is NOT meant to be used by anything other than generated legacy
code for PDM (pve-api-types) and only affects the serde based
deserializer. The "old" `schema.parse_property_string() -> Value`
method does not utilize this for now.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 10:56:58 +01:00
Wolfgang Bumiller
4378d44bcb notify: use builder for ObjectSchema
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 10:56:58 +01:00
Wolfgang Bumiller
3c34ef5573 section-config: use builder pattern for ObjectSchema
To prepare for a breaking change in proxmox-schema.
Since new fields in the schema constitute a breaking change, using the
builder methods will let this compile later as well.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-14 11:48:52 +01:00
Wolfgang Bumiller
c99a31c66f router: test: sort object schema properties
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-14 10:34:29 +01:00
Dominik Csapak
be57fb0122 schema: updater: add blanked implementation for PropertyString
so that we can have a property:

```
foo: Option<PropertyString<Bar>>,
```

within a struct that derives `Updater`

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2025-01-14 10:19:54 +01:00
Wolfgang Bumiller
8c5fa1c562 schema: fix pointer/length confusion in str_slice_to_range
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-13 15:22:40 +01:00
Wolfgang Bumiller
62e105a34e api-macro: bump to 1.3.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-09 14:21:53 +01:00
Wolfgang Bumiller
dce9102163 api-macro: add json_schema!() macro
This allows using the json schema notation to generate `Schema`
expressions.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-09 14:19:42 +01:00
Wolfgang Bumiller
619c290cf8 client: bump to 0.5.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-09 14:16:03 +01:00
Dietmar Maurer
b31ab119bb client: improve api error message (avoid duplicate status code)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2025-01-09 12:02:28 +01:00
Wolfgang Bumiller
ddc154e5cd notify: add missing tracing::error macro import
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-07 10:20:37 +01:00