Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions pkg/project/stack/azuretf.config.yaml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions pkg/project/stack/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
23 changes: 15 additions & 8 deletions pkg/view/tui/commands/stack/new/stack_new.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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, ", ")),
}
}

Expand Down Expand Up @@ -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)
Expand Down