Add -json flag to snapshot show|list

Signed-off-by: Joshua Colson <joshua.colson@gmail.com>
This commit is contained in:
Joshua Colson
2021-09-21 06:11:45 -07:00
committed by Lorenzo Bolla
parent f9c0d99790
commit 0f1575d5af
20 changed files with 583 additions and 15 deletions
+13
View File
@@ -266,6 +266,19 @@ func (l *PackageList) Strings() []string {
return result
}
// FullNames builds a list of package {name}_{version}_{arch}
func (l *PackageList) FullNames() []string {
result := make([]string, l.Len())
i := 0
for _, p := range l.packages {
result[i] = p.GetFullName()
i++
}
return result
}
// depSliceDeduplicate removes dups in slice of Dependencies
func depSliceDeduplicate(s []Dependency) []Dependency {
l := len(s)
+5
View File
@@ -361,6 +361,11 @@ func (p *Package) GetName() string {
return p.Name
}
// GetFullName returns the package full name
func (p *Package) GetFullName() string {
return strings.Join([]string{p.Name, p.Version, p.Architecture}, "_")
}
// GetVersion returns package version
func (p *Package) GetVersion() string {
return p.Version
+1 -1
View File
@@ -33,7 +33,7 @@ const (
// RemoteRepo represents remote (fetchable) Debian repository.
//
// Repostitory could be filtered when fetching by components, architectures
// Repository could be filtered when fetching by components, architectures
type RemoteRepo struct {
// Permanent internal ID
UUID string
+7 -1
View File
@@ -26,8 +26,14 @@ type Snapshot struct {
CreatedAt time.Time
// Source: kind + ID
SourceKind string `codec:"SourceKind" json:"-"`
SourceKind string `codec:"SourceKind"`
SourceIDs []string `codec:"SourceIDs" json:"-"`
// Sources
Snapshots []*Snapshot `codec:"-" json:",omitempty"`
RemoteRepos []*RemoteRepo `codec:"-" json:",omitempty"`
LocalRepos []*LocalRepo `codec:"-" json:",omitempty"`
Packages []string `codec:"-" json:",omitempty"`
// Description of how snapshot was created
Description string