platforms: move ToProto, FromProto to api/types
These utilities resulted in the platforms package to have the containerd
API as dependency. As this package is used in many parts of the code, as
well as external consumers, we should try to keep it light on dependencies,
with the potential to make it a standalone module.
These utilities were added in f3b7436b61,
which has not yet been included in a release, so skipping deprecation
and aliases for these.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -118,8 +118,6 @@ import (
|
||||
"strings"
|
||||
|
||||
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
|
||||
"github.com/containerd/containerd/api/types"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -290,31 +288,3 @@ func Normalize(platform specs.Platform) specs.Platform {
|
||||
|
||||
return platform
|
||||
}
|
||||
|
||||
// ToProto converts from a slice of [Platform] to a slice of
|
||||
// the protobuf definition [types.Platform].
|
||||
func ToProto(platforms []Platform) []*types.Platform {
|
||||
ap := make([]*types.Platform, len(platforms))
|
||||
for i := range platforms {
|
||||
ap[i] = &types.Platform{
|
||||
OS: platforms[i].OS,
|
||||
Architecture: platforms[i].Architecture,
|
||||
Variant: platforms[i].Variant,
|
||||
}
|
||||
}
|
||||
return ap
|
||||
}
|
||||
|
||||
// FromProto converts a slice of the protobuf definition [types.Platform]
|
||||
// to a slice of [Platform].
|
||||
func FromProto(platforms []*types.Platform) []specs.Platform {
|
||||
op := make([]specs.Platform, len(platforms))
|
||||
for i := range platforms {
|
||||
op[i] = specs.Platform{
|
||||
OS: platforms[i].OS,
|
||||
Architecture: platforms[i].Architecture,
|
||||
Variant: platforms[i].Variant,
|
||||
}
|
||||
}
|
||||
return op
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user