Platforms: Add From/ToProto helpers for types

Helpers to convert from a slice of platforms to our protobuf representation
and vice-versa appear a couple times. It seems sane to just expose this facility
in the platforms pkg.

Signed-off-by: Danny Canter <danny@dcantah.dev>
This commit is contained in:
Danny Canter
2023-06-28 15:12:30 -07:00
parent b3ab1f26c4
commit f3b7436b61
4 changed files with 33 additions and 46 deletions

View File

@@ -156,15 +156,7 @@ func (iis *ImageExportStream) UnmarshalAny(ctx context.Context, sm streaming.Str
return err
}
var specified []v1.Platform
for _, p := range s.Platforms {
specified = append(specified, v1.Platform{
OS: p.OS,
Architecture: p.Architecture,
Variant: p.Variant,
})
}
specified := platforms.FromProto(s.Platforms)
iis.stream = tstreaming.WriteByteStream(ctx, stream)
iis.mediaType = s.MediaType
iis.platforms = specified