mirror of
https://github.com/containers/skopeo.git
synced 2025-07-19 09:07:13 +00:00
Remove temporary variables in (skopeo inspect)
We abort on failure to get the data anyway, so there is no need to use temporaries to avoid modifying outputData on failure. This is not a simplification yet, but handling optional (e.g. Docker-specific) data this way will be simpler, and handling non-optional data the same way will be more consistent.
This commit is contained in:
parent
847b5bff85
commit
0314fdb49e
@ -50,19 +50,11 @@ var inspectCmd = cli.Command{
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
manifestDigest, err := utils.ManifestDigest(rawManifest)
|
||||
if err != nil {
|
||||
logrus.Fatalf("Error computing manifest digest: %s", err.Error())
|
||||
}
|
||||
repoTags, err := img.GetRepositoryTags()
|
||||
if err != nil {
|
||||
logrus.Fatalf("Error determining repository tags: %s", err.Error())
|
||||
}
|
||||
outputData := inspectOutput{
|
||||
Name: imgInspect.Name,
|
||||
Tag: imgInspect.Tag,
|
||||
Digest: manifestDigest,
|
||||
RepoTags: repoTags,
|
||||
Name: imgInspect.Name,
|
||||
Tag: imgInspect.Tag,
|
||||
// Digest is set below.
|
||||
// RepoTags are set below.
|
||||
Created: imgInspect.Created,
|
||||
DockerVersion: imgInspect.DockerVersion,
|
||||
Labels: imgInspect.Labels,
|
||||
@ -70,6 +62,14 @@ var inspectCmd = cli.Command{
|
||||
Os: imgInspect.Os,
|
||||
Layers: imgInspect.Layers,
|
||||
}
|
||||
outputData.Digest, err = utils.ManifestDigest(rawManifest)
|
||||
if err != nil {
|
||||
logrus.Fatalf("Error computing manifest digest: %s", err.Error())
|
||||
}
|
||||
outputData.RepoTags, err = img.GetRepositoryTags()
|
||||
if err != nil {
|
||||
logrus.Fatalf("Error determining repository tags: %s", err.Error())
|
||||
}
|
||||
out, err := json.MarshalIndent(outputData, "", " ")
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
|
Loading…
Reference in New Issue
Block a user