Skip to content

Commit

Permalink
added input validations for policy/querypack assignment
Browse files Browse the repository at this point in the history
Signed-off-by: Paul <[email protected]>
  • Loading branch information
Pauti committed Jun 26, 2024
1 parent 59b77be commit 5864427
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions internal/provider/policy_assignment_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ package provider
import (
"context"
"fmt"

"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
mondoov1 "go.mondoo.com/mondoo-go"

"github.com/hashicorp/terraform-plugin-framework/resource"
Expand Down Expand Up @@ -62,6 +65,9 @@ func (r *policyAssignmentResource) Schema(ctx context.Context, req resource.Sche
Default: stringdefault.StaticString("enabled"),
Computed: true,
Optional: true,
Validators: []validator.String{
stringvalidator.OneOf("enabled", "disabled", "preview"),
},
},
},
}
Expand Down
8 changes: 7 additions & 1 deletion internal/provider/querypack_assignment_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ package provider
import (
"context"
"fmt"
"strings"

"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
mondoov1 "go.mondoo.com/mondoo-go"
"strings"

"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand Down Expand Up @@ -63,6 +66,9 @@ func (r *queryPackAssignmentResource) Schema(ctx context.Context, req resource.S
Default: stringdefault.StaticString("enabled"),
Computed: true,
Optional: true,
Validators: []validator.String{
stringvalidator.OneOf("enabled", "disabled"),
},
},
},
}
Expand Down

0 comments on commit 5864427

Please sign in to comment.