Document BUILDAH_* environment variables in buildah bud --help output
We also want to show the default settings. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #956 Approved by: rhatdan
This commit is contained in:
parent
745bf7e56b
commit
46c58b2919
|
|
@ -72,16 +72,9 @@ func budCmd(c *cli.Context) error {
|
|||
}
|
||||
|
||||
dockerfiles := getDockerfiles(c.StringSlice("file"))
|
||||
format := defaultFormat()
|
||||
if c.IsSet("format") {
|
||||
format = strings.ToLower(c.String("format"))
|
||||
}
|
||||
if strings.HasPrefix(format, "oci") {
|
||||
format = imagebuildah.OCIv1ImageFormat
|
||||
} else if strings.HasPrefix(format, "docker") {
|
||||
format = imagebuildah.Dockerv2ImageFormat
|
||||
} else {
|
||||
return errors.Errorf("unrecognized image type %q", format)
|
||||
format, err := getFormat(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
layers := buildahcli.UseLayers()
|
||||
if c.IsSet("layers") {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/containers/image/storage"
|
||||
|
|
@ -116,13 +115,9 @@ func commitCmd(c *cli.Context) error {
|
|||
timestamp = finfo.ModTime().UTC()
|
||||
}
|
||||
|
||||
format := c.String("format")
|
||||
if strings.HasPrefix(strings.ToLower(format), "oci") {
|
||||
format = buildah.OCIv1ImageManifest
|
||||
} else if strings.HasPrefix(strings.ToLower(format), "docker") {
|
||||
format = buildah.Dockerv2ImageManifest
|
||||
} else {
|
||||
return errors.Errorf("unrecognized image type %q", format)
|
||||
format, err := getFormat(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
store, err := getStore(c)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
is "github.com/containers/image/storage"
|
||||
|
|
@ -152,7 +153,7 @@ func defaultFormat() string {
|
|||
if format != "" {
|
||||
return format
|
||||
}
|
||||
return "oci"
|
||||
return buildah.OCI
|
||||
}
|
||||
|
||||
// imageIsParent goes through the layers in the store and checks if i.TopLayer is
|
||||
|
|
@ -216,3 +217,15 @@ func getImageOfTopLayer(images []storage.Image, layer string) []string {
|
|||
}
|
||||
return matches
|
||||
}
|
||||
|
||||
func getFormat(c *cli.Context) (string, error) {
|
||||
format := strings.ToLower(c.String("format"))
|
||||
if strings.HasPrefix(format, buildah.OCI) {
|
||||
return buildah.OCIv1ImageManifest, nil
|
||||
}
|
||||
|
||||
if strings.HasPrefix(format, buildah.DOCKER) {
|
||||
return buildah.Dockerv2ImageManifest, nil
|
||||
}
|
||||
return "", errors.Errorf("unrecognized image type %q", format)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,13 @@ import (
|
|||
"github.com/containers/image/types"
|
||||
)
|
||||
|
||||
const (
|
||||
// OCI used to define the "oci" image format
|
||||
OCI = "oci"
|
||||
// DOCKER used to define the "docker" image format
|
||||
DOCKER = "docker"
|
||||
)
|
||||
|
||||
func getCopyOptions(reportWriter io.Writer, sourceSystemContext *types.SystemContext, destinationSystemContext *types.SystemContext, manifestType string) *cp.Options {
|
||||
return &cp.Options{
|
||||
ReportWriter: reportWriter,
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/projectatomic/buildah"
|
||||
"github.com/projectatomic/buildah/util"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var (
|
||||
runtime = util.Runtime()
|
||||
usernsFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "userns",
|
||||
|
|
@ -113,7 +113,8 @@ var (
|
|||
},
|
||||
cli.StringFlag{
|
||||
Name: "format",
|
||||
Usage: "`format` of the built image's manifest and metadata",
|
||||
Usage: "`format` of the built image's manifest and metadata. Use BUILDAH_FORMAT environment variable to override.",
|
||||
Value: DefaultFormat(),
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "iidfile",
|
||||
|
|
@ -121,7 +122,8 @@ var (
|
|||
},
|
||||
cli.StringFlag{
|
||||
Name: "isolation",
|
||||
Usage: "`type` of process isolation to use",
|
||||
Usage: "`type` of process isolation to use. Use BUILDAH_ISOLATION environment variable to override.",
|
||||
Value: DefaultIsolation(),
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "label",
|
||||
|
|
@ -129,7 +131,7 @@ var (
|
|||
},
|
||||
cli.BoolFlag{
|
||||
Name: "layers",
|
||||
Usage: fmt.Sprintf("cache intermediate layers during build (default %t)", UseLayers()),
|
||||
Usage: fmt.Sprintf("cache intermediate layers during build. Use BUILDAH_LAYERS environment variable to override. (default %t)", UseLayers()),
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "no-cache",
|
||||
|
|
@ -161,8 +163,8 @@ var (
|
|||
},
|
||||
cli.StringFlag{
|
||||
Name: "runtime",
|
||||
Usage: "`path` to an alternate runtime",
|
||||
Value: runtime,
|
||||
Usage: "`path` to an alternate runtime. Use BUILDAH_RUNTIME environment variable to override.",
|
||||
Value: util.Runtime(),
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "runtime-flag",
|
||||
|
|
@ -260,3 +262,21 @@ func UseLayers() bool {
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// DefaultFormat returns the default image format
|
||||
func DefaultFormat() string {
|
||||
format := os.Getenv("BUILDAH_FORMAT")
|
||||
if format != "" {
|
||||
return format
|
||||
}
|
||||
return buildah.OCI
|
||||
}
|
||||
|
||||
// DefaultIsolation returns the default image format
|
||||
func DefaultIsolation() string {
|
||||
isolation := os.Getenv("BUILDAH_ISOLATION")
|
||||
if isolation != "" {
|
||||
return isolation
|
||||
}
|
||||
return buildah.OCI
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue