MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / run

Function run

misc/python/materialize/cli/scratch/destroy.py:37–69  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

35
36
37def run(args: argparse.Namespace) -> None:
38 if args.all_mine and args.instances:
39 print(
40 "scratch: error: cannot specify --all-mine and instance IDs",
41 file=sys.stderr,
42 )
43 sys.exit(1)
44
45 if args.all_mine:
46 instances = [
47 i
48 for i in list_all_instances()
49 if i.state
50 and i.state["Name"] in ("pending", "running", "stopping", "stopped")
51 ]
52 elif args.instances:
53 instances = [get_instance(id) for id in args.instances]
54 else:
55 instances = [pick_instance()]
56
57 if not instances:
58 print("No instances to destroy.")
59 return
60
61 print("Destroying instances:")
62 print_instances(instances, args.output_format)
63
64 if not args.yes and not ui.confirm("Would you like to continue?"):
65 sys.exit(0)
66
67 for instance in instances:
68 instance.terminate()
69 print("Instances destroyed.")

Callers

nothing calls this directly

Calls 5

list_all_instancesFunction · 0.90
get_instanceFunction · 0.90
pick_instanceFunction · 0.90
print_instancesFunction · 0.90
terminateMethod · 0.45

Tested by

no test coverage detected