Use default token for env replacement parsing
This commit is contained in:
parent
6eced4b12d
commit
e885d6a5e6
|
|
@ -44,7 +44,7 @@ func (c *CopyCommand) ExecuteCommand(config *manifest.Schema2Config) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dest = resolvedEnvs[len(c.cmd.SourcesAndDest)-1]
|
||||
dest = resolvedEnvs[len(resolvedEnvs)-1]
|
||||
// Get a map of [src]:[files rooted at src]
|
||||
srcMap, err := util.ResolveSources(resolvedEnvs, c.buildcontext)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -53,25 +53,6 @@ func TestUpdateEnvConfig(t *testing.T) {
|
|||
updateConfigEnv(newEnvs, cfg)
|
||||
testutil.CheckErrorAndDeepEqual(t, false, nil, expectedEnvArray, cfg.Env)
|
||||
}
|
||||
|
||||
func TestEnvToString(t *testing.T) {
|
||||
envCmd := &instructions.EnvCommand{
|
||||
Env: []instructions.KeyValuePair{
|
||||
{
|
||||
Key: "PATH",
|
||||
Value: "/some/path",
|
||||
},
|
||||
{
|
||||
Key: "HOME",
|
||||
Value: "/root",
|
||||
},
|
||||
},
|
||||
}
|
||||
expectedString := "ENV PATH=/some/path HOME=/root"
|
||||
actualString := envToString(envCmd)
|
||||
testutil.CheckErrorAndDeepEqual(t, false, nil, expectedString, actualString)
|
||||
}
|
||||
|
||||
func Test_EnvExecute(t *testing.T) {
|
||||
cfg := &manifest.Schema2Config{
|
||||
Env: []string{
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ limitations under the License.
|
|||
package commands
|
||||
|
||||
import (
|
||||
"github.com/GoogleCloudPlatform/k8s-container-builder/pkg/util"
|
||||
"github.com/containers/image/manifest"
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
"github.com/docker/docker/builder/dockerfile/shell"
|
||||
"github.com/sirupsen/logrus"
|
||||
"strings"
|
||||
)
|
||||
|
|
@ -36,9 +36,8 @@ func updateLabels(labels []instructions.KeyValuePair, config *manifest.Schema2Co
|
|||
existingLabels := config.Labels
|
||||
|
||||
// Let's unescape values before setting the label
|
||||
shlex := shell.NewLex('\\')
|
||||
for index, kvp := range labels {
|
||||
unescaped, err := shlex.ProcessWord(kvp.Value, []string{})
|
||||
unescaped, err := util.ResolveEnvironmentReplacement(kvp.Value, []string{}, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue