mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-19 00:30:30 +02:00
parse arg commands at the top of dockerfiles (#404)
* parse arg commands at the top of dockerfiles * fix pointer reference bug and remove debugging * fixing tests * account for meta args with no value * don't take fs snapshot if / is the only changed path * move metaArgs inside KanikoStage * removing unused property * check for any directory instead of just / * remove unnecessary check
This commit is contained in:
@@ -18,6 +18,7 @@ package util
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@@ -44,7 +45,13 @@ var (
|
||||
)
|
||||
|
||||
// RetrieveSourceImage returns the base image of the stage at index
|
||||
func RetrieveSourceImage(stage config.KanikoStage, buildArgs []string, opts *config.KanikoOptions) (v1.Image, error) {
|
||||
func RetrieveSourceImage(stage config.KanikoStage, opts *config.KanikoOptions) (v1.Image, error) {
|
||||
buildArgs := opts.BuildArgs
|
||||
var metaArgsString []string
|
||||
for _, arg := range stage.MetaArgs {
|
||||
metaArgsString = append(metaArgsString, fmt.Sprintf("%s=%s", arg.Key, arg.ValueString()))
|
||||
}
|
||||
buildArgs = append(buildArgs, metaArgsString...)
|
||||
currentBaseName, err := ResolveEnvironmentReplacement(stage.BaseName, buildArgs, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -57,7 +57,7 @@ func Test_StandardImage(t *testing.T) {
|
||||
retrieveRemoteImage = mock
|
||||
actual, err := RetrieveSourceImage(config.KanikoStage{
|
||||
Stage: stages[0],
|
||||
}, nil, &config.KanikoOptions{})
|
||||
}, &config.KanikoOptions{})
|
||||
testutil.CheckErrorAndDeepEqual(t, false, err, nil, actual)
|
||||
}
|
||||
func Test_ScratchImage(t *testing.T) {
|
||||
@@ -67,7 +67,7 @@ func Test_ScratchImage(t *testing.T) {
|
||||
}
|
||||
actual, err := RetrieveSourceImage(config.KanikoStage{
|
||||
Stage: stages[1],
|
||||
}, nil, &config.KanikoOptions{})
|
||||
}, &config.KanikoOptions{})
|
||||
expected := empty.Image
|
||||
testutil.CheckErrorAndDeepEqual(t, false, err, expected, actual)
|
||||
}
|
||||
@@ -89,7 +89,7 @@ func Test_TarImage(t *testing.T) {
|
||||
BaseImageStoredLocally: true,
|
||||
BaseImageIndex: 0,
|
||||
Stage: stages[2],
|
||||
}, nil, &config.KanikoOptions{})
|
||||
}, &config.KanikoOptions{})
|
||||
testutil.CheckErrorAndDeepEqual(t, false, err, nil, actual)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user