-
Notifications
You must be signed in to change notification settings - Fork 949
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 volumes-from for container #1131
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1131 +/- ##
==========================================
- Coverage 15.57% 15.33% -0.25%
==========================================
Files 172 173 +1
Lines 9727 9782 +55
==========================================
- Hits 1515 1500 -15
- Misses 8103 8174 +71
+ Partials 109 108 -1
|
@@ -80,6 +80,7 @@ func addCommonFlags(flagSet *pflag.FlagSet) *container { | |||
flagSet.StringVar(&c.utsMode, "uts", "", "UTS namespace to use") | |||
|
|||
flagSet.StringSliceVarP(&c.volume, "volume", "v", nil, "Bind mount volumes to container, format is: [source:]<destination>[:mode], [source] can be volume or host's path, <destination> is container's path, [mode] can be \"ro/rw/dr/rr/z/Z/nocopy/private/rprivate/slave/rslave/shared/rshared\"") | |||
flagSet.StringSliceVar(&c.volumesFrom, "volumes-from", nil, "set volumes from other containers, format is <container>[:mode]") |
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 think it is other container
, since we cannot set volumes for multiple containers.
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 don't think so, the api VolumesFrom
is a slice, it means it can use more than one container's volumes.
daemon/mgr/container.go
Outdated
@@ -1592,6 +1634,21 @@ func checkBind(b string) ([]string, error) { | |||
return arr, nil | |||
} | |||
|
|||
func parseVolumesFrom(volume string) (string, string, error) { |
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 move this part into pkg opts.
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.
OK
Could we add some integration test for this PR. Thanks a lot. @rudyfly |
May I give some suggestions about integration tests, I would prefer tests like following: Positive test:
|
test/cli_run_test.go
Outdated
for _, line := range strings.Split(out, "\n") { | ||
if strings.Contains(line, "\"volumesfrom-test-volume\": \"/mnt\"") { | ||
volumeFound = true | ||
continue |
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.
break?
Add volumes-from for container, container can use the volumes of another containers. The format is "<containerID>[:mode]" Signed-off-by: Rudy Zhang <[email protected]>
LGTM |
Ⅰ. Describe what this PR did
Add volumes-from for container, container can use the volumes of another
containers. The format is
<containerID>[:mode]
Ⅱ. Does this pull request fix one issue?
fixes #463
Ⅲ. Describe how you did it
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews
Signed-off-by: Rudy Zhang [email protected]