mirror of
https://github.com/containers/podman.git
synced 2025-12-02 11:08:36 +08:00
vendor: bump containers/(storage, common, buildah, image)
Bump containers/(storage, common, buildah and image) Changes since 2023-01-01: - skip mount-cache-selinux-long-name test under remote, with a FIXME requesting that someone see if it can be made to work. - skip six tests that fail under rootless-remote - add new --build-arg-file option: - update man page Squash of: *cf56eb1865*561f082772Signed-off-by: Ed Santiago <santiago@redhat.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Signed-off-by: Aditya R <arajan@redhat.com>
This commit is contained in:
53
vendor/github.com/containers/buildah/pkg/cli/build.go
generated
vendored
53
vendor/github.com/containers/buildah/pkg/cli/build.go
generated
vendored
@@ -105,19 +105,16 @@ func GenBuildOptions(c *cobra.Command, inputArgs []string, iopts BuildOptions) (
|
||||
logrus.Debugf("Pull Policy for pull [%v]", pullPolicy)
|
||||
|
||||
args := make(map[string]string)
|
||||
if c.Flag("build-arg-file").Changed {
|
||||
for _, argfile := range iopts.BuildArgFile {
|
||||
if err := readBuildArgFile(argfile, args); err != nil {
|
||||
return options, nil, nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
if c.Flag("build-arg").Changed {
|
||||
for _, arg := range iopts.BuildArg {
|
||||
av := strings.SplitN(arg, "=", 2)
|
||||
if len(av) > 1 {
|
||||
args[av[0]] = av[1]
|
||||
} else {
|
||||
// check if the env is set in the local environment and use that value if it is
|
||||
if val, present := os.LookupEnv(av[0]); present {
|
||||
args[av[0]] = val
|
||||
} else {
|
||||
delete(args, av[0])
|
||||
}
|
||||
}
|
||||
readBuildArg(arg, args)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,7 +322,7 @@ func GenBuildOptions(c *cobra.Command, inputArgs []string, iopts BuildOptions) (
|
||||
// If user explicitly specified `--cache-ttl=0s`
|
||||
// it would effectively mean that user is asking
|
||||
// to use no cache at all. In such use cases
|
||||
// buildah can skip looking for cache entierly
|
||||
// buildah can skip looking for cache entirely
|
||||
// by setting `--no-cache=true` internally.
|
||||
if int64(cacheTTL) == 0 {
|
||||
logrus.Debug("Setting --no-cache=true since --cache-ttl was set to 0s which effectively means user wants to ignore cache")
|
||||
@@ -375,7 +372,6 @@ func GenBuildOptions(c *cobra.Command, inputArgs []string, iopts BuildOptions) (
|
||||
ContextDirectory: contextDir,
|
||||
Devices: iopts.Devices,
|
||||
DropCapabilities: iopts.CapDrop,
|
||||
Envs: iopts.Envs,
|
||||
Err: stderr,
|
||||
Excludes: excludes,
|
||||
ForceRmIntermediateCtrs: iopts.ForceRm,
|
||||
@@ -425,9 +421,40 @@ func GenBuildOptions(c *cobra.Command, inputArgs []string, iopts BuildOptions) (
|
||||
if iopts.Quiet {
|
||||
options.ReportWriter = io.Discard
|
||||
}
|
||||
|
||||
options.Envs = LookupEnvVarReferences(iopts.Envs, os.Environ())
|
||||
|
||||
return options, containerfiles, removeAll, nil
|
||||
}
|
||||
|
||||
func readBuildArgFile(buildargfile string, args map[string]string) error {
|
||||
argfile, err := os.ReadFile(buildargfile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, arg := range strings.Split(string(argfile), "\n") {
|
||||
if len (arg) == 0 || arg[0] == '#' {
|
||||
continue
|
||||
}
|
||||
readBuildArg(arg, args)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func readBuildArg(buildarg string, args map[string]string) {
|
||||
av := strings.SplitN(buildarg, "=", 2)
|
||||
if len(av) > 1 {
|
||||
args[av[0]] = av[1]
|
||||
} else {
|
||||
// check if the env is set in the local environment and use that value if it is
|
||||
if val, present := os.LookupEnv(av[0]); present {
|
||||
args[av[0]] = val
|
||||
} else {
|
||||
delete(args, av[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getContainerfiles(files []string) []string {
|
||||
var containerfiles []string
|
||||
for _, f := range files {
|
||||
|
||||
42
vendor/github.com/containers/buildah/pkg/cli/common.go
generated
vendored
42
vendor/github.com/containers/buildah/pkg/cli/common.go
generated
vendored
@@ -53,6 +53,7 @@ type BudResults struct {
|
||||
Annotation []string
|
||||
Authfile string
|
||||
BuildArg []string
|
||||
BuildArgFile []string
|
||||
BuildContext []string
|
||||
CacheFrom []string
|
||||
CacheTo []string
|
||||
@@ -204,6 +205,7 @@ func GetBudFlags(flags *BudResults) pflag.FlagSet {
|
||||
fs.StringVar(&flags.Authfile, "authfile", "", "path of the authentication file.")
|
||||
fs.StringArrayVar(&flags.OCIHooksDir, "hooks-dir", []string{}, "set the OCI hooks directory path (may be set multiple times)")
|
||||
fs.StringArrayVar(&flags.BuildArg, "build-arg", []string{}, "`argument=value` to supply to the builder")
|
||||
fs.StringArrayVar(&flags.BuildArgFile, "build-arg-file", []string{}, "`argfile.conf` containing lines of argument=value to supply to the builder")
|
||||
fs.StringArrayVar(&flags.BuildContext, "build-context", []string{}, "`argument=value` to supply additional build context to the builder")
|
||||
fs.StringArrayVar(&flags.CacheFrom, "cache-from", []string{}, "remote repository list to utilise as potential cache source.")
|
||||
fs.StringArrayVar(&flags.CacheTo, "cache-to", []string{}, "remote repository list to utilise as potential cache destination.")
|
||||
@@ -285,6 +287,7 @@ func GetBudFlagsCompletions() commonComp.FlagCompletions {
|
||||
flagCompletion["arch"] = commonComp.AutocompleteNone
|
||||
flagCompletion["authfile"] = commonComp.AutocompleteDefault
|
||||
flagCompletion["build-arg"] = commonComp.AutocompleteNone
|
||||
flagCompletion["build-arg-file"] = commonComp.AutocompleteDefault
|
||||
flagCompletion["build-context"] = commonComp.AutocompleteNone
|
||||
flagCompletion["cache-from"] = commonComp.AutocompleteNone
|
||||
flagCompletion["cache-to"] = commonComp.AutocompleteNone
|
||||
@@ -481,3 +484,42 @@ func AliasFlags(f *pflag.FlagSet, name string) pflag.NormalizedName {
|
||||
}
|
||||
return pflag.NormalizedName(name)
|
||||
}
|
||||
|
||||
// LookupEnvVarReferences returns a copy of specs with keys and values resolved
|
||||
// from environ. Strings are in "key=value" form, the same as [os.Environ].
|
||||
//
|
||||
// - When a string in specs lacks "=", it is treated as a key and the value
|
||||
// is retrieved from environ. When the key is missing from environ, neither
|
||||
// the key nor value are returned.
|
||||
//
|
||||
// - When a string in specs lacks "=" and ends with "*", it is treated as
|
||||
// a key prefix and any keys with the same prefix in environ are returned.
|
||||
//
|
||||
// - When a string in specs is exactly "*", all keys and values in environ
|
||||
// are returned.
|
||||
func LookupEnvVarReferences(specs, environ []string) []string {
|
||||
result := make([]string, 0, len(specs))
|
||||
|
||||
for _, spec := range specs {
|
||||
if key, _, ok := strings.Cut(spec, "="); ok {
|
||||
result = append(result, spec)
|
||||
|
||||
} else if key == "*" {
|
||||
result = append(result, environ...)
|
||||
|
||||
} else {
|
||||
prefix := key + "="
|
||||
if strings.HasSuffix(key, "*") {
|
||||
prefix = strings.TrimSuffix(key, "*")
|
||||
}
|
||||
|
||||
for _, spec := range environ {
|
||||
if strings.HasPrefix(spec, prefix) {
|
||||
result = append(result, spec)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user