58 lines
No EOL
1.6 KiB
Go
58 lines
No EOL
1.6 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, _ := range protoDependency{
|
|
dependencies[i].ID = protoDependency[i].GetId()
|
|
dependencies[i].VersionFilter = protoDependency[i].GetVersionFilter()
|
|
}
|
|
|
|
return dependencies
|
|
}
|
|
|
|
func fillChecksums(checksum []*proto.Checksum) Checksums {
|
|
checksums := Checksums{}
|
|
|
|
for i, _ := range checksum{
|
|
switch checksum[i].Algorithm{
|
|
case 0: checksums.MD5 = checksum[i].Checksum
|
|
case 1: checksums.SHA1 = checksum[i].Checksum
|
|
case 2: checksums.SHA256 = checksum[i].Checksum
|
|
case 3: checksums.SHA512 = checksum[i].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())
|
|
} |