Set env at command run time instead of in the process. (#91)
This commit is contained in:
parent
2ff7a6556a
commit
0438539cbc
|
|
@ -17,12 +17,12 @@ limitations under the License.
|
|||
package commands
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/GoogleCloudPlatform/kaniko/pkg/util"
|
||||
"github.com/containers/image/manifest"
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
"github.com/sirupsen/logrus"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type EnvCommand struct {
|
||||
|
|
@ -45,10 +45,6 @@ func (e *EnvCommand) ExecuteCommand(config *manifest.Schema2Config) error {
|
|||
Key: expandedKey,
|
||||
Value: expandedValue,
|
||||
}
|
||||
logrus.Infof("Setting environment variable %s=%s", pair.Key, expandedValue)
|
||||
if err := os.Setenv(pair.Key, expandedValue); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return updateConfigEnv(newEnvs, config)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,14 +17,15 @@ limitations under the License.
|
|||
package commands
|
||||
|
||||
import (
|
||||
"github.com/containers/image/manifest"
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
"github.com/sirupsen/logrus"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/containers/image/manifest"
|
||||
"github.com/docker/docker/builder/dockerfile/instructions"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type RunCommand struct {
|
||||
|
|
@ -48,6 +49,8 @@ func (r *RunCommand) ExecuteCommand(config *manifest.Schema2Config) error {
|
|||
cmd := exec.Command(newCommand[0], newCommand[1:]...)
|
||||
cmd.Dir = config.WorkingDir
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Env = config.Env
|
||||
|
||||
// If specified, run the command as a specific user
|
||||
if config.User != "" {
|
||||
userAndGroup := strings.Split(config.User, ":")
|
||||
|
|
|
|||
Loading…
Reference in New Issue