diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2022-07-11 10:03:44 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2022-07-26 13:34:38 -0400 |
commit | 9c1de040b36483fed1c331c438d8bce5fd8fab58 (patch) | |
tree | 7423c50dd57336eb045fea31665f4a1fb808acab /vendor/github.com/openshift/imagebuilder | |
parent | 03eaea8bbe4dc7791c2129d64321988d3ec12bb0 (diff) | |
download | podman-9c1de040b36483fed1c331c438d8bce5fd8fab58.tar.gz podman-9c1de040b36483fed1c331c438d8bce5fd8fab58.tar.bz2 podman-9c1de040b36483fed1c331c438d8bce5fd8fab58.zip |
Vendor in containers/(storage,image, common, buildah)
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/github.com/openshift/imagebuilder')
4 files changed, 69 insertions, 19 deletions
diff --git a/vendor/github.com/openshift/imagebuilder/.travis.yml b/vendor/github.com/openshift/imagebuilder/.travis.yml index ff6afee5a..42713c92c 100644 --- a/vendor/github.com/openshift/imagebuilder/.travis.yml +++ b/vendor/github.com/openshift/imagebuilder/.travis.yml @@ -1,16 +1,23 @@ language: go +services: + - docker + go: - - "1.16" - "1.17" + - "1.18" -install: +before_install: + - sudo apt-get update -q -y + - sudo apt-get install -q -y golang + - docker pull busybox + - docker pull centos:7 + - chmod -R go-w ./dockerclient/testdata script: - make build - make test + - travis_wait 30 make test-conformance notifications: irc: "chat.freenode.net#openshift-dev" - -sudo: false diff --git a/vendor/github.com/openshift/imagebuilder/Makefile b/vendor/github.com/openshift/imagebuilder/Makefile index 1cbb26eed..1a0cf0df2 100644 --- a/vendor/github.com/openshift/imagebuilder/Makefile +++ b/vendor/github.com/openshift/imagebuilder/Makefile @@ -3,9 +3,9 @@ build: .PHONY: build test: - go test $(go list ./... | grep -v /vendor/) + go test ./... .PHONY: test test-conformance: - go test -v -tags conformance -timeout 10m ./dockerclient + go test -v -tags conformance -timeout 30m ./dockerclient .PHONY: test-conformance diff --git a/vendor/github.com/openshift/imagebuilder/builder.go b/vendor/github.com/openshift/imagebuilder/builder.go index 71dc41ea5..db0c2f11b 100644 --- a/vendor/github.com/openshift/imagebuilder/builder.go +++ b/vendor/github.com/openshift/imagebuilder/builder.go @@ -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, } } diff --git a/vendor/github.com/openshift/imagebuilder/dispatchers.go b/vendor/github.com/openshift/imagebuilder/dispatchers.go index c437e4c23..2afbbf1b2 100644 --- a/vendor/github.com/openshift/imagebuilder/dispatchers.go +++ b/vendor/github.com/openshift/imagebuilder/dispatchers.go @@ -142,7 +142,13 @@ func add(b *Builder, args []string, attributes map[string]bool, flagArgs []strin var chmod string last := len(args) - 1 dest := makeAbsolute(args[last], b.RunConfig.WorkingDir) - userArgs := mergeEnv(envMapAsSlice(b.Args), b.Env) + filteredUserArgs := make(map[string]string) + for k, v := range b.Args { + if _, ok := b.AllowedArgs[k]; ok { + filteredUserArgs[k] = v + } + } + userArgs := mergeEnv(envMapAsSlice(filteredUserArgs), b.Env) for _, a := range flagArgs { arg, err := ProcessWord(a, userArgs) if err != nil { @@ -223,8 +229,20 @@ func from(b *Builder, args []string, attributes map[string]bool, flagArgs []stri for n, v := range b.HeadingArgs { argStrs = append(argStrs, n+"="+v) } + defaultArgs := envMapAsSlice(builtinBuildArgs) + filteredUserArgs := make(map[string]string) + for k, v := range b.UserArgs { + for _, a := range b.GlobalAllowedArgs { + if a == k { + filteredUserArgs[k] = v + } + } + } + userArgs := mergeEnv(envMapAsSlice(filteredUserArgs), b.Env) + userArgs = mergeEnv(defaultArgs, userArgs) + nameArgs := mergeEnv(argStrs, userArgs) var err error - if name, err = ProcessWord(name, argStrs); err != nil { + if name, err = ProcessWord(name, nameArgs); err != nil { return err } @@ -234,9 +252,6 @@ func from(b *Builder, args []string, attributes map[string]bool, flagArgs []stri return fmt.Errorf("Windows does not support FROM scratch") } } - defaultArgs := envMapAsSlice(builtinBuildArgs) - userArgs := mergeEnv(envMapAsSlice(b.Args), b.Env) - userArgs = mergeEnv(defaultArgs, userArgs) for _, a := range flagArgs { arg, err := ProcessWord(a, userArgs) if err != nil { @@ -323,7 +338,13 @@ func run(b *Builder, args []string, attributes map[string]bool, flagArgs []strin args = handleJSONArgs(args, attributes) var mounts []string - userArgs := mergeEnv(envMapAsSlice(b.Args), b.Env) + filteredUserArgs := make(map[string]string) + for k, v := range b.Args { + if _, ok := b.AllowedArgs[k]; ok { + filteredUserArgs[k] = v + } + } + userArgs := mergeEnv(envMapAsSlice(filteredUserArgs), b.Env) for _, a := range flagArgs { arg, err := ProcessWord(a, userArgs) if err != nil { |