Execute implements subcommands.Command.Execute.
(_ context.Context, f *flag.FlagSet, args ...any)
| 250 | |
| 251 | // Execute implements subcommands.Command.Execute. |
| 252 | func (s *Spec) Execute(_ context.Context, f *flag.FlagSet, args ...any) subcommands.ExitStatus { |
| 253 | // Grab the arguments. |
| 254 | containerArgs := f.Args() |
| 255 | if len(containerArgs) == 0 { |
| 256 | containerArgs = []string{"sh"} |
| 257 | } |
| 258 | |
| 259 | confPath := filepath.Join(s.bundle, "config.json") |
| 260 | if _, err := os.Stat(confPath); !os.IsNotExist(err) { |
| 261 | util.Fatalf("file %q already exists", confPath) |
| 262 | } |
| 263 | |
| 264 | configFile, err := os.OpenFile(confPath, os.O_WRONLY|os.O_CREATE, 0664) |
| 265 | if err != nil { |
| 266 | util.Fatalf("opening file %q: %v", confPath, err) |
| 267 | } |
| 268 | |
| 269 | err = writeSpec(configFile, s.cwd, s.netns, containerArgs, s.tpu) |
| 270 | if err != nil { |
| 271 | util.Fatalf("writing to %q: %v", confPath, err) |
| 272 | } |
| 273 | |
| 274 | return subcommands.ExitSuccess |
| 275 | } |