Skip to content

Commit

Permalink
fix env var from host truncated at equal sign
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasten committed Apr 24, 2024
1 parent 4638e77 commit d8a2d7a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ego/premain/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func PreMain(payload string, mounter Mounter, fs afero.Fs, hostEnviron []string)
// Convert host environment string array to key-value map
hostEnvironMap := make(map[string]string, len(hostEnviron))
for _, envVar := range hostEnviron {
splitString := strings.Split(envVar, "=")
hostEnvironMap[splitString[0]] = splitString[1]
name, val, _ := strings.Cut(envVar, "=")
hostEnvironMap[name] = val
}

// Check if we run as a Marble or a normal EGo application
Expand Down
3 changes: 2 additions & 1 deletion ego/premain/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestPremain(t *testing.T) {
assert := assert.New(t)
require := require.New(t)

hostEnviron := []string{"EDG_CWD=/host"}
hostEnviron := []string{"EDG_CWD=/host", "EDG_CONTAINS_EQUAL_SIGN=foo=bar"}
fs := afero.NewMemMapFs()

// sane default values
Expand All @@ -51,6 +51,7 @@ func TestPremain(t *testing.T) {
// Supply valid payload, no Marble
mounter := assertionMounter{assert: assert, expectedMounts: conf.Mounts, usedTargets: make(map[string]bool), remountAsHostFS: false}
assert.NoError(PreMain("", &mounter, fs, hostEnviron))
assert.Equal("foo=bar", os.Getenv("EDG_CONTAINS_EQUAL_SIGN"))

// Supply valid payload, no Marble
payload, err := json.Marshal(conf)
Expand Down

0 comments on commit d8a2d7a

Please sign in to comment.