Merge pull request #57 from mrunalp/pod_name_param
Allow overriding name in a pod sandbox config file
This commit is contained in:
commit
fe774f82b1
1 changed files with 12 additions and 2 deletions
|
@ -29,6 +29,11 @@ var runPodSandboxCommand = cli.Command{
|
|||
Value: "config.json",
|
||||
Usage: "the path of a pod sandbox config file",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "name",
|
||||
Value: "",
|
||||
Usage: "the name of the pod sandbox",
|
||||
},
|
||||
},
|
||||
Action: func(context *cli.Context) error {
|
||||
// Set up a connection to the server.
|
||||
|
@ -40,7 +45,7 @@ var runPodSandboxCommand = cli.Command{
|
|||
client := pb.NewRuntimeServiceClient(conn)
|
||||
|
||||
// Test RuntimeServiceClient.RunPodSandbox
|
||||
err = RunPodSandbox(client, context.String("config"))
|
||||
err = RunPodSandbox(client, context.String("config"), context.String("name"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Creating the pod sandbox failed: %v", err)
|
||||
}
|
||||
|
@ -151,12 +156,17 @@ var listPodSandboxCommand = cli.Command{
|
|||
|
||||
// RunPodSandbox sends a RunPodSandboxRequest to the server, and parses
|
||||
// the returned RunPodSandboxResponse.
|
||||
func RunPodSandbox(client pb.RuntimeServiceClient, path string) error {
|
||||
func RunPodSandbox(client pb.RuntimeServiceClient, path string, name string) error {
|
||||
config, err := loadPodSandboxConfig(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Override the name by the one specified through CLI
|
||||
if name != "" {
|
||||
config.Metadata.Name = &name
|
||||
}
|
||||
|
||||
r, err := client.RunPodSandbox(context.Background(), &pb.RunPodSandboxRequest{Config: config})
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in a new issue