Skip to content

Commit

Permalink
config validation throws warnings, not errors
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbloss committed Dec 13, 2024
1 parent 7bfae0b commit 729760f
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion opslevel/resource_opslevel_check_alert_source_usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (r *CheckAlertSourceUsageResource) ValidateConfig(ctx context.Context, req
predicateModel, diags := PredicateObjectToModel(ctx, alertNamePredicate)
resp.Diagnostics.Append(diags...)
if err := predicateModel.Validate(); err != nil {
resp.Diagnostics.AddAttributeError(path.Root("alert_name_predicate"), "Invalid Attribute Configuration", err.Error())
resp.Diagnostics.AddAttributeWarning(path.Root("alert_name_predicate"), "Invalid Attribute Configuration", err.Error())
}
}

Expand Down
2 changes: 1 addition & 1 deletion opslevel/resource_opslevel_check_package_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (r *CheckPackageVersionResource) ValidateConfig(ctx context.Context, req re
resp.Diagnostics.AddError("version_constraint_predicate", fmt.Sprintf("version_constraint_predicate must be one of %v", packageVersionPossiblePredicateTypes))
} else {
if err := predicateModel.Validate(); err != nil {
resp.Diagnostics.AddAttributeError(path.Root("version_constraint_predicate"), "Invalid Configuration", err.Error())
resp.Diagnostics.AddAttributeWarning(path.Root("version_constraint_predicate"), "Invalid Configuration", err.Error())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion opslevel/resource_opslevel_check_repository_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (r *CheckRepositoryFileResource) ValidateConfig(ctx context.Context, req re
predicateModel, diags := PredicateObjectToModel(ctx, fileContentsPredicate)
resp.Diagnostics.Append(diags...)
if err := predicateModel.Validate(); err != nil {
resp.Diagnostics.AddAttributeError(path.Root("file_contents_predicate"), "Invalid Attribute Configuration", err.Error())
resp.Diagnostics.AddAttributeWarning(path.Root("file_contents_predicate"), "Invalid Attribute Configuration", err.Error())
}
}

Expand Down
2 changes: 1 addition & 1 deletion opslevel/resource_opslevel_check_repository_grep.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (r *CheckRepositoryGrepResource) ValidateConfig(ctx context.Context, req re
resp.Diagnostics.AddError("Config Error", "When 'directory_search' is true, file_contents_predicate type must be 'exists' or 'does_not_exist'")
}
if err := predicateModel.Validate(); err != nil {
resp.Diagnostics.AddAttributeError(path.Root("file_contents_predicate"), "Invalid Attribute Configuration", err.Error())
resp.Diagnostics.AddAttributeWarning(path.Root("file_contents_predicate"), "Invalid Attribute Configuration", err.Error())
}
}

Expand Down
2 changes: 1 addition & 1 deletion opslevel/resource_opslevel_check_repository_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (r *CheckRepositorySearchResource) ValidateConfig(ctx context.Context, req
resp.Diagnostics.AddError("Config Error", "file_contents_predicate type must not be 'exists' or 'does_not_exist'")
}
if err := predicateModel.Validate(); err != nil {
resp.Diagnostics.AddAttributeError(path.Root("file_contents_predicate"), "Invalid Attribute Configuration", err.Error())
resp.Diagnostics.AddAttributeWarning(path.Root("file_contents_predicate"), "Invalid Attribute Configuration", err.Error())
}
}

Expand Down
2 changes: 1 addition & 1 deletion opslevel/resource_opslevel_check_service_ownership.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (r *CheckServiceOwnershipResource) ValidateConfig(ctx context.Context, req
predicateModel, diags := PredicateObjectToModel(ctx, tagPredicate)
resp.Diagnostics.Append(diags...)
if err := predicateModel.Validate(); err != nil {
resp.Diagnostics.AddAttributeError(path.Root("tag_predicate"), "Invalid Attribute Configuration", err.Error())
resp.Diagnostics.AddAttributeWarning(path.Root("tag_predicate"), "Invalid Attribute Configuration", err.Error())
}
}

Expand Down
2 changes: 1 addition & 1 deletion opslevel/resource_opslevel_check_service_property.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (r *CheckServicePropertyResource) ValidateConfig(ctx context.Context, req r
predicateModel, diags := PredicateObjectToModel(ctx, predicate)
resp.Diagnostics.Append(diags...)
if err := predicateModel.Validate(); err != nil {
resp.Diagnostics.AddAttributeError(path.Root("predicate"), "Invalid Attribute Configuration", err.Error())
resp.Diagnostics.AddAttributeWarning(path.Root("predicate"), "Invalid Attribute Configuration", err.Error())
}
}

Expand Down
2 changes: 1 addition & 1 deletion opslevel/resource_opslevel_check_tag_defined.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (r *CheckTagDefinedResource) ValidateConfig(ctx context.Context, req resour
predicateModel, diags := PredicateObjectToModel(ctx, tagPredicate)
resp.Diagnostics.Append(diags...)
if err := predicateModel.Validate(); err != nil {
resp.Diagnostics.AddAttributeError(path.Root("tag_predicate"), "Invalid Attribute Configuration", err.Error())
resp.Diagnostics.AddAttributeWarning(path.Root("tag_predicate"), "Invalid Attribute Configuration", err.Error())
}
}

Expand Down
2 changes: 1 addition & 1 deletion opslevel/resource_opslevel_check_tool_usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (r *CheckToolUsageResource) ValidateConfig(ctx context.Context, req resourc
predicateModel, diags := PredicateObjectToModel(ctx, predicate)
resp.Diagnostics.Append(diags...)
if err := predicateModel.Validate(); err != nil {
resp.Diagnostics.AddAttributeError(path.Root(predicateSchemaName), "Invalid Attribute Configuration", err.Error())
resp.Diagnostics.AddAttributeWarning(path.Root(predicateSchemaName), "Invalid Attribute Configuration", err.Error())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion opslevel/resource_opslevel_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (r *FilterResource) ValidateConfig(ctx context.Context, req resource.Valida

for _, filterPredicate := range predicateModels {
if err := filterPredicate.Validate(); err != nil {
resp.Diagnostics.AddAttributeError(path.Root("predicate"), "Invalid Attribute Configuration", err.Error())
resp.Diagnostics.AddAttributeWarning(path.Root("predicate"), "Invalid Attribute Configuration", err.Error())
}
}
}
Expand Down

0 comments on commit 729760f

Please sign in to comment.