-
Notifications
You must be signed in to change notification settings - Fork 12
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
Allow override a Pulumi token by using SetToken of infer.Annotator #129
Conversation
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.
Nifty!
panic(fmt.Sprintf("Module (%q) must comply with %s, but does not", module, tokens.QNameRegexp)) | ||
} | ||
if !tokens.IsName(token) { | ||
panic(fmt.Sprintf("Token (%q) must comply with %s, but does not", token, tokens.NameRegexp)) |
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.
If you get this wrong, when do you see the panic? At compile time for the provider?
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.
At schema generation time.
|
||
func (c *ObjectToken) Annotate(a infer.Annotator) { a.SetToken("obj", "Customized") } | ||
|
||
func TestTokens(t *testing.T) { |
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 looks like this change touches the code that generates the default names; do we have a similar test that checks the names produced without these annotations?
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 have a bunch of integration tests that verify their schema.
fn := runtime.FuncForPC(reflect.ValueOf(i).Pointer()) | ||
parts := strings.Split(fn.Name(), ".") | ||
name = parts[len(parts)-1] | ||
mod = strings.Join(parts[:len(parts)-1], "/") |
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 didn't see this move anywhere else in this review; do we not want this behavior? is is covered somewhere else by the change in layering?
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 never use this behavior. This was a remnant from when we tried to make Invoke and Construct calls wrappers around functions instead of structs. I forgot to remove it.
This is a cleaned up version of #128 (written by @tmeckel).