Added structs for PackageMetadata and childs
This commit is contained in:
parent
ff755e8e05
commit
b99e508a9b
3 changed files with 72 additions and 0 deletions
8
ProtoHandler/Checksums.go
Normal file
8
ProtoHandler/Checksums.go
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
package ProtoHandler
|
||||||
|
|
||||||
|
type Checksums struct {
|
||||||
|
MD5 string
|
||||||
|
SHA1 string
|
||||||
|
SHA256 string
|
||||||
|
SHA512 string
|
||||||
|
}
|
||||||
6
ProtoHandler/Dependency.go
Normal file
6
ProtoHandler/Dependency.go
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
package ProtoHandler
|
||||||
|
|
||||||
|
type Dependency struct {
|
||||||
|
ID string
|
||||||
|
VersionFilter string
|
||||||
|
}
|
||||||
58
ProtoHandler/PackageMetadata.go
Normal file
58
ProtoHandler/PackageMetadata.go
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
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())
|
||||||
|
}
|
||||||
Reference in a new issue