mirror of
https://github.com/containers/buildah.git
synced 2026-02-05 09:45:38 +01:00
info,inspect: use the "formats" package to get some builtins
Use the "formats" package to format `info` and `inspect` output, so that template users will be able to use whatever functions are provided with `images` and `containers` output, including "json", "lower", and "upper". Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
@@ -6,10 +6,10 @@ import (
|
||||
"os"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"text/template"
|
||||
|
||||
"github.com/containers/buildah"
|
||||
"github.com/containers/buildah/define"
|
||||
"github.com/containers/common/pkg/formats"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
@@ -71,7 +71,7 @@ func infoCmd(c *cobra.Command, iopts infoResults) error {
|
||||
} else if !matched {
|
||||
return fmt.Errorf("invalid format provided: %s", format)
|
||||
}
|
||||
t, err := template.New("format").Parse(format)
|
||||
t, err := formats.NewParse("info", format)
|
||||
if err != nil {
|
||||
return fmt.Errorf("template parsing error: %w", err)
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"text/template"
|
||||
|
||||
"github.com/containers/buildah"
|
||||
buildahcli "github.com/containers/buildah/pkg/cli"
|
||||
"github.com/containers/buildah/pkg/parse"
|
||||
"github.com/containers/common/pkg/formats"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
@@ -113,7 +113,7 @@ func inspectCmd(c *cobra.Command, args []string, iopts inspectResults) error {
|
||||
} else if !matched {
|
||||
return fmt.Errorf("invalid format provided: %s", format)
|
||||
}
|
||||
t, err := template.New("format").Parse(format)
|
||||
t, err := formats.NewParse("inspect", format)
|
||||
if err != nil {
|
||||
return fmt.Errorf("template parsing error: %w", err)
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ load helpers
|
||||
run_buildah inspect --type image --format '{{.OCIv1.Config}}' alpine-image
|
||||
inspect_after_commit=$output
|
||||
|
||||
# ...except that at some point in November 2019 buildah-inspect started
|
||||
# including version. Strip it out,
|
||||
# ...except that in #2510/#3036/#3829 we started adding a label with
|
||||
# buildah's version. Strip it out for comparison.
|
||||
run_buildah --version
|
||||
local -a output_fields=($output)
|
||||
buildah_version=${output_fields[2]}
|
||||
|
||||
Reference in New Issue
Block a user