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

Inspect prints the metadata in yaml format #690

Merged
merged 1 commit into from
Oct 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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