in deploy/azure/generate_dev_template.py [0:0]
def parse_args(argv):
"""
Parse command-line arguments.
:param argv: The arguments
:return: Parsed argparse namespace
"""
will_call_az_cli = "--deploy" in argv
parser = argparse.ArgumentParser(description="Deploy Azure resources for a single account")
parser.add_argument(
"--template-type",
help="The type of template to use",
default="single-account",
choices=["single-account", "organization-account"],
)
parser.add_argument(
"--output-file",
help="The output file to write the modified template to",
default=None, # Replace later
)
parser.add_argument("--deploy", help="Perform deployment", action="store_true")
parser.add_argument(
"--resource-group",
help="The resource group to deploy to",
default=f"{os.environ.get('USER', 'unknown')}-cloudbeat-dev-{int(time.time())}",
)
parser.add_argument("--location", help="The location to deploy to", default=os.environ.get("LOCATION", "centralus"))
parser.add_argument("--subscription-id", help="The subscription ID to deploy to (defaults to current)")
parser.add_argument("--management-group-id", help="The management group ID to deploy to")
parser.add_argument("--public-ssh-key", help="SSH public key to use for the VMs", required=will_call_az_cli)
parser.add_argument("--artifact-server", help="The URL of the artifact server", required=will_call_az_cli)
parser.add_argument(
"--elastic-agent-version",
help="The version of elastic-agent to install",
default=os.environ.get("ELK_VERSION", ""),
)
parser.add_argument("--fleet-url", help="The fleet URL of elastic-agent", required=will_call_az_cli)
parser.add_argument("--enrollment-token", help="The enrollment token of elastic-agent", required=will_call_az_cli)
args = parser.parse_args(argv)
if args.deploy != will_call_az_cli:
parser.error("Assertion failed: --deploy detected but parser returned different result")
args.template_file = pathlib.Path(__file__).parent / f"ARM-for-{args.template_type}.json"
if args.output_file is None:
args.output_file = str(args.template_file).replace(".json", ".dev.json")
if args.template_type == "single-account" and args.management_group_id is not None:
parser.error("Cannot specify management group for single-account template")
elif args.deploy and args.template_type == "organization-account" and args.management_group_id is None:
parser.error("Must specify management group for organization-account template")
return args