Skip to content

Commit

Permalink
Use default token for env replacement parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Priya Wadhwa committed Mar 27, 2018
1 parent 6eced4b commit e885d6a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pkg/commands/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 0 additions & 19 deletions pkg/commands/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
5 changes: 2 additions & 3 deletions pkg/commands/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
}
Expand Down

0 comments on commit e885d6a

Please sign in to comment.