-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Add ShowByID filtering generation #3227
base: main
Are you sure you want to change the base?
Conversation
…nowflake into sdk-generator-show-by-id
…eded Identifier value
Integration tests failure for 1599afb36a36122395af19213ab1a4562b220e90 |
@@ -107,7 +107,7 @@ func ReadSecrets(ctx context.Context, d *schema.ResourceData, meta any) diag.Dia | |||
req := sdk.NewShowSecretRequest() | |||
|
|||
handleLike(d, &req.Like) | |||
err := handleExtendedIn(d, &req.In) | |||
err := handleExtendedIn(d, &req.ExtendedIn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open for discussions, but I'm not sure if it's necessary. On the other hand, in Snowflake, is just IN
, and initially ExtendedIn
was used only to distinguish from In
with limited filtering capabilities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will change how the filtering in the template is handled and how we should define filtering for the ShowBiIDFiltering
struct. But it can be changed if it is preferred to leave the Extended In
as before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, it's more readable that way because I know it's the extended version, but both options are ok.
{{ $impl }}, err := v.Show(ctx, NewShow{{ .ObjectInterface.NameSingular }}Request()) | ||
request := NewShow{{ .ObjectInterface.NameSingular }}Request() | ||
{{- if not .ShowByIDFiltering }} | ||
// TODO: adjust request if e.g. LIKE is supported for the resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can leave the default behavior as it is, but we can point the SDK users to use g.ShowByIDLikeFiltering,
and others more explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about: // TODO: adjust request if e.g. LIKE is supported for the resource with ShowByIDLikeFiltering
and other filters for "ShowByIdOperation" in the definition file."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
Args: "Pattern: String(id.Name())", | ||
IdentifierBased: false, | ||
}) | ||
case ShowByIDInFiltering: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use it (non-extended In) in one object to show if it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, i will generate some objects to show all the filtering options
type ShowByIDFiltering struct { | ||
Kind string | ||
Args string | ||
IdentifierBased bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could use an enum instead? What if we have more showByIDs which have a different behavior? Such flag could be confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, that would probably be a better approach than just a flag
ShowByIDInFiltering | ||
// Enables filtering with: ExtendedIn | ||
// Based on the identifier Kind | ||
ShowByIDExtendedInFiltering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In your doc you proposed sth like
ShowByIDSchemaFiltering ShowByIDFilteringKind = "In{Schema: id.SchemaId()}"
ShowByIDInDatabaseFiltering ShowByIDFilteringKind = "In{Database: id.DatabaseId()}"
I'm not saying it's bad, but I'm curious about the other approach here.
I wonder if we can separate these abstractions (one is database vs schema, and the other is in vs extended in)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can skip the In vs. ExtendedIn because those filterings use different structs. For ExtendedIn, we need to provide the ExtendedIn struct, and for Simple In, just the In struct.
I aimed to make it similar in use to what we have for the ShowOperation
:
g.NewQueryStruct("ShowSecret").
...
OptionalLike().
OptionalExtendedIn(),
and then for the filtering we use:
).ShowByIdOperation(
g.ShowByIDLikeFiltering,
g.ShowByIDExtendedInFiltering,
)
Changes
implement_functions
templateOperation
struct with Filtering optionsTo generate filtering options, add filtering options in
ShowByIDOperation
:Test Plan