Skip to content

Commit

Permalink
Implement Podman Container Clone
Browse files Browse the repository at this point in the history
podman container clone takes the id of an existing continer and creates a specgen from the given container's config
recreating all proper namespaces and overriding spec options like resource limits and the container name if given in the cli options

this command utilizes the common function DefineCreateFlags meaning that we can funnel as many create options as we want
into clone over time allowing the user to clone with as much or as little of the original config as they want.

container clone takes a second argument which is a new name and a third argument which is an image name to use instead of the original container's

the current supported flags are:

--destroy (remove the original container)
--name (new ctr name)
--cpus (sets cpu period and quota)
--cpuset-cpus
--cpu-period
--cpu-rt-period
--cpu-rt-runtime
--cpu-shares
--cpuset-mems
--memory
--run

resolves containers#10875

Signed-off-by: cdoern <cdoern@redhat.com>
Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
Signed-off-by: cdoern <cdoern@redhat.com>
  • Loading branch information
cdoern committed Feb 21, 2022
1 parent f918a94 commit 94df701
Show file tree
Hide file tree
Showing 28 changed files with 1,215 additions and 328 deletions.
14 changes: 14 additions & 0 deletions cmd/podman/common/completion.go
Expand Up @@ -1308,3 +1308,17 @@ func AutocompleteCompressionFormat(cmd *cobra.Command, args []string, toComplete
types := []string{"gzip", "zstd", "zstd:chunked"}
return types, cobra.ShellCompDirectiveNoFileComp
}

// AutocompleteClone - Autocomplete container and image names
func AutocompleteClone(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if !validCurrentCmdLine(cmd, args, toComplete) {
return nil, cobra.ShellCompDirectiveNoFileComp
}
switch len(args) {
case 0:
return getContainers(cmd, toComplete, completeDefault)
case 2:
return getImages(cmd, toComplete)
}
return nil, cobra.ShellCompDirectiveNoFileComp
}

0 comments on commit 94df701

Please sign in to comment.