Skip to content

Commit 9afee44

Browse files
committed
return errWorkspaceNoLongerExists from readSettings
1 parent 7f96434 commit 9afee44

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

internal/provider/resource_tfe_workspace_settings.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,15 +465,19 @@ func (r *workspaceSettings) readSettings(ctx context.Context, workspaceID string
465465
ws, err := r.config.Client.Workspaces.ReadByIDWithOptions(ctx, workspaceID, &tfe.WorkspaceReadOptions{
466466
Include: []tfe.WSIncludeOpt{tfe.WSEffectiveTagBindings},
467467
})
468-
if err != nil && errors.Is(err, tfe.ErrInvalidIncludeValue) {
468+
if errors.Is(err, tfe.ErrResourceNotFound) {
469+
log.Printf("[DEBUG] Workspace %s no longer exists", workspaceID)
470+
return nil, errWorkspaceNoLongerExists
471+
} else if errors.Is(err, tfe.ErrInvalidIncludeValue) {
469472
log.Printf("[DEBUG] Workspace %s read failed due to unsupported Include; retrying without it", workspaceID)
470473
ws, err = r.config.Client.Workspaces.ReadByID(ctx, workspaceID)
471-
if err != nil && errors.Is(err, tfe.ErrResourceNotFound) {
472-
return nil, err
474+
if errors.Is(err, tfe.ErrResourceNotFound) {
475+
return nil, errWorkspaceNoLongerExists
473476
} else if err != nil {
474477
return nil, fmt.Errorf("Error reading workspace %s without include: %w", workspaceID, err)
475478
}
476479
}
480+
477481
if err != nil {
478482
return nil, fmt.Errorf("Error reading configuration of workspace %s: %w", workspaceID, err)
479483
}

0 commit comments

Comments
 (0)