vendor: update buildah to latest main

Includes one breaking change for the flag as BuildOutputs now accept a
slice.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2025-06-05 11:47:46 +02:00
parent 96abeafc61
commit ac71bc6cf2
39 changed files with 824 additions and 234 deletions

View File

@ -2,6 +2,7 @@ package imagebuilder
import (
"bytes"
"errors"
"fmt"
"io"
"io/ioutil"
@ -9,6 +10,7 @@ import (
"os"
"path/filepath"
"runtime"
"slices"
"strconv"
"strings"
@ -288,6 +290,55 @@ type Stage struct {
}
func NewStages(node *parser.Node, b *Builder) (Stages, error) {
getStageFrom := func(stageIndex int, root *parser.Node) (from string, as string, err error) {
for _, child := range root.Children {
if !strings.EqualFold(child.Value, command.From) {
continue
}
if child.Next == nil {
return "", "", errors.New("FROM requires an argument")
}
if child.Next.Value == "" {
return "", "", errors.New("FROM requires a non-empty argument")
}
from = child.Next.Value
if name, ok := extractNameFromNode(child); ok {
as = name
}
return from, as, nil
}
return "", "", fmt.Errorf("stage %d requires a FROM instruction (%q)", stageIndex+1, root.Original)
}
argInstructionsInStages := make(map[string][]string)
setStageInheritedArgs := func(s *Stage) error {
from, as, err := getStageFrom(s.Position, s.Node)
if err != nil {
return err
}
inheritedArgs := argInstructionsInStages[from]
thisStageArgs := slices.Clone(inheritedArgs)
for _, child := range s.Node.Children {
if !strings.EqualFold(child.Value, command.Arg) {
continue
}
if child.Next == nil {
return errors.New("ARG requires an argument")
}
if child.Next.Value == "" {
return errors.New("ARG requires a non-empty argument")
}
next := child.Next
for next != nil {
thisStageArgs = append(thisStageArgs, next.Value)
next = next.Next
}
}
if as != "" {
argInstructionsInStages[as] = thisStageArgs
}
argInstructionsInStages[strconv.Itoa(s.Position)] = thisStageArgs
return arg(s.Builder, inheritedArgs, nil, nil, "", nil)
}
var stages Stages
var headingArgs []string
if err := b.extractHeadingArgsFromNode(node); err != nil {
@ -297,8 +348,8 @@ func NewStages(node *parser.Node, b *Builder) (Stages, error) {
headingArgs = append(headingArgs, k)
}
for i, root := range SplitBy(node, command.From) {
name, _ := extractNameFromNode(root.Children[0])
if len(name) == 0 {
name, hasName := extractNameFromNode(root.Children[0])
if !hasName {
name = strconv.Itoa(i)
}
filteredUserArgs := make(map[string]string)
@ -317,12 +368,16 @@ func NewStages(node *parser.Node, b *Builder) (Stages, error) {
if err != nil {
return nil, err
}
stages = append(stages, Stage{
stage := Stage{
Position: i,
Name: processedName,
Builder: b.builderForStage(headingArgs),
Node: root,
})
}
if err := setStageInheritedArgs(&stage); err != nil {
return nil, err
}
stages = append(stages, stage)
}
return stages, nil
}