Skip to content

Commit

Permalink
Merge pull request #16809 from mlschroe/master
Browse files Browse the repository at this point in the history
[backend] Put registry information in the DoD containers
  • Loading branch information
mlschroe authored Sep 5, 2024
2 parents 49f9d12 + bee9ab4 commit 7ddd062
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/backend/BSRepServer/Containerinfo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ BSRepServer::Containerinfo
=cut

=head2 containerinfo2nevra - convert a containerinfo file to name/epoch/version/release/arch
=head2 containerinfo2nevra - convert containerinfo data to name/epoch/version/release/arch
input: $containerinfo - containerinfo filename in $dir
input: $containerinfo - containerinfo data
output: hash containting name/epoch/...
Expand Down
1 change: 1 addition & 0 deletions src/backend/BSRepServer/Registry.pm
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ sub construct_containerinfo {
BSVerify::verify_nevraquery($lnk);
$lnk->{'hdrmd5'} = $containerinfo->{'tar_md5sum'};
$lnk->{'path'} = "$pkgname.tar";
$lnk->{'annotation'} = $data->{'annotation'} if $data->{'annotation'};
BSUtil::store("$dir/.$pkgname.obsbinlnk", "$dir/$pkgname.obsbinlnk", $lnk);
}

Expand Down
2 changes: 1 addition & 1 deletion src/backend/BSRepServer/Remote.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sub import_annotation {
my ($annotation) = @_;
return $annotation unless ref($annotation);
my %a;
for (qw{repo disturl buildtime}) {
for (qw{repo disturl buildtime registry_refname registry_digest registry_fatdigest}) {
$a{$_} = $annotation->{$_} if exists $annotation->{$_};
}
return BSUtil::toxml(\%a, $BSXML::binannotation);
Expand Down
3 changes: 3 additions & 0 deletions src/backend/BSXML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,9 @@ our $binannotation = [
'buildhost',
'disturl',
'binaryid',
'registry_refname', # in DoD containers
'registry_digest', # in DoD containers
'registry_fatdigest', # in DoD containers
'package', # only in build job annotation
'epoch', # only in build job annotation
'version', # only in build job annotation
Expand Down
15 changes: 13 additions & 2 deletions src/backend/bs_dodup
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,13 @@ sub dod_registry {
for my $resource (@dodresources) {
next unless $resource =~ /^container:(.*):([^\/:]+)$/s;
my ($repo, $tag) = ($1, $2);
$repo = "library/$repo" if $url =~ /docker\.io$/ && $repo !~ /\//;
$repo = $2 if $repo =~ /^([^\/]+)\/(.+)$/s && $1 eq $urldomain;
my $refname = "$repo:$tag";
if ($repo !~ /\//) {
$repo = "library/$repo" if $url =~ /docker\.io$/;
} else {
$repo = $2 if $repo =~ /^([^\/]+)\/(.+)$/s && $1 eq $urldomain;
$refname = "$repo:$tag";
}
my $oldentry;
$oldentry = $oldcache->{$resource} if $olddodresources{$resource};
my ($olddigest, $oldfatdigest);
Expand Down Expand Up @@ -605,6 +610,12 @@ sub dod_registry {
'digest' => $digest,
};
$pkg->{'fatdigest'} = $fatdigest if $fatdigest;
my $annotation = {
'registry_refname' => ($urldomain =~ /docker\.io/ ? '' : "$urldomain/") . $refname,
'registry_digest' => $digest,
};
$annotation->{'registry_fatdigest'} = $fatdigest if $fatdigest;
$pkg->{'annotation'} = BSUtil::toxml($annotation, $BSXML::binannotation);
$cache->{$resource} = $pkg;
}
$cache->{'/dodresources'} = \@newdodresources;
Expand Down

0 comments on commit 7ddd062

Please sign in to comment.