Use default token for env replacement parsing

This commit is contained in:
Priya Wadhwa 2018-03-27 09:48:37 -07:00
parent 6eced4b12d
commit e885d6a5e6
No known key found for this signature in database
GPG Key ID: 0D0DAFD8F7AA73AE
3 changed files with 3 additions and 23 deletions

View File

@ -44,7 +44,7 @@ func (c *CopyCommand) ExecuteCommand(config *manifest.Schema2Config) error {
if err != nil { if err != nil {
return err return err
} }
dest = resolvedEnvs[len(c.cmd.SourcesAndDest)-1] dest = resolvedEnvs[len(resolvedEnvs)-1]
// Get a map of [src]:[files rooted at src] // Get a map of [src]:[files rooted at src]
srcMap, err := util.ResolveSources(resolvedEnvs, c.buildcontext) srcMap, err := util.ResolveSources(resolvedEnvs, c.buildcontext)
if err != nil { if err != nil {

View File

@ -53,25 +53,6 @@ func TestUpdateEnvConfig(t *testing.T) {
updateConfigEnv(newEnvs, cfg) updateConfigEnv(newEnvs, cfg)
testutil.CheckErrorAndDeepEqual(t, false, nil, expectedEnvArray, cfg.Env) 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) { func Test_EnvExecute(t *testing.T) {
cfg := &manifest.Schema2Config{ cfg := &manifest.Schema2Config{
Env: []string{ Env: []string{

View File

@ -17,9 +17,9 @@ limitations under the License.
package commands package commands
import ( import (
"github.com/GoogleCloudPlatform/k8s-container-builder/pkg/util"
"github.com/containers/image/manifest" "github.com/containers/image/manifest"
"github.com/docker/docker/builder/dockerfile/instructions" "github.com/docker/docker/builder/dockerfile/instructions"
"github.com/docker/docker/builder/dockerfile/shell"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"strings" "strings"
) )
@ -36,9 +36,8 @@ func updateLabels(labels []instructions.KeyValuePair, config *manifest.Schema2Co
existingLabels := config.Labels existingLabels := config.Labels
// Let's unescape values before setting the label // Let's unescape values before setting the label
shlex := shell.NewLex('\\')
for index, kvp := range labels { for index, kvp := range labels {
unescaped, err := shlex.ProcessWord(kvp.Value, []string{}) unescaped, err := util.ResolveEnvironmentReplacement(kvp.Value, []string{}, false)
if err != nil { if err != nil {
return err return err
} }