Skip to content

Commit

Permalink
fix(climc): add scope parameter to pod-exec (#20151)
Browse files Browse the repository at this point in the history
  • Loading branch information
zexi authored Apr 28, 2024
1 parent 360231b commit 0169988
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/climc/shell/compute/server_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ func init() {
})

R(&options.PodExecOptions{}, "pod-exec", "Execute a command in a container", func(s *mcclient.ClientSession, opt *options.PodExecOptions) error {
ctrs, err := modules.Containers.List(s, jsonutils.Marshal(map[string]string{
listOpt := map[string]string{
"guest_id": opt.ID,
}))
}
if len(opt.Scope) != 0 {
listOpt["scope"] = opt.Scope
}
ctrs, err := modules.Containers.List(s, jsonutils.Marshal(listOpt))
if err != nil {
return errors.Wrapf(err, "list containers by guest_id %s", opt.ID)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/mcclient/options/compute/server_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,6 @@ func (o *PodCreateOptions) Params() (*computeapi.ServerCreateInput, error) {

type PodExecOptions struct {
ContainerExecOptions
Scope string `help:"Scope of containers query" choices:"system|domain|project"`
Container string `help:"Container name. If omitted, use the first container." short-token:"c"`
}

0 comments on commit 0169988

Please sign in to comment.