Skip to content

Commit 7838954

Browse files
authored
Moved contains function to common package (#2990)
* Moved function to common package * Replace custom `contains` function
1 parent 60d596b commit 7838954

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

catalog/update.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,16 @@ import (
66

77
"github.com/databricks/terraform-provider-databricks/common"
88
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
9+
"golang.org/x/exp/slices"
910
)
1011

11-
func contains[T comparable](s []T, e T) bool {
12-
for _, a := range s {
13-
if a == e {
14-
return true
15-
}
16-
}
17-
return false
18-
}
19-
2012
func updateFunctionFactory(pathPrefix string, updatable []string) func(context.Context, *schema.ResourceData, *common.DatabricksClient) error {
2113
return func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
2214
patch := map[string]any{}
2315
for _, field := range updatable {
2416

2517
// these fields cannot be set during creation
26-
if d.IsNewResource() && !contains([]string{
18+
if d.IsNewResource() && !slices.Contains([]string{
2719
"owner",
2820
"delta_sharing_scope",
2921
"delta_sharing_recipient_token_lifetime_in_seconds",

0 commit comments

Comments
 (0)