From 729760f3e18272678dbdd353ad950d4ff2c36001 Mon Sep 17 00:00:00 2001 From: David Bloss Date: Fri, 13 Dec 2024 10:06:04 -0600 Subject: [PATCH] config validation throws warnings, not errors --- opslevel/resource_opslevel_check_alert_source_usage.go | 2 +- opslevel/resource_opslevel_check_package_version.go | 2 +- opslevel/resource_opslevel_check_repository_file.go | 2 +- opslevel/resource_opslevel_check_repository_grep.go | 2 +- opslevel/resource_opslevel_check_repository_search.go | 2 +- opslevel/resource_opslevel_check_service_ownership.go | 2 +- opslevel/resource_opslevel_check_service_property.go | 2 +- opslevel/resource_opslevel_check_tag_defined.go | 2 +- opslevel/resource_opslevel_check_tool_usage.go | 2 +- opslevel/resource_opslevel_filter.go | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/opslevel/resource_opslevel_check_alert_source_usage.go b/opslevel/resource_opslevel_check_alert_source_usage.go index c7defe0b..a03ba823 100644 --- a/opslevel/resource_opslevel_check_alert_source_usage.go +++ b/opslevel/resource_opslevel_check_alert_source_usage.go @@ -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()) } } diff --git a/opslevel/resource_opslevel_check_package_version.go b/opslevel/resource_opslevel_check_package_version.go index c5b58b04..f68bc8f4 100644 --- a/opslevel/resource_opslevel_check_package_version.go +++ b/opslevel/resource_opslevel_check_package_version.go @@ -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()) } } } diff --git a/opslevel/resource_opslevel_check_repository_file.go b/opslevel/resource_opslevel_check_repository_file.go index 39186b77..f5cb02f1 100644 --- a/opslevel/resource_opslevel_check_repository_file.go +++ b/opslevel/resource_opslevel_check_repository_file.go @@ -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()) } } diff --git a/opslevel/resource_opslevel_check_repository_grep.go b/opslevel/resource_opslevel_check_repository_grep.go index ec559df9..8fc318aa 100644 --- a/opslevel/resource_opslevel_check_repository_grep.go +++ b/opslevel/resource_opslevel_check_repository_grep.go @@ -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()) } } diff --git a/opslevel/resource_opslevel_check_repository_search.go b/opslevel/resource_opslevel_check_repository_search.go index d4c40864..168fc61f 100644 --- a/opslevel/resource_opslevel_check_repository_search.go +++ b/opslevel/resource_opslevel_check_repository_search.go @@ -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()) } } diff --git a/opslevel/resource_opslevel_check_service_ownership.go b/opslevel/resource_opslevel_check_service_ownership.go index 7e1c976c..4f292c91 100644 --- a/opslevel/resource_opslevel_check_service_ownership.go +++ b/opslevel/resource_opslevel_check_service_ownership.go @@ -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()) } } diff --git a/opslevel/resource_opslevel_check_service_property.go b/opslevel/resource_opslevel_check_service_property.go index 56e3b8ca..d8ce43f0 100644 --- a/opslevel/resource_opslevel_check_service_property.go +++ b/opslevel/resource_opslevel_check_service_property.go @@ -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()) } } diff --git a/opslevel/resource_opslevel_check_tag_defined.go b/opslevel/resource_opslevel_check_tag_defined.go index 0326826d..10ed16d3 100644 --- a/opslevel/resource_opslevel_check_tag_defined.go +++ b/opslevel/resource_opslevel_check_tag_defined.go @@ -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()) } } diff --git a/opslevel/resource_opslevel_check_tool_usage.go b/opslevel/resource_opslevel_check_tool_usage.go index 488eda81..430d6c69 100644 --- a/opslevel/resource_opslevel_check_tool_usage.go +++ b/opslevel/resource_opslevel_check_tool_usage.go @@ -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()) } } } diff --git a/opslevel/resource_opslevel_filter.go b/opslevel/resource_opslevel_filter.go index f8eeece9..8d7fee45 100644 --- a/opslevel/resource_opslevel_filter.go +++ b/opslevel/resource_opslevel_filter.go @@ -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()) } } }