build(deps): bump github.com/openshift/imagebuilder

Bumps [github.com/openshift/imagebuilder](https://github.com/openshift/imagebuilder) from 1.2.4-0.20230207193036-6e08c897da73 to 1.2.4.
- [Release notes](https://github.com/openshift/imagebuilder/releases)
- [Commits](https://github.com/openshift/imagebuilder/commits/v1.2.4)

---
updated-dependencies:
- dependency-name: github.com/openshift/imagebuilder
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2023-03-16 16:16:48 +00:00
committed by GitHub
parent 931cd1d7da
commit 1ea62f32f0
20 changed files with 72 additions and 252 deletions

View File

@@ -1,15 +1,16 @@
language: go
dist: jammy
services:
- docker
go:
- "1.17"
- "1.18"
- "1.19"
- "1.20"
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
@@ -17,7 +18,7 @@ before_install:
script:
- make build
- make test
- travis_wait 30 make test-conformance
- travis_wait 45 make test-conformance
notifications:
irc: "chat.freenode.net#openshift-dev"

View File

@@ -7,5 +7,5 @@ test:
.PHONY: test
test-conformance:
go test -v -tags conformance -timeout 30m ./dockerclient
go test -v -tags conformance -timeout 45m ./dockerclient
.PHONY: test-conformance

View File

@@ -39,11 +39,16 @@ type Run struct {
Args []string
// Mounts are mounts specified through the --mount flag inside the Containerfile
Mounts []string
// Network specifies the network mode to run the container with
Network string
}
type Executor interface {
Preserve(path string) error
// EnsureContainerPath should ensure that the directory exists, creating any components required
EnsureContainerPath(path string) error
// EnsureContainerPathAs should ensure that the directory exists, creating any components required
// with the specified owner and mode, if either is specified
EnsureContainerPathAs(path, user string, mode *os.FileMode) error
Copy(excludes []string, copies ...Copy) error
Run(run Run, config docker.Config) error

View File

@@ -12,7 +12,6 @@ import (
"fmt"
"os"
"path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
@@ -20,12 +19,13 @@ import (
docker "github.com/fsouza/go-dockerclient"
"github.com/containerd/containerd/platforms"
"github.com/containers/storage/pkg/regexp"
"github.com/openshift/imagebuilder/signal"
"github.com/openshift/imagebuilder/strslice"
)
var (
obRgex = regexp.MustCompile(`(?i)^\s*ONBUILD\s*`)
obRgex = regexp.Delayed(`(?i)^\s*ONBUILD\s*`)
)
var localspec = platforms.DefaultSpec()
@@ -53,7 +53,6 @@ func init() {
//
// Sets the environment variable foo to bar, also makes interpolation
// in the dockerfile available from the next statement on via ${foo}.
//
func env(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
if len(args) == 0 {
return errAtLeastOneArgument("ENV")
@@ -106,7 +105,6 @@ func maintainer(b *Builder, args []string, attributes map[string]bool, flagArgs
// LABEL some json data describing the image
//
// Sets the Label variable foo to bar,
//
func label(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
if len(args) == 0 {
return errAtLeastOneArgument("LABEL")
@@ -133,7 +131,6 @@ func label(b *Builder, args []string, attributes map[string]bool, flagArgs []str
//
// Add the file 'foo' to '/path'. Tarball and Remote URL (git, http) handling
// exist here. If you do not wish to have this automatic handling, use COPY.
//
func add(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
if len(args) < 2 {
return errAtLeastTwoArgument("ADD")
@@ -174,7 +171,6 @@ func add(b *Builder, args []string, attributes map[string]bool, flagArgs []strin
// COPY foo /path
//
// Same as 'ADD' but without the tar and remote url handling.
//
func dispatchCopy(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
if len(args) < 2 {
return errAtLeastTwoArgument("COPY")
@@ -212,7 +208,6 @@ func dispatchCopy(b *Builder, args []string, attributes map[string]bool, flagArg
// FROM imagename
//
// This sets the image the dockerfile will build on top of.
//
func from(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
switch {
case len(args) == 1:
@@ -278,7 +273,6 @@ func from(b *Builder, args []string, attributes map[string]bool, flagArgs []stri
// evaluator.go and comments around dispatch() in the same file explain the
// special cases. search for 'OnBuild' in internals.go for additional special
// cases.
//
func onbuild(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
if len(args) == 0 {
return errAtLeastOneArgument("ONBUILD")
@@ -301,7 +295,6 @@ func onbuild(b *Builder, args []string, attributes map[string]bool, flagArgs []s
// WORKDIR /tmp
//
// Set the working directory for future RUN/CMD/etc statements.
//
func workdir(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
if len(args) != 1 {
return errExactlyOneArgument("WORKDIR")
@@ -329,7 +322,6 @@ func workdir(b *Builder, args []string, attributes map[string]bool, flagArgs []s
// RUN echo hi # sh -c echo hi (Linux)
// RUN echo hi # cmd /S /C echo hi (Windows)
// RUN [ "echo", "hi" ] # echo hi
//
func run(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
if b.RunConfig.Image == "" {
return fmt.Errorf("Please provide a source image with `from` prior to run")
@@ -338,6 +330,7 @@ func run(b *Builder, args []string, attributes map[string]bool, flagArgs []strin
args = handleJSONArgs(args, attributes)
var mounts []string
var network string
filteredUserArgs := make(map[string]string)
for k, v := range b.Args {
if _, ok := b.AllowedArgs[k]; ok {
@@ -354,14 +347,17 @@ func run(b *Builder, args []string, attributes map[string]bool, flagArgs []strin
case strings.HasPrefix(arg, "--mount="):
mount := strings.TrimPrefix(arg, "--mount=")
mounts = append(mounts, mount)
case strings.HasPrefix(arg, "--network="):
network = strings.TrimPrefix(arg, "--network=")
default:
return fmt.Errorf("RUN only supports the --mount flag")
return fmt.Errorf("RUN only supports the --mount and --network flag")
}
}
run := Run{
Args: args,
Mounts: mounts,
Args: args,
Mounts: mounts,
Network: network,
}
if !attributes["json"] {
@@ -375,7 +371,6 @@ func run(b *Builder, args []string, attributes map[string]bool, flagArgs []strin
//
// Set the default command to run in the container (which may be empty).
// Argument handling is the same as RUN.
//
func cmd(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
cmdSlice := handleJSONArgs(args, attributes)
@@ -401,7 +396,6 @@ func cmd(b *Builder, args []string, attributes map[string]bool, flagArgs []strin
//
// Handles command processing similar to CMD and RUN, only b.RunConfig.Entrypoint
// is initialized at NewBuilder time instead of through argument parsing.
//
func entrypoint(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
parsed := handleJSONArgs(args, attributes)
@@ -433,7 +427,6 @@ func entrypoint(b *Builder, args []string, attributes map[string]bool, flagArgs
//
// Expose ports for links and port mappings. This all ends up in
// b.RunConfig.ExposedPorts for runconfig.
//
func expose(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
if len(args) == 0 {
return errAtLeastOneArgument("EXPOSE")
@@ -461,7 +454,6 @@ func expose(b *Builder, args []string, attributes map[string]bool, flagArgs []st
//
// Set the user to 'foo' for future commands and when running the
// ENTRYPOINT/CMD at container run time.
//
func user(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
if len(args) != 1 {
return errExactlyOneArgument("USER")
@@ -474,7 +466,6 @@ func user(b *Builder, args []string, attributes map[string]bool, flagArgs []stri
// VOLUME /foo
//
// Expose the volume /foo for use. Will also accept the JSON array form.
//
func volume(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
if len(args) == 0 {
return errAtLeastOneArgument("VOLUME")
@@ -515,7 +506,6 @@ func stopSignal(b *Builder, args []string, attributes map[string]bool, flagArgs
//
// Set the default healthcheck command to run in the container (which may be empty).
// Argument handling is the same as RUN.
//
func healthcheck(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
if len(args) == 0 {
return errAtLeastOneArgument("HEALTHCHECK")

View File

@@ -36,7 +36,6 @@ func parseIgnore(rest string, d *Directive) (*Node, map[string]bool, error) {
// statement with sub-statements.
//
// ONBUILD RUN foo bar -> (onbuild (run foo bar))
//
func parseSubCommand(rest string, d *Directive) (*Node, map[string]bool, error) {
if rest == "" {
return nil, nil, nil

View File

@@ -4,6 +4,7 @@ package parser
import (
"bufio"
"bytes"
"errors"
"fmt"
"io"
"regexp"
@@ -12,9 +13,9 @@ import (
"strings"
"unicode"
"github.com/openshift/imagebuilder/dockerfile/command"
sRegexp "github.com/containers/storage/pkg/regexp"
"github.com/containers/storage/pkg/system"
"github.com/pkg/errors"
"github.com/openshift/imagebuilder/dockerfile/command"
)
// Node is a structure used to represent a parse tree.
@@ -28,7 +29,6 @@ import (
// This data structure is frankly pretty lousy for handling complex languages,
// but lucky for us the Dockerfile isn't very complicated. This structure
// works a little more effectively than a "proper" parse tree for our needs.
//
type Node struct {
Value string // actual content
Next *Node // the next item in the current sexp
@@ -82,10 +82,10 @@ func (node *Node) AddChild(child *Node, startLine, endLine int) {
var (
dispatch map[string]func(string, *Directive) (*Node, map[string]bool, error)
tokenWhitespace = regexp.MustCompile(`[\t\v\f\r ]+`)
tokenEscapeCommand = regexp.MustCompile(`^#[ \t]*escape[ \t]*=[ \t]*(?P<escapechar>.).*$`)
tokenPlatformCommand = regexp.MustCompile(`^#[ \t]*platform[ \t]*=[ \t]*(?P<platform>.*)$`)
tokenComment = regexp.MustCompile(`^#.*$`)
tokenWhitespace = sRegexp.Delayed(`[\t\v\f\r ]+`)
tokenEscapeCommand = sRegexp.Delayed(`^#[ \t]*escape[ \t]*=[ \t]*(?P<escapechar>.).*$`)
tokenPlatformCommand = sRegexp.Delayed(`^#[ \t]*platform[ \t]*=[ \t]*(?P<platform>.*)$`)
tokenComment = sRegexp.Delayed(`^#.*$`)
)
// DefaultEscapeToken is the default escape token

View File

@@ -34,10 +34,14 @@ var replaceEnvAllowed = map[string]bool{
// Certain commands are allowed to have their args split into more
// words after env var replacements. Meaning:
// ENV foo="123 456"
// EXPOSE $foo
//
// ENV foo="123 456"
// EXPOSE $foo
//
// should result in the same thing as:
// EXPOSE 123 456
//
// EXPOSE 123 456
//
// and not treat "123 456" as a single word.
// Note that: EXPOSE "$foo" and EXPOSE $foo are not the same thing.
// Quotes will cause it to still be treated as single word.

View File

@@ -12,7 +12,7 @@
#
%global golang_version 1.8.1
%{!?version: %global version 1.2.4-dev}
%{!?version: %global version 1.2.4}
%{!?release: %global release 1}
%global package_name imagebuilder
%global product_name Container Image Builder

View File

@@ -269,7 +269,14 @@ func (sw *shellWord) processDollar() (string, error) {
newValue = word
}
return newValue, nil
case '?':
if newValue == "" {
newValue = word
}
if newValue == "" {
return "", fmt.Errorf("Failed to process `%s`: %s is not allowed to be unset", sw.word, name)
}
return newValue, nil
default:
return "", fmt.Errorf("Unsupported modifier (%c) in substitution: %s", modifier, sw.word)
}