Skip to content

Commit

Permalink
Merge pull request containers#992 from rhatdan/inspect
Browse files Browse the repository at this point in the history
Make InspectOutput an external object
  • Loading branch information
rhatdan authored Aug 3, 2020
2 parents 5e88eb5 + 4fb724f commit c052ed7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
20 changes: 2 additions & 18 deletions cmd/skopeo/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,19 @@ import (
"fmt"
"io"
"strings"
"time"

"github.com/containers/image/v5/docker"
"github.com/containers/image/v5/image"
"github.com/containers/image/v5/manifest"
"github.com/containers/image/v5/transports"
"github.com/containers/image/v5/types"
digest "github.com/opencontainers/go-digest"
"github.com/containers/skopeo/cmd/skopeo/inspect"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

// inspectOutput is the output format of (skopeo inspect), primarily so that we can format it with a simple json.MarshalIndent.
type inspectOutput struct {
Name string `json:",omitempty"`
Tag string `json:",omitempty"`
Digest digest.Digest
RepoTags []string
Created *time.Time
DockerVersion string
Labels map[string]string
Architecture string
Os string
Layers []string
Env []string
}

type inspectOptions struct {
global *globalOptions
image *imageOptions
Expand Down Expand Up @@ -164,7 +148,7 @@ func (opts *inspectOptions) run(args []string, stdout io.Writer) (retErr error)
return err
}

outputData := inspectOutput{
outputData := inspect.Output{
Name: "", // Set below if DockerReference() is known
Tag: imgInspect.Tag,
// Digest is set below.
Expand Down
23 changes: 23 additions & 0 deletions cmd/skopeo/inspect/output.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package inspect

import (
"time"

digest "github.com/opencontainers/go-digest"
)

// Output is the output format of (skopeo inspect),
// primarily so that we can format it with a simple json.MarshalIndent.
type Output struct {
Name string `json:",omitempty"`
Tag string `json:",omitempty"`
Digest digest.Digest
RepoTags []string
Created *time.Time
DockerVersion string
Labels map[string]string
Architecture string
Os string
Layers []string
Env []string
}

0 comments on commit c052ed7

Please sign in to comment.