Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #690 from rumpl/feat-meta-yaml
Browse files Browse the repository at this point in the history
Inspect prints the metadata in yaml format
  • Loading branch information
glours committed Oct 14, 2019
2 parents fc64d21 + 940a2e4 commit 3e97bfd
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 20 deletions.
13 changes: 5 additions & 8 deletions internal/inspect/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"strings"
"text/tabwriter"

"gopkg.in/yaml.v2"

"github.com/deislabs/cnab-go/bundle"
"github.com/docker/app/internal"
"github.com/docker/app/render"
Expand Down Expand Up @@ -132,14 +134,9 @@ func printTable(out io.Writer, appInfo appInfo) error {

func printMetadata(out io.Writer, app appInfo) {
meta := app.Metadata
fmt.Fprintln(out, meta.Name, meta.Version)
if maintainers := meta.Maintainers.String(); maintainers != "" {
fmt.Fprintln(out)
fmt.Fprintln(out, "Maintained by:", maintainers)
}
if meta.Description != "" {
fmt.Fprintln(out)
fmt.Fprintln(out, meta.Description)

if bytes, err := yaml.Marshal(meta); err == nil {
fmt.Fprintln(out, string(bytes))
}
}

Expand Down
10 changes: 6 additions & 4 deletions internal/inspect/testdata/inspect-full.golden
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
myapp 0.1.0
version: 0.1.0
name: myapp
description: some description
maintainers:
- name: dev
email: dev@example.com

Maintained by: dev <dev@example.com>

some description

Services (2) Replicas Ports Image
------------ -------- ----- -----
Expand Down
8 changes: 6 additions & 2 deletions internal/inspect/testdata/inspect-no-description.golden
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
myapp 0.1.0
version: 0.1.0
name: myapp
description: ""
maintainers:
- name: dev
email: dev@example.com

Maintained by: dev <dev@example.com>
6 changes: 5 additions & 1 deletion internal/inspect/testdata/inspect-no-maintainers.golden
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
myapp 0.1.0
version: 0.1.0
name: myapp
description: ""
maintainers: []

10 changes: 6 additions & 4 deletions internal/inspect/testdata/inspect-no-parameters.golden
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
myapp 0.1.0
version: 0.1.0
name: myapp
description: some description
maintainers:
- name: dev
email: dev@example.com

Maintained by: dev <dev@example.com>

some description
6 changes: 5 additions & 1 deletion internal/inspect/testdata/inspect-overridden.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
myapp 0.1.0
version: 0.1.0
name: myapp
description: ""
maintainers: []


Service (1) Replicas Ports Image
----------- -------- ----- -----
Expand Down

0 comments on commit 3e97bfd

Please sign in to comment.