[pbs-devel] [PATCH v6 pve-manager 3/5] api: apt: add call for repository check
Fabian Ebner
f.ebner at proxmox.com
Fri Jun 11 13:44:16 CEST 2021
Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
Changes from v5:
* The check_repositories function in Rust takes an Option<&str> now. Adapt
to that and work around edge case in perlmod (already fixed in
current master)
PVE/API2/APT.pm | 78 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
diff --git a/PVE/API2/APT.pm b/PVE/API2/APT.pm
index 0e1cc260..2815785e 100644
--- a/PVE/API2/APT.pm
+++ b/PVE/API2/APT.pm
@@ -68,6 +68,7 @@ __PACKAGE__->register_method({
my $res = [
{ id => 'changelog' },
{ id => 'repositories' },
+ { id => 'checkrepositories' },
{ id => 'update' },
{ id => 'versions' },
];
@@ -631,6 +632,83 @@ __PACKAGE__->register_method({
};
}});
+__PACKAGE__->register_method({
+ name => 'checkrepositories',
+ path => 'checkrepositories',
+ method => 'GET',
+ proxyto => 'node',
+ description => "Additional sanity checks for the configured APT repositories.",
+ permissions => {
+ check => ['perm', '/nodes/{node}', [ 'Sys.Audit' ]],
+ },
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ digest => {
+ type => "string",
+ description => "Digest to detect modifications.",
+ maxLength => 80,
+ optional => 1,
+ },
+ },
+ },
+ returns => {
+ type => "object",
+ description => "Additional sanity checks for the configured APT repositories.",
+ properties => {
+ infos => {
+ type => "array",
+ description => "Additional information/warnings for APT repositories.",
+ items => {
+ type => "object",
+ properties => {
+ path => {
+ type => "string",
+ description => "Path to the associated file.",
+ },
+ number => {
+ type => "string",
+ description => "Number of the associated repository within the file.",
+ },
+ kind => {
+ type => "string",
+ description => "Kind of the information (e.g. warning).",
+ },
+ message => {
+ type => "string",
+ description => "Information message.",
+ }
+ },
+ },
+ },
+ enterprise => {
+ type => "boolean",
+ description => "Whether the enterprise repository is enabled or not.",
+ },
+ nosubscription => {
+ type => "boolean",
+ description => "Whether the no-subscription repository is enabled or not.",
+ }
+ },
+ },
+ code => sub {
+ my ($param) = @_;
+
+ # NOTE As of perlmod 0.4.3, passing $param->{digest} directly will fail if the value is
+ # undef. Assign it to a variable first to work around the issue.
+ my $digest = $param->{digest};
+
+ my ($infos, $enterprise, $nosubscription) =
+ PVE::RS::APT::Repositories::check_repositories($digest);
+
+ return {
+ infos => $infos,
+ enterprise => $enterprise,
+ nosubscription => $nosubscription,
+ };
+ }});
+
__PACKAGE__->register_method({
name => 'versions',
path => 'versions',
--
2.20.1
More information about the pbs-devel
mailing list