summaryrefslogtreecommitdiff
path: root/cmd/podman/inspect
diff options
context:
space:
mode:
authorAditya R <arajan@redhat.com>2022-08-23 13:12:46 +0530
committerAditya R <arajan@redhat.com>2022-08-23 13:39:01 +0530
commit70e103c04cdb5dd098b77a46f8030c7b0fad11b4 (patch)
treed0bc0e4b122ab95951b671f2449c0818c75b9929 /cmd/podman/inspect
parentd97f4dfbcc5af69c01afa2a76194486d178f63a6 (diff)
downloadpodman-70e103c04cdb5dd098b77a46f8030c7b0fad11b4.tar.gz
podman-70e103c04cdb5dd098b77a46f8030c7b0fad11b4.tar.bz2
podman-70e103c04cdb5dd098b77a46f8030c7b0fad11b4.zip
inspect, image: alias .Config.HealthCheck to .HealthCheck for compatibility
Support inspecting image healthcheck using docker supported `.Config.HealthCheck` by aliasing field to `.HealthCheck` Now supports ```Console podman image inspect -f "{{.Config.Healthcheck}}" imagename ``` Closes: https://github.com/containers/podman/issues/14661 Signed-off-by: Aditya R <arajan@redhat.com>
Diffstat (limited to 'cmd/podman/inspect')
-rw-r--r--cmd/podman/inspect/inspect.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/cmd/podman/inspect/inspect.go b/cmd/podman/inspect/inspect.go
index edddf026e..d519bc7d9 100644
--- a/cmd/podman/inspect/inspect.go
+++ b/cmd/podman/inspect/inspect.go
@@ -201,7 +201,7 @@ func (i *inspector) inspect(namesOrIDs []string) error {
err = printJSON(data)
default:
// Landing here implies user has given a custom --format
- row := inspectNormalize(i.options.Format)
+ row := inspectNormalize(i.options.Format, tmpType)
row = report.NormalizeFormat(row)
row = report.EnforceRange(row)
err = printTmpl(tmpType, row, data)
@@ -300,7 +300,7 @@ func (i *inspector) inspectAll(ctx context.Context, namesOrIDs []string) ([]inte
return data, allErrs, nil
}
-func inspectNormalize(row string) string {
+func inspectNormalize(row string, inspectType string) string {
m := regexp.MustCompile(`{{\s*\.Id\s*}}`)
row = m.ReplaceAllString(row, "{{.ID}}")
@@ -309,5 +309,18 @@ func inspectNormalize(row string) string {
".Dst", ".Destination",
".ImageID", ".Image",
)
+
+ // If inspect type is `image` we need to replace
+ // certain additional fields like `.Config.HealthCheck`
+ // but don't want to replace them for other inspect types.
+ if inspectType == common.ImageType {
+ r = strings.NewReplacer(
+ ".Src", ".Source",
+ ".Dst", ".Destination",
+ ".ImageID", ".Image",
+ ".Config.Healthcheck", ".HealthCheck",
+ )
+ }
+
return r.Replace(row)
}