Add -json flag to publish list|show

Signed-off-by: Joshua Colson <joshua.colson@gmail.com>
This commit is contained in:
Joshua Colson
2021-09-21 18:46:59 -07:00
committed by Lorenzo Bolla
parent 129eb8644d
commit 899ed92ebc
11 changed files with 302 additions and 52 deletions
+13 -1
View File
@@ -282,7 +282,7 @@ func NewPublishedRepo(storage, prefix, distribution string, architectures []stri
return result, nil
}
// MarshalJSON requires object to be "loeaded completely"
// MarshalJSON requires object to be "loaded completely"
func (p *PublishedRepo) MarshalJSON() ([]byte, error) {
type sourceInfo struct {
Component, Name string
@@ -313,6 +313,7 @@ func (p *PublishedRepo) MarshalJSON() ([]byte, error) {
"NotAutomatic": p.NotAutomatic,
"ButAutomaticUpgrades": p.ButAutomaticUpgrades,
"Prefix": p.Prefix,
"Path": p.GetPath(),
"SourceKind": p.SourceKind,
"Sources": sources,
"Storage": p.Storage,
@@ -491,6 +492,17 @@ func (p *PublishedRepo) GetLabel() string {
return p.Label
}
// GetName returns the unique name of the repo
func (p *PublishedRepo) GetPath() string {
prefix := p.StoragePrefix()
if prefix == "" {
return p.Distribution
}
return fmt.Sprintf("%s/%s", prefix, p.Distribution)
}
// GetSuite returns default or manual Suite:
func (p *PublishedRepo) GetSuite() string {
if p.Suite == "" {