Skip to content

Commit

Permalink
Use projectId from Model
Browse files Browse the repository at this point in the history
  • Loading branch information
vicentepinto98 committed Oct 10, 2023
1 parent 4f73517 commit 6536183
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (r *credentialsGroupResource) Read(ctx context.Context, req resource.ReadRe
ctx = tflog.SetField(ctx, "project_id", projectId)
ctx = tflog.SetField(ctx, "credentials_group_id", credentialsGroupId)

err := readCredentialsGroups(ctx, &model, projectId, r.client)
err := readCredentialsGroups(ctx, &model, r.client)
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentialsGroup", fmt.Sprintf("getting credential group from list of credentials groups: %v", err))
return
Expand Down Expand Up @@ -307,14 +307,14 @@ func (r *credentialsGroupResource) enableProject(ctx context.Context, model *Mod

// readCredentialsGroups gets all the existing credentials groups for the specified project,
// finds the credentials group that is being read and updates the state. If the credentials group cannot be found, it throws an error
func readCredentialsGroups(ctx context.Context, model *Model, projectId string, client objectStorageClient) error {
func readCredentialsGroups(ctx context.Context, model *Model, client objectStorageClient) error {
found := false

if model.CredentialsGroupId.ValueString() == "" && model.Name.ValueString() == "" {
return fmt.Errorf("missing configuration: either name or credentials group id must be provided")
}

credentialsGroupsResp, err := client.GetCredentialsGroupsExecute(ctx, projectId)
credentialsGroupsResp, err := client.GetCredentialsGroupsExecute(ctx, model.ProjectId.ValueString())
if err != nil {
return fmt.Errorf("getting credentials groups: %w", err)
}
Expand Down

0 comments on commit 6536183

Please sign in to comment.