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: Fix database show by and resource logic #3055

Merged
merged 30 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
812da99
Remove schema and db old integration test helpers
sfc-gh-asawicki Sep 5, 2024
90191b7
Remove warehouse old integration test helpers
sfc-gh-asawicki Sep 5, 2024
27bd54b
Cleanup Client in acceptance tests (WIP)
sfc-gh-asawicki Sep 5, 2024
884d0b5
Fix setup in two unsafe execute tests
sfc-gh-asawicki Sep 6, 2024
46fe9cb
Removed dependency on acceptance in the unit test for custom diffs
sfc-gh-asawicki Sep 6, 2024
fe2daaa
Extract grant/revoke helpers
sfc-gh-asawicki Sep 6, 2024
67652d2
Use client external volume
sfc-gh-asawicki Sep 6, 2024
53d3a02
Add granting ownership to helper
sfc-gh-asawicki Sep 6, 2024
289c4db
Extract external table helper
sfc-gh-asawicki Sep 6, 2024
df6be53
Move replication databases to the helper
sfc-gh-asawicki Sep 6, 2024
644371e
Remove old policy references from helpers
sfc-gh-asawicki Sep 6, 2024
41e9130
Extract showing grants to share to helper
sfc-gh-asawicki Sep 6, 2024
140dba0
Extract showing grants of roles to helpers
sfc-gh-asawicki Sep 6, 2024
43a5665
Extract showing grants to roles to helpers
sfc-gh-asawicki Sep 6, 2024
973ce71
Remove client method from acceptance tests
sfc-gh-asawicki Sep 6, 2024
bb9f507
Use only secondary test client
sfc-gh-asawicki Sep 6, 2024
b6b21ab
Add TODO
sfc-gh-asawicki Sep 6, 2024
ad4b88e
Assign issue number to the TODOs
sfc-gh-asawicki Sep 6, 2024
84a2fbe
Move helpers to a proper client
sfc-gh-asawicki Sep 6, 2024
84e8bec
Move helpers to a proper client
sfc-gh-asawicki Sep 6, 2024
78c14e4
Merge branch 'main' into clean-up-old-test-object-helpers
sfc-gh-asawicki Sep 9, 2024
49c4e27
Fix after review
sfc-gh-asawicki Sep 9, 2024
90d2fc7
Add known share issue to the list
sfc-gh-asawicki Sep 9, 2024
3ad3a2e
Mark row access policy as started
sfc-gh-asawicki Sep 9, 2024
89aff81
Fix show by id for database and the resource
sfc-gh-asawicki Sep 9, 2024
d33d0c6
Merge branch 'main' into fix-database-show-by-id
sfc-gh-asawicki Sep 10, 2024
0883c84
Fix policy references implementation and test
sfc-gh-asawicki Sep 10, 2024
b774856
Merge branch 'main' into fix-database-show-by-id
sfc-gh-asawicki Sep 10, 2024
85fcb4a
Fix TODO comments issues links
sfc-gh-asawicki Sep 10, 2024
0bcd1f0
Fix views tests
sfc-gh-asawicki Sep 10, 2024
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
2 changes: 1 addition & 1 deletion pkg/resources/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func ReadDatabase(ctx context.Context, d *schema.ResourceData, meta any) diag.Di

database, err := client.Databases.ShowByID(ctx, id)
if err != nil {
if errors.Is(err, sdk.ErrObjectNotExistOrAuthorized) || errors.Is(err, sdk.ErrObjectNotFound) {
if errors.Is(err, sdk.ErrObjectNotFound) {
d.SetId("")
return diag.Diagnostics{
diag.Diagnostic{
Expand Down
9 changes: 3 additions & 6 deletions pkg/sdk/databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"strconv"
"strings"
"time"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections"
)

var (
Expand Down Expand Up @@ -791,12 +793,7 @@ func (v *databases) ShowByID(ctx context.Context, id AccountObjectIdentifier) (*
if err != nil {
return nil, err
}
for _, database := range databases {
if database.ID() == id {
return &database, nil
}
}
return nil, ErrObjectNotExistOrAuthorized
return collections.FindFirst(databases, func(r Database) bool { return r.Name == id.Name() })
}

type DatabaseDetails struct {
Expand Down
2 changes: 1 addition & 1 deletion v1-preparations/ESSENTIAL_GA_OBJECTS.MD
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ newer provider versions. We will address these while working on the given object
| FUNCTION | 👨‍💻 | [2859](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2859), [#2735](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2735), [#2426](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2426), [#1479](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1479), [#1393](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1393), [#1208](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1208), [#1079](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1079) |
| MASKING POLICY | ❌ | [#2236](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2236), [#2035](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2035), [#1799](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1799), [#1764](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1764), [#1656](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1656), [#1444](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1444), [#1422](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1422), [#1097](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1097) |
| PROCEDURE | 👨‍💻 | [#2735](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2735), [#2623](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2623), [#2257](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2257), [#2146](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2146), [#1855](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1855), [#1695](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1695), [#1640](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1640), [#1195](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1195), [#1189](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1189), [#1178](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1178), [#1050](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1050) |
| ROW ACCESS POLICY | ❌ | [#2053](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2053), [#1600](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1600), [#1151](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1151) |
| ROW ACCESS POLICY | 👨‍💻 | [#2053](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2053), [#1600](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1600), [#1151](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1151) |
| SCHEMA | 🚀 | issues in the older versions: [resources](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues?q=label%3Aresource%3Aschema+) and [datasources](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues?q=label%3Adata_source%3Aschemas+) |
| STAGE | ❌ | [#2995](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2995), [#2818](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2818), [#2505](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2505), [#1911](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1911), [#1903](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1903), [#1795](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1795), [#1705](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1705), [#1544](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1544), [#1491](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1491), [#1087](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1087), [#265](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/265) |
| STREAM | ❌ | [#2975](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2975), [#2413](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2413), [#2201](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2201), [#1150](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/1150) |
Expand Down
Loading
Loading