Add an API method for querying the tags of a reference from an OCI registry.
Signed-off-by: Filip Schauer <[email protected]> --- Introduced in v5 PVE/API2/Nodes.pm | 47 +++++++++++++++++++++++++++++++++++++++++++++++ debian/control | 1 + 2 files changed, 48 insertions(+) diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm index 4590b618..8f86afd9 100644 --- a/PVE/API2/Nodes.pm +++ b/PVE/API2/Nodes.pm @@ -279,6 +279,7 @@ __PACKAGE__->register_method({ { name => 'netstat' }, { name => 'network' }, { name => 'qemu' }, + { name => 'query-oci-repo-tags' }, { name => 'query-url-metadata' }, { name => 'replication' }, { name => 'report' }, @@ -1761,6 +1762,52 @@ __PACKAGE__->register_method({ }, }); +__PACKAGE__->register_method({ + name => 'query_oci_repo_tags', + path => 'query-oci-repo-tags', + method => 'GET', + description => "List all tags for an OCI repository reference.", + proxyto => 'node', + permissions => { + check => ['perm', '/nodes/{node}', ['Sys.AccessNetwork']], + }, + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + reference => { + description => "The reference to the repository to query tags from.", + type => 'string', + pattern => '^(?:(?:[a-zA-Z\d]|[a-zA-Z\d][a-zA-Z\d-]*[a-zA-Z\d])' + . '(?:\.(?:[a-zA-Z\d]|[a-zA-Z\d][a-zA-Z\d-]*[a-zA-Z\d]))*(?::\d+)?/)?[a-z\d]+' + . '(?:(?:[._]|__|[-]*)[a-z\d]+)*(?:/[a-z\d]+(?:(?:[._]|__|[-]*)[a-z\d]+)*)*$', + }, + }, + }, + returns => { + type => 'array', + items => { + type => 'string', + }, + }, + code => sub { + my ($param) = @_; + + die "Install 'skopeo' to list tags from OCI registries.\n" if (!-f '/usr/bin/skopeo'); + + my $reference = $param->{reference}; + my $tags_json = ""; + PVE::Tools::run_command( + ["skopeo", "list-tags", "docker://$reference"], + outfunc => sub { + $tags_json = $tags_json . shift; + }, + ); + my $tags = decode_json($tags_json); + return $tags->{Tags}; + }, +}); + __PACKAGE__->register_method({ name => 'query_url_metadata', path => 'query-url-metadata', diff --git a/debian/control b/debian/control index 64b942ce..afd0386a 100644 --- a/debian/control +++ b/debian/control @@ -105,6 +105,7 @@ Depends: apt (>= 1.5~), Recommends: proxmox-firewall, proxmox-offline-mirror-helper, pve-nvidia-vgpu-helper, + skopeo, Conflicts: vlan, vzdump, Replaces: vlan, vzdump, Provides: vlan, vzdump, -- 2.47.3 _______________________________________________ pve-devel mailing list [email protected] https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
