from opta.commands.init_templates.helpers import dictionary_deep_set from opta.commands.init_templates.template import TemplateVariable def apply(d: dict, v: str) -> dict: set_path = dictionary_deep_set(["org_name"]) set_path(d, v) return d orgNameVariable = TemplateVariable(prompt="Org name", applier=apply,)
"us-central1", "us-east1", "us-east4", "us-west1", "us-west2", "us-west3", "us-west4", ] def validate(region_name: str) -> bool: return region_name in REGIONS def apply(d: dict, v: str) -> dict: set_path = dictionary_deep_set(["providers", "google", "region"]) set_path(d, v) return d indented_regions = [f"\t{region}" for region in REGIONS] region_string = "\n".join(indented_regions) gcpRegionVariable = TemplateVariable( prompt="GCP region (you can see a full list at https://cloud.google.com/compute/docs/regions-zones) ", applier=apply, validator=validate, error_message=f"Must be one of\n{region_string}", default_value="us-central1", )
import re from opta.commands.init_templates.helpers import dictionary_deep_set from opta.commands.init_templates.template import TemplateVariable def validate(account_id: str) -> bool: return re.match(r"^\d{12}$", account_id) is not None def apply(d: dict, v: str) -> dict: set_path = dictionary_deep_set(["providers", "aws", "account_id"]) set_path(d, v) return d accountIdVariable = TemplateVariable( prompt="AWS account id", applier=apply, validator=validate, error_message="invalid account id -- must be a string of 12 digits", )
import os from opta.commands.init_templates.helpers import dictionary_deep_set from opta.commands.init_templates.template import TemplateVariable from opta.layer import Layer def apply(d: dict, v: str) -> dict: set_path = dictionary_deep_set(["name"]) set_path(d, v) return d nameVariable = TemplateVariable( prompt="Name", applier=apply, validator=Layer.valid_name, error_message="Invalid name: can only contain letters, dashes and numbers", default_value=os.path.basename(os.getcwd()), )
from opta.commands.init_templates.helpers import set_module_field from opta.commands.init_templates.template import TemplateVariable dnsDomainVariable = TemplateVariable( prompt="DNS domain (e.g. mydomain.dev)", applier=set_module_field("dns", ["domain"]), )
"eu-west-3", "eu-north-1", "me-south-1", "sa-east-1", "us-gov-east-1", "us-gov-west-1", ] def validate(region_name: str) -> bool: return region_name in REGIONS def apply(d: dict, v: str) -> dict: set_path = dictionary_deep_set(["providers", "aws", "region"]) set_path(d, v) return d indented_regions = [f"\t{region}" for region in REGIONS] region_string = "\n".join(indented_regions) awsRegionVariable = TemplateVariable( prompt= "AWS region (you can see a full list at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html)", applier=apply, validator=validate, error_message=f"Must be one of\n{region_string}", default_value="us-east-1", )
"southafricanorth", "southcentralus", "southeastasia", "uksouth", "westeurope", "westus2", "westus3", ] def validate(location_name: str) -> bool: return location_name in LOCATIONS def apply(d: dict, v: str) -> dict: set_path = dictionary_deep_set(["providers", "azurerm", "location"]) set_path(d, v) return d indented_locations = [f"\t{location}" for location in LOCATIONS] location_string = "\n".join(indented_locations) azureLocationVariable = TemplateVariable( prompt="Azure location", applier=apply, validator=validate, error_message=f"Must be one of\n{location_string}", default_value="centralus", )
from opta.commands.init_templates.helpers import dictionary_deep_set from opta.commands.init_templates.template import TemplateVariable def apply(d: dict, v: str) -> dict: set_path = dictionary_deep_set(["providers", "google", "project"]) set_path(d, v) return d gcpProjectVariable = TemplateVariable( prompt="GCP project", applier=apply, )
from opta.commands.init_templates.helpers import dictionary_deep_set from opta.commands.init_templates.template import TemplateVariable def apply(d: dict, v: str) -> dict: set_path = dictionary_deep_set(["providers", "azurerm", "tenant_id"]) set_path(d, v) return d azureTenantIdVariant = TemplateVariable( prompt= "Azure tenant ID (see https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-create-new-tenant)", applier=apply, )
from opta.commands.init_templates.helpers import dictionary_deep_set from opta.commands.init_templates.template import TemplateVariable def apply(d: dict, v: str) -> dict: set_path = dictionary_deep_set(["providers", "azurerm", "subscription_id"]) set_path(d, v) return d azureSubscriptionIdVariable = TemplateVariable( prompt="Azure subscription ID", applier=apply, )