update buildah to latest and use new network stack

Make sure buildah uses the new network stack.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2022-01-06 14:50:12 +01:00
parent 495884b319
commit 0151e10b62
77 changed files with 2786 additions and 1122 deletions

View File

@@ -4,6 +4,7 @@ import (
"io"
"time"
nettypes "github.com/containers/common/libnetwork/types"
"github.com/containers/image/v5/types"
encconfig "github.com/containers/ocicrypt/config"
"github.com/containers/storage/pkg/archive"
@@ -70,7 +71,9 @@ type CommonBuildOptions struct {
Ulimit []string
// Volumes to bind mount into the container
Volumes []string
// Secrets are the available secrets to use in a build
// Secrets are the available secrets to use in a build. Each item in the
// slice takes the form "id=foo,src=bar", where both "id" and "src" are
// required, in that order, and "bar" is the name of a file.
Secrets []string
// SSHSources is the available ssh agent connections to forward in the build
SSHSources []string
@@ -78,6 +81,8 @@ type CommonBuildOptions struct {
// BuildOptions can be used to alter how an image is built.
type BuildOptions struct {
// ContainerSuffix it the name to suffix containers with
ContainerSuffix string
// ContextDirectory is the default source location for COPY and ADD
// commands.
ContextDirectory string
@@ -157,6 +162,10 @@ type BuildOptions struct {
// CNIConfigDir is the location of CNI configuration files, if the files in
// the default configuration directory shouldn't be used.
CNIConfigDir string
// NetworkInterface is the libnetwork network interface used to setup CNI or netavark networks.
NetworkInterface nettypes.ContainerNetwork `json:"-"`
// ID mapping options to use if we're setting up our own user namespace
// when handling RUN instructions.
IDMappingOptions *IDMappingOptions
@@ -227,6 +236,8 @@ type BuildOptions struct {
RusageLogFile string
// Excludes is a list of excludes to be used instead of the .dockerignore file.
Excludes []string
// IgnoreFile is a name of the .containerignore file
IgnoreFile string
// From is the image name to use to replace the value specified in the first
// FROM instruction in the Containerfile
From string
@@ -234,4 +245,10 @@ type BuildOptions struct {
// to build the image for. If this slice has items in it, the OS and
// Architecture fields above are ignored.
Platforms []struct{ OS, Arch, Variant string }
// AllPlatforms tells the builder to set the list of target platforms
// to match the set of platforms for which all of the build's base
// images are available. If this field is set, Platforms is ignored.
AllPlatforms bool
// UnsetEnvs is a list of environments to not add to final image.
UnsetEnvs []string
}

View File

@@ -29,15 +29,11 @@ const (
Package = "buildah"
// Version for the Package. Bump version in contrib/rpm/buildah.spec
// too.
Version = "1.23.1"
Version = "1.24.0-dev"
// DefaultRuntime if containers.conf fails.
DefaultRuntime = "runc"
DefaultCNIPluginPath = "/usr/libexec/cni:/opt/cni/bin"
// DefaultCNIConfigDir is the default location of CNI configuration files.
DefaultCNIConfigDir = "/etc/cni/net.d"
// OCIv1ImageManifest is the MIME type of an OCIv1 image manifest,
// suitable for specifying as a value of the PreferredManifestType
// member of a CommitOptions structure. It is also the default.
@@ -93,6 +89,13 @@ type IDMappingOptions struct {
GIDMap []specs.LinuxIDMapping
}
// Secret is a secret source that can be used in a RUN
type Secret struct {
ID string
Source string
SourceType string
}
// TempDirForURL checks if the passed-in string looks like a URL or -. If it is,
// TempDirForURL creates a temporary directory, arranges for its contents to be
// the contents of that URL, and returns the temporary directory's path, along
@@ -117,12 +120,12 @@ func TempDirForURL(dir, prefix, url string) (name string, subdir string, err err
return "", "", errors.Wrapf(err, "error parsing url %q", url)
}
if strings.HasPrefix(url, "git://") || strings.HasSuffix(urlParsed.Path, ".git") {
err = cloneToDirectory(url, name)
combinedOutput, err := cloneToDirectory(url, name)
if err != nil {
if err2 := os.RemoveAll(name); err2 != nil {
logrus.Debugf("error removing temporary directory %q: %v", name, err2)
}
return "", "", err
return "", "", errors.Wrapf(err, "cloning %q to %q:\n%s", url, name, string(combinedOutput))
}
return name, "", nil
}
@@ -160,7 +163,7 @@ func TempDirForURL(dir, prefix, url string) (name string, subdir string, err err
return "", "", errors.Errorf("unreachable code reached")
}
func cloneToDirectory(url, dir string) error {
func cloneToDirectory(url, dir string) ([]byte, error) {
gitBranch := strings.Split(url, "#")
var cmd *exec.Cmd
if len(gitBranch) < 2 {
@@ -170,7 +173,7 @@ func cloneToDirectory(url, dir string) error {
logrus.Debugf("cloning repo %q and branch %q to %q", gitBranch[0], gitBranch[1], dir)
cmd = exec.Command("git", "clone", "--recurse-submodules", "-b", gitBranch[1], gitBranch[0], dir)
}
return cmd.Run()
return cmd.CombinedOutput()
}
func downloadToDirectory(url, dir string) error {