58 lines
No EOL
1.5 KiB
Go
58 lines
No EOL
1.5 KiB
Go
package ProtoHandler
|
|
|
|
import proto "lpm-cli/Proto/lpm/go"
|
|
|
|
type PackageMetadata struct {
|
|
Publisher string
|
|
Name string
|
|
Version string
|
|
Description string
|
|
Tags []string
|
|
Labels map[string]string
|
|
PackageSize uint64
|
|
Checksums Checksums
|
|
Platform string
|
|
Architecture string
|
|
Dependencies []Dependency
|
|
}
|
|
|
|
|
|
func fillDependencies(protoDependency []*proto.Dependency) []Dependency {
|
|
dependencies := make([]Dependency, len(protoDependency))
|
|
|
|
for i, dep := range protoDependency{
|
|
dependencies[i].ID = dep.GetId()
|
|
dependencies[i].VersionFilter = dep.GetVersionFilter()
|
|
}
|
|
|
|
return dependencies
|
|
}
|
|
|
|
func fillChecksums(checksum []*proto.Checksum) Checksums {
|
|
checksums := Checksums{}
|
|
|
|
for i, chk := range checksum{
|
|
switch checksum[i].Algorithm{
|
|
case 0: checksums.MD5 = chk.Checksum
|
|
case 1: checksums.SHA1 = chk.Checksum
|
|
case 2: checksums.SHA256 = chk.Checksum
|
|
case 3: checksums.SHA512 = chk.Checksum
|
|
}
|
|
}
|
|
|
|
return checksums
|
|
}
|
|
|
|
func (metadata* PackageMetadata) FillMetadata(protoData *proto.PackageMetadata) {
|
|
metadata.Publisher = protoData.GetPublisher()
|
|
metadata.Name = protoData.GetName()
|
|
metadata.Version = protoData.GetVersion()
|
|
metadata.Description = protoData.GetDescription()
|
|
metadata.Tags = protoData.GetTags()
|
|
metadata.Labels = protoData.GetLabels()
|
|
metadata.PackageSize = protoData.GetPackageSize()
|
|
metadata.Checksums = fillChecksums(protoData.GetChecksums())
|
|
metadata.Platform = protoData.Platform
|
|
metadata.Architecture = protoData.Architecture
|
|
metadata.Dependencies = fillDependencies(protoData.GetDependencies())
|
|
} |