feat(account): add support for identity in project resource#3660
feat(account): add support for identity in project resource#3660remyleone wants to merge 1 commit intoscaleway:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3660 +/- ##
========================================
- Coverage 2.33% 2.33% -0.01%
========================================
Files 453 453
Lines 49839 49853 +14
========================================
- Hits 1165 1163 -2
- Misses 48582 48597 +15
- Partials 92 93 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Pull request overview
Adds Terraform Identity support to the scaleway_account_project resource so project identity can be tracked via project_id, and updates related read/state-setting logic plus acceptance coverage.
Changes:
- Add
Identity: identity.DefaultProjectID()to the account project resource and set identity viaidentity.SetFlatIdentityon create/read. - Refactor shared project state population into
setProjectStateand reuse it from the data source. - Extend acceptance tests to verify resource import for the project resource.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
internal/services/account/project.go |
Adds project identity support and uses SetFlatIdentity; extracts setProjectState helper. |
internal/services/account/project_data_source.go |
Reworks data source read path to avoid calling resource read (now identity-dependent) and sets state via setProjectState. |
internal/services/account/project_test.go |
Adds import-state verification steps to acceptance tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| res, err := accountAPI.GetProject(&accountSDK.ProjectAPIGetProjectRequest{ | ||
| ProjectID: d.Id(), | ||
| }, scw.WithContext(ctx)) | ||
| if err != nil { | ||
| if httperrors.Is404(err) { | ||
| d.SetId("") | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| return diag.FromErr(err) | ||
| } | ||
|
|
||
| setProjectState(d, res) | ||
|
|
||
| if d.Id() == "" { | ||
| return diag.Errorf("account project (%s) not found", projectID) | ||
| } |
There was a problem hiding this comment.
In this data source, a 404 now returns nil diagnostics (after clearing the ID), which changes behavior from the previous implementation that surfaced a "not found" error (via the later if d.Id() == "" check). For data sources, silently succeeding on missing remote objects can mask configuration issues; additionally, the if d.Id() == "" block becomes effectively unreachable with the early return. Consider handling 404 by setting the ID empty and then returning the existing account project (...) not found diagnostic (or directly returning that diagnostic on 404), and remove/adjust the now-dead code accordingly.
No description provided.