Skip to content

Commit

Permalink
Changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jcieslak committed Nov 13, 2023
1 parent 8c0b058 commit 7daba7a
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 45 deletions.
8 changes: 6 additions & 2 deletions pkg/sdk/poc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,12 @@ find a better solution to solve the issue (add more logic to the templates ?)
- generate getters for requests, at least for identifier/name
- generate integration tests in child package (because now we keep them in `testint` package)
- struct_to_builder is not supporting templated-like values. See stages_def.go where in SQL there could be value, where 'n' can be replaced with any number
- SKIP_FILE_n - this looks more like keyword without a space between SQL prefix and int
- SKIP_FILE_n% (e.g. SKIP_FILE_123%) - this is more template-like behaviour, notice that 'n' is inside the value (we cannot reproduce that right now with struct_to_builder capabilities)
- `SKIP_FILE_n` - this looks more like keyword without a space between SQL prefix and int
- `SKIP_FILE_n%` (e.g. `SKIP_FILE_123%`) - this is more template-like behaviour, notice that 'n' is inside the value (we cannot reproduce that right now with struct_to_builder capabilities)
- fix builder generation
- we can add `flatten` option in cases where some sql structs had to be nested to create correct sql representation
- for example encryption options in `stages_def.go` (instead of calling `.WithEncryption(NewEncryptionRequest(encryption))` we could call `.WithEncryption(encryption)`)
- operation names (or their sql struct names) should dictate more how constructors are made

##### Known issues
- generating two converts when Show and Desc use the same data structure
Expand Down
12 changes: 6 additions & 6 deletions pkg/sdk/stages_dto_builders_gen.go

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

12 changes: 6 additions & 6 deletions pkg/sdk/stages_dto_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ type ExternalS3StageParamsRequest struct {
}

type ExternalStageS3CredentialsRequest struct {
AwsKeyId *string
AwsSecretKey *string
AwsToken *string
AwsRole *string
AWSKeyId *string
AWSSecretKey *string
AWSToken *string
AWSRole *string
}

type ExternalStageS3EncryptionRequest struct {
Expand Down Expand Up @@ -186,8 +186,8 @@ type CreateOnS3CompatibleStageRequest struct {
}

type ExternalStageS3CompatibleCredentialsRequest struct {
AwsKeyId *string // required
AwsSecretKey *string // required
AWSKeyId *string // required
AWSSecretKey *string // required
}

type AlterStageRequest struct {
Expand Down
12 changes: 6 additions & 6 deletions pkg/sdk/stages_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ type ExternalS3StageParams struct {
}

type ExternalStageS3Credentials struct {
AwsKeyId *string `ddl:"parameter,single_quotes" sql:"AWS_KEY_ID"`
AwsSecretKey *string `ddl:"parameter,single_quotes" sql:"AWS_SECRET_KEY"`
AwsToken *string `ddl:"parameter,single_quotes" sql:"AWS_TOKEN"`
AwsRole *string `ddl:"parameter,single_quotes" sql:"AWS_ROLE"`
AWSKeyId *string `ddl:"parameter,single_quotes" sql:"AWS_KEY_ID"`
AWSSecretKey *string `ddl:"parameter,single_quotes" sql:"AWS_SECRET_KEY"`
AWSToken *string `ddl:"parameter,single_quotes" sql:"AWS_TOKEN"`
AWSRole *string `ddl:"parameter,single_quotes" sql:"AWS_ROLE"`
}

type ExternalStageS3Encryption struct {
Expand Down Expand Up @@ -206,8 +206,8 @@ type CreateOnS3CompatibleStageOptions struct {
}

type ExternalStageS3CompatibleCredentials struct {
AwsKeyId *string `ddl:"parameter,single_quotes" sql:"AWS_KEY_ID"`
AwsSecretKey *string `ddl:"parameter,single_quotes" sql:"AWS_SECRET_KEY"`
AWSKeyId *string `ddl:"parameter,single_quotes" sql:"AWS_KEY_ID"`
AWSSecretKey *string `ddl:"parameter,single_quotes" sql:"AWS_SECRET_KEY"`
}

// AlterStageOptions is based on https://docs.snowflake.com/en/sql-reference/sql/alter-stage.
Expand Down
22 changes: 11 additions & 11 deletions pkg/sdk/stages_gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestStages_CreateOnS3(t *testing.T) {
opts.ExternalStageParams = &ExternalS3StageParams{
StorageIntegration: &integrationId,
Credentials: &ExternalStageS3Credentials{
AwsRole: String("aws-role"),
AWSRole: String("aws-role"),
},
}
assertOptsInvalidJoinedErrors(t, opts, errOneOf(".ExternalStageParams", "StorageIntegration", "Credentials"))
Expand All @@ -110,8 +110,8 @@ func TestStages_CreateOnS3(t *testing.T) {
opts := defaultOpts()
opts.ExternalStageParams = &ExternalS3StageParams{
Credentials: &ExternalStageS3Credentials{
AwsKeyId: String("aws-key-id"),
AwsRole: String("aws-role"),
AWSKeyId: String("aws-key-id"),
AWSRole: String("aws-role"),
},
}
assertOptsInvalidJoinedErrors(t, opts, errOneOf(".ExternalStageParams.Credentials", "AwsKeyId", "AwsRole"))
Expand Down Expand Up @@ -144,9 +144,9 @@ func TestStages_CreateOnS3(t *testing.T) {
opts.ExternalStageParams = &ExternalS3StageParams{
Url: "some url",
Credentials: &ExternalStageS3Credentials{
AwsKeyId: String("aws-key-id"),
AwsSecretKey: String("aws-secret-key"),
AwsToken: String("aws-token"),
AWSKeyId: String("aws-key-id"),
AWSSecretKey: String("aws-secret-key"),
AWSToken: String("aws-token"),
},
}
opts.DirectoryTableOptions = &ExternalS3DirectoryTableOptions{
Expand Down Expand Up @@ -313,8 +313,8 @@ func TestStages_CreateOnS3Compatible(t *testing.T) {
opts.Url = "some url"
opts.Endpoint = "some endpoint"
opts.Credentials = &ExternalStageS3CompatibleCredentials{
AwsKeyId: String("aws-key-id"),
AwsSecretKey: String("aws-secret-key"),
AWSKeyId: String("aws-key-id"),
AWSSecretKey: String("aws-secret-key"),
}
opts.FileFormat = &StageFileFormat{
Type: &FileFormatTypeCSV,
Expand Down Expand Up @@ -471,7 +471,7 @@ func TestStages_AlterExternalS3Stage(t *testing.T) {
opts.ExternalStageParams = &ExternalS3StageParams{
StorageIntegration: &integrationId,
Credentials: &ExternalStageS3Credentials{
AwsRole: String("aws-role"),
AWSRole: String("aws-role"),
},
}
assertOptsInvalidJoinedErrors(t, opts, errOneOf(".ExternalStageParams", "StorageIntegration", "Credentials"))
Expand All @@ -481,8 +481,8 @@ func TestStages_AlterExternalS3Stage(t *testing.T) {
opts := defaultOpts()
opts.ExternalStageParams = &ExternalS3StageParams{
Credentials: &ExternalStageS3Credentials{
AwsKeyId: String("aws-key-id"),
AwsRole: String("aws-role"),
AWSKeyId: String("aws-key-id"),
AWSRole: String("aws-role"),
},
}
assertOptsInvalidJoinedErrors(t, opts, errOneOf(".ExternalStageParams.Credentials", "AwsKeyId", "AwsRole"))
Expand Down
20 changes: 10 additions & 10 deletions pkg/sdk/stages_impl_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ func (r *CreateOnS3StageRequest) toOpts() *CreateOnS3StageOptions {
}
if r.ExternalStageParams.Credentials != nil {
opts.ExternalStageParams.Credentials = &ExternalStageS3Credentials{
AwsKeyId: r.ExternalStageParams.Credentials.AwsKeyId,
AwsSecretKey: r.ExternalStageParams.Credentials.AwsSecretKey,
AwsToken: r.ExternalStageParams.Credentials.AwsToken,
AwsRole: r.ExternalStageParams.Credentials.AwsRole,
AWSKeyId: r.ExternalStageParams.Credentials.AWSKeyId,
AWSSecretKey: r.ExternalStageParams.Credentials.AWSSecretKey,
AWSToken: r.ExternalStageParams.Credentials.AWSToken,
AWSRole: r.ExternalStageParams.Credentials.AWSRole,
}
}
if r.ExternalStageParams.Encryption != nil {
Expand Down Expand Up @@ -357,8 +357,8 @@ func (r *CreateOnS3CompatibleStageRequest) toOpts() *CreateOnS3CompatibleStageOp
}
if r.Credentials != nil {
opts.Credentials = &ExternalStageS3CompatibleCredentials{
AwsKeyId: r.Credentials.AwsKeyId,
AwsSecretKey: r.Credentials.AwsSecretKey,
AWSKeyId: r.Credentials.AWSKeyId,
AWSSecretKey: r.Credentials.AWSSecretKey,
}
}
if r.DirectoryTableOptions != nil {
Expand Down Expand Up @@ -456,10 +456,10 @@ func (r *AlterExternalS3StageStageRequest) toOpts() *AlterExternalS3StageStageOp
}
if r.ExternalStageParams.Credentials != nil {
opts.ExternalStageParams.Credentials = &ExternalStageS3Credentials{
AwsKeyId: r.ExternalStageParams.Credentials.AwsKeyId,
AwsSecretKey: r.ExternalStageParams.Credentials.AwsSecretKey,
AwsToken: r.ExternalStageParams.Credentials.AwsToken,
AwsRole: r.ExternalStageParams.Credentials.AwsRole,
AWSKeyId: r.ExternalStageParams.Credentials.AWSKeyId,
AWSSecretKey: r.ExternalStageParams.Credentials.AWSSecretKey,
AWSToken: r.ExternalStageParams.Credentials.AWSToken,
AWSRole: r.ExternalStageParams.Credentials.AWSRole,
}
}
if r.ExternalStageParams.Encryption != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/sdk/stages_validations_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func (opts *CreateOnS3StageOptions) validate() error {
errs = append(errs, errOneOf("CreateOnS3StageOptions.ExternalStageParams", "StorageIntegration", "Credentials"))
}
if valueSet(opts.ExternalStageParams.Credentials) {
if everyValueSet(opts.ExternalStageParams.Credentials.AwsKeyId, opts.ExternalStageParams.Credentials.AwsRole) {
errs = append(errs, errOneOf("AlterExternalS3StageStageOptions.ExternalStageParams.Credentials", "AwsKeyId", "AwsRole"))
if everyValueSet(opts.ExternalStageParams.Credentials.AWSKeyId, opts.ExternalStageParams.Credentials.AWSRole) {
errs = append(errs, errOneOf("AlterExternalS3StageStageOptions.ExternalStageParams.Credentials", "AWSKeyId", "AWSRole"))
}
}
}
Expand Down Expand Up @@ -131,8 +131,8 @@ func (opts *AlterExternalS3StageStageOptions) validate() error {
errs = append(errs, errOneOf("AlterExternalS3StageStageOptions.ExternalStageParams", "StorageIntegration", "Credentials"))
}
if valueSet(opts.ExternalStageParams.Credentials) {
if everyValueSet(opts.ExternalStageParams.Credentials.AwsKeyId, opts.ExternalStageParams.Credentials.AwsRole) {
errs = append(errs, errOneOf("AlterExternalS3StageStageOptions.ExternalStageParams.Credentials", "AwsKeyId", "AwsRole"))
if everyValueSet(opts.ExternalStageParams.Credentials.AWSKeyId, opts.ExternalStageParams.Credentials.AWSRole) {
errs = append(errs, errOneOf("AlterExternalS3StageStageOptions.ExternalStageParams.Credentials", "AWSKeyId", "AWSRole"))
}
}
}
Expand Down

0 comments on commit 7daba7a

Please sign in to comment.