- Notifications
You must be signed in to change notification settings - Fork3
fix: skip validating unknown version names#123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -896,9 +896,27 @@ func (a *activeVersionValidator) ValidateList(ctx context.Context, req validator | ||
return | ||
} | ||
// Check all versions have unique names | ||
uniqueNames := make(map[string]struct{}) | ||
for _, version := range data { | ||
if version.Name.IsNull() || version.Name.IsUnknown() { | ||
continue | ||
} | ||
if _, ok := uniqueNames[version.Name.ValueString()]; ok { | ||
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Template version names must be unique. `%s` appears twice.", version.Name.ValueString())) | ||
return | ||
} | ||
uniqueNames[version.Name.ValueString()] = struct{}{} | ||
} | ||
// Check if only one item in Version has active set to true | ||
active := false | ||
for _, version := range data { | ||
// `active` is required, so if it's null or unknown, this is Terraform | ||
// requesting an early validation. | ||
if version.Active.IsNull() || version.Active.IsUnknown() { | ||
return | ||
} | ||
if version.Active.ValueBool() { | ||
if active { | ||
resp.Diagnostics.AddError("Client Error", "Only one template version can be active at a time.") | ||
@@ -910,19 +928,6 @@ func (a *activeVersionValidator) ValidateList(ctx context.Context, req validator | ||
if !active { | ||
resp.Diagnostics.AddError("Client Error", "At least one template version must be active.") | ||
} | ||
MemberAuthor
| ||
} | ||
var _ validator.List = &activeVersionValidator{} | ||
Uh oh!
There was an error while loading.Please reload this page.