diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-09-20 14:02:42 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-20 14:02:42 -0400 |
commit | fff178fe517406f61fc6ddad00312ee7282e0174 (patch) | |
tree | 29567b74d24b7061efdbd7da8d6f93df9a8e732b /cmd/podman/common/create.go | |
parent | a2b367414394e069a7560dc7e189af035abf0973 (diff) | |
parent | cb077c968de08c98eda023f5eeefc7d9d8e79231 (diff) | |
download | podman-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.go | 12 |
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() |