-
Notifications
You must be signed in to change notification settings - Fork 950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: add envs for pouch exec #2250
Conversation
Codecov Report
|
daemon/mgr/container_exec.go
Outdated
} | ||
|
||
mgr.ExecProcesses.Put(execid, execConfig) | ||
|
||
return execid, nil | ||
} | ||
|
||
// MergeEnvs merge oldEnvs with new Env | ||
func MergeEnvs(oldEnv, newEnv []string) []string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if that we have already supported this function, in https://github.com/alibaba/pouch/blob/master/daemon/mgr/container_utils.go#L262
I think this is a common function.
apis/swagger.yml
Outdated
@@ -3193,6 +3193,11 @@ definitions: | |||
minItems: 1 | |||
items: | |||
type: "string" | |||
Env: | |||
type: "array" | |||
description: "Env for commands" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
envs for exec command in container
I think this is more specific.
@@ -41,7 +41,7 @@ type RegistryServiceConfig struct { | |||
// > are in compliance with any terms that cover redistributing | |||
// > nondistributable artifacts. | |||
// | |||
AllowNondistributableArtifactsCIDRs []string `json:"AllowNondistributableArtifactsCIDRs,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this file when you git commit
. We do not need this change. And the change done by swagger-0.12.0 is because swagger has a bug in itself.
cli/exec.go
Outdated
@@ -51,6 +52,7 @@ func (e *ExecCommand) addFlags() { | |||
flagSet.BoolVarP(&e.Terminal, "tty", "t", false, "Allocate a tty device") | |||
flagSet.BoolVarP(&e.Interactive, "interactive", "i", false, "Open container's STDIN") | |||
flagSet.StringVarP(&e.User, "user", "u", "", "Username or UID (format: <name|uid>[:<group|gid>])") | |||
flagSet.StringArrayVarP(&e.Envs,"env","e", []string{}, "Set environment variables") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set environment variables for exec command in container
daemon/mgr/container_exec.go
Outdated
"github.com/pkg/errors" | ||
"strings" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please package strings
would be in the first part, not in the third-part one.
daemon/mgr/container_exec.go
Outdated
@@ -27,18 +29,48 @@ func (mgr *ContainerManager) CreateExec(ctx context.Context, name string, config | |||
return "", fmt.Errorf("container %s is not running", c.ID) | |||
} | |||
|
|||
Envs := MergeEnvs(c.Config.Env, config.Env) | |||
logrus.Info("Envs", Envs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line of log is Info
, and I think it is too casual. It will add more info log in production. How about changing this into Debugf
?
Please also the corresponding cli integration test for this pull request. Thanks a lot. @knightXun |
@allencloud I will add tests for this. |
@knightXun Thanks for your contribution. 🍻 |
@pouchrobot /test |
LGTM, and would you like to sign the cla again? Since Alibaba org has updated something, then everyone of us needs to sign it again. @knightXun |
Codecov Report
@@ Coverage Diff @@
## master #2250 +/- ##
==========================================
+ Coverage 66.7% 66.74% +0.04%
==========================================
Files 208 208
Lines 16919 16923 +4
==========================================
+ Hits 11286 11296 +10
- Misses 4268 4272 +4
+ Partials 1365 1355 -10
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## master #2250 +/- ##
==========================================
+ Coverage 66.7% 66.74% +0.04%
==========================================
Files 208 208
Lines 16919 16923 +4
==========================================
+ Hits 11286 11296 +10
- Misses 4268 4272 +4
+ Partials 1365 1355 -10
|
@@ -27,11 +27,18 @@ func (mgr *ContainerManager) CreateExec(ctx context.Context, name string, config | |||
return "", fmt.Errorf("container %s is not running", c.ID) | |||
} | |||
|
|||
envs, err := mergeEnvSlice(c.Config.Env, config.Env) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first argu of mergeEnvSlice should config.Env
ping @knightXun cc @HusterWan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will correct it tonight
Ⅰ. Describe what this PR did
Provide new Environments for
pouch exec
Ⅱ. Does this pull request fix one issue?
Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews