Skip to content

Commit

Permalink
Fix : User and group permission.name validation (#9)
Browse files Browse the repository at this point in the history
* fix: Remove regex validation on user and group permission name

* chore: Print git diff on CI test.generate job
  • Loading branch information
qboileau authored Oct 7, 2024
1 parent 08e35f8 commit 491bed8
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 42 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
- run: go generate ./...
- name: git diff
run: |
git diff --compact-summary
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/user_v2_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestAccUserV2Resource(t *testing.T) {
resource.TestCheckResourceAttr(resourceRef, "spec.lastname", "Beesly"),
resource.TestCheckResourceAttr(resourceRef, "spec.permissions.#", "1"),
resource.TestCheckResourceAttr(resourceRef, "spec.permissions.0.resource_type", "TOPIC"),
resource.TestCheckResourceAttr(resourceRef, "spec.permissions.0.name", "test-topic"),
resource.TestCheckResourceAttr(resourceRef, "spec.permissions.0.name", "team1.test-topic"),
resource.TestCheckResourceAttr(resourceRef, "spec.permissions.0.pattern_type", "LITERAL"),
resource.TestCheckResourceAttr(resourceRef, "spec.permissions.0.cluster", "*"),
resource.TestCheckResourceAttr(resourceRef, "spec.permissions.0.permissions.#", "3"),
Expand All @@ -49,7 +49,7 @@ func TestAccUserV2Resource(t *testing.T) {
resource.TestCheckResourceAttr(resourceRef, "spec.permissions.0.resource_type", "PLATFORM"),
resource.TestCheckResourceAttr(resourceRef, "spec.permissions.0.permissions.#", "4"),
resource.TestCheckResourceAttr(resourceRef, "spec.permissions.1.resource_type", "TOPIC"),
resource.TestCheckResourceAttr(resourceRef, "spec.permissions.1.name", "test-topic"),
resource.TestCheckResourceAttr(resourceRef, "spec.permissions.1.name", "team1.test-topic"),
resource.TestCheckResourceAttr(resourceRef, "spec.permissions.1.pattern_type", "LITERAL"),
resource.TestCheckResourceAttr(resourceRef, "spec.permissions.1.cluster", "*"),
),
Expand Down
3 changes: 0 additions & 3 deletions internal/schema/resource_group_v2/group_v2_resource_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions internal/schema/resource_user_v2/user_v2_resource_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/testdata/user_v2_resource_create.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ resource "conduktor_user_v2" "test" {
{
resource_type = "TOPIC"
permissions = ["topicViewConfig", "topicConsume", "topicProduce"]
name = "test-topic"
name = "team1.test-topic"
pattern_type = "LITERAL"
cluster = "*"
}
Expand Down
2 changes: 1 addition & 1 deletion internal/testdata/user_v2_resource_update.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ resource "conduktor_user_v2" "test" {
{
resource_type = "TOPIC"
permissions = ["topicViewConfig", "topicConsume", "topicProduce"]
name = "test-topic"
name = "team1.test-topic"
pattern_type = "LITERAL"
cluster = "*"
}
Expand Down
34 changes: 2 additions & 32 deletions provider_code_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,7 @@
"name": "name",
"string": {
"description": "Name of the resource to apply permission could be a topic, a cluster, a consumer group, etc. depending on resource_type",
"computed_optional_required": "optional",
"validators": [
{
"custom": {
"imports": [
{
"path": "regexp"
},
{
"path": "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
}
],
"schema_definition": "stringvalidator.RegexMatches(regexp.MustCompile(\"^[0-9a-z\\\\_\\\\-\\\\*]+$\"), \"\")"
}
}
]
"computed_optional_required": "optional"
}
},
{
Expand Down Expand Up @@ -394,22 +379,7 @@
"name": "name",
"string": {
"description": "Name of the resource to apply permission could be a topic, a cluster, a consumer group, etc. depending on resource_type",
"computed_optional_required": "optional",
"validators": [
{
"custom": {
"imports": [
{
"path": "regexp"
},
{
"path": "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
}
],
"schema_definition": "stringvalidator.RegexMatches(regexp.MustCompile(\"^[0-9a-z\\\\_\\\\-\\\\*]+$\"), \"\")"
}
}
]
"computed_optional_required": "optional"
}
},
{
Expand Down

0 comments on commit 491bed8

Please sign in to comment.