This repository has been archived by the owner on Aug 20, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49e287a
commit 8f42e2b
Showing
5 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package inspect | ||
|
||
import ( | ||
"github.com/rancher/k3c/pkg/cliclient" | ||
"github.com/rancher/k3c/pkg/tables" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
type Inspect struct { | ||
Format string `usage:"Pretty-print images using a Go template" default:"json"` | ||
} | ||
|
||
func (i *Inspect) Run(ctx *cli.Context) error { | ||
c, err := cliclient.New(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
t := tables.NewInspect(ctx) | ||
|
||
for _, arg := range ctx.Args().Slice() { | ||
container, _, _, err := c.GetContainer(ctx.Context, arg) | ||
if err == nil { | ||
t.Write(container) | ||
continue | ||
} | ||
|
||
image, err := c.GetImage(ctx.Context, arg) | ||
if err == nil { | ||
t.Write(image) | ||
} | ||
} | ||
|
||
return t.Close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package tables | ||
|
||
import ( | ||
"github.com/rancher/k3c/pkg/table" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func NewInspect(cli *cli.Context) table.Writer { | ||
cols := [][]string{ | ||
{"", "{{. | json}}"}, | ||
} | ||
|
||
w := table.NewWriter(cols, config(cli, "")) | ||
return w | ||
} |