summaryrefslogtreecommitdiff
path: root/cmd/podman/common/create.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-09-20 14:02:42 -0400
committerGitHub <noreply@github.com>2021-09-20 14:02:42 -0400
commitfff178fe517406f61fc6ddad00312ee7282e0174 (patch)
tree29567b74d24b7061efdbd7da8d6f93df9a8e732b /cmd/podman/common/create.go
parenta2b367414394e069a7560dc7e189af035abf0973 (diff)
parentcb077c968de08c98eda023f5eeefc7d9d8e79231 (diff)
downloadpodman-fff178fe517406f61fc6ddad00312ee7282e0174.tar.gz
podman-fff178fe517406f61fc6ddad00312ee7282e0174.tar.bz2
podman-fff178fe517406f61fc6ddad00312ee7282e0174.zip
Merge pull request #11601 from cdoern/mapOptions
Created MapOptions for PodCreate
Diffstat (limited to 'cmd/podman/common/create.go')
-rw-r--r--cmd/podman/common/create.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go
index 6200592b4..a65e90fab 100644
--- a/cmd/podman/common/create.go
+++ b/cmd/podman/common/create.go
@@ -15,6 +15,18 @@ const sizeWithUnitFormat = "(format: `<number>[<unit>]`, where unit = b (bytes),
var containerConfig = registry.PodmanConfig()
+// ContainerToPodOptions takes the Container and Pod Create options, assigning the matching values back to podCreate for the purpose of the libpod API
+// For this function to succeed, the JSON tags in PodCreateOptions and ContainerCreateOptions need to match due to the Marshaling and Unmarshaling done.
+// The types of the options also need to match or else the unmarshaling will fail even if the tags match
+func ContainerToPodOptions(containerCreate *entities.ContainerCreateOptions, podCreate *entities.PodCreateOptions) error {
+ contMarshal, err := json.Marshal(containerCreate)
+ if err != nil {
+ return err
+ }
+ return json.Unmarshal(contMarshal, podCreate)
+}
+
+// DefineCreateFlags declares and instantiates the container create flags
func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions, isInfra bool) {
createFlags := cmd.Flags()