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
feat(idtoken): Allow format options #1665
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -47,6 +47,7 @@ type DialSettings struct { | |||||||||||||||||||||
ImpersonationConfig *impersonate.Config | ||||||||||||||||||||||
EnableDirectPath bool | ||||||||||||||||||||||
AllowNonDefaultServiceAccount bool | ||||||||||||||||||||||
CustomFormat string | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we want this plumbed to the DialSettings as this is a package things and not an over all client library thing. Also, there is no mechanism to set this field. I think I have a pattern laying around somewhere for doing something like this but it involves exposing custom client options. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now DialSettings seems to already have a field called CustomClaims that only package idtoken uses google-api-go-client/internal/settings.go Line 45 in d6ee425
And the way it is set google-api-go-client/idtoken/idtoken.go Lines 146 to 154 in 62364a2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right, but I don't think it should. This works but only because these two packages are in the same repo today, but in the future they may not be. DialSetting was used here out of convenience, but it muddies the waters of what DialSetting should be used for I think. There are patterns we could adopt to allow any package to declare its own options without needing to touch DialOptions at all. I think we CustomClaims could be re-written in such a manner -- as well as format. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have a pattern in mind? My first thought is have opts be of type interface{} and then type switch each opt func NewClient(ctx context.Context, audience string, opts ...interface{}) (*http.Client, error) {
var ds internal.DialSettings
for _, opt := range opts {
switch x := opt.(type) {
case ClientOption:
x.Apply(&ds)
}
} Are there any immediate drawbacks you see with this? |
||||||||||||||||||||||
|
||||||||||||||||||||||
// Google API system parameters. For more information please read: | ||||||||||||||||||||||
// https://cloud.google.com/apis/docs/system-parameters | ||||||||||||||||||||||
|
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.
This changes the default behaviour which is not desired.
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.
The default format was already full, so default behavior should be the same.