906 Commits

Author SHA1 Message Date
Wolfgang Bumiller
f35dbbd651 add proxmox-section-config crate
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-11 11:39:59 +02:00
Wolfgang Bumiller
41f3fdfeb9 add proxmox-schema and proxmox-router crates
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-11 11:39:59 +02:00
Wolfgang Bumiller
01a8b6f1bf add proxmox-io crate
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-11 10:07:53 +02:00
Wolfgang Bumiller
91f59f9f59 add proxmox-lang crate
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-08 15:22:17 +02:00
Wolfgang Bumiller
9b6fe4aceb add proxmox-time crate
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-08 15:22:17 +02:00
Wolfgang Bumiller
7db0a3c6df add proxmox-borrow crate
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-08 15:22:17 +02:00
Wolfgang Bumiller
bd67ccc1b3 add proxmox-uuid crate
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-08 15:22:17 +02:00
Wolfgang Bumiller
77dc52c047 add proxmox-tfa crate
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-08 15:22:17 +02:00
Wolfgang Bumiller
2859858f59 fix systemd::escape_unit's hex encoding
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-08 15:22:17 +02:00
Wolfgang Bumiller
b89c56b96e start checklist for adding crates in README.rst
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-06 10:37:17 +02:00
Wolfgang Bumiller
f189895cef fix deprecated use of std::u16 module
integer primitive type modules are deprecated, use
associated constants instead

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-04 15:03:50 +02:00
Dietmar Maurer
5bff2a1d4b add test for property string verification errors 2021-09-29 08:59:28 +02:00
Dietmar Maurer
d62d1e5707 move api schema tests into separate file 2021-09-29 08:25:23 +02:00
Dietmar Maurer
8e1d573844 add tests for schema verification errors 2021-09-29 08:17:53 +02:00
Dietmar Maurer
9ec9d1f9e6 ParameterError: construct XPath like string to identify nested properties 2021-09-28 12:34:08 +02:00
Dietmar Maurer
b5ea4f9bb2 bump proxmox version to 0.13.5-1 2021-09-28 09:52:27 +02:00
Dietmar Maurer
51db0d0f12 ParameterError: record parameter names 2021-09-28 09:52:27 +02:00
Dominik Csapak
5a88aaf074 cli/text_table: calculate correct column width for unicode characters
When printing unicode text, a glyph can take up more (or less) space than
a single column. To handle that, use the 'unicode-width' crate which
calculates the width by the unicode standard.

This makes the text tables correctly aligned when printing unicode
characters (e.g. in a datastore/user/syncjob comment).

'unicode-width' is used itself in the rust compiler to format errors
(see e.g. the Cargo.toml in /compiler/rustc_errors of the rust git)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-09-28 08:05:28 +02:00
Dominik Csapak
5a37cfd4c0 upid: remove arbitrary 128 max length for UPID
we can easily go beyond that when having long datastore/remote names
also because we do 'systemd-encode' them, which means that every special
char takes up 4 bytes (e.g. '-' => '\x2d')

while we could just increase the lenght to say 256 or 512, i do not
really see the benefit to limit this at all, since users cannot create
tasks with arbitrary names, and all other fields are generated from
other valid types (username, datastore, remote, etc.)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-09-24 11:08:59 +02:00
Dietmar Maurer
3cec879463 bump proxmox version to 0.13.4-1 2021-09-23 12:06:48 +02:00
Dietmar Maurer
ed9bdab576 add UPID api type 2021-09-23 12:04:15 +02:00
Dietmar Maurer
fc2253b3e8 add systemd escape_unit and unescape_unit 2021-09-23 12:04:15 +02:00
Fabian Grünbichler
0999494564 schema: add extra info to array parameters
it's not immediately obvious that they can be specified more than once
otherwise.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-22 07:58:52 +02:00
Fabian Grünbichler
5f5a5194de schema: print item type-text instead of <array>
this is only used for CLI synopsis/usage strings, the API viewer already
prints the full type text in a correct format. the old variant was also
rather misleading, since on the CLI we don't pass in an array, but each
item as its own parameter.

noticed this while working on the pull/sync filtering series, but it
affects quite a lot of stuff, among other things the Updater and
Deleteable CLI, e.g. from `man proxmox-backup-manager`:

>       --delete <array>
>                     List of properties to delete.

vs.

>       --delete disable|validation-delay
>                     List of properties to delete.

But some of them might only have <string> as the item type text,
which is not much nicer but also not really worse.

The whole "List of .." is confusing anyway, but not easily solvable,
since the description is used for
- API dump/viewer (where it is a list/array of ..)
- usage message/man pages (where it's a parameter that gives a single
  element, but it might be passed in multiple times to construct an
  array)

Also, for some common occurrences, the item description is too
generic, and it's not possible to override the description for
external types with the current api macro.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
 [ Thomas: Added more context that was in the diffstat of the path ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-22 07:56:09 +02:00
Dietmar Maurer
3cd221c163 bump proxmox version to 0.13.3-1 2021-09-21 06:45:28 +02:00
Dietmar Maurer
b6b9118ce3 atomic_open_or_create_file: add support for OFlag::O_EXCL 2021-09-20 08:24:44 +02:00
Dietmar Maurer
b46a0720ae atomic_open_or_create_file: catch unsupported flag OFlag::O_DIRECTORY 2021-09-20 08:13:28 +02:00
Dietmar Maurer
c7e1a1f3c8 update proxmox/debian/control 2021-09-20 08:12:18 +02:00
Dietmar Maurer
297a076478 bump proxmox version to 0.13.2-1 2021-09-16 11:03:27 +02:00
Dietmar Maurer
fb2b7a4e93 impl <T: UserInformation> UserInformation for std::sync::Arc<T> 2021-09-16 10:21:50 +02:00
Dominik Csapak
254ef7ff82 proxmox: generate_usage_str: don't require static lifetimes
this prevents us from using it under certain conditions and it's
actually not necessary, so drop them

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-09-15 08:09:24 +02:00
Wolfgang Bumiller
6a52b3b8e7 proxmox: bump d/control for api-macro 0.5.1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-30 10:49:27 +02:00
Wolfgang Bumiller
36ed21c548 bump proxmox to 0.13.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-30 10:47:28 +02:00
Wolfgang Bumiller
cb96de1c4d bump proxmox-api-macro to 0.5.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-30 10:46:05 +02:00
Wolfgang Bumiller
14bd81fbc4 doc: update UpdaterType documentation
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-30 08:21:08 +02:00
Wolfgang Bumiller
76641b0a72 api-macro: allow external schemas in 'returns' specification
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-26 13:34:23 +02:00
Wolfgang Bumiller
bf84e75603 api: move ReturnType from router to schema
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-26 11:39:55 +02:00
Wolfgang Bumiller
0f2caafc4e bump proxmox to 0.13.0-1 and proxmox-api-macro to 0.5.0
and proxmox-http to 0.4.0... urgh

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-25 09:41:17 +02:00
Wolfgang Bumiller
2df0b8efb3 tools::serde: support Option<String> in string_as_base64
This will make Updater derivations go more smoothly.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-25 09:41:17 +02:00
Wolfgang Bumiller
8c125364e4 websocket: fix doc test
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-24 15:19:47 +02:00
Wolfgang Bumiller
917ce00dd6 rustfmt
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-13 13:31:57 +02:00
Wolfgang Bumiller
744d69c2ab more updater cleanups
* Updatable is now named UpdaterType
* UPDATER_IS_OPTION is now assumed to always be true
    While an updater can be a non-optional struct, being an
    updater, all its fields are also Updaters, so after
    expanding all levels of nesting, the resulting list of
    fields can only contain optional values.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-13 11:11:27 +02:00
Wolfgang Bumiller
cb9d57b453 put API_SCHEMA variable into ApiType trait
This way we can assign `API_SCHEMA` constants to `Option`
types.

Here's why:

The api-macro generated code usese `T::API_SCHEMA` when
building ObjectSchemas.

For Updaters we replace `T` with
  `<T as Updatable>::Updater`

This means for "simple" wrappers like our `Authid` or
`Userid`, the ObjectSchema will try to refer to
  `<Authid as Updatable>::Updater::API_SCHEMA`
which resolves to:
  `Option<Authid>::API_SCHEMA`
which does not exist, for which we cannot add a normal
`impl` block to add the schema variable, since `Option` is
not "ours".

But we now have a blanket implementation of `ApiType` for
`Option<T> where T: ApiType` which just points to the
original `T::API_SCHEMA`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-12 10:15:13 +02:00
Wolfgang Bumiller
783cbcb499 fixup schema entry for updaters with explicit types
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-10 14:17:20 +02:00
Wolfgang Bumiller
34020ea3d6 change updater derivation
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-10 12:03:29 +02:00
Wolfgang Bumiller
017b81712e api macro: assume that field types are api types by default
#[api]
    struct Foo {
        field: Bar,
    }

does not require the use of
    #[api(
        properties: {
            field: {
                type: Bar,
            },
        },
    )]

anymore

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-10 11:42:24 +02:00
Wolfgang Bumiller
8ebcd68a2c refactor serde parsing for later reuse
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-08-10 11:42:24 +02:00
Thomas Lamprecht
cb04553d47 proxmox: d/control: commit version update changes
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-22 09:53:38 +02:00
Thomas Lamprecht
907a9f344d proxmox: bump version to 0.12.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-22 09:48:04 +02:00
Thomas Lamprecht
3fd900d2b2 tools fs: rust fmt
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-22 09:44:17 +02:00