-
Notifications
You must be signed in to change notification settings - Fork 60
Conversation
7dd0dc1
to
bf5b3ae
Compare
Could you document this, please? |
d564ce0
to
aedb206
Compare
Done. |
@iaguis 👍 |
|
||
for p, _ := range dockerConfig.Volumes { | ||
n := filepath.Join("volume-", p) | ||
sn, err := appctypes.SanitizeACName(n) |
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.
Hrm maybe a corner case but don't we need to deal with duplicates? e.g. /data#
, /data$
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.
Yes we do, thanks!
LGTM modulo question about duplicates. |
mps := []appctypes.MountPoint{} | ||
dup := make(map[string]int) | ||
|
||
for p, _ := range dockerVolumes { |
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.
No need for the underline, you can simply type p := range dockerVolumes
.
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.
Right
A Docker image can specify Volumes which are akin to mountPoints in the appc spec. This commit converts Volumes to mountPoints allowing the user to mount volumes with rkt's --volume option. Since Docker doesn't name Volumes but the appc spec requires a name, we generate a name by appending the path to "volume-". That is, if a Volume has "/var/tmp" as path, the resulting mountPoint name will be "volume-/var/tmp". A mountPoint name must be a valid ACName so any invalid characters will be replaced by a "-".
We're converting Docker Volumes to mountPoints but the user doesn't know it nor their names unless she looks manually in the manifest. This commit prints the converted volumes: their name, path inside the container and whether they're read-only or not.
And add example.
Converting Docker Volumes to mountPoints can result in duplicates. For example, if there're two Docker Volumes with paths "/data#", "/data$" and "/data-" the resulting mountPoints will have the same name: "volume-/data". This commit adds the "-N" suffix to duplicated mountPoint names, where N is a number starting from 1. In the previous example, the names would be "volume-/data", "volume-/data-1" and "volume-/data-2".
@@ -65,6 +68,12 @@ func runDocker2ACI(arg string, flagNoSquash bool, flagImage string, flagDebug bo | |||
return fmt.Errorf("conversion error: %v", err) | |||
} | |||
|
|||
if squash { |
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.
What about printing converted volumes in non-squashing scenario?
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 can add it. It looks a bit ugly because there will be a lot of repeated volumes:
Converted volumes in "postgres-26bdc4facea7aad8cfdf3da846e3767bfa027fc0b3c621501f8d7a2413fd24e2-latest-linux-amd64.aci":
name: "volume-/var/lib/postgresql/data", path: "/var/lib/postgresql/data", readOnly: false
Converted volumes in "postgres-3508d36eab9991998d587938711fd19286205eb1a7e994fc4df804ab08e14013-latest-linux-amd64.aci":
name: "volume-/var/lib/postgresql/data", path: "/var/lib/postgresql/data", readOnly: false
Converted volumes in "postgres-86cff6f79a0869259cd911587f61282d9c7a5afc87ca425290cfc781cfaa83bd-latest-linux-amd64.aci":
name: "volume-/var/lib/postgresql/data", path: "/var/lib/postgresql/data", readOnly: false
Converted volumes in "postgres-9c5489b55573bdc2e214f35ed102543845c0de6ca5df10eb5c037ee93a126002-latest-linux-amd64.aci":
name: "volume-/var/lib/postgresql/data", path: "/var/lib/postgresql/data", readOnly: false
Converted volumes in "postgres-dcce0da1c31105323a840ded6e79f39b7338907f5c2477109b68692e7acb75be-latest-linux-amd64.aci":
name: "volume-/var/lib/postgresql/data", path: "/var/lib/postgresql/data", readOnly: false
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.
Hm, then maybe deduping it beforehand would be useful?
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, I dedup the mountpoints before printing them
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.
And I hate go for its lack of generics
Downloading layer: d47fc7449244382dc6121e68100a2c677f4964b495c5bdbbe2975be21777151e | ||
Downloading layer: f2fb89b0a711a7178528c7785d247ba3572924353b0d5e23e9b28f0518253b22 | ||
|
||
Converted volumes in "redis-latest.aci": |
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 actually is not printed. :P
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 is still a WIP 😬
Updated. |
@@ -73,6 +80,41 @@ func runDocker2ACI(arg string, flagNoSquash bool, flagImage string, flagDebug bo | |||
return nil | |||
} | |||
|
|||
func printConvertedVolumes(aciPaths []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.
I would pass just a string instead of an array. Or at least document why we are using only last element here.
LGTM. |
😃 |
Convert Docker Volumes to mountPoints
A Docker image can specify Volumes which are akin to mountPoints in the
appc spec. This commit converts Volumes to mountPoints allowing the user
to mount volumes with rkt's --volume option.
Since Docker doesn't name Volumes but the appc spec requires a name, we
generate a name by appending the path to "volume-". That is, if a Volume
has "/var/tmp" as path, the resulting mountPoint name will be
"volume-/var/tmp". A mountPoint name must be a valid ACName so any
invalid characters will be replaced by a "-".