Vendor in containers/(storage,image, common, buildah)

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2022-07-11 10:03:44 -04:00
parent 5f848d89ed
commit f67ab1eb20
576 changed files with 40399 additions and 10219 deletions

View File

@ -215,6 +215,17 @@ type Stage struct {
func NewStages(node *parser.Node, b *Builder) (Stages, error) {
var stages Stages
var allDeclaredArgs []string
for _, root := range SplitBy(node, command.Arg) {
argNode := root.Children[0]
if argNode.Value == command.Arg {
// extract declared variable
s := strings.SplitN(argNode.Original, " ", 2)
if len(s) == 2 && (strings.ToLower(s[0]) == command.Arg) {
allDeclaredArgs = append(allDeclaredArgs, s[1])
}
}
}
if err := b.extractHeadingArgsFromNode(node); err != nil {
return stages, err
}
@ -226,7 +237,7 @@ func NewStages(node *parser.Node, b *Builder) (Stages, error) {
stages = append(stages, Stage{
Position: i,
Name: name,
Builder: b.builderForStage(),
Builder: b.builderForStage(allDeclaredArgs),
Node: root,
})
}
@ -290,8 +301,8 @@ func extractNameFromNode(node *parser.Node) (string, bool) {
return n.Next.Value, true
}
func (b *Builder) builderForStage() *Builder {
stageBuilder := NewBuilder(b.UserArgs)
func (b *Builder) builderForStage(globalArgsList []string) *Builder {
stageBuilder := newBuilderWithGlobalAllowedArgs(b.UserArgs, globalArgsList)
for k, v := range b.HeadingArgs {
stageBuilder.HeadingArgs[k] = v
}
@ -307,6 +318,12 @@ type Builder struct {
UserArgs map[string]string
CmdSet bool
Author string
// Certain instructions like `FROM` will need to use
// `ARG` decalred before or not in this stage hence
// while processing instruction like `FROM ${SOME_ARG}`
// we will make sure to verify if they are declared any
// where in containerfile or not.
GlobalAllowedArgs []string
AllowedArgs map[string]bool
Volumes VolumeSet
@ -323,6 +340,10 @@ type Builder struct {
}
func NewBuilder(args map[string]string) *Builder {
return newBuilderWithGlobalAllowedArgs(args, []string{})
}
func newBuilderWithGlobalAllowedArgs(args map[string]string, globalallowedargs []string) *Builder {
allowed := make(map[string]bool)
for k, v := range builtinAllowedBuildArgs {
allowed[k] = v
@ -334,10 +355,11 @@ func NewBuilder(args map[string]string) *Builder {
initialArgs[k] = v
}
return &Builder{
Args: initialArgs,
UserArgs: userArgs,
HeadingArgs: make(map[string]string),
AllowedArgs: allowed,
Args: initialArgs,
UserArgs: userArgs,
HeadingArgs: make(map[string]string),
AllowedArgs: allowed,
GlobalAllowedArgs: globalallowedargs,
}
}