Skip to content
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

Merged
merged 6 commits into from
Sep 29, 2023

Conversation

iwahbe
Copy link
Member

@iwahbe iwahbe commented Sep 26, 2023

This is a cleaned up version of #128 (written by @tmeckel).

@iwahbe iwahbe self-assigned this Sep 26, 2023
@iwahbe iwahbe requested a review from t0yv0 September 26, 2023 23:45
@iwahbe iwahbe requested a review from a team September 27, 2023 17:18
Copy link
Member

@mjeffryes mjeffryes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nifty!

infer/function.go Outdated Show resolved Hide resolved
Comment on lines +92 to +95
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))
Copy link
Member

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?

Copy link
Member Author

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) {
Copy link
Member

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?

Copy link
Member Author

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.

Comment on lines -95 to -98
fn := runtime.FuncForPC(reflect.ValueOf(i).Pointer())
parts := strings.Split(fn.Name(), ".")
name = parts[len(parts)-1]
mod = strings.Join(parts[:len(parts)-1], "/")
Copy link
Member

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?

Copy link
Member Author

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.

@iwahbe iwahbe requested a review from mjeffryes September 29, 2023 00:45
@iwahbe iwahbe merged commit fbb4f93 into main Sep 29, 2023
5 checks passed
@iwahbe iwahbe deleted the iwahbe/set-token branch September 29, 2023 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants