Skip to content

Commit

Permalink
regenerate secrets back to In
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-fbudzynski committed Dec 2, 2024
1 parent aaf81f1 commit 6370828
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 32 deletions.
2 changes: 1 addition & 1 deletion pkg/datasources/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func ReadSecrets(ctx context.Context, d *schema.ResourceData, meta any) diag.Dia
req := sdk.NewShowSecretRequest()

handleLike(d, &req.Like)
err := handleExtendedIn(d, &req.ExtendedIn)
err := handleExtendedIn(d, &req.In)
if err != nil {
return diag.FromErr(err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/poc/generator/show_by_id_filtering.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
// Enables filtering with: In
// Based on the identifier Kind
ShowByIDInFiltering
// Enables filtering with: ExtendedIn
// Enables filtering with: In
// Based on the identifier Kind
ShowByIDExtendedInFiltering
// Enables filtering with: Limit
Expand Down Expand Up @@ -62,7 +62,7 @@ func newShowByIDInFiltering(identifierKind string) ShowByIDFiltering {
}

func newShowByIDExtendedInFiltering(identifierKind string) ShowByIDFiltering {
return newShowByIDFiltering("In", "ExtendedIn", "In: In{%[1]v: id.%[1]vId()}", &identifierKind)
return newShowByIDFiltering("In", "In", "In: In{%[1]v: id.%[1]vId()}", &identifierKind)
}

func newShowByIDLimitFiltering(string) ShowByIDFiltering {
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/secrets_dto_builders_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/sdk/secrets_dto_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ type DropSecretRequest struct {
}

type ShowSecretRequest struct {
Like *Like
ExtendedIn *ExtendedIn
Like *Like
In *ExtendedIn
}

type DescribeSecretRequest struct {
Expand Down
8 changes: 4 additions & 4 deletions pkg/sdk/secrets_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ type DropSecretOptions struct {

// ShowSecretOptions is based on https://docs.snowflake.com/en/sql-reference/sql/show-secrets.
type ShowSecretOptions struct {
show bool `ddl:"static" sql:"SHOW"`
secrets bool `ddl:"static" sql:"SECRETS"`
Like *Like `ddl:"keyword" sql:"LIKE"`
ExtendedIn *ExtendedIn `ddl:"keyword" sql:"IN"`
show bool `ddl:"static" sql:"SHOW"`
secrets bool `ddl:"static" sql:"SECRETS"`
Like *Like `ddl:"keyword" sql:"LIKE"`
In *ExtendedIn `ddl:"keyword" sql:"IN"`
}
type secretDBRow struct {
CreatedOn time.Time `db:"created_on"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/sdk/secrets_gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func TestSecrets_Show(t *testing.T) {

t.Run("show with in", func(t *testing.T) {
opts := defaultOpts()
opts.ExtendedIn = &ExtendedIn{
opts.In = &ExtendedIn{
In: In{
Account: Bool(true),
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/sdk/secrets_impl_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (v *secrets) Describe(ctx context.Context, id SchemaObjectIdentifier) (*Sec
func (v *secrets) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*Secret, error) {
request := NewShowSecretRequest().
WithLike(Like{Pattern: String(id.Name())}).
WithExtendedIn(ExtendedIn{In: In{Schema: id.SchemaId()}})
WithIn(ExtendedIn{In: In{Schema: id.SchemaId()}})
secrets, err := v.Show(ctx, request)
if err != nil {
return nil, err
Expand Down Expand Up @@ -193,8 +193,8 @@ func (r *DropSecretRequest) toOpts() *DropSecretOptions {

func (r *ShowSecretRequest) toOpts() *ShowSecretOptions {
opts := &ShowSecretOptions{
Like: r.Like,
ExtendedIn: r.ExtendedIn,
Like: r.Like,
In: r.In,
}
return opts
}
Expand Down
7 changes: 2 additions & 5 deletions pkg/sdk/streamlits_impl_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,19 @@ func (r *AlterStreamlitRequest) toOpts() *AlterStreamlitOptions {
}

if r.Set != nil {

opts.Set = &StreamlitSet{
RootLocation: r.Set.RootLocation,
MainFile: r.Set.MainFile,
QueryWarehouse: r.Set.QueryWarehouse,

Comment: r.Set.Comment,
Title: r.Set.Title,
Comment: r.Set.Comment,
Title: r.Set.Title,
}

if r.Set.ExternalAccessIntegrations != nil {
opts.Set.ExternalAccessIntegrations = &ExternalAccessIntegrations{
ExternalAccessIntegrations: r.Set.ExternalAccessIntegrations.ExternalAccessIntegrations,
}
}

}

if r.Unset != nil {
Expand Down
24 changes: 12 additions & 12 deletions pkg/sdk/testint/secrets_gen_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,15 +594,15 @@ func TestInt_Secrets(t *testing.T) {
secret, secretCleanup := testClientHelper().Secret.CreateWithOAuthClientCredentialsFlow(t, id, integrationId, []sdk.ApiIntegrationScope{{Scope: "foo"}})
t.Cleanup(secretCleanup)

returnedSecrets, err := client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithExtendedIn(sdk.ExtendedIn{In: sdk.In{Account: sdk.Pointer(true)}}))
returnedSecrets, err := client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithIn(sdk.ExtendedIn{In: sdk.In{Account: sdk.Pointer(true)}}))
require.NoError(t, err)
require.Contains(t, returnedSecrets, *secret)

returnedSecrets, err = client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithExtendedIn(sdk.ExtendedIn{In: sdk.In{Database: id.DatabaseId()}}))
returnedSecrets, err = client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithIn(sdk.ExtendedIn{In: sdk.In{Database: id.DatabaseId()}}))
require.NoError(t, err)
require.Contains(t, returnedSecrets, *secret)

returnedSecrets, err = client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithExtendedIn(sdk.ExtendedIn{In: sdk.In{Schema: id.SchemaId()}}))
returnedSecrets, err = client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithIn(sdk.ExtendedIn{In: sdk.In{Schema: id.SchemaId()}}))
require.NoError(t, err)
require.Contains(t, returnedSecrets, *secret)
})
Expand All @@ -612,15 +612,15 @@ func TestInt_Secrets(t *testing.T) {
secret, secretCleanup := testClientHelper().Secret.CreateWithOAuthAuthorizationCodeFlow(t, id, integrationId, "foo", refreshTokenExpiryTime)
t.Cleanup(secretCleanup)

returnedSecrets, err := client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithExtendedIn(sdk.ExtendedIn{In: sdk.In{Account: sdk.Pointer(true)}}))
returnedSecrets, err := client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithIn(sdk.ExtendedIn{In: sdk.In{Account: sdk.Pointer(true)}}))
require.NoError(t, err)
require.Contains(t, returnedSecrets, *secret)

returnedSecrets, err = client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithExtendedIn(sdk.ExtendedIn{In: sdk.In{Database: id.DatabaseId()}}))
returnedSecrets, err = client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithIn(sdk.ExtendedIn{In: sdk.In{Database: id.DatabaseId()}}))
require.NoError(t, err)
require.Contains(t, returnedSecrets, *secret)

returnedSecrets, err = client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithExtendedIn(sdk.ExtendedIn{In: sdk.In{Schema: id.SchemaId()}}))
returnedSecrets, err = client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithIn(sdk.ExtendedIn{In: sdk.In{Schema: id.SchemaId()}}))
require.NoError(t, err)
require.Contains(t, returnedSecrets, *secret)
})
Expand All @@ -640,21 +640,21 @@ func TestInt_Secrets(t *testing.T) {
secretGenericString, secretCleanupWithGenericString := testClientHelper().Secret.CreateWithGenericString(t, testClientHelper().Ids.RandomSchemaObjectIdentifier(), "foo")
t.Cleanup(secretCleanupWithGenericString)

returnedSecrets, err := client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithExtendedIn(sdk.ExtendedIn{In: sdk.In{Account: sdk.Pointer(true)}}))
returnedSecrets, err := client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithIn(sdk.ExtendedIn{In: sdk.In{Account: sdk.Pointer(true)}}))
require.NoError(t, err)
require.Contains(t, returnedSecrets, *secretOAuthClientCredentials)
require.Contains(t, returnedSecrets, *secretOAuthAuthorizationCode)
require.Contains(t, returnedSecrets, *secretBasicAuthentication)
require.Contains(t, returnedSecrets, *secretGenericString)

returnedSecrets, err = client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithExtendedIn(sdk.ExtendedIn{In: sdk.In{Database: id.DatabaseId()}}))
returnedSecrets, err = client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithIn(sdk.ExtendedIn{In: sdk.In{Database: id.DatabaseId()}}))
require.NoError(t, err)
require.Contains(t, returnedSecrets, *secretOAuthClientCredentials)
require.Contains(t, returnedSecrets, *secretOAuthAuthorizationCode)
require.Contains(t, returnedSecrets, *secretBasicAuthentication)
require.Contains(t, returnedSecrets, *secretGenericString)

returnedSecrets, err = client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithExtendedIn(sdk.ExtendedIn{In: sdk.In{Schema: id.SchemaId()}}))
returnedSecrets, err = client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithIn(sdk.ExtendedIn{In: sdk.In{Schema: id.SchemaId()}}))
require.NoError(t, err)
require.Contains(t, returnedSecrets, *secretOAuthClientCredentials)
require.Contains(t, returnedSecrets, *secretOAuthAuthorizationCode)
Expand All @@ -667,15 +667,15 @@ func TestInt_Secrets(t *testing.T) {
secret, secretCleanup := testClientHelper().Secret.CreateWithGenericString(t, id, "foo")
t.Cleanup(secretCleanup)

returnedSecrets, err := client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithExtendedIn(sdk.ExtendedIn{In: sdk.In{Account: sdk.Pointer(true)}}))
returnedSecrets, err := client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithIn(sdk.ExtendedIn{In: sdk.In{Account: sdk.Pointer(true)}}))
require.NoError(t, err)
require.Contains(t, returnedSecrets, *secret)

returnedSecrets, err = client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithExtendedIn(sdk.ExtendedIn{In: sdk.In{Database: id.DatabaseId()}}))
returnedSecrets, err = client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithIn(sdk.ExtendedIn{In: sdk.In{Database: id.DatabaseId()}}))
require.NoError(t, err)
require.Contains(t, returnedSecrets, *secret)

returnedSecrets, err = client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithExtendedIn(sdk.ExtendedIn{In: sdk.In{Schema: id.SchemaId()}}))
returnedSecrets, err = client.Secrets.Show(ctx, sdk.NewShowSecretRequest().WithIn(sdk.ExtendedIn{In: sdk.In{Schema: id.SchemaId()}}))
require.NoError(t, err)
require.Contains(t, returnedSecrets, *secret)
})
Expand Down

0 comments on commit 6370828

Please sign in to comment.