diff --git a/pkg/project/stack/azuretf.config.yaml b/pkg/project/stack/azuretf.config.yaml new file mode 100644 index 000000000..dfb4d0912 --- /dev/null +++ b/pkg/project/stack/azuretf.config.yaml @@ -0,0 +1,44 @@ +# The provider to use and it's published version +# See releases: +# https://github.com/nitrictech/nitric/tags +provider: nitric/azuretf@{{.Version}} +# The target Azure region to deploy to +# See available regions: +# https://azure.microsoft.com/en-us/explore/global-infrastructure/products-by-region/?products=container-apps +region: + +# Org to associate deployed API Management services with +org: + +# Subscription ID to associate deployed services with +subscription-id: + +# Admin email to associate deployed API Management services with, this can be any email address +adminemail: test@example.com +# Optional configuration below + +# # Configure your deployed functions/services +# config: +# # How functions without a type will be deployed +# default: +# # configure a sample rate for telemetry (between 0 and 1) e.g. 0.5 is 50% +# telemetry: 0 +# # configure functions to deploy to Google Cloud Run +# # see: https://learn.microsoft.com/en-us/azure/container-apps/containers#configuration +# containerapps: # Available since v0.26.0 +# # set 1/4 vCPU +# cpu: 0.25 +# # set 0.5GB of RAM +# memory: 0.5 +# # The minimum number of instances to scale down to +# min-replicas: 0 +# # The maximum number of instances to scale up to +# max-replicas: 10 +# # Additional deployment types +# # You can target these types by setting a `type` in your project configuration +# big-service: +# telemetry: 0 +# containerapps: +# memory: 1 +# min-replicas: 2 +# max-replicas: 100 diff --git a/pkg/project/stack/stack.go b/pkg/project/stack/stack.go index 31cece66a..5a1ca847e 100644 --- a/pkg/project/stack/stack.go +++ b/pkg/project/stack/stack.go @@ -52,6 +52,9 @@ var gcpConfigTemplate string //go:embed gcptf.config.yaml var gcpTfConfigTemplate string +//go:embed azuretf.config.yaml +var azureTfConfigTemplate string + var fileNameRegex = regexp.MustCompile(`(?i)^nitric\.(\S+)\.ya?ml$`) func IsValidFileName(stackName string) bool { @@ -78,6 +81,8 @@ func NewStackFile(fs afero.Fs, providerName string, stackName string, dir string templateStr = awsTfConfigTemplate case "gcp-tf": templateStr = gcpTfConfigTemplate + case "azure-tf": + templateStr = azureTfConfigTemplate } // Parse and execute the template with the version injected diff --git a/pkg/view/tui/commands/stack/new/stack_new.go b/pkg/view/tui/commands/stack/new/stack_new.go index e1478fc78..4d59f075d 100644 --- a/pkg/view/tui/commands/stack/new/stack_new.go +++ b/pkg/view/tui/commands/stack/new/stack_new.go @@ -295,14 +295,15 @@ func stackNameExistsValidator(projectDir string) validation.StringValidator { } const ( - Aws = "Pulumi AWS" - Azure = "Pulumi Azure" - Gcp = "Pulumi Google Cloud" - AwsTf = "Terraform AWS (Preview)" - GcpTf = "Terraform Google Cloud (Preview)" + Aws = "Pulumi AWS" + Azure = "Pulumi Azure" + Gcp = "Pulumi Google Cloud" + AwsTf = "Terraform AWS (Preview)" + AzureTf = "Terraform Azure (Preview)" + GcpTf = "Terraform Google Cloud (Preview)" ) -var availableProviders = []string{Aws, Gcp, Azure, AwsTf, GcpTf} +var availableProviders = []string{Aws, Gcp, Azure, AwsTf, GcpTf, AzureTf} func New(fs afero.Fs, args Args) Model { // Load and update the project name in the template's nitric.yaml @@ -347,9 +348,13 @@ func New(fs afero.Fs, args Args) Model { } if args.ProviderName != "" { - if !lo.Contains([]string{"aws", "azure", "gcp", "aws-tf"}, args.ProviderName) { + validProviders := lo.Map(availableProviders, func(p string, _ int) string { + return providerLabelToValue(p) + }) + + if !lo.Contains(validProviders, args.ProviderName) { return Model{ - err: fmt.Errorf("cloud name is not valid, must be aws, azure, gcp, or aws-tf"), + err: fmt.Errorf("cloud name is not valid, must be one of: %v", strings.Join(validProviders, ", ")), } } @@ -394,6 +399,8 @@ func providerLabelToValue(provider string) string { return "aws-tf" case GcpTf: return "gcp-tf" + case AzureTf: + return "azure-tf" } return strings.ToLower(provider)