Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(project_user): invite error handling #1371

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ nav_order: 1

# Changelog


## [3.13.3] - 2023-09-28

- Fix `aiven_project_user` 409 error handling

## [3.13.2] - 2023-06-01

- Improve Kafka Topic 404 error handling
Expand Down
2 changes: 2 additions & 0 deletions internal/service/kafka/kafka_topic_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func TestGetTopicCache(t *testing.T) {
&kafkaTopicCache{
internal: make(map[string]map[string]aiven.KafkaTopic),
inQueue: make(map[string][]string),
missing: make(map[string][]string),
v1list: make(map[string][]string),
},
ivan-savciuc marked this conversation as resolved.
Show resolved Hide resolved
},
}
Expand Down
12 changes: 11 additions & 1 deletion internal/service/project/project_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ func ResourceProjectUser() *schema.Resource {
}
}

// isProjectUserAlreadyInvited return true if user already been invited to the project
func isProjectUserAlreadyInvited(err error) bool {
if e, ok := err.(aiven.Error); ok {
if strings.Contains(e.Message, "already been invited to this project") && e.Status == 409 {
return true
}
}
return false
}

func resourceProjectUserCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
client := m.(*aiven.Client)
projectName := d.Get("project").(string)
Expand All @@ -58,7 +68,7 @@ func resourceProjectUserCreate(ctx context.Context, d *schema.ResourceData, m in
MemberType: d.Get("member_type").(string),
},
)
if err != nil {
if err != nil && !isProjectUserAlreadyInvited(err) {
return diag.FromErr(err)
}

Expand Down
Loading