From f8ca759d3e8d3a7c0a35bf47301a835e24a5bde3 Mon Sep 17 00:00:00 2001 From: Artur Sawicki Date: Sun, 1 Sep 2024 20:21:13 +0200 Subject: [PATCH 1/3] Move collection utils --- .../collections/collection_helpers_test.go | 0 pkg/{sdk => }/internal/collections/queue.go | 0 .../internal/collections/queue_test.go | 0 pkg/sdk/api_integrations_impl_gen.go | 2 +- pkg/sdk/application_packages_impl_gen.go | 2 +- pkg/sdk/application_roles_impl_gen.go | 2 +- pkg/sdk/applications_impl_gen.go | 2 +- pkg/sdk/cortex_search_services_impl_gen.go | 2 +- pkg/sdk/database_role_impl.go | 2 +- pkg/sdk/dynamic_table_impl.go | 2 +- pkg/sdk/errors.go | 2 +- pkg/sdk/event_tables_impl_gen.go | 2 +- pkg/sdk/external_functions_impl_gen.go | 2 +- pkg/sdk/external_tables_impl.go | 2 +- pkg/sdk/functions_impl_gen.go | 2 +- pkg/sdk/grants_impl.go | 3 +-- .../collections/collection_helpers.go | 24 ------------------- pkg/sdk/managed_accounts_impl_gen.go | 2 +- pkg/sdk/materialized_views_impl_gen.go | 2 +- pkg/sdk/network_policies_impl_gen.go | 2 +- pkg/sdk/network_rule_impl_gen.go | 2 +- pkg/sdk/notification_integrations_impl_gen.go | 2 +- pkg/sdk/pipes_impl.go | 2 +- .../generator/templates/implementation.tmpl | 2 +- pkg/sdk/procedures_impl_gen.go | 2 +- pkg/sdk/roles_impl.go | 2 +- pkg/sdk/row_access_policies_impl_gen.go | 2 +- pkg/sdk/schemas.go | 2 +- pkg/sdk/security_integrations_impl_gen.go | 2 +- pkg/sdk/sequences_impl_gen.go | 2 +- pkg/sdk/session_policies_impl_gen.go | 2 +- pkg/sdk/stages_impl_gen.go | 2 +- pkg/sdk/storage_integration_impl_gen.go | 2 +- pkg/sdk/streamlits_impl_gen.go | 2 +- pkg/sdk/streams_impl_gen.go | 2 +- pkg/sdk/system_functions.go | 2 +- pkg/sdk/tables_impl.go | 2 +- pkg/sdk/tags_impl.go | 2 +- pkg/sdk/tasks_impl_gen.go | 2 +- .../api_integrations_gen_integration_test.go | 2 +- .../application_roles_gen_integration_test.go | 2 +- .../testint/database_role_integration_test.go | 2 +- pkg/sdk/testint/databases_integration_test.go | 4 +--- .../testint/event_tables_integration_test.go | 2 +- .../external_tables_integration_test.go | 2 +- pkg/sdk/testint/functions_integration_test.go | 5 ++-- pkg/sdk/testint/grants_integration_test.go | 2 +- .../testint/identifier_integration_test.go | 2 +- .../managed_accounts_gen_integration_test.go | 2 +- ...materialized_views_gen_integration_test.go | 2 +- .../network_policies_gen_integration_test.go | 2 +- ...ation_integrations_gen_integration_test.go | 2 +- .../testint/procedures_integration_test.go | 2 +- ...ow_access_policies_gen_integration_test.go | 2 +- pkg/sdk/testint/schemas_integration_test.go | 2 +- ...urity_integrations_gen_integration_test.go | 2 +- pkg/sdk/testint/sequences_integration_test.go | 2 +- .../session_policies_gen_integration_test.go | 2 +- ...torage_integration_gen_integration_test.go | 2 +- .../testint/streamlits_integration_test.go | 2 +- .../testint/streams_gen_integration_test.go | 2 +- pkg/sdk/testint/tables_integration_test.go | 2 +- pkg/sdk/testint/tags_integration_test.go | 2 +- pkg/sdk/testint/views_gen_integration_test.go | 2 +- pkg/sdk/views_impl_gen.go | 2 +- 65 files changed, 62 insertions(+), 90 deletions(-) rename pkg/{sdk => }/internal/collections/collection_helpers_test.go (100%) rename pkg/{sdk => }/internal/collections/queue.go (100%) rename pkg/{sdk => }/internal/collections/queue_test.go (100%) delete mode 100644 pkg/sdk/internal/collections/collection_helpers.go diff --git a/pkg/sdk/internal/collections/collection_helpers_test.go b/pkg/internal/collections/collection_helpers_test.go similarity index 100% rename from pkg/sdk/internal/collections/collection_helpers_test.go rename to pkg/internal/collections/collection_helpers_test.go diff --git a/pkg/sdk/internal/collections/queue.go b/pkg/internal/collections/queue.go similarity index 100% rename from pkg/sdk/internal/collections/queue.go rename to pkg/internal/collections/queue.go diff --git a/pkg/sdk/internal/collections/queue_test.go b/pkg/internal/collections/queue_test.go similarity index 100% rename from pkg/sdk/internal/collections/queue_test.go rename to pkg/internal/collections/queue_test.go diff --git a/pkg/sdk/api_integrations_impl_gen.go b/pkg/sdk/api_integrations_impl_gen.go index 7968228246..151429bc69 100644 --- a/pkg/sdk/api_integrations_impl_gen.go +++ b/pkg/sdk/api_integrations_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ ApiIntegrations = (*apiIntegrations)(nil) diff --git a/pkg/sdk/application_packages_impl_gen.go b/pkg/sdk/application_packages_impl_gen.go index 21872bf3c5..0db872f4cd 100644 --- a/pkg/sdk/application_packages_impl_gen.go +++ b/pkg/sdk/application_packages_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ ApplicationPackages = (*applicationPackages)(nil) diff --git a/pkg/sdk/application_roles_impl_gen.go b/pkg/sdk/application_roles_impl_gen.go index c173ccbfe8..737403fdac 100644 --- a/pkg/sdk/application_roles_impl_gen.go +++ b/pkg/sdk/application_roles_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ ApplicationRoles = (*applicationRoles)(nil) diff --git a/pkg/sdk/applications_impl_gen.go b/pkg/sdk/applications_impl_gen.go index 474c9814e8..a442001580 100644 --- a/pkg/sdk/applications_impl_gen.go +++ b/pkg/sdk/applications_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ Applications = (*applications)(nil) diff --git a/pkg/sdk/cortex_search_services_impl_gen.go b/pkg/sdk/cortex_search_services_impl_gen.go index e9968da053..c8c7e54e1f 100644 --- a/pkg/sdk/cortex_search_services_impl_gen.go +++ b/pkg/sdk/cortex_search_services_impl_gen.go @@ -4,7 +4,7 @@ import ( "context" "strings" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ CortexSearchServices = (*cortexSearchServices)(nil) diff --git a/pkg/sdk/database_role_impl.go b/pkg/sdk/database_role_impl.go index 21d0bc7210..a768a3b73d 100644 --- a/pkg/sdk/database_role_impl.go +++ b/pkg/sdk/database_role_impl.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ DatabaseRoles = (*databaseRoles)(nil) diff --git a/pkg/sdk/dynamic_table_impl.go b/pkg/sdk/dynamic_table_impl.go index 55bbb38a02..3f64424e98 100644 --- a/pkg/sdk/dynamic_table_impl.go +++ b/pkg/sdk/dynamic_table_impl.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ DynamicTables = (*dynamicTables)(nil) diff --git a/pkg/sdk/errors.go b/pkg/sdk/errors.go index 79a659d08d..ab09c984dc 100644 --- a/pkg/sdk/errors.go +++ b/pkg/sdk/errors.go @@ -8,7 +8,7 @@ import ( "runtime" "strings" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var ( diff --git a/pkg/sdk/event_tables_impl_gen.go b/pkg/sdk/event_tables_impl_gen.go index e20443f951..980fb2c8f2 100644 --- a/pkg/sdk/event_tables_impl_gen.go +++ b/pkg/sdk/event_tables_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ EventTables = (*eventTables)(nil) diff --git a/pkg/sdk/external_functions_impl_gen.go b/pkg/sdk/external_functions_impl_gen.go index c1eb5b484f..ee7eee6f87 100644 --- a/pkg/sdk/external_functions_impl_gen.go +++ b/pkg/sdk/external_functions_impl_gen.go @@ -5,7 +5,7 @@ import ( "log" "strings" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ ExternalFunctions = (*externalFunctions)(nil) diff --git a/pkg/sdk/external_tables_impl.go b/pkg/sdk/external_tables_impl.go index a7bc20d7bd..898bef37e8 100644 --- a/pkg/sdk/external_tables_impl.go +++ b/pkg/sdk/external_tables_impl.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ ExternalTables = (*externalTables)(nil) diff --git a/pkg/sdk/functions_impl_gen.go b/pkg/sdk/functions_impl_gen.go index e2122633d5..a7dcb95c2d 100644 --- a/pkg/sdk/functions_impl_gen.go +++ b/pkg/sdk/functions_impl_gen.go @@ -5,7 +5,7 @@ import ( "log" "strings" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ Functions = (*functions)(nil) diff --git a/pkg/sdk/grants_impl.go b/pkg/sdk/grants_impl.go index 39293055c1..b64c83b0e5 100644 --- a/pkg/sdk/grants_impl.go +++ b/pkg/sdk/grants_impl.go @@ -8,8 +8,7 @@ import ( "slices" "strings" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" - + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/logging" ) diff --git a/pkg/sdk/internal/collections/collection_helpers.go b/pkg/sdk/internal/collections/collection_helpers.go deleted file mode 100644 index eccda7f07d..0000000000 --- a/pkg/sdk/internal/collections/collection_helpers.go +++ /dev/null @@ -1,24 +0,0 @@ -package collections - -import ( - "errors" -) - -var ErrObjectNotFound = errors.New("object does not exist") - -func FindOne[T any](collection []T, condition func(T) bool) (*T, error) { - for _, o := range collection { - if condition(o) { - return &o, nil - } - } - return nil, ErrObjectNotFound -} - -func Map[T any, R any](collection []T, mapper func(T) R) []R { - result := make([]R, len(collection)) - for i, elem := range collection { - result[i] = mapper(elem) - } - return result -} diff --git a/pkg/sdk/managed_accounts_impl_gen.go b/pkg/sdk/managed_accounts_impl_gen.go index 62db79b682..2873cb9920 100644 --- a/pkg/sdk/managed_accounts_impl_gen.go +++ b/pkg/sdk/managed_accounts_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ ManagedAccounts = (*managedAccounts)(nil) diff --git a/pkg/sdk/materialized_views_impl_gen.go b/pkg/sdk/materialized_views_impl_gen.go index b37c0534c6..c278d2f6e9 100644 --- a/pkg/sdk/materialized_views_impl_gen.go +++ b/pkg/sdk/materialized_views_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ MaterializedViews = (*materializedViews)(nil) diff --git a/pkg/sdk/network_policies_impl_gen.go b/pkg/sdk/network_policies_impl_gen.go index 8021781c5b..593e62ef5b 100644 --- a/pkg/sdk/network_policies_impl_gen.go +++ b/pkg/sdk/network_policies_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ NetworkPolicies = (*networkPolicies)(nil) diff --git a/pkg/sdk/network_rule_impl_gen.go b/pkg/sdk/network_rule_impl_gen.go index e3613bc7c6..5b575496ff 100644 --- a/pkg/sdk/network_rule_impl_gen.go +++ b/pkg/sdk/network_rule_impl_gen.go @@ -4,7 +4,7 @@ import ( "context" "strings" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ NetworkRules = (*networkRules)(nil) diff --git a/pkg/sdk/notification_integrations_impl_gen.go b/pkg/sdk/notification_integrations_impl_gen.go index d3e6f42259..7e33ac332a 100644 --- a/pkg/sdk/notification_integrations_impl_gen.go +++ b/pkg/sdk/notification_integrations_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ NotificationIntegrations = (*notificationIntegrations)(nil) diff --git a/pkg/sdk/pipes_impl.go b/pkg/sdk/pipes_impl.go index 5dd0627182..6a69d84a97 100644 --- a/pkg/sdk/pipes_impl.go +++ b/pkg/sdk/pipes_impl.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ Pipes = (*pipes)(nil) diff --git a/pkg/sdk/poc/generator/templates/implementation.tmpl b/pkg/sdk/poc/generator/templates/implementation.tmpl index 7381162f68..36d4a8e2b6 100644 --- a/pkg/sdk/poc/generator/templates/implementation.tmpl +++ b/pkg/sdk/poc/generator/templates/implementation.tmpl @@ -3,7 +3,7 @@ import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) {{ $impl := .NameLowerCased }} diff --git a/pkg/sdk/procedures_impl_gen.go b/pkg/sdk/procedures_impl_gen.go index 0f58bc946b..1152b2c139 100644 --- a/pkg/sdk/procedures_impl_gen.go +++ b/pkg/sdk/procedures_impl_gen.go @@ -5,7 +5,7 @@ import ( "log" "strings" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ Procedures = (*procedures)(nil) diff --git a/pkg/sdk/roles_impl.go b/pkg/sdk/roles_impl.go index 43c848734b..ebe55252db 100644 --- a/pkg/sdk/roles_impl.go +++ b/pkg/sdk/roles_impl.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var ( diff --git a/pkg/sdk/row_access_policies_impl_gen.go b/pkg/sdk/row_access_policies_impl_gen.go index c5ac6fa88a..8fd42f1e9d 100644 --- a/pkg/sdk/row_access_policies_impl_gen.go +++ b/pkg/sdk/row_access_policies_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ RowAccessPolicies = (*rowAccessPolicies)(nil) diff --git a/pkg/sdk/schemas.go b/pkg/sdk/schemas.go index 24b560cbb8..c6f5778133 100644 --- a/pkg/sdk/schemas.go +++ b/pkg/sdk/schemas.go @@ -7,7 +7,7 @@ import ( "slices" "time" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var ( diff --git a/pkg/sdk/security_integrations_impl_gen.go b/pkg/sdk/security_integrations_impl_gen.go index 089b8d1a5e..196ce3ec94 100644 --- a/pkg/sdk/security_integrations_impl_gen.go +++ b/pkg/sdk/security_integrations_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ SecurityIntegrations = (*securityIntegrations)(nil) diff --git a/pkg/sdk/sequences_impl_gen.go b/pkg/sdk/sequences_impl_gen.go index 79e1d356ab..1095e19b59 100644 --- a/pkg/sdk/sequences_impl_gen.go +++ b/pkg/sdk/sequences_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ Sequences = (*sequences)(nil) diff --git a/pkg/sdk/session_policies_impl_gen.go b/pkg/sdk/session_policies_impl_gen.go index 7d6284f0f3..2ad349fd67 100644 --- a/pkg/sdk/session_policies_impl_gen.go +++ b/pkg/sdk/session_policies_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ SessionPolicies = (*sessionPolicies)(nil) diff --git a/pkg/sdk/stages_impl_gen.go b/pkg/sdk/stages_impl_gen.go index 686820f8b3..0e7cc4b3d6 100644 --- a/pkg/sdk/stages_impl_gen.go +++ b/pkg/sdk/stages_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ Stages = (*stages)(nil) diff --git a/pkg/sdk/storage_integration_impl_gen.go b/pkg/sdk/storage_integration_impl_gen.go index 8678cbe487..cc89ee6645 100644 --- a/pkg/sdk/storage_integration_impl_gen.go +++ b/pkg/sdk/storage_integration_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ StorageIntegrations = (*storageIntegrations)(nil) diff --git a/pkg/sdk/streamlits_impl_gen.go b/pkg/sdk/streamlits_impl_gen.go index 5a0e79ecdd..5d006afd26 100644 --- a/pkg/sdk/streamlits_impl_gen.go +++ b/pkg/sdk/streamlits_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ Streamlits = (*streamlits)(nil) diff --git a/pkg/sdk/streams_impl_gen.go b/pkg/sdk/streams_impl_gen.go index de15c02dcc..994cf1ca19 100644 --- a/pkg/sdk/streams_impl_gen.go +++ b/pkg/sdk/streams_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ Streams = (*streams)(nil) diff --git a/pkg/sdk/system_functions.go b/pkg/sdk/system_functions.go index 91e76ccb3a..39c4396788 100644 --- a/pkg/sdk/system_functions.go +++ b/pkg/sdk/system_functions.go @@ -6,7 +6,7 @@ import ( "fmt" "strings" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) type SystemFunctions interface { diff --git a/pkg/sdk/tables_impl.go b/pkg/sdk/tables_impl.go index 7736ecc418..43d95116e4 100644 --- a/pkg/sdk/tables_impl.go +++ b/pkg/sdk/tables_impl.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ Tables = (*tables)(nil) diff --git a/pkg/sdk/tags_impl.go b/pkg/sdk/tags_impl.go index 86392b2154..48b11269b6 100644 --- a/pkg/sdk/tags_impl.go +++ b/pkg/sdk/tags_impl.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ Tags = (*tags)(nil) diff --git a/pkg/sdk/tasks_impl_gen.go b/pkg/sdk/tasks_impl_gen.go index b3003470aa..0a1ce9d111 100644 --- a/pkg/sdk/tasks_impl_gen.go +++ b/pkg/sdk/tasks_impl_gen.go @@ -8,7 +8,7 @@ import ( "slices" "strings" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ Tasks = (*tasks)(nil) diff --git a/pkg/sdk/testint/api_integrations_gen_integration_test.go b/pkg/sdk/testint/api_integrations_gen_integration_test.go index bd89521c69..484f5f3e81 100644 --- a/pkg/sdk/testint/api_integrations_gen_integration_test.go +++ b/pkg/sdk/testint/api_integrations_gen_integration_test.go @@ -4,8 +4,8 @@ import ( "strings" "testing" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/application_roles_gen_integration_test.go b/pkg/sdk/testint/application_roles_gen_integration_test.go index 2d4e3e429e..81332be3ec 100644 --- a/pkg/sdk/testint/application_roles_gen_integration_test.go +++ b/pkg/sdk/testint/application_roles_gen_integration_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/testvars" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/database_role_integration_test.go b/pkg/sdk/testint/database_role_integration_test.go index affca49e1f..7ca8a9707b 100644 --- a/pkg/sdk/testint/database_role_integration_test.go +++ b/pkg/sdk/testint/database_role_integration_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/databases_integration_test.go b/pkg/sdk/testint/databases_integration_test.go index 2c80e42c96..a74772ca8d 100644 --- a/pkg/sdk/testint/databases_integration_test.go +++ b/pkg/sdk/testint/databases_integration_test.go @@ -5,10 +5,8 @@ import ( "testing" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers" - - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/pkg/sdk/testint/event_tables_integration_test.go b/pkg/sdk/testint/event_tables_integration_test.go index 6ecfb53a44..d18a4d31ba 100644 --- a/pkg/sdk/testint/event_tables_integration_test.go +++ b/pkg/sdk/testint/event_tables_integration_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/external_tables_integration_test.go b/pkg/sdk/testint/external_tables_integration_test.go index 801cc804ae..81ecb9bbc9 100644 --- a/pkg/sdk/testint/external_tables_integration_test.go +++ b/pkg/sdk/testint/external_tables_integration_test.go @@ -5,8 +5,8 @@ import ( "fmt" "testing" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/functions_integration_test.go b/pkg/sdk/testint/functions_integration_test.go index 500e4d2b51..cef7e7cf21 100644 --- a/pkg/sdk/testint/functions_integration_test.go +++ b/pkg/sdk/testint/functions_integration_test.go @@ -7,10 +7,9 @@ import ( "testing" "time" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" - "github.com/stretchr/testify/assert" - + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/grants_integration_test.go b/pkg/sdk/testint/grants_integration_test.go index d009e32142..fdec0791d5 100644 --- a/pkg/sdk/testint/grants_integration_test.go +++ b/pkg/sdk/testint/grants_integration_test.go @@ -4,8 +4,8 @@ import ( "fmt" "testing" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/identifier_integration_test.go b/pkg/sdk/testint/identifier_integration_test.go index f4153a5252..0ebe8e27ef 100644 --- a/pkg/sdk/testint/identifier_integration_test.go +++ b/pkg/sdk/testint/identifier_integration_test.go @@ -5,8 +5,8 @@ import ( "fmt" "testing" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/managed_accounts_gen_integration_test.go b/pkg/sdk/testint/managed_accounts_gen_integration_test.go index a6c6e2f5af..717db30db0 100644 --- a/pkg/sdk/testint/managed_accounts_gen_integration_test.go +++ b/pkg/sdk/testint/managed_accounts_gen_integration_test.go @@ -5,8 +5,8 @@ import ( "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/testenvs" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/materialized_views_gen_integration_test.go b/pkg/sdk/testint/materialized_views_gen_integration_test.go index 5fdf47085b..6f17a07cd2 100644 --- a/pkg/sdk/testint/materialized_views_gen_integration_test.go +++ b/pkg/sdk/testint/materialized_views_gen_integration_test.go @@ -5,8 +5,8 @@ import ( "fmt" "testing" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/network_policies_gen_integration_test.go b/pkg/sdk/testint/network_policies_gen_integration_test.go index 38a31eb16f..a271cf2061 100644 --- a/pkg/sdk/testint/network_policies_gen_integration_test.go +++ b/pkg/sdk/testint/network_policies_gen_integration_test.go @@ -4,8 +4,8 @@ import ( "fmt" "testing" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/notification_integrations_gen_integration_test.go b/pkg/sdk/testint/notification_integrations_gen_integration_test.go index b6fb761ae8..96a57a9885 100644 --- a/pkg/sdk/testint/notification_integrations_gen_integration_test.go +++ b/pkg/sdk/testint/notification_integrations_gen_integration_test.go @@ -3,8 +3,8 @@ package testint import ( "testing" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/procedures_integration_test.go b/pkg/sdk/testint/procedures_integration_test.go index 40d2c5ae47..bd98da65a7 100644 --- a/pkg/sdk/testint/procedures_integration_test.go +++ b/pkg/sdk/testint/procedures_integration_test.go @@ -5,8 +5,8 @@ import ( "fmt" "testing" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/row_access_policies_gen_integration_test.go b/pkg/sdk/testint/row_access_policies_gen_integration_test.go index 040706b09b..ad6dc6f1d6 100644 --- a/pkg/sdk/testint/row_access_policies_gen_integration_test.go +++ b/pkg/sdk/testint/row_access_policies_gen_integration_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/schemas_integration_test.go b/pkg/sdk/testint/schemas_integration_test.go index 5effa07bd2..1d88a346fa 100644 --- a/pkg/sdk/testint/schemas_integration_test.go +++ b/pkg/sdk/testint/schemas_integration_test.go @@ -5,8 +5,8 @@ import ( "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/security_integrations_gen_integration_test.go b/pkg/sdk/testint/security_integrations_gen_integration_test.go index ae9b097e3f..f398167c4a 100644 --- a/pkg/sdk/testint/security_integrations_gen_integration_test.go +++ b/pkg/sdk/testint/security_integrations_gen_integration_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/sequences_integration_test.go b/pkg/sdk/testint/sequences_integration_test.go index c09c6208a2..1a8cb538f2 100644 --- a/pkg/sdk/testint/sequences_integration_test.go +++ b/pkg/sdk/testint/sequences_integration_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/session_policies_gen_integration_test.go b/pkg/sdk/testint/session_policies_gen_integration_test.go index 8f4b35db4f..6f936e33ff 100644 --- a/pkg/sdk/testint/session_policies_gen_integration_test.go +++ b/pkg/sdk/testint/session_policies_gen_integration_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/storage_integration_gen_integration_test.go b/pkg/sdk/testint/storage_integration_gen_integration_test.go index 9bd40e52e0..b9414abb47 100644 --- a/pkg/sdk/testint/storage_integration_gen_integration_test.go +++ b/pkg/sdk/testint/storage_integration_gen_integration_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/testenvs" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/streamlits_integration_test.go b/pkg/sdk/testint/streamlits_integration_test.go index ac4a4ac70d..5cfeaa06b7 100644 --- a/pkg/sdk/testint/streamlits_integration_test.go +++ b/pkg/sdk/testint/streamlits_integration_test.go @@ -7,8 +7,8 @@ import ( "testing" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/streams_gen_integration_test.go b/pkg/sdk/testint/streams_gen_integration_test.go index 618f0c5a62..763b799f25 100644 --- a/pkg/sdk/testint/streams_gen_integration_test.go +++ b/pkg/sdk/testint/streams_gen_integration_test.go @@ -5,8 +5,8 @@ import ( "fmt" "testing" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/tables_integration_test.go b/pkg/sdk/testint/tables_integration_test.go index 4a3dcf8ee4..d0bbc90f42 100644 --- a/pkg/sdk/testint/tables_integration_test.go +++ b/pkg/sdk/testint/tables_integration_test.go @@ -10,9 +10,9 @@ import ( "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/snowflakeroles" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/tags_integration_test.go b/pkg/sdk/testint/tags_integration_test.go index eb4911222c..dd8af002c3 100644 --- a/pkg/sdk/testint/tags_integration_test.go +++ b/pkg/sdk/testint/tags_integration_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers/random" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/testint/views_gen_integration_test.go b/pkg/sdk/testint/views_gen_integration_test.go index 78003a45d6..ff23d78ce1 100644 --- a/pkg/sdk/testint/views_gen_integration_test.go +++ b/pkg/sdk/testint/views_gen_integration_test.go @@ -11,9 +11,9 @@ import ( "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert/objectassert" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/helpers" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/snowflakeroles" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/pkg/sdk/views_impl_gen.go b/pkg/sdk/views_impl_gen.go index 149dfbccbd..7e20ce0c59 100644 --- a/pkg/sdk/views_impl_gen.go +++ b/pkg/sdk/views_impl_gen.go @@ -3,7 +3,7 @@ package sdk import ( "context" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/internal/collections" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections" ) var _ Views = (*views)(nil) From cace259db83c334a2cd9e224cf519c2fe4e12251 Mon Sep 17 00:00:00 2001 From: Artur Sawicki Date: Sun, 1 Sep 2024 20:27:17 +0200 Subject: [PATCH 2/3] Add basic test to FindOne --- .../collections/collection_helpers.go | 1 - .../collections/collection_helpers_test.go | 28 ++++++++++++++++++- pkg/internal/collections/queue_test.go | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/pkg/internal/collections/collection_helpers.go b/pkg/internal/collections/collection_helpers.go index 72950e189c..eccda7f07d 100644 --- a/pkg/internal/collections/collection_helpers.go +++ b/pkg/internal/collections/collection_helpers.go @@ -6,7 +6,6 @@ import ( var ErrObjectNotFound = errors.New("object does not exist") -// TODO [SNOW-1473414]: move collection helpers fully with a separate PR func FindOne[T any](collection []T, condition func(T) bool) (*T, error) { for _, o := range collection { if condition(o) { diff --git a/pkg/internal/collections/collection_helpers_test.go b/pkg/internal/collections/collection_helpers_test.go index 150cecbda6..826a9341fb 100644 --- a/pkg/internal/collections/collection_helpers_test.go +++ b/pkg/internal/collections/collection_helpers_test.go @@ -1,12 +1,38 @@ package collections import ( + "strings" "testing" "github.com/stretchr/testify/require" ) -func TestMap(t *testing.T) { +func Test_FindOne(t *testing.T) { + stringSlice := []string{"1", "22", "333", "334"} + + t.Run("basic find", func(t *testing.T) { + result, resultErr := FindOne(stringSlice, func(s string) bool { return s == "22" }) + + require.Equal(t, "22", *result) + require.Nil(t, resultErr) + }) + + t.Run("two matching, first returned", func(t *testing.T) { + result, resultErr := FindOne(stringSlice, func(s string) bool { return strings.HasPrefix(s, "33") }) + + require.Equal(t, "333", *result) + require.Nil(t, resultErr) + }) + + t.Run("no item", func(t *testing.T) { + result, resultErr := FindOne(stringSlice, func(s string) bool { return s == "4444" }) + + require.Nil(t, result) + require.ErrorIs(t, resultErr, ErrObjectNotFound) + }) +} + +func Test_Map(t *testing.T) { t.Run("basic mapping", func(t *testing.T) { stringSlice := []string{"1", "22", "333"} stringLenSlice := Map(stringSlice, func(s string) int { return len(s) }) diff --git a/pkg/internal/collections/queue_test.go b/pkg/internal/collections/queue_test.go index 05387df658..3c2d3a43bf 100644 --- a/pkg/internal/collections/queue_test.go +++ b/pkg/internal/collections/queue_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestQueue(t *testing.T) { +func Test_Queue(t *testing.T) { t.Run("empty queue initialization", func(t *testing.T) { queue := NewQueue[int]() From 91661f29c41827b7b27ec0193f7ebe18c773a6f5 Mon Sep 17 00:00:00 2001 From: Artur Sawicki Date: Sun, 1 Sep 2024 20:29:38 +0200 Subject: [PATCH 3/3] Rename FindOne to FindFirst --- pkg/acceptance/helpers/parameter_client.go | 2 +- .../collections/collection_helpers.go | 2 +- .../collections/collection_helpers_test.go | 8 +-- .../api_authentication_integration_common.go | 20 ++++---- ...tegration_with_authorization_code_grant.go | 8 +-- ...ion_integration_with_client_credentials.go | 4 +- ...hentication_integration_with_jwt_bearer.go | 8 +-- pkg/resources/custom_diffs.go | 2 +- pkg/resources/database_state_upgraders.go | 2 +- pkg/resources/external_oauth_integration.go | 46 ++++++++--------- pkg/resources/network_policy.go | 8 +-- .../oauth_integration_for_custom_clients.go | 28 +++++------ ...th_integration_for_partner_applications.go | 14 +++--- pkg/resources/saml2_integration.go | 50 +++++++++---------- pkg/resources/scim_integration.go | 12 ++--- pkg/sdk/api_integrations_impl_gen.go | 2 +- pkg/sdk/application_packages_impl_gen.go | 2 +- pkg/sdk/application_roles_impl_gen.go | 2 +- pkg/sdk/applications_impl_gen.go | 2 +- pkg/sdk/cortex_search_services_impl_gen.go | 2 +- pkg/sdk/database_role_impl.go | 2 +- pkg/sdk/dynamic_table_impl.go | 2 +- pkg/sdk/event_tables_impl_gen.go | 2 +- pkg/sdk/external_functions_impl_gen.go | 2 +- pkg/sdk/external_tables_impl.go | 2 +- pkg/sdk/functions_impl_gen.go | 2 +- pkg/sdk/managed_accounts_impl_gen.go | 2 +- pkg/sdk/materialized_views_impl_gen.go | 2 +- pkg/sdk/network_policies_impl_gen.go | 2 +- pkg/sdk/network_rule_impl_gen.go | 2 +- pkg/sdk/notification_integrations_impl_gen.go | 2 +- pkg/sdk/pipes_impl.go | 2 +- .../implementation_functions.tmpl | 2 +- pkg/sdk/procedures_impl_gen.go | 2 +- pkg/sdk/roles_impl.go | 2 +- pkg/sdk/row_access_policies_impl_gen.go | 2 +- pkg/sdk/schemas.go | 2 +- pkg/sdk/security_integrations_impl_gen.go | 2 +- pkg/sdk/sequences_impl_gen.go | 2 +- pkg/sdk/session_policies_impl_gen.go | 2 +- pkg/sdk/stages_impl_gen.go | 2 +- pkg/sdk/storage_integration_impl_gen.go | 2 +- pkg/sdk/streamlits_impl_gen.go | 2 +- pkg/sdk/streams_impl_gen.go | 2 +- pkg/sdk/tables_impl.go | 2 +- pkg/sdk/tags_impl.go | 2 +- .../application_roles_gen_integration_test.go | 2 +- pkg/sdk/testint/databases_integration_test.go | 10 ++-- pkg/sdk/testint/grants_integration_test.go | 30 +++++------ .../testint/identifier_integration_test.go | 2 +- .../network_policies_gen_integration_test.go | 2 +- ...ation_integrations_gen_integration_test.go | 10 ++-- pkg/sdk/testint/schemas_integration_test.go | 6 +-- ...urity_integrations_gen_integration_test.go | 2 +- ...torage_integration_gen_integration_test.go | 2 +- .../testint/streams_gen_integration_test.go | 12 ++--- pkg/sdk/testint/tables_integration_test.go | 4 +- pkg/sdk/views_impl_gen.go | 2 +- 58 files changed, 180 insertions(+), 180 deletions(-) diff --git a/pkg/acceptance/helpers/parameter_client.go b/pkg/acceptance/helpers/parameter_client.go index 9abb7d0299..3a138fe5ba 100644 --- a/pkg/acceptance/helpers/parameter_client.go +++ b/pkg/acceptance/helpers/parameter_client.go @@ -122,7 +122,7 @@ func (c *ParameterClient) UnsetAccountParameter(t *testing.T, parameter sdk.Acco func FindParameter[T ~string](t *testing.T, parameters []*sdk.Parameter, parameter T) *sdk.Parameter { t.Helper() - param, err := collections.FindOne(parameters, func(p *sdk.Parameter) bool { return p.Key == string(parameter) }) + param, err := collections.FindFirst(parameters, func(p *sdk.Parameter) bool { return p.Key == string(parameter) }) require.NoError(t, err) return *param } diff --git a/pkg/internal/collections/collection_helpers.go b/pkg/internal/collections/collection_helpers.go index eccda7f07d..b71c44d62d 100644 --- a/pkg/internal/collections/collection_helpers.go +++ b/pkg/internal/collections/collection_helpers.go @@ -6,7 +6,7 @@ import ( var ErrObjectNotFound = errors.New("object does not exist") -func FindOne[T any](collection []T, condition func(T) bool) (*T, error) { +func FindFirst[T any](collection []T, condition func(T) bool) (*T, error) { for _, o := range collection { if condition(o) { return &o, nil diff --git a/pkg/internal/collections/collection_helpers_test.go b/pkg/internal/collections/collection_helpers_test.go index 826a9341fb..87260e1113 100644 --- a/pkg/internal/collections/collection_helpers_test.go +++ b/pkg/internal/collections/collection_helpers_test.go @@ -7,25 +7,25 @@ import ( "github.com/stretchr/testify/require" ) -func Test_FindOne(t *testing.T) { +func Test_FindFirst(t *testing.T) { stringSlice := []string{"1", "22", "333", "334"} t.Run("basic find", func(t *testing.T) { - result, resultErr := FindOne(stringSlice, func(s string) bool { return s == "22" }) + result, resultErr := FindFirst(stringSlice, func(s string) bool { return s == "22" }) require.Equal(t, "22", *result) require.Nil(t, resultErr) }) t.Run("two matching, first returned", func(t *testing.T) { - result, resultErr := FindOne(stringSlice, func(s string) bool { return strings.HasPrefix(s, "33") }) + result, resultErr := FindFirst(stringSlice, func(s string) bool { return strings.HasPrefix(s, "33") }) require.Equal(t, "333", *result) require.Nil(t, resultErr) }) t.Run("no item", func(t *testing.T) { - result, resultErr := FindOne(stringSlice, func(s string) bool { return s == "4444" }) + result, resultErr := FindFirst(stringSlice, func(s string) bool { return s == "4444" }) require.Nil(t, result) require.ErrorIs(t, resultErr, ErrObjectNotFound) diff --git a/pkg/resources/api_authentication_integration_common.go b/pkg/resources/api_authentication_integration_common.go index c505cd1bef..8791a5d0df 100644 --- a/pkg/resources/api_authentication_integration_common.go +++ b/pkg/resources/api_authentication_integration_common.go @@ -223,7 +223,7 @@ func handleApiAuthImport(d *schema.ResourceData, integration *sdk.SecurityIntegr return err } - oauthAccessTokenValidity, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { + oauthAccessTokenValidity, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ACCESS_TOKEN_VALIDITY" }) if err == nil { @@ -235,7 +235,7 @@ func handleApiAuthImport(d *schema.ResourceData, integration *sdk.SecurityIntegr return err } } - oauthRefreshTokenValidity, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { + oauthRefreshTokenValidity, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_REFRESH_TOKEN_VALIDITY" }) if err == nil { @@ -247,13 +247,13 @@ func handleApiAuthImport(d *schema.ResourceData, integration *sdk.SecurityIntegr return err } } - oauthClientId, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_CLIENT_ID" }) + oauthClientId, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_CLIENT_ID" }) if err == nil { if err = d.Set("oauth_client_id", oauthClientId.Value); err != nil { return err } } - oauthClientAuthMethod, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { + oauthClientAuthMethod, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_CLIENT_AUTH_METHOD" }) if err == nil { @@ -261,7 +261,7 @@ func handleApiAuthImport(d *schema.ResourceData, integration *sdk.SecurityIntegr return err } } - oauthTokenEndpoint, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_TOKEN_ENDPOINT" }) + oauthTokenEndpoint, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_TOKEN_ENDPOINT" }) if err == nil { if err = d.Set("oauth_token_endpoint", oauthTokenEndpoint.Value); err != nil { return err @@ -288,33 +288,33 @@ func handleApiAuthRead(d *schema.ResourceData, return err } if withExternalChangesMarking { - oauthAccessTokenValidity, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { + oauthAccessTokenValidity, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ACCESS_TOKEN_VALIDITY" }) if err != nil { return err } - oauthRefreshTokenValidity, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { + oauthRefreshTokenValidity, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_REFRESH_TOKEN_VALIDITY" }) if err != nil { return err } - oauthClientId, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_CLIENT_ID" }) + oauthClientId, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_CLIENT_ID" }) if err != nil { return err } - oauthClientAuthMethod, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { + oauthClientAuthMethod, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_CLIENT_AUTH_METHOD" }) if err != nil { return err } - oauthTokenEndpoint, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_TOKEN_ENDPOINT" }) + oauthTokenEndpoint, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_TOKEN_ENDPOINT" }) if err != nil { return err } diff --git a/pkg/resources/api_authentication_integration_with_authorization_code_grant.go b/pkg/resources/api_authentication_integration_with_authorization_code_grant.go index 28c3b6b721..a1fb3df121 100644 --- a/pkg/resources/api_authentication_integration_with_authorization_code_grant.go +++ b/pkg/resources/api_authentication_integration_with_authorization_code_grant.go @@ -79,7 +79,7 @@ func ImportApiAuthenticationWithAuthorizationCodeGrant(ctx context.Context, d *s if err := handleApiAuthImport(d, integration, properties); err != nil { return nil, err } - oauthAuthorizationEndpoint, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { + oauthAuthorizationEndpoint, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_AUTHORIZATION_ENDPOINT" }) if err == nil { @@ -87,7 +87,7 @@ func ImportApiAuthenticationWithAuthorizationCodeGrant(ctx context.Context, d *s return nil, err } } - oauthAllowedScopes, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ALLOWED_SCOPES" }) + oauthAllowedScopes, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ALLOWED_SCOPES" }) if err == nil { if err = d.Set("oauth_allowed_scopes", sdk.ParseCommaSeparatedStringArray(oauthAllowedScopes.Value, false)); err != nil { return nil, err @@ -168,14 +168,14 @@ func ReadContextApiAuthenticationIntegrationWithAuthorizationCodeGrant(withExter if c := integration.Category; c != sdk.SecurityIntegrationCategory { return diag.FromErr(fmt.Errorf("expected %v to be a %s integration, got %v", id, sdk.SecurityIntegrationCategory, c)) } - oauthAuthorizationEndpoint, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { + oauthAuthorizationEndpoint, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_AUTHORIZATION_ENDPOINT" }) if err != nil { return diag.FromErr(err) } - oauthAllowedScopes, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ALLOWED_SCOPES" }) + oauthAllowedScopes, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ALLOWED_SCOPES" }) if err != nil { return diag.FromErr(err) } diff --git a/pkg/resources/api_authentication_integration_with_client_credentials.go b/pkg/resources/api_authentication_integration_with_client_credentials.go index 852ed10d84..53231d8cf3 100644 --- a/pkg/resources/api_authentication_integration_with_client_credentials.go +++ b/pkg/resources/api_authentication_integration_with_client_credentials.go @@ -71,7 +71,7 @@ func ImportApiAuthenticationWithClientCredentials(ctx context.Context, d *schema if err := handleApiAuthImport(d, integration, properties); err != nil { return nil, err } - oauthAllowedScopes, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ALLOWED_SCOPES" }) + oauthAllowedScopes, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ALLOWED_SCOPES" }) if err == nil { if err = d.Set("oauth_allowed_scopes", sdk.ParseCommaSeparatedStringArray(oauthAllowedScopes.Value, false)); err != nil { return nil, err @@ -148,7 +148,7 @@ func ReadContextApiAuthenticationIntegrationWithClientCredentials(withExternalCh if c := integration.Category; c != sdk.SecurityIntegrationCategory { return diag.FromErr(fmt.Errorf("expected %v to be a %s integration, got %v", id, sdk.SecurityIntegrationCategory, c)) } - oauthAllowedScopes, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ALLOWED_SCOPES" }) + oauthAllowedScopes, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ALLOWED_SCOPES" }) if err != nil { return diag.FromErr(err) } diff --git a/pkg/resources/api_authentication_integration_with_jwt_bearer.go b/pkg/resources/api_authentication_integration_with_jwt_bearer.go index f8785ab402..23c4a68ee5 100644 --- a/pkg/resources/api_authentication_integration_with_jwt_bearer.go +++ b/pkg/resources/api_authentication_integration_with_jwt_bearer.go @@ -76,7 +76,7 @@ func ImportApiAuthenticationWithJwtBearer(ctx context.Context, d *schema.Resourc if err := handleApiAuthImport(d, integration, properties); err != nil { return nil, err } - oauthAuthorizationEndpoint, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { + oauthAuthorizationEndpoint, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_AUTHORIZATION_ENDPOINT" }) if err == nil { @@ -84,7 +84,7 @@ func ImportApiAuthenticationWithJwtBearer(ctx context.Context, d *schema.Resourc return nil, err } } - oauthAssertionIssuer, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ASSERTION_ISSUER" }) + oauthAssertionIssuer, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ASSERTION_ISSUER" }) if err == nil { if err = d.Set("oauth_assertion_issuer", oauthAssertionIssuer.Value); err != nil { return nil, err @@ -156,14 +156,14 @@ func ReadContextApiAuthenticationIntegrationWithJwtBearer(withExternalChangesMar if c := integration.Category; c != sdk.SecurityIntegrationCategory { return diag.FromErr(fmt.Errorf("expected %v to be a %s integration, got %v", id, sdk.SecurityIntegrationCategory, c)) } - oauthAuthorizationEndpoint, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { + oauthAuthorizationEndpoint, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_AUTHORIZATION_ENDPOINT" }) if err != nil { return diag.FromErr(err) } - oauthAssertionIssuer, err := collections.FindOne(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ASSERTION_ISSUER" }) + oauthAssertionIssuer, err := collections.FindFirst(properties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ASSERTION_ISSUER" }) if err != nil { return diag.FromErr(err) } diff --git a/pkg/resources/custom_diffs.go b/pkg/resources/custom_diffs.go index d49370eb73..d495e7cd93 100644 --- a/pkg/resources/custom_diffs.go +++ b/pkg/resources/custom_diffs.go @@ -27,7 +27,7 @@ func BoolParameterValueComputedIf[T ~string](key string, params []*sdk.Parameter func ParameterValueComputedIf[T ~string](key string, parameters []*sdk.Parameter, objectParameterLevel sdk.ParameterType, param T, valueToString func(v any) string) schema.CustomizeDiffFunc { return func(ctx context.Context, d *schema.ResourceDiff, meta any) error { - foundParameter, err := collections.FindOne(parameters, func(parameter *sdk.Parameter) bool { return parameter.Key == string(param) }) + foundParameter, err := collections.FindFirst(parameters, func(parameter *sdk.Parameter) bool { return parameter.Key == string(param) }) if err != nil { log.Printf("[WARN] failed to find parameter: %s", param) return nil diff --git a/pkg/resources/database_state_upgraders.go b/pkg/resources/database_state_upgraders.go index f028487eb1..06ff004771 100644 --- a/pkg/resources/database_state_upgraders.go +++ b/pkg/resources/database_state_upgraders.go @@ -43,7 +43,7 @@ func v092DatabaseStateUpgrader(ctx context.Context, rawState map[string]any, met } for i, accountLocator := range accountLocators { - replicationAccount, err := collections.FindOne(replicationAccounts, func(account *sdk.ReplicationAccount) bool { + replicationAccount, err := collections.FindFirst(replicationAccounts, func(account *sdk.ReplicationAccount) bool { return account.AccountLocator == accountLocator }) if err != nil { diff --git a/pkg/resources/external_oauth_integration.go b/pkg/resources/external_oauth_integration.go index 31aa448d47..c8b7ffbead 100644 --- a/pkg/resources/external_oauth_integration.go +++ b/pkg/resources/external_oauth_integration.go @@ -219,33 +219,33 @@ func ImportExternalOauthIntegration(ctx context.Context, d *schema.ResourceData, return nil, err } } - if prop, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_ISSUER" }); err == nil { + if prop, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_ISSUER" }); err == nil { if err = d.Set("external_oauth_issuer", prop.Value); err != nil { return nil, err } } - if prop, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if prop, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_JWS_KEYS_URL" }); err == nil { if err = d.Set("external_oauth_jws_keys_url", sdk.ParseCommaSeparatedStringArray(prop.Value, false)); err != nil { return nil, err } } - if prop, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if prop, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_ANY_ROLE_MODE" }); err == nil { if err = d.Set("external_oauth_any_role_mode", prop.Value); err != nil { return nil, err } } - if prop, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if prop, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_RSA_PUBLIC_KEY" }); err == nil { if err = d.Set("external_oauth_rsa_public_key", prop.Value); err != nil { return nil, err } } - if prop, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if prop, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_RSA_PUBLIC_KEY_2" }); err == nil { if err = d.Set("external_oauth_rsa_public_key_2", prop.Value); err != nil { @@ -253,7 +253,7 @@ func ImportExternalOauthIntegration(ctx context.Context, d *schema.ResourceData, } } - if prop, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if prop, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_BLOCKED_ROLES_LIST" }); err == nil { roles := sdk.ParseCommaSeparatedStringArray(prop.Value, false) @@ -261,42 +261,42 @@ func ImportExternalOauthIntegration(ctx context.Context, d *schema.ResourceData, return nil, err } } - if prop, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if prop, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_ALLOWED_ROLES_LIST" }); err == nil { if err = d.Set("external_oauth_allowed_roles_list", sdk.ParseCommaSeparatedStringArray(prop.Value, false)); err != nil { return nil, err } } - if prop, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if prop, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_AUDIENCE_LIST" }); err == nil { if err = d.Set("external_oauth_audience_list", sdk.ParseCommaSeparatedStringArray(prop.Value, false)); err != nil { return nil, err } } - if prop, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if prop, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM" }); err == nil { if err = d.Set("external_oauth_token_user_mapping_claim", sdk.ParseCommaSeparatedStringArray(prop.Value, true)); err != nil { return nil, err } } - if prop, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if prop, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE" }); err == nil { if err = d.Set("external_oauth_snowflake_user_mapping_attribute", prop.Value); err != nil { return nil, err } } - if prop, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if prop, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_SCOPE_DELIMITER" }); err == nil { if err = d.Set("external_oauth_scope_delimiter", prop.Value); err != nil { return nil, err } } - if prop, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "COMMENT" }); err == nil { + if prop, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "COMMENT" }); err == nil { if err = d.Set("comment", prop.Value); err != nil { return nil, err } @@ -452,65 +452,65 @@ func ReadContextExternalOauthIntegration(withExternalChangesMarking bool) schema return diag.FromErr(err) } if withExternalChangesMarking { - externalOauthIssuer, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_ISSUER" }) + externalOauthIssuer, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_ISSUER" }) if err != nil { return diag.FromErr(err) } - externalOauthJwsKeysUrl, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + externalOauthJwsKeysUrl, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_JWS_KEYS_URL" }) if err != nil { return diag.FromErr(err) } - externalOauthAnyRoleMode, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + externalOauthAnyRoleMode, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_ANY_ROLE_MODE" }) if err != nil { return diag.FromErr(err) } - externalOauthRsaPublicKey, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + externalOauthRsaPublicKey, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_RSA_PUBLIC_KEY" }) if err != nil { return diag.FromErr(err) } - externalOauthRsaPublicKey2, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + externalOauthRsaPublicKey2, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_RSA_PUBLIC_KEY_2" }) if err != nil { return diag.FromErr(err) } - externalOauthBlockedRolesList, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + externalOauthBlockedRolesList, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_BLOCKED_ROLES_LIST" }) if err != nil { return diag.FromErr(err) } - externalOauthAllowedRolesList, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + externalOauthAllowedRolesList, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_ALLOWED_ROLES_LIST" }) if err != nil { return diag.FromErr(err) } - externalOauthAudienceList, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + externalOauthAudienceList, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_AUDIENCE_LIST" }) if err != nil { return diag.FromErr(err) } - externalOauthTokenUserMappingClaim, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + externalOauthTokenUserMappingClaim, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_TOKEN_USER_MAPPING_CLAIM" }) if err != nil { return diag.FromErr(err) } - externalOauthSnowflakeUserMappingAttribute, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + externalOauthSnowflakeUserMappingAttribute, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_SNOWFLAKE_USER_MAPPING_ATTRIBUTE" }) if err != nil { return diag.FromErr(err) } - externalOauthScopeDelimiter, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + externalOauthScopeDelimiter, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "EXTERNAL_OAUTH_SCOPE_DELIMITER" }) if err != nil { diff --git a/pkg/resources/network_policy.go b/pkg/resources/network_policy.go index d22c86eeee..d04b44bf86 100644 --- a/pkg/resources/network_policy.go +++ b/pkg/resources/network_policy.go @@ -216,7 +216,7 @@ func ReadContextNetworkPolicy(ctx context.Context, d *schema.ResourceData, meta } allowedIpList := make([]string, 0) - if allowedIpListProperty, err := collections.FindOne(policyProperties, func(prop sdk.NetworkPolicyProperty) bool { return prop.Name == "ALLOWED_IP_LIST" }); err == nil { + if allowedIpListProperty, err := collections.FindFirst(policyProperties, func(prop sdk.NetworkPolicyProperty) bool { return prop.Name == "ALLOWED_IP_LIST" }); err == nil { allowedIpList = append(allowedIpList, sdk.ParseCommaSeparatedStringArray(allowedIpListProperty.Value, false)...) } if err = d.Set("allowed_ip_list", allowedIpList); err != nil { @@ -224,7 +224,7 @@ func ReadContextNetworkPolicy(ctx context.Context, d *schema.ResourceData, meta } blockedIpList := make([]string, 0) - if blockedIpListProperty, err := collections.FindOne(policyProperties, func(prop sdk.NetworkPolicyProperty) bool { return prop.Name == "BLOCKED_IP_LIST" }); err == nil { + if blockedIpListProperty, err := collections.FindFirst(policyProperties, func(prop sdk.NetworkPolicyProperty) bool { return prop.Name == "BLOCKED_IP_LIST" }); err == nil { blockedIpList = append(blockedIpList, sdk.ParseCommaSeparatedStringArray(blockedIpListProperty.Value, false)...) } if err = d.Set("blocked_ip_list", blockedIpList); err != nil { @@ -232,7 +232,7 @@ func ReadContextNetworkPolicy(ctx context.Context, d *schema.ResourceData, meta } allowedNetworkRules := make([]string, 0) - if allowedNetworkRuleList, err := collections.FindOne(policyProperties, func(prop sdk.NetworkPolicyProperty) bool { return prop.Name == "ALLOWED_NETWORK_RULE_LIST" }); err == nil { + if allowedNetworkRuleList, err := collections.FindFirst(policyProperties, func(prop sdk.NetworkPolicyProperty) bool { return prop.Name == "ALLOWED_NETWORK_RULE_LIST" }); err == nil { networkRules, err := sdk.ParseNetworkRulesSnowflakeDto(allowedNetworkRuleList.Value) if err != nil { return diag.FromErr(err) @@ -250,7 +250,7 @@ func ReadContextNetworkPolicy(ctx context.Context, d *schema.ResourceData, meta } blockedNetworkRules := make([]string, 0) - if blockedNetworkRuleList, err := collections.FindOne(policyProperties, func(prop sdk.NetworkPolicyProperty) bool { return prop.Name == "BLOCKED_NETWORK_RULE_LIST" }); err == nil { + if blockedNetworkRuleList, err := collections.FindFirst(policyProperties, func(prop sdk.NetworkPolicyProperty) bool { return prop.Name == "BLOCKED_NETWORK_RULE_LIST" }); err == nil { networkRules, err := sdk.ParseNetworkRulesSnowflakeDto(blockedNetworkRuleList.Value) if err != nil { return diag.FromErr(err) diff --git a/pkg/resources/oauth_integration_for_custom_clients.go b/pkg/resources/oauth_integration_for_custom_clients.go index aa133197a3..7d7828626b 100644 --- a/pkg/resources/oauth_integration_for_custom_clients.go +++ b/pkg/resources/oauth_integration_for_custom_clients.go @@ -216,7 +216,7 @@ func ImportOauthForCustomClientsIntegration(ctx context.Context, d *schema.Resou return nil, err } - if allowNonTlsRedirectUri, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if allowNonTlsRedirectUri, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ALLOW_NON_TLS_REDIRECT_URI" }); err == nil { if err = d.Set("oauth_allow_non_tls_redirect_uri", allowNonTlsRedirectUri.Value); err != nil { @@ -224,7 +224,7 @@ func ImportOauthForCustomClientsIntegration(ctx context.Context, d *schema.Resou } } - if enforcePkce, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if enforcePkce, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ENFORCE_PKCE" }); err == nil { if err = d.Set("oauth_enforce_pkce", enforcePkce.Value); err != nil { @@ -232,7 +232,7 @@ func ImportOauthForCustomClientsIntegration(ctx context.Context, d *schema.Resou } } - if issueRefreshTokens, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if issueRefreshTokens, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ISSUE_REFRESH_TOKENS" }); err == nil { if err = d.Set("oauth_issue_refresh_tokens", issueRefreshTokens.Value); err != nil { @@ -240,7 +240,7 @@ func ImportOauthForCustomClientsIntegration(ctx context.Context, d *schema.Resou } } - if refreshTokenValidity, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if refreshTokenValidity, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_REFRESH_TOKEN_VALIDITY" }); err == nil { refreshTokenValidityValue, err := strconv.ParseInt(refreshTokenValidity.Value, 10, 64) @@ -394,7 +394,7 @@ func ReadContextOauthIntegrationForCustomClients(withExternalChangesMarking bool return diag.FromErr(err) } - oauthClientType, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + oauthClientType, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_CLIENT_TYPE" }) if err != nil { @@ -404,7 +404,7 @@ func ReadContextOauthIntegrationForCustomClients(withExternalChangesMarking bool return diag.FromErr(err) } - oauthRedirectUri, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + oauthRedirectUri, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_REDIRECT_URI" }) if err != nil { @@ -414,7 +414,7 @@ func ReadContextOauthIntegrationForCustomClients(withExternalChangesMarking bool return diag.FromErr(err) } - preAuthorizedRolesList, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + preAuthorizedRolesList, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "PRE_AUTHORIZED_ROLES_LIST" }) if err != nil { @@ -428,7 +428,7 @@ func ReadContextOauthIntegrationForCustomClients(withExternalChangesMarking bool return diag.FromErr(err) } - blockedRolesList, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + blockedRolesList, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "BLOCKED_ROLES_LIST" }) if err != nil { @@ -442,7 +442,7 @@ func ReadContextOauthIntegrationForCustomClients(withExternalChangesMarking bool return diag.FromErr(err) } - networkPolicy, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + networkPolicy, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "NETWORK_POLICY" }) if err != nil { @@ -459,35 +459,35 @@ func ReadContextOauthIntegrationForCustomClients(withExternalChangesMarking bool return diag.FromErr(err) } - oauthAllowNonTlsRedirectUri, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + oauthAllowNonTlsRedirectUri, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ALLOW_NON_TLS_REDIRECT_URI" }) if err != nil { return diag.FromErr(err) } - oauthEnforcePkce, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + oauthEnforcePkce, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ENFORCE_PKCE" }) if err != nil { return diag.FromErr(err) } - oauthUseSecondaryRoles, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + oauthUseSecondaryRoles, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_USE_SECONDARY_ROLES" }) if err != nil { return diag.FromErr(err) } - oauthIssueRefreshTokens, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + oauthIssueRefreshTokens, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ISSUE_REFRESH_TOKENS" }) if err != nil { return diag.FromErr(err) } - oauthRefreshTokenValidity, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + oauthRefreshTokenValidity, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_REFRESH_TOKEN_VALIDITY" }) if err != nil { diff --git a/pkg/resources/oauth_integration_for_partner_applications.go b/pkg/resources/oauth_integration_for_partner_applications.go index 9cf0dfcefc..de031dab6c 100644 --- a/pkg/resources/oauth_integration_for_partner_applications.go +++ b/pkg/resources/oauth_integration_for_partner_applications.go @@ -169,7 +169,7 @@ func ImportOauthForPartnerApplicationIntegration(ctx context.Context, d *schema. return nil, err } - if issueRefreshTokens, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if issueRefreshTokens, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ISSUE_REFRESH_TOKENS" }); err == nil { if err = d.Set("oauth_issue_refresh_tokens", issueRefreshTokens.Value); err != nil { @@ -177,7 +177,7 @@ func ImportOauthForPartnerApplicationIntegration(ctx context.Context, d *schema. } } - if refreshTokenValidity, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if refreshTokenValidity, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_REFRESH_TOKEN_VALIDITY" }); err == nil { refreshTokenValidityValue, err := strconv.ParseInt(refreshTokenValidity.Value, 10, 64) @@ -189,7 +189,7 @@ func ImportOauthForPartnerApplicationIntegration(ctx context.Context, d *schema. } } - if oauthUseSecondaryRoles, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + if oauthUseSecondaryRoles, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_USE_SECONDARY_ROLES" }); err == nil { oauthUseSecondaryRolesValue, err := sdk.ToOauthSecurityIntegrationUseSecondaryRolesOption(oauthUseSecondaryRoles.Value) @@ -318,7 +318,7 @@ func ReadContextOauthIntegrationForPartnerApplications(withExternalChangesMarkin return diag.FromErr(err) } - blockedRolesList, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + blockedRolesList, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "BLOCKED_ROLES_LIST" }) if err != nil { @@ -339,14 +339,14 @@ func ReadContextOauthIntegrationForPartnerApplications(withExternalChangesMarkin return diag.FromErr(err) } - oauthIssueRefreshTokens, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + oauthIssueRefreshTokens, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_ISSUE_REFRESH_TOKENS" }) if err != nil { return diag.FromErr(err) } - oauthRefreshTokenValidity, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + oauthRefreshTokenValidity, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_REFRESH_TOKEN_VALIDITY" }) if err != nil { @@ -357,7 +357,7 @@ func ReadContextOauthIntegrationForPartnerApplications(withExternalChangesMarkin return diag.FromErr(err) } - oauthUseSecondaryRoles, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + oauthUseSecondaryRoles, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "OAUTH_USE_SECONDARY_ROLES" }) if err != nil { diff --git a/pkg/resources/saml2_integration.go b/pkg/resources/saml2_integration.go index a460970f1f..3939d2249a 100644 --- a/pkg/resources/saml2_integration.go +++ b/pkg/resources/saml2_integration.go @@ -210,7 +210,7 @@ func ImportSaml2Integration(ctx context.Context, d *schema.ResourceData, meta an return nil, err } - samlIssuer, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_ISSUER" }) + samlIssuer, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_ISSUER" }) if err != nil { return nil, fmt.Errorf("failed to find saml2 saml issuer, err = %w", err) } @@ -218,7 +218,7 @@ func ImportSaml2Integration(ctx context.Context, d *schema.ResourceData, meta an return nil, err } - ssoUrl, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_SSO_URL" }) + ssoUrl, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_SSO_URL" }) if err != nil { return nil, fmt.Errorf("failed to find saml2 sso url, err = %w", err) } @@ -226,7 +226,7 @@ func ImportSaml2Integration(ctx context.Context, d *schema.ResourceData, meta an return nil, err } - samlProvider, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_PROVIDER" }) + samlProvider, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_PROVIDER" }) if err != nil { return nil, fmt.Errorf("failed to find saml2 provider, err = %w", err) } @@ -238,7 +238,7 @@ func ImportSaml2Integration(ctx context.Context, d *schema.ResourceData, meta an return nil, err } - x509Cert, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_X509_CERT" }) + x509Cert, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_X509_CERT" }) if err != nil { return nil, fmt.Errorf("failed to find saml2 x509 cert, err = %w", err) } @@ -246,7 +246,7 @@ func ImportSaml2Integration(ctx context.Context, d *schema.ResourceData, meta an return nil, err } - spInitiatedLoginPageLabel, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + spInitiatedLoginPageLabel, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_SP_INITIATED_LOGIN_PAGE_LABEL" }) if err != nil { @@ -256,7 +256,7 @@ func ImportSaml2Integration(ctx context.Context, d *schema.ResourceData, meta an return nil, err } - enableSpInitiated, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + enableSpInitiated, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_ENABLE_SP_INITIATED" }) if err != nil { @@ -266,7 +266,7 @@ func ImportSaml2Integration(ctx context.Context, d *schema.ResourceData, meta an return nil, err } - signRequest, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + signRequest, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_SIGN_REQUEST" }) if err != nil { @@ -276,7 +276,7 @@ func ImportSaml2Integration(ctx context.Context, d *schema.ResourceData, meta an return nil, err } - requestedNameIdFormat, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + requestedNameIdFormat, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_REQUESTED_NAMEID_FORMAT" }) if err != nil { @@ -286,7 +286,7 @@ func ImportSaml2Integration(ctx context.Context, d *schema.ResourceData, meta an return nil, err } - postLogoutRedirectUrl, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + postLogoutRedirectUrl, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_POST_LOGOUT_REDIRECT_URL" }) if err != nil { @@ -296,7 +296,7 @@ func ImportSaml2Integration(ctx context.Context, d *schema.ResourceData, meta an return nil, err } - forceAuthn, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + forceAuthn, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_FORCE_AUTHN" }) if err != nil { @@ -306,7 +306,7 @@ func ImportSaml2Integration(ctx context.Context, d *schema.ResourceData, meta an return nil, err } - snowflakeIssuerUrl, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + snowflakeIssuerUrl, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_SNOWFLAKE_ISSUER_URL" }) if err != nil { @@ -316,7 +316,7 @@ func ImportSaml2Integration(ctx context.Context, d *schema.ResourceData, meta an return nil, err } - snowflakeAcsUrl, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + snowflakeAcsUrl, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_SNOWFLAKE_ACS_URL" }) if err != nil { @@ -338,7 +338,7 @@ func ImportSaml2Integration(ctx context.Context, d *schema.ResourceData, meta an } func getOptionalListField(props []sdk.SecurityIntegrationProperty, propName string) []string { - found, err := collections.FindOne(props, func(property sdk.SecurityIntegrationProperty) bool { + found, err := collections.FindFirst(props, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == propName }) if err != nil { @@ -494,7 +494,7 @@ func ReadContextSAML2Integration(withExternalChangesMarking bool) schema.ReadCon return diag.FromErr(err) } - samlIssuer, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_ISSUER" }) + samlIssuer, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_ISSUER" }) if err != nil { return diag.FromErr(fmt.Errorf("failed to find saml2 saml issuer, err = %w", err)) } @@ -502,7 +502,7 @@ func ReadContextSAML2Integration(withExternalChangesMarking bool) schema.ReadCon return diag.FromErr(err) } - ssoUrl, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_SSO_URL" }) + ssoUrl, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_SSO_URL" }) if err != nil { return diag.FromErr(fmt.Errorf("failed to find saml2 sso url, err = %w", err)) } @@ -510,7 +510,7 @@ func ReadContextSAML2Integration(withExternalChangesMarking bool) schema.ReadCon return diag.FromErr(err) } - samlProvider, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_PROVIDER" }) + samlProvider, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_PROVIDER" }) if err != nil { return diag.FromErr(fmt.Errorf("failed to find saml2 provider, err = %w", err)) } @@ -522,7 +522,7 @@ func ReadContextSAML2Integration(withExternalChangesMarking bool) schema.ReadCon return diag.FromErr(err) } - x509Cert, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_X509_CERT" }) + x509Cert, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_X509_CERT" }) if err != nil { return diag.FromErr(fmt.Errorf("failed to find saml2 x509 cert, err = %w", err)) } @@ -530,7 +530,7 @@ func ReadContextSAML2Integration(withExternalChangesMarking bool) schema.ReadCon return diag.FromErr(err) } - postLogoutRedirectUrl, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + postLogoutRedirectUrl, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_POST_LOGOUT_REDIRECT_URL" }) if err != nil { @@ -559,49 +559,49 @@ func ReadContextSAML2Integration(withExternalChangesMarking bool) schema.ReadCon return diag.FromErr(err) } - enableSpInitiated, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + enableSpInitiated, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_ENABLE_SP_INITIATED" }) if err != nil { return diag.FromErr(fmt.Errorf("failed to find saml2 enable sp initiated, err = %w", err)) } - signRequest, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + signRequest, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_SIGN_REQUEST" }) if err != nil { return diag.FromErr(fmt.Errorf("failed to find saml2 sign request, err = %w", err)) } - requestedNameIdFormat, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + requestedNameIdFormat, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_REQUESTED_NAMEID_FORMAT" }) if err != nil { return diag.FromErr(fmt.Errorf("failed to find saml2 requested nameid format, err = %w", err)) } - forceAuthn, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + forceAuthn, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_FORCE_AUTHN" }) if err != nil { return diag.FromErr(fmt.Errorf("failed to find saml2 force authn, err = %w", err)) } - snowflakeIssuerUrl, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + snowflakeIssuerUrl, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_SNOWFLAKE_ISSUER_URL" }) if err != nil { return diag.FromErr(fmt.Errorf("failed to find saml2 snowflake issuer url, err = %w", err)) } - snowflakeAcsUrl, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + snowflakeAcsUrl, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_SNOWFLAKE_ACS_URL" }) if err != nil { return diag.FromErr(fmt.Errorf("failed to find saml2 snowflake acs url, err = %w", err)) } - spInitiatedLoginPageLabel, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { + spInitiatedLoginPageLabel, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SAML2_SP_INITIATED_LOGIN_PAGE_LABEL" }) if err != nil { diff --git a/pkg/resources/scim_integration.go b/pkg/resources/scim_integration.go index 15fd779d52..fab3d51ae0 100644 --- a/pkg/resources/scim_integration.go +++ b/pkg/resources/scim_integration.go @@ -162,12 +162,12 @@ func ImportScimIntegration(ctx context.Context, d *schema.ResourceData, meta any if err = d.Set("scim_client", scimClient); err != nil { return nil, err } - if runAsRoleProperty, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "RUN_AS_ROLE" }); err == nil { + if runAsRoleProperty, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "RUN_AS_ROLE" }); err == nil { if err = d.Set("run_as_role", runAsRoleProperty.Value); err != nil { return nil, err } } - if networkPolicyProperty, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "NETWORK_POLICY" }); err == nil { + if networkPolicyProperty, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "NETWORK_POLICY" }); err == nil { if err = d.Set("network_policy", networkPolicyProperty.Value); err != nil { return nil, err } @@ -177,7 +177,7 @@ func ImportScimIntegration(ctx context.Context, d *schema.ResourceData, meta any return nil, err } } else { - if syncPasswordProperty, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SYNC_PASSWORD" }); err == nil { + if syncPasswordProperty, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SYNC_PASSWORD" }); err == nil { if err = d.Set("sync_password", syncPasswordProperty.Value); err != nil { return nil, err } @@ -303,7 +303,7 @@ func ReadContextSCIMIntegration(withExternalChangesMarking bool) schema.ReadCont return diag.FromErr(err) } - runAsRoleProperty, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "RUN_AS_ROLE" }) + runAsRoleProperty, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "RUN_AS_ROLE" }) if err != nil { return diag.FromErr(err) } @@ -317,7 +317,7 @@ func ReadContextSCIMIntegration(withExternalChangesMarking bool) schema.ReadCont } if withExternalChangesMarking { - networkPolicyProperty, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "NETWORK_POLICY" }) + networkPolicyProperty, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "NETWORK_POLICY" }) if err != nil { return diag.FromErr(err) } @@ -329,7 +329,7 @@ func ReadContextSCIMIntegration(withExternalChangesMarking bool) schema.ReadCont } if !strings.EqualFold(strings.TrimSpace(scimClient), string(sdk.ScimSecurityIntegrationScimClientAzure)) { - syncPasswordProperty, err := collections.FindOne(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SYNC_PASSWORD" }) + syncPasswordProperty, err := collections.FindFirst(integrationProperties, func(property sdk.SecurityIntegrationProperty) bool { return property.Name == "SYNC_PASSWORD" }) if err != nil { return diag.FromErr(err) } diff --git a/pkg/sdk/api_integrations_impl_gen.go b/pkg/sdk/api_integrations_impl_gen.go index 151429bc69..6de2304572 100644 --- a/pkg/sdk/api_integrations_impl_gen.go +++ b/pkg/sdk/api_integrations_impl_gen.go @@ -44,7 +44,7 @@ func (v *apiIntegrations) ShowByID(ctx context.Context, id AccountObjectIdentifi if err != nil { return nil, err } - return collections.FindOne(apiIntegrations, func(r ApiIntegration) bool { return r.Name == id.Name() }) + return collections.FindFirst(apiIntegrations, func(r ApiIntegration) bool { return r.Name == id.Name() }) } func (v *apiIntegrations) Describe(ctx context.Context, id AccountObjectIdentifier) ([]ApiIntegrationProperty, error) { diff --git a/pkg/sdk/application_packages_impl_gen.go b/pkg/sdk/application_packages_impl_gen.go index 0db872f4cd..36b23c8f47 100644 --- a/pkg/sdk/application_packages_impl_gen.go +++ b/pkg/sdk/application_packages_impl_gen.go @@ -43,7 +43,7 @@ func (v *applicationPackages) ShowByID(ctx context.Context, id AccountObjectIden if err != nil { return nil, err } - return collections.FindOne(applicationPackages, func(r ApplicationPackage) bool { return r.Name == id.Name() }) + return collections.FindFirst(applicationPackages, func(r ApplicationPackage) bool { return r.Name == id.Name() }) } func (r *CreateApplicationPackageRequest) toOpts() *CreateApplicationPackageOptions { diff --git a/pkg/sdk/application_roles_impl_gen.go b/pkg/sdk/application_roles_impl_gen.go index 737403fdac..a02e940f3d 100644 --- a/pkg/sdk/application_roles_impl_gen.go +++ b/pkg/sdk/application_roles_impl_gen.go @@ -38,7 +38,7 @@ func (v *applicationRoles) ShowByID(ctx context.Context, id DatabaseObjectIdenti if err != nil { return nil, err } - return collections.FindOne(applicationRoles, func(r ApplicationRole) bool { return r.Name == id.Name() }) + return collections.FindFirst(applicationRoles, func(r ApplicationRole) bool { return r.Name == id.Name() }) } func (r *GrantApplicationRoleRequest) toOpts() *GrantApplicationRoleOptions { diff --git a/pkg/sdk/applications_impl_gen.go b/pkg/sdk/applications_impl_gen.go index a442001580..dab57a9411 100644 --- a/pkg/sdk/applications_impl_gen.go +++ b/pkg/sdk/applications_impl_gen.go @@ -43,7 +43,7 @@ func (v *applications) ShowByID(ctx context.Context, id AccountObjectIdentifier) if err != nil { return nil, err } - return collections.FindOne(applications, func(r Application) bool { return r.Name == id.Name() }) + return collections.FindFirst(applications, func(r Application) bool { return r.Name == id.Name() }) } func (v *applications) Describe(ctx context.Context, id AccountObjectIdentifier) ([]ApplicationProperty, error) { diff --git a/pkg/sdk/cortex_search_services_impl_gen.go b/pkg/sdk/cortex_search_services_impl_gen.go index c8c7e54e1f..320a5eaf40 100644 --- a/pkg/sdk/cortex_search_services_impl_gen.go +++ b/pkg/sdk/cortex_search_services_impl_gen.go @@ -41,7 +41,7 @@ func (v *cortexSearchServices) ShowByID(ctx context.Context, id SchemaObjectIden if err != nil { return nil, err } - return collections.FindOne(cortexSearchServices, func(r CortexSearchService) bool { return r.Name == id.Name() }) + return collections.FindFirst(cortexSearchServices, func(r CortexSearchService) bool { return r.Name == id.Name() }) } func (v *cortexSearchServices) Describe(ctx context.Context, id SchemaObjectIdentifier) (*CortexSearchServiceDetails, error) { diff --git a/pkg/sdk/database_role_impl.go b/pkg/sdk/database_role_impl.go index a768a3b73d..131edf442e 100644 --- a/pkg/sdk/database_role_impl.go +++ b/pkg/sdk/database_role_impl.go @@ -50,7 +50,7 @@ func (v *databaseRoles) ShowByID(ctx context.Context, id DatabaseObjectIdentifie return nil, err } - return collections.FindOne(databaseRoles, func(r DatabaseRole) bool { return r.Name == id.Name() }) + return collections.FindFirst(databaseRoles, func(r DatabaseRole) bool { return r.Name == id.Name() }) } func (v *databaseRoles) Grant(ctx context.Context, request *GrantDatabaseRoleRequest) error { diff --git a/pkg/sdk/dynamic_table_impl.go b/pkg/sdk/dynamic_table_impl.go index 3f64424e98..eb2123d958 100644 --- a/pkg/sdk/dynamic_table_impl.go +++ b/pkg/sdk/dynamic_table_impl.go @@ -52,7 +52,7 @@ func (v *dynamicTables) ShowByID(ctx context.Context, id SchemaObjectIdentifier) if err != nil { return nil, err } - return collections.FindOne(dynamicTables, func(r DynamicTable) bool { return r.Name == id.Name() }) + return collections.FindFirst(dynamicTables, func(r DynamicTable) bool { return r.Name == id.Name() }) } func (s *CreateDynamicTableRequest) toOpts() *createDynamicTableOptions { diff --git a/pkg/sdk/event_tables_impl_gen.go b/pkg/sdk/event_tables_impl_gen.go index 980fb2c8f2..57b18fdbcb 100644 --- a/pkg/sdk/event_tables_impl_gen.go +++ b/pkg/sdk/event_tables_impl_gen.go @@ -33,7 +33,7 @@ func (v *eventTables) ShowByID(ctx context.Context, id SchemaObjectIdentifier) ( if err != nil { return nil, err } - return collections.FindOne(eventTables, func(r EventTable) bool { return r.Name == id.Name() }) + return collections.FindFirst(eventTables, func(r EventTable) bool { return r.Name == id.Name() }) } func (v *eventTables) Describe(ctx context.Context, id SchemaObjectIdentifier) (*EventTableDetails, error) { diff --git a/pkg/sdk/external_functions_impl_gen.go b/pkg/sdk/external_functions_impl_gen.go index ee7eee6f87..51831541f1 100644 --- a/pkg/sdk/external_functions_impl_gen.go +++ b/pkg/sdk/external_functions_impl_gen.go @@ -39,7 +39,7 @@ func (v *externalFunctions) ShowByID(ctx context.Context, id SchemaObjectIdentif if err != nil { return nil, err } - return collections.FindOne(externalFunctions, func(r ExternalFunction) bool { return r.ID().FullyQualifiedName() == id.FullyQualifiedName() }) + return collections.FindFirst(externalFunctions, func(r ExternalFunction) bool { return r.ID().FullyQualifiedName() == id.FullyQualifiedName() }) } func (v *externalFunctions) Describe(ctx context.Context, id SchemaObjectIdentifierWithArguments) ([]ExternalFunctionProperty, error) { diff --git a/pkg/sdk/external_tables_impl.go b/pkg/sdk/external_tables_impl.go index 898bef37e8..145e44fc57 100644 --- a/pkg/sdk/external_tables_impl.go +++ b/pkg/sdk/external_tables_impl.go @@ -61,7 +61,7 @@ func (v *externalTables) ShowByID(ctx context.Context, id SchemaObjectIdentifier return nil, err } - return collections.FindOne(externalTables, func(t ExternalTable) bool { return t.ID().FullyQualifiedName() == id.FullyQualifiedName() }) + return collections.FindFirst(externalTables, func(t ExternalTable) bool { return t.ID().FullyQualifiedName() == id.FullyQualifiedName() }) } func (v *externalTables) DescribeColumns(ctx context.Context, req *DescribeExternalTableColumnsRequest) ([]ExternalTableColumnDetails, error) { diff --git a/pkg/sdk/functions_impl_gen.go b/pkg/sdk/functions_impl_gen.go index a7dcb95c2d..2abf41c1e6 100644 --- a/pkg/sdk/functions_impl_gen.go +++ b/pkg/sdk/functions_impl_gen.go @@ -64,7 +64,7 @@ func (v *functions) ShowByID(ctx context.Context, id SchemaObjectIdentifierWithA if err != nil { return nil, err } - return collections.FindOne(functions, func(r Function) bool { return r.ID().FullyQualifiedName() == id.FullyQualifiedName() }) + return collections.FindFirst(functions, func(r Function) bool { return r.ID().FullyQualifiedName() == id.FullyQualifiedName() }) } func (v *functions) Describe(ctx context.Context, id SchemaObjectIdentifierWithArguments) ([]FunctionDetail, error) { diff --git a/pkg/sdk/managed_accounts_impl_gen.go b/pkg/sdk/managed_accounts_impl_gen.go index 2873cb9920..f7a93b05d6 100644 --- a/pkg/sdk/managed_accounts_impl_gen.go +++ b/pkg/sdk/managed_accounts_impl_gen.go @@ -37,7 +37,7 @@ func (v *managedAccounts) ShowByID(ctx context.Context, id AccountObjectIdentifi if err != nil { return nil, err } - return collections.FindOne(managedAccounts, func(r ManagedAccount) bool { return r.Name == id.Name() }) + return collections.FindFirst(managedAccounts, func(r ManagedAccount) bool { return r.Name == id.Name() }) } func (r *CreateManagedAccountRequest) toOpts() *CreateManagedAccountOptions { diff --git a/pkg/sdk/materialized_views_impl_gen.go b/pkg/sdk/materialized_views_impl_gen.go index c278d2f6e9..d422d59b04 100644 --- a/pkg/sdk/materialized_views_impl_gen.go +++ b/pkg/sdk/materialized_views_impl_gen.go @@ -43,7 +43,7 @@ func (v *materializedViews) ShowByID(ctx context.Context, id SchemaObjectIdentif if err != nil { return nil, err } - return collections.FindOne(materializedViews, func(r MaterializedView) bool { return r.Name == id.Name() }) + return collections.FindFirst(materializedViews, func(r MaterializedView) bool { return r.Name == id.Name() }) } func (v *materializedViews) Describe(ctx context.Context, id SchemaObjectIdentifier) ([]MaterializedViewDetails, error) { diff --git a/pkg/sdk/network_policies_impl_gen.go b/pkg/sdk/network_policies_impl_gen.go index 593e62ef5b..950b9491e3 100644 --- a/pkg/sdk/network_policies_impl_gen.go +++ b/pkg/sdk/network_policies_impl_gen.go @@ -43,7 +43,7 @@ func (v *networkPolicies) ShowByID(ctx context.Context, id AccountObjectIdentifi return nil, err } - return collections.FindOne(networkPolicies, func(r NetworkPolicy) bool { return r.Name == id.Name() }) + return collections.FindFirst(networkPolicies, func(r NetworkPolicy) bool { return r.Name == id.Name() }) } func (v *networkPolicies) Describe(ctx context.Context, id AccountObjectIdentifier) ([]NetworkPolicyProperty, error) { diff --git a/pkg/sdk/network_rule_impl_gen.go b/pkg/sdk/network_rule_impl_gen.go index 5b575496ff..a4f84e23ba 100644 --- a/pkg/sdk/network_rule_impl_gen.go +++ b/pkg/sdk/network_rule_impl_gen.go @@ -47,7 +47,7 @@ func (v *networkRules) ShowByID(ctx context.Context, id SchemaObjectIdentifier) if err != nil { return nil, err } - return collections.FindOne(networkRules, func(r NetworkRule) bool { return r.Name == id.Name() }) + return collections.FindFirst(networkRules, func(r NetworkRule) bool { return r.Name == id.Name() }) } func (v *networkRules) Describe(ctx context.Context, id SchemaObjectIdentifier) (*NetworkRuleDetails, error) { diff --git a/pkg/sdk/notification_integrations_impl_gen.go b/pkg/sdk/notification_integrations_impl_gen.go index 7e33ac332a..aaf5f38433 100644 --- a/pkg/sdk/notification_integrations_impl_gen.go +++ b/pkg/sdk/notification_integrations_impl_gen.go @@ -44,7 +44,7 @@ func (v *notificationIntegrations) ShowByID(ctx context.Context, id AccountObjec if err != nil { return nil, err } - return collections.FindOne(notificationIntegrations, func(r NotificationIntegration) bool { return r.Name == id.Name() }) + return collections.FindFirst(notificationIntegrations, func(r NotificationIntegration) bool { return r.Name == id.Name() }) } func (v *notificationIntegrations) Describe(ctx context.Context, id AccountObjectIdentifier) ([]NotificationIntegrationProperty, error) { diff --git a/pkg/sdk/pipes_impl.go b/pkg/sdk/pipes_impl.go index 6a69d84a97..a288e9883c 100644 --- a/pkg/sdk/pipes_impl.go +++ b/pkg/sdk/pipes_impl.go @@ -55,7 +55,7 @@ func (v *pipes) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*Pipe, return nil, err } - return collections.FindOne(pipes, func(p Pipe) bool { return p.ID().name == id.Name() }) + return collections.FindFirst(pipes, func(p Pipe) bool { return p.ID().name == id.Name() }) } func (v *pipes) Describe(ctx context.Context, id SchemaObjectIdentifier) (*Pipe, error) { diff --git a/pkg/sdk/poc/generator/templates/sub_templates/implementation_functions.tmpl b/pkg/sdk/poc/generator/templates/sub_templates/implementation_functions.tmpl index 575dd835d0..5b79463dbb 100644 --- a/pkg/sdk/poc/generator/templates/sub_templates/implementation_functions.tmpl +++ b/pkg/sdk/poc/generator/templates/sub_templates/implementation_functions.tmpl @@ -19,7 +19,7 @@ if err != nil { return nil, err } - return collections.FindOne({{ $impl }}, func(r {{ .ObjectInterface.NameSingular }}) bool { return r.Name == id.Name() }) + return collections.FindFirst({{ $impl }}, func(r {{ .ObjectInterface.NameSingular }}) bool { return r.Name == id.Name() }) } {{ else if and (eq .Name "Describe") .DescribeMapping }} {{ if .DescribeKind }} diff --git a/pkg/sdk/procedures_impl_gen.go b/pkg/sdk/procedures_impl_gen.go index 1152b2c139..80cb096373 100644 --- a/pkg/sdk/procedures_impl_gen.go +++ b/pkg/sdk/procedures_impl_gen.go @@ -64,7 +64,7 @@ func (v *procedures) ShowByID(ctx context.Context, id SchemaObjectIdentifierWith if err != nil { return nil, err } - return collections.FindOne(procedures, func(r Procedure) bool { return r.ID().FullyQualifiedName() == id.FullyQualifiedName() }) + return collections.FindFirst(procedures, func(r Procedure) bool { return r.ID().FullyQualifiedName() == id.FullyQualifiedName() }) } func (v *procedures) Describe(ctx context.Context, id SchemaObjectIdentifierWithArguments) ([]ProcedureDetail, error) { diff --git a/pkg/sdk/roles_impl.go b/pkg/sdk/roles_impl.go index ebe55252db..1b1ec5d27c 100644 --- a/pkg/sdk/roles_impl.go +++ b/pkg/sdk/roles_impl.go @@ -41,7 +41,7 @@ func (v *roles) ShowByID(ctx context.Context, id AccountObjectIdentifier) (*Role if err != nil { return nil, err } - return collections.FindOne(roleList, func(r Role) bool { return r.ID().name == id.Name() }) + return collections.FindFirst(roleList, func(r Role) bool { return r.ID().name == id.Name() }) } func (v *roles) Grant(ctx context.Context, req *GrantRoleRequest) error { diff --git a/pkg/sdk/row_access_policies_impl_gen.go b/pkg/sdk/row_access_policies_impl_gen.go index 8fd42f1e9d..8f04e4eae2 100644 --- a/pkg/sdk/row_access_policies_impl_gen.go +++ b/pkg/sdk/row_access_policies_impl_gen.go @@ -43,7 +43,7 @@ func (v *rowAccessPolicies) ShowByID(ctx context.Context, id SchemaObjectIdentif if err != nil { return nil, err } - return collections.FindOne(rowAccessPolicies, func(r RowAccessPolicy) bool { return r.Name == id.Name() }) + return collections.FindFirst(rowAccessPolicies, func(r RowAccessPolicy) bool { return r.Name == id.Name() }) } func (v *rowAccessPolicies) Describe(ctx context.Context, id SchemaObjectIdentifier) (*RowAccessPolicyDescription, error) { diff --git a/pkg/sdk/schemas.go b/pkg/sdk/schemas.go index c6f5778133..b8b4593245 100644 --- a/pkg/sdk/schemas.go +++ b/pkg/sdk/schemas.go @@ -568,7 +568,7 @@ func (v *schemas) ShowByID(ctx context.Context, id DatabaseObjectIdentifier) (*S if err != nil { return nil, err } - return collections.FindOne(schemas, func(r Schema) bool { return r.Name == id.Name() }) + return collections.FindFirst(schemas, func(r Schema) bool { return r.Name == id.Name() }) } func (v *schemas) Use(ctx context.Context, id DatabaseObjectIdentifier) error { diff --git a/pkg/sdk/security_integrations_impl_gen.go b/pkg/sdk/security_integrations_impl_gen.go index 196ce3ec94..d430bbc2d9 100644 --- a/pkg/sdk/security_integrations_impl_gen.go +++ b/pkg/sdk/security_integrations_impl_gen.go @@ -125,7 +125,7 @@ func (v *securityIntegrations) ShowByID(ctx context.Context, id AccountObjectIde if err != nil { return nil, err } - return collections.FindOne(securityIntegrations, func(r SecurityIntegration) bool { return r.Name == id.Name() }) + return collections.FindFirst(securityIntegrations, func(r SecurityIntegration) bool { return r.Name == id.Name() }) } func (r *CreateApiAuthenticationWithClientCredentialsFlowSecurityIntegrationRequest) toOpts() *CreateApiAuthenticationWithClientCredentialsFlowSecurityIntegrationOptions { diff --git a/pkg/sdk/sequences_impl_gen.go b/pkg/sdk/sequences_impl_gen.go index 1095e19b59..202f61b605 100644 --- a/pkg/sdk/sequences_impl_gen.go +++ b/pkg/sdk/sequences_impl_gen.go @@ -38,7 +38,7 @@ func (v *sequences) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*S if err != nil { return nil, err } - return collections.FindOne(sequences, func(r Sequence) bool { return r.Name == id.Name() }) + return collections.FindFirst(sequences, func(r Sequence) bool { return r.Name == id.Name() }) } func (v *sequences) Describe(ctx context.Context, id SchemaObjectIdentifier) (*SequenceDetail, error) { diff --git a/pkg/sdk/session_policies_impl_gen.go b/pkg/sdk/session_policies_impl_gen.go index 2ad349fd67..93a0293b93 100644 --- a/pkg/sdk/session_policies_impl_gen.go +++ b/pkg/sdk/session_policies_impl_gen.go @@ -43,7 +43,7 @@ func (v *sessionPolicies) ShowByID(ctx context.Context, id SchemaObjectIdentifie return nil, err } - return collections.FindOne(sessionPolicies, func(r SessionPolicy) bool { return r.Name == id.Name() }) + return collections.FindFirst(sessionPolicies, func(r SessionPolicy) bool { return r.Name == id.Name() }) } func (v *sessionPolicies) Describe(ctx context.Context, id SchemaObjectIdentifier) (*SessionPolicyDescription, error) { diff --git a/pkg/sdk/stages_impl_gen.go b/pkg/sdk/stages_impl_gen.go index 0e7cc4b3d6..9797678aa5 100644 --- a/pkg/sdk/stages_impl_gen.go +++ b/pkg/sdk/stages_impl_gen.go @@ -104,7 +104,7 @@ func (v *stages) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*Stag if err != nil { return nil, err } - return collections.FindOne(stages, func(r Stage) bool { return r.Name == id.Name() }) + return collections.FindFirst(stages, func(r Stage) bool { return r.Name == id.Name() }) } func (s *CreateInternalStageRequest) toOpts() *CreateInternalStageOptions { diff --git a/pkg/sdk/storage_integration_impl_gen.go b/pkg/sdk/storage_integration_impl_gen.go index cc89ee6645..1361bfdfad 100644 --- a/pkg/sdk/storage_integration_impl_gen.go +++ b/pkg/sdk/storage_integration_impl_gen.go @@ -44,7 +44,7 @@ func (v *storageIntegrations) ShowByID(ctx context.Context, id AccountObjectIden if err != nil { return nil, err } - return collections.FindOne(storageIntegrations, func(r StorageIntegration) bool { return r.Name == id.Name() }) + return collections.FindFirst(storageIntegrations, func(r StorageIntegration) bool { return r.Name == id.Name() }) } func (v *storageIntegrations) Describe(ctx context.Context, id AccountObjectIdentifier) ([]StorageIntegrationProperty, error) { diff --git a/pkg/sdk/streamlits_impl_gen.go b/pkg/sdk/streamlits_impl_gen.go index 5d006afd26..0544bc8cfe 100644 --- a/pkg/sdk/streamlits_impl_gen.go +++ b/pkg/sdk/streamlits_impl_gen.go @@ -43,7 +43,7 @@ func (v *streamlits) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (* if err != nil { return nil, err } - return collections.FindOne(streamlits, func(r Streamlit) bool { return r.Name == id.Name() }) + return collections.FindFirst(streamlits, func(r Streamlit) bool { return r.Name == id.Name() }) } func (v *streamlits) Describe(ctx context.Context, id SchemaObjectIdentifier) (*StreamlitDetail, error) { diff --git a/pkg/sdk/streams_impl_gen.go b/pkg/sdk/streams_impl_gen.go index 994cf1ca19..4b96f017ce 100644 --- a/pkg/sdk/streams_impl_gen.go +++ b/pkg/sdk/streams_impl_gen.go @@ -66,7 +66,7 @@ func (v *streams) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*Str if err != nil { return nil, err } - return collections.FindOne(streams, func(r Stream) bool { return r.Name == id.Name() }) + return collections.FindFirst(streams, func(r Stream) bool { return r.Name == id.Name() }) } func (v *streams) Describe(ctx context.Context, request *DescribeStreamRequest) (*Stream, error) { diff --git a/pkg/sdk/tables_impl.go b/pkg/sdk/tables_impl.go index 43d95116e4..f26ea5363d 100644 --- a/pkg/sdk/tables_impl.go +++ b/pkg/sdk/tables_impl.go @@ -83,7 +83,7 @@ func (v *tables) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*Tabl if err != nil { return nil, err } - return collections.FindOne(returnedTables, func(r Table) bool { return r.Name == id.Name() }) + return collections.FindFirst(returnedTables, func(r Table) bool { return r.Name == id.Name() }) } func (v *tables) DescribeColumns(ctx context.Context, req *DescribeTableColumnsRequest) ([]TableColumnDetails, error) { diff --git a/pkg/sdk/tags_impl.go b/pkg/sdk/tags_impl.go index 48b11269b6..e5b63af758 100644 --- a/pkg/sdk/tags_impl.go +++ b/pkg/sdk/tags_impl.go @@ -41,7 +41,7 @@ func (v *tags) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*Tag, e if err != nil { return nil, err } - return collections.FindOne(tags, func(r Tag) bool { return r.Name == id.Name() }) + return collections.FindFirst(tags, func(r Tag) bool { return r.Name == id.Name() }) } func (v *tags) Drop(ctx context.Context, request *DropTagRequest) error { diff --git a/pkg/sdk/testint/application_roles_gen_integration_test.go b/pkg/sdk/testint/application_roles_gen_integration_test.go index 81332be3ec..9cf12f26ec 100644 --- a/pkg/sdk/testint/application_roles_gen_integration_test.go +++ b/pkg/sdk/testint/application_roles_gen_integration_test.go @@ -55,7 +55,7 @@ func TestInt_ApplicationRoles(t *testing.T) { assertApplicationRoles := func(t *testing.T, appRoles []sdk.ApplicationRole, name string, comment string) { t.Helper() - appRole, err := collections.FindOne(appRoles, func(role sdk.ApplicationRole) bool { + appRole, err := collections.FindFirst(appRoles, func(role sdk.ApplicationRole) bool { return role.Name == name }) require.NoError(t, err) diff --git a/pkg/sdk/testint/databases_integration_test.go b/pkg/sdk/testint/databases_integration_test.go index a74772ca8d..38b7d6c229 100644 --- a/pkg/sdk/testint/databases_integration_test.go +++ b/pkg/sdk/testint/databases_integration_test.go @@ -347,7 +347,7 @@ func TestInt_DatabasesAlter(t *testing.T) { assertDatabaseParameterEqualsToDefaultValue := func(t *testing.T, params []*sdk.Parameter, parameterName sdk.ObjectParameter) { t.Helper() - param, err := collections.FindOne(params, func(param *sdk.Parameter) bool { return param.Key == string(parameterName) }) + param, err := collections.FindFirst(params, func(param *sdk.Parameter) bool { return param.Key == string(parameterName) }) assert.NoError(t, err) assert.NotNil(t, param) if param != nil && (*param).Level == "" { @@ -857,7 +857,7 @@ func TestInt_DatabasesShow(t *testing.T) { }) require.NoError(t, err) - database, err := collections.FindOne(databases, func(database sdk.Database) bool { return database.Name == databaseTest.Name }) + database, err := collections.FindFirst(databases, func(database sdk.Database) bool { return database.Name == databaseTest.Name }) require.NoError(t, err) assert.Equal(t, databaseTest.Name, database.Name) @@ -878,7 +878,7 @@ func TestInt_DatabasesShow(t *testing.T) { }) require.NoError(t, err) - droppedDatabase, err := collections.FindOne(databases, func(database sdk.Database) bool { return database.Name == databaseTest3.Name }) + droppedDatabase, err := collections.FindFirst(databases, func(database sdk.Database) bool { return database.Name == databaseTest3.Name }) require.NoError(t, err) assert.Equal(t, databaseTest3.Name, droppedDatabase.Name) @@ -894,7 +894,7 @@ func TestInt_DatabasesShow(t *testing.T) { }) require.NoError(t, err) - database, err := collections.FindOne(databases, func(database sdk.Database) bool { return database.Name == databaseTest.Name }) + database, err := collections.FindFirst(databases, func(database sdk.Database) bool { return database.Name == databaseTest.Name }) require.NoError(t, err) assert.Equal(t, databaseTest.Name, database.Name) @@ -917,7 +917,7 @@ func TestInt_DatabasesDescribe(t *testing.T) { ctx := testContext(t) assertContainsSchema := func(details *sdk.DatabaseDetails, schemaName string) { - _, err := collections.FindOne(details.Rows, func(row sdk.DatabaseDetailsRow) bool { return row.Kind == "SCHEMA" && row.Name == schemaName }) + _, err := collections.FindFirst(details.Rows, func(row sdk.DatabaseDetailsRow) bool { return row.Kind == "SCHEMA" && row.Name == schemaName }) assert.NoError(t, err) } diff --git a/pkg/sdk/testint/grants_integration_test.go b/pkg/sdk/testint/grants_integration_test.go index fdec0791d5..429e8cfc63 100644 --- a/pkg/sdk/testint/grants_integration_test.go +++ b/pkg/sdk/testint/grants_integration_test.go @@ -179,7 +179,7 @@ func TestInt_GrantAndRevokePrivilegesToAccountRole(t *testing.T) { }, }) require.NoError(t, err) - selectPrivilege, err := collections.FindOne[sdk.Grant](grants, func(g sdk.Grant) bool { return g.Privilege == sdk.SchemaObjectPrivilegeSelect.String() }) + selectPrivilege, err := collections.FindFirst[sdk.Grant](grants, func(g sdk.Grant) bool { return g.Privilege == sdk.SchemaObjectPrivilegeSelect.String() }) require.NoError(t, err) assert.Equal(t, tableTest.ID().FullyQualifiedName(), selectPrivilege.Name.FullyQualifiedName()) @@ -222,7 +222,7 @@ func TestInt_GrantAndRevokePrivilegesToAccountRole(t *testing.T) { }, }) require.NoError(t, err) - selectPrivilege, err := collections.FindOne[sdk.Grant](grants, func(g sdk.Grant) bool { return g.Privilege == sdk.SchemaObjectPrivilegeUsage.String() }) + selectPrivilege, err := collections.FindFirst[sdk.Grant](grants, func(g sdk.Grant) bool { return g.Privilege == sdk.SchemaObjectPrivilegeUsage.String() }) require.NoError(t, err) assert.Equal(t, cortex.ID().FullyQualifiedName(), selectPrivilege.Name.FullyQualifiedName()) @@ -266,7 +266,7 @@ func TestInt_GrantAndRevokePrivilegesToAccountRole(t *testing.T) { }, }) require.NoError(t, err) - usagePrivilege, err := collections.FindOne[sdk.Grant](grants, func(g sdk.Grant) bool { + usagePrivilege, err := collections.FindFirst[sdk.Grant](grants, func(g sdk.Grant) bool { return g.Privilege == sdk.SchemaObjectPrivilegeUsage.String() }) require.NoError(t, err) @@ -495,11 +495,11 @@ func TestInt_GrantAndRevokePrivilegesToDatabaseRole(t *testing.T) { // Expecting two grants because database role has usage on database by default require.Equal(t, 2, len(returnedGrants)) - usagePrivilege, err := collections.FindOne[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.AccountObjectPrivilegeUsage.String() }) + usagePrivilege, err := collections.FindFirst[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.AccountObjectPrivilegeUsage.String() }) require.NoError(t, err) assert.Equal(t, sdk.ObjectTypeDatabaseRole, usagePrivilege.GrantedTo) - createSchemaPrivilege, err := collections.FindOne[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.AccountObjectPrivilegeCreateSchema.String() }) + createSchemaPrivilege, err := collections.FindFirst[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.AccountObjectPrivilegeCreateSchema.String() }) require.NoError(t, err) assert.Equal(t, sdk.ObjectTypeDatabase, createSchemaPrivilege.GrantedOn) assert.Equal(t, sdk.ObjectTypeDatabaseRole, createSchemaPrivilege.GrantedTo) @@ -545,11 +545,11 @@ func TestInt_GrantAndRevokePrivilegesToDatabaseRole(t *testing.T) { // Expecting two grants because database role has usage on database by default require.Equal(t, 2, len(returnedGrants)) - usagePrivilege, err := collections.FindOne[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.AccountObjectPrivilegeUsage.String() }) + usagePrivilege, err := collections.FindFirst[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.AccountObjectPrivilegeUsage.String() }) require.NoError(t, err) assert.Equal(t, sdk.ObjectTypeDatabaseRole, usagePrivilege.GrantedTo) - createAlertPrivilege, err := collections.FindOne[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.SchemaPrivilegeCreateAlert.String() }) + createAlertPrivilege, err := collections.FindFirst[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.SchemaPrivilegeCreateAlert.String() }) require.NoError(t, err) assert.Equal(t, sdk.ObjectTypeSchema, createAlertPrivilege.GrantedOn) assert.Equal(t, sdk.ObjectTypeDatabaseRole, createAlertPrivilege.GrantedTo) @@ -598,11 +598,11 @@ func TestInt_GrantAndRevokePrivilegesToDatabaseRole(t *testing.T) { require.NoError(t, err) // Expecting two grants because database role has usage on database by default require.LessOrEqual(t, 2, len(returnedGrants)) - usagePrivilege, err := collections.FindOne[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.AccountObjectPrivilegeUsage.String() }) + usagePrivilege, err := collections.FindFirst[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.AccountObjectPrivilegeUsage.String() }) require.NoError(t, err) assert.Equal(t, sdk.ObjectTypeDatabaseRole, usagePrivilege.GrantedTo) - selectPrivilege, err := collections.FindOne[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.SchemaObjectPrivilegeSelect.String() }) + selectPrivilege, err := collections.FindFirst[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.SchemaObjectPrivilegeSelect.String() }) require.NoError(t, err) assert.Equal(t, sdk.ObjectTypeTable, selectPrivilege.GrantedOn) assert.Equal(t, sdk.ObjectTypeDatabaseRole, selectPrivilege.GrantedTo) @@ -652,11 +652,11 @@ func TestInt_GrantAndRevokePrivilegesToDatabaseRole(t *testing.T) { require.NoError(t, err) // Expecting two grants because database role has usage on database by default require.LessOrEqual(t, 2, len(returnedGrants)) - usagePrivilege, err := collections.FindOne[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.GrantedOn == sdk.ObjectTypeDatabase }) + usagePrivilege, err := collections.FindFirst[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.GrantedOn == sdk.ObjectTypeDatabase }) require.NoError(t, err) assert.Equal(t, sdk.ObjectTypeDatabaseRole, usagePrivilege.GrantedTo) - selectPrivilege, err := collections.FindOne[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.GrantedOn == sdk.ObjectTypeCortexSearchService }) + selectPrivilege, err := collections.FindFirst[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.GrantedOn == sdk.ObjectTypeCortexSearchService }) require.NoError(t, err) assert.Equal(t, sdk.SchemaObjectPrivilegeUsage.String(), selectPrivilege.Privilege) assert.Equal(t, sdk.ObjectTypeDatabaseRole, selectPrivilege.GrantedTo) @@ -847,7 +847,7 @@ func TestInt_GrantPrivilegeToShare(t *testing.T) { assertGrant := func(t *testing.T, grants []sdk.Grant, onId sdk.ObjectIdentifier, privilege sdk.ObjectPrivilege, grantedOn sdk.ObjectType, granteeName sdk.ObjectIdentifier, shareName string) { t.Helper() - actualGrant, err := collections.FindOne(grants, func(grant sdk.Grant) bool { + actualGrant, err := collections.FindFirst(grants, func(grant sdk.Grant) bool { return grant.GranteeName.Name() == shareName && grant.Privilege == string(privilege) }) require.NoError(t, err) @@ -1034,7 +1034,7 @@ func TestInt_GrantOwnership(t *testing.T) { }, }) require.NoError(t, err) - _, err = collections.FindOne(grants, func(grant sdk.Grant) bool { + _, err = collections.FindFirst(grants, func(grant sdk.Grant) bool { return grant.Privilege == "OWNERSHIP" && grant.GranteeName.Name() == role.Name() }) require.NoError(t, err) @@ -1245,11 +1245,11 @@ func TestInt_GrantOwnership(t *testing.T) { // Expecting two grants because database role has usage on database by default require.Equal(t, 2, len(returnedGrants)) - usagePrivilege, err := collections.FindOne[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.AccountObjectPrivilegeUsage.String() }) + usagePrivilege, err := collections.FindFirst[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.AccountObjectPrivilegeUsage.String() }) require.NoError(t, err) assert.Equal(t, sdk.ObjectTypeDatabaseRole, usagePrivilege.GrantedTo) - ownership, err := collections.FindOne[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.SchemaObjectOwnership.String() }) + ownership, err := collections.FindFirst[sdk.Grant](returnedGrants, func(g sdk.Grant) bool { return g.Privilege == sdk.SchemaObjectOwnership.String() }) require.NoError(t, err) assert.Equal(t, sdk.ObjectTypeTable, ownership.GrantedOn) assert.Equal(t, sdk.ObjectTypeDatabaseRole, ownership.GrantedTo) diff --git a/pkg/sdk/testint/identifier_integration_test.go b/pkg/sdk/testint/identifier_integration_test.go index 0ebe8e27ef..8e58fa5ee6 100644 --- a/pkg/sdk/testint/identifier_integration_test.go +++ b/pkg/sdk/testint/identifier_integration_test.go @@ -147,7 +147,7 @@ func TestInt_IdentifiersForTwoPartIdentifierAsReference(t *testing.T) { err = testClient(t).QueryForTests(ctx, &grants, fmt.Sprintf("SHOW GRANTS ON SCHEMA %s", testCase.Name.FullyQualifiedName())) require.NoError(t, err) - createTableGrant, err := collections.FindOne(grants, func(output RawGrantOutput) bool { return output.Privilege == sdk.SchemaPrivilegeCreateTable.String() }) + createTableGrant, err := collections.FindFirst(grants, func(output RawGrantOutput) bool { return output.Privilege == sdk.SchemaPrivilegeCreateTable.String() }) require.NoError(t, err) // For two part identifiers, we expect Snowflake to return escaped identifiers with exception diff --git a/pkg/sdk/testint/network_policies_gen_integration_test.go b/pkg/sdk/testint/network_policies_gen_integration_test.go index a271cf2061..6f03642057 100644 --- a/pkg/sdk/testint/network_policies_gen_integration_test.go +++ b/pkg/sdk/testint/network_policies_gen_integration_test.go @@ -42,7 +42,7 @@ func TestInt_NetworkPolicies(t *testing.T) { } findNetworkPolicy := func(nps []sdk.NetworkPolicy, name string) (*sdk.NetworkPolicy, error) { - return collections.FindOne[sdk.NetworkPolicy](nps, func(t sdk.NetworkPolicy) bool { + return collections.FindFirst[sdk.NetworkPolicy](nps, func(t sdk.NetworkPolicy) bool { return t.Name == name }) } diff --git a/pkg/sdk/testint/notification_integrations_gen_integration_test.go b/pkg/sdk/testint/notification_integrations_gen_integration_test.go index 96a57a9885..2a706790a9 100644 --- a/pkg/sdk/testint/notification_integrations_gen_integration_test.go +++ b/pkg/sdk/testint/notification_integrations_gen_integration_test.go @@ -138,7 +138,7 @@ func TestInt_NotificationIntegrations(t *testing.T) { assert.Contains(t, details, sdk.NotificationIntegrationProperty{Name: "GCP_PUBSUB_SUBSCRIPTION_NAME", Type: "String", Value: gcpPubsubSubscriptionName, Default: ""}) assert.Contains(t, details, sdk.NotificationIntegrationProperty{Name: "COMMENT", Type: "String", Value: "", Default: ""}) - prop, err := collections.FindOne(details, func(property sdk.NotificationIntegrationProperty) bool { + prop, err := collections.FindFirst(details, func(property sdk.NotificationIntegrationProperty) bool { return property.Name == "GCP_PUBSUB_SERVICE_ACCOUNT" }) assert.NoError(t, err) @@ -159,13 +159,13 @@ func TestInt_NotificationIntegrations(t *testing.T) { assert.Contains(t, details, sdk.NotificationIntegrationProperty{Name: "AZURE_STORAGE_QUEUE_PRIMARY_URI", Type: "String", Value: azureStorageQueuePrimaryUri, Default: ""}) assert.Contains(t, details, sdk.NotificationIntegrationProperty{Name: "COMMENT", Type: "String", Value: "", Default: ""}) - prop, err := collections.FindOne(details, func(property sdk.NotificationIntegrationProperty) bool { + prop, err := collections.FindFirst(details, func(property sdk.NotificationIntegrationProperty) bool { return property.Name == "AZURE_CONSENT_URL" }) assert.NoError(t, err) assert.NotEmpty(t, prop.Value) - prop, err = collections.FindOne(details, func(property sdk.NotificationIntegrationProperty) bool { + prop, err = collections.FindFirst(details, func(property sdk.NotificationIntegrationProperty) bool { return property.Name == "AZURE_MULTI_TENANT_APP_NAME" }) assert.NoError(t, err) @@ -189,10 +189,10 @@ func TestInt_NotificationIntegrations(t *testing.T) { assert.Contains(t, details, sdk.NotificationIntegrationProperty{Name: "AWS_SNS_ROLE_ARN", Type: "String", Value: awsSnsRoleArn, Default: ""}) assert.Contains(t, details, sdk.NotificationIntegrationProperty{Name: "COMMENT", Type: "String", Value: "", Default: ""}) - prop, err := collections.FindOne(details, func(property sdk.NotificationIntegrationProperty) bool { return property.Name == "SF_AWS_IAM_USER_ARN" }) + prop, err := collections.FindFirst(details, func(property sdk.NotificationIntegrationProperty) bool { return property.Name == "SF_AWS_IAM_USER_ARN" }) assert.NoError(t, err) assert.NotEmpty(t, prop.Value) - prop, err = collections.FindOne(details, func(property sdk.NotificationIntegrationProperty) bool { return property.Name == "SF_AWS_EXTERNAL_ID" }) + prop, err = collections.FindFirst(details, func(property sdk.NotificationIntegrationProperty) bool { return property.Name == "SF_AWS_EXTERNAL_ID" }) assert.NoError(t, err) assert.NotEmpty(t, prop.Value) }) diff --git a/pkg/sdk/testint/schemas_integration_test.go b/pkg/sdk/testint/schemas_integration_test.go index 1d88a346fa..7d3116b138 100644 --- a/pkg/sdk/testint/schemas_integration_test.go +++ b/pkg/sdk/testint/schemas_integration_test.go @@ -26,7 +26,7 @@ func TestInt_Schemas(t *testing.T) { assertParameterEqualsToDefaultValue := func(t *testing.T, params []*sdk.Parameter, parameterName sdk.ObjectParameter) { t.Helper() - param, err := collections.FindOne(params, func(param *sdk.Parameter) bool { return param.Key == string(parameterName) }) + param, err := collections.FindFirst(params, func(param *sdk.Parameter) bool { return param.Key == string(parameterName) }) assert.NoError(t, err) assert.NotNil(t, param) assert.Equal(t, (*param).Default, (*param).Value) @@ -561,7 +561,7 @@ func TestInt_Schemas(t *testing.T) { }) require.NoError(t, err) - schema, err := collections.FindOne(schemas, func(schema sdk.Schema) bool { return schema.Name == schema1.Name }) + schema, err := collections.FindFirst(schemas, func(schema sdk.Schema) bool { return schema.Name == schema1.Name }) require.NoError(t, err) assert.Equal(t, schema1.Name, schema.Name) @@ -580,7 +580,7 @@ func TestInt_Schemas(t *testing.T) { }) require.NoError(t, err) - droppedSchema, err := collections.FindOne(schemas, func(schema sdk.Schema) bool { return schema.Name == schema3.Name }) + droppedSchema, err := collections.FindFirst(schemas, func(schema sdk.Schema) bool { return schema.Name == schema3.Name }) require.NoError(t, err) assert.Equal(t, schema3.Name, droppedSchema.Name) diff --git a/pkg/sdk/testint/security_integrations_gen_integration_test.go b/pkg/sdk/testint/security_integrations_gen_integration_test.go index f398167c4a..cc2fd07ab4 100644 --- a/pkg/sdk/testint/security_integrations_gen_integration_test.go +++ b/pkg/sdk/testint/security_integrations_gen_integration_test.go @@ -171,7 +171,7 @@ func TestInt_SecurityIntegrations(t *testing.T) { // TODO(SNOW-1449579): move to helpers assertFieldContainsList := func(details []sdk.SecurityIntegrationProperty, field, value, sep string) { - found, err := collections.FindOne(details, func(d sdk.SecurityIntegrationProperty) bool { return d.Name == field }) + found, err := collections.FindFirst(details, func(d sdk.SecurityIntegrationProperty) bool { return d.Name == field }) assert.NoError(t, err) values := strings.Split(found.Value, sep) for _, exp := range strings.Split(value, sep) { diff --git a/pkg/sdk/testint/storage_integration_gen_integration_test.go b/pkg/sdk/testint/storage_integration_gen_integration_test.go index b9414abb47..cc3edad74d 100644 --- a/pkg/sdk/testint/storage_integration_gen_integration_test.go +++ b/pkg/sdk/testint/storage_integration_gen_integration_test.go @@ -33,7 +33,7 @@ func TestInt_StorageIntegrations(t *testing.T) { findProp := func(t *testing.T, props []sdk.StorageIntegrationProperty, name string) *sdk.StorageIntegrationProperty { t.Helper() - prop, err := collections.FindOne(props, func(property sdk.StorageIntegrationProperty) bool { return property.Name == name }) + prop, err := collections.FindFirst(props, func(property sdk.StorageIntegrationProperty) bool { return property.Name == name }) require.NoError(t, err) return prop } diff --git a/pkg/sdk/testint/streams_gen_integration_test.go b/pkg/sdk/testint/streams_gen_integration_test.go index 763b799f25..cf6c4d9705 100644 --- a/pkg/sdk/testint/streams_gen_integration_test.go +++ b/pkg/sdk/testint/streams_gen_integration_test.go @@ -263,7 +263,7 @@ func TestInt_Streams(t *testing.T) { s, err := client.Streams.Show(ctx, sdk.NewShowStreamRequest().WithTerse(sdk.Bool(true))) require.NoError(t, err) - stream, err := collections.FindOne[sdk.Stream](s, func(stream sdk.Stream) bool { return id.Name() == stream.Name }) + stream, err := collections.FindFirst[sdk.Stream](s, func(stream sdk.Stream) bool { return id.Name() == stream.Name }) require.NoError(t, err) assert.NotNil(t, stream) @@ -304,7 +304,7 @@ func TestInt_Streams(t *testing.T) { require.NoError(t, err) assert.Equal(t, 1, len(s)) - stream, err := collections.FindOne[sdk.Stream](s, func(stream sdk.Stream) bool { return id.Name() == stream.Name }) + stream, err := collections.FindFirst[sdk.Stream](s, func(stream sdk.Stream) bool { return id.Name() == stream.Name }) require.NoError(t, err) assertStream(t, stream, id, "Table", "DEFAULT") @@ -336,10 +336,10 @@ func TestInt_Streams(t *testing.T) { require.NoError(t, err) assert.Equal(t, 2, len(s)) - stream, err := collections.FindOne[sdk.Stream](s, func(stream sdk.Stream) bool { return id.Name() == stream.Name }) + stream, err := collections.FindFirst[sdk.Stream](s, func(stream sdk.Stream) bool { return id.Name() == stream.Name }) require.NoError(t, err) - stream2, err := collections.FindOne[sdk.Stream](s, func(stream sdk.Stream) bool { return id2.Name() == stream.Name }) + stream2, err := collections.FindFirst[sdk.Stream](s, func(stream sdk.Stream) bool { return id2.Name() == stream.Name }) require.NoError(t, err) assertStream(t, stream, id, "Table", "DEFAULT") @@ -382,10 +382,10 @@ func TestInt_Streams(t *testing.T) { require.NoError(t, err) assert.Equal(t, 2, len(s)) - stream, err := collections.FindOne[sdk.Stream](s, func(stream sdk.Stream) bool { return id.Name() == stream.Name }) + stream, err := collections.FindFirst[sdk.Stream](s, func(stream sdk.Stream) bool { return id.Name() == stream.Name }) require.NoError(t, err) - stream2, err := collections.FindOne[sdk.Stream](s, func(stream sdk.Stream) bool { return id2.Name() == stream.Name }) + stream2, err := collections.FindFirst[sdk.Stream](s, func(stream sdk.Stream) bool { return id2.Name() == stream.Name }) require.NoError(t, err) assertStream(t, stream, id, "Table", "DEFAULT") diff --git a/pkg/sdk/testint/tables_integration_test.go b/pkg/sdk/testint/tables_integration_test.go index d0bbc90f42..8c6898dda4 100644 --- a/pkg/sdk/testint/tables_integration_test.go +++ b/pkg/sdk/testint/tables_integration_test.go @@ -917,9 +917,9 @@ func TestInt_Table(t *testing.T) { tables, err := client.Tables.Show(ctx, sdk.NewShowTableRequest()) require.NoError(t, err) - t1, err := collections.FindOne(tables, func(t sdk.Table) bool { return t.ID().FullyQualifiedName() == table.ID().FullyQualifiedName() }) + t1, err := collections.FindFirst(tables, func(t sdk.Table) bool { return t.ID().FullyQualifiedName() == table.ID().FullyQualifiedName() }) require.NoError(t, err) - t2, err := collections.FindOne(tables, func(t sdk.Table) bool { return t.ID().FullyQualifiedName() == table2.ID().FullyQualifiedName() }) + t2, err := collections.FindFirst(tables, func(t sdk.Table) bool { return t.ID().FullyQualifiedName() == table2.ID().FullyQualifiedName() }) require.NoError(t, err) assertTable(t, t1, table.ID()) diff --git a/pkg/sdk/views_impl_gen.go b/pkg/sdk/views_impl_gen.go index 7e20ce0c59..d9a939a268 100644 --- a/pkg/sdk/views_impl_gen.go +++ b/pkg/sdk/views_impl_gen.go @@ -43,7 +43,7 @@ func (v *views) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*View, if err != nil { return nil, err } - return collections.FindOne(views, func(r View) bool { return r.Name == id.Name() }) + return collections.FindFirst(views, func(r View) bool { return r.Name == id.Name() }) } func (v *views) Describe(ctx context.Context, id SchemaObjectIdentifier) ([]ViewDetails, error) {