Skip to content

Commit 64f9234

Browse files
fix(project): validate billingReference for standalone public projects
1 parent 3dd453a commit 64f9234

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

internal/cmd/project/create/create.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ func configureFlags(cmd *cobra.Command) {
112112
func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel, error) {
113113
globalFlags := globalflags.Parse(p, cmd)
114114

115+
networkAreaId := flags.FlagToStringPointer(p, cmd, networkAreaIdFlag)
116+
115117
labels := flags.FlagToStringToStringPointer(p, cmd, labelFlag)
116118
if labels != nil {
117119
labelKeyRegex := regexp.MustCompile(labelKeyRegex)
@@ -131,6 +133,18 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
131133
}
132134
}
133135
}
136+
137+
if scope, hasScope := (*labels)["scope"]; hasScope && scope == "PUBLIC" {
138+
_, hasBilling := (*labels)["billingReference"]
139+
140+
if networkAreaId == nil && !hasBilling {
141+
return nil, &errors.FlagValidationError{
142+
Flag: labelFlag,
143+
Details: "creating a standalone public project (without a network area) requires a 'billingReference' label (e.g., --label billingReference=<value>)",
144+
}
145+
}
146+
}
147+
134148
}
135149

136150
model := inputModel{

0 commit comments

Comments
 (0)