Skip to content

Commit a9ea6c3

Browse files
committed
Improve functions naming
1 parent 41892b0 commit a9ea6c3

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

internal/provider/data_source_openai_project_user.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ func dataSourceOpenAIProjectUser() *schema.Resource {
4747
}
4848
}
4949

50-
// findProjectUserWithPaginationDataSource finds a user in a project by ID with automatic pagination.
50+
// dataSourceFindProjectUser finds a user in a project by ID with automatic pagination.
5151
// This is used by the data source to ensure proper user lookups across all pages.
52-
func findProjectUserWithPaginationDataSource(ctx context.Context, c interface{}, projectID, userID string) (*client.ProjectUser, bool, error) {
52+
func dataSourceFindProjectUser(ctx context.Context, c interface{}, projectID, userID string) (*client.ProjectUser, bool, error) {
5353
clientInstance, err := GetOpenAIClientWithAdminKey(c)
5454
if err != nil {
5555
return nil, false, err
@@ -90,9 +90,9 @@ func findProjectUserWithPaginationDataSource(ctx context.Context, c interface{},
9090
return nil, false, nil
9191
}
9292

93-
// findProjectUserByEmailWithPaginationDataSource finds a user in a project by email with automatic pagination.
93+
// dataSourceFindProjectUserByEmail finds a user in a project by email with automatic pagination.
9494
// This is used by the data source to ensure proper user lookups across all pages.
95-
func findProjectUserByEmailWithPaginationDataSource(ctx context.Context, c interface{}, projectID, email string) (*client.ProjectUser, bool, error) {
95+
func dataSourceFindProjectUserByEmail(ctx context.Context, c interface{}, projectID, email string) (*client.ProjectUser, bool, error) {
9696
clientInstance, err := GetOpenAIClientWithAdminKey(c)
9797
if err != nil {
9898
return nil, false, err
@@ -157,7 +157,7 @@ func dataSourceOpenAIProjectUserRead(ctx context.Context, d *schema.ResourceData
157157
tflog.Debug(ctx, fmt.Sprintf("Checking if user %s exists in project %s", userID, projectID))
158158

159159
// Check if the user exists in the project using the provider's API key
160-
projectUser, exists, err = findProjectUserWithPaginationDataSource(ctx, m, projectID, userID)
160+
projectUser, exists, err = dataSourceFindProjectUser(ctx, m, projectID, userID)
161161
if err != nil {
162162
tflog.Error(ctx, fmt.Sprintf("Error checking if user exists: %v", err))
163163
return diag.Errorf("Error checking if user exists in project: %s", err)
@@ -179,7 +179,7 @@ func dataSourceOpenAIProjectUserRead(ctx context.Context, d *schema.ResourceData
179179
tflog.Debug(ctx, fmt.Sprintf("Checking if user with email %s exists in project %s", email, projectID))
180180

181181
// Check if the user exists in the project by email using the provider's API key
182-
projectUser, exists, err = findProjectUserByEmailWithPaginationDataSource(ctx, m, projectID, email)
182+
projectUser, exists, err = dataSourceFindProjectUserByEmail(ctx, m, projectID, email)
183183
if err != nil {
184184
tflog.Error(ctx, fmt.Sprintf("Error checking if user exists by email: %v", err))
185185
return diag.Errorf("Error checking if user exists in project by email: %s", err)

internal/provider/resource_openai_project_user.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ func resourceOpenAIProjectUser() *schema.Resource {
5757
}
5858
}
5959

60-
// findProjectUserWithPagination finds a user in a project by ID with automatic pagination.
60+
// findProjectUser finds a user in a project by ID with automatic pagination.
6161
// This helper function ensures we search through all pages of users to properly detect drift.
62-
func findProjectUserWithPagination(ctx context.Context, c interface{}, projectID, userID string) (*client.ProjectUser, bool, error) {
62+
func findProjectUser(ctx context.Context, c interface{}, projectID, userID string) (*client.ProjectUser, bool, error) {
6363
clientInstance, err := GetOpenAIClientWithAdminKey(c)
6464
if err != nil {
6565
return nil, false, err
@@ -118,7 +118,7 @@ func resourceOpenAIProjectUserCreate(ctx context.Context, d *schema.ResourceData
118118

119119
// First check if the user is already in the project
120120
tflog.Debug(ctx, fmt.Sprintf("Checking if user %s already exists in project %s", userID, projectID))
121-
existingUser, exists, err := findProjectUserWithPagination(ctx, m, projectID, userID)
121+
existingUser, exists, err := findProjectUser(ctx, m, projectID, userID)
122122
if err != nil {
123123
tflog.Error(ctx, fmt.Sprintf("Error checking if user exists: %v", err))
124124
return diag.Errorf("Error checking if user exists in project: %s", err)
@@ -155,7 +155,7 @@ func resourceOpenAIProjectUserCreate(ctx context.Context, d *schema.ResourceData
155155
tflog.Info(ctx, fmt.Sprintf("User %s already exists in project, continuing: %s", userID, err))
156156

157157
// Try to get user details again
158-
existingUser, exists, findErr := findProjectUserWithPagination(ctx, m, projectID, userID)
158+
existingUser, exists, findErr := findProjectUser(ctx, m, projectID, userID)
159159
if findErr == nil && exists {
160160
// Update the Terraform state with values from the existing user
161161
if err := d.Set("email", existingUser.Email); err != nil {
@@ -205,7 +205,7 @@ func resourceOpenAIProjectUserRead(ctx context.Context, d *schema.ResourceData,
205205

206206
// Check if the user exists in the project
207207
tflog.Debug(ctx, fmt.Sprintf("Checking if user %s exists in project %s", userID, projectID))
208-
existingUser, exists, err := findProjectUserWithPagination(ctx, m, projectID, userID)
208+
existingUser, exists, err := findProjectUser(ctx, m, projectID, userID)
209209
if err != nil {
210210
// If it's a permissions error, just keep the state
211211
if strings.Contains(err.Error(), "insufficient permissions") {
@@ -411,7 +411,7 @@ func resourceOpenAIProjectUserImport(ctx context.Context, d *schema.ResourceData
411411
}
412412

413413
// Find the user in the project to get additional details
414-
existingUser, exists, err := findProjectUserWithPagination(ctx, m, projectID, userID)
414+
existingUser, exists, err := findProjectUser(ctx, m, projectID, userID)
415415
if err != nil {
416416
return nil, fmt.Errorf("error retrieving project user: %s", err)
417417
}

0 commit comments

Comments
 (0)