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

tiltfile: can attach links to local resource [ch9609] #3833

Merged
merged 5 commits into from
Oct 7, 2020

Conversation

maiamcc
Copy link
Contributor

@maiamcc maiamcc commented Oct 6, 2020

Hello @nicks, @landism,

Please review the following commits I made in branch maiamcc/local-resource-link-tiltfile:

047d4ba (2020-10-06 12:33:42 -0400)
clean up

01f30a2 (2020-10-05 18:35:42 -0400)
implement, tests green

b3eef22 (2020-10-05 12:56:25 -0400)
red test

Code review reminders, by giving a LGTM you attest that:

  • Commits are adequately tested
  • Code is easy to understand and conforms to style guides
  • Incomplete code is marked with TODOs
  • Code is suitably instrumented with logging and metrics

@maiamcc maiamcc requested review from landism and nicks October 6, 2020 16:34
"github.com/tilt-dev/tilt/pkg/model"
)

func convertLinks(val starlark.Value) ([]model.Link, error) {
Copy link
Member

Choose a reason for hiding this comment

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

can you make this implement the Unpack interface? here's a good example
https://github.com/tilt-dev/tilt/blob/master/internal/tiltfile/value/duration.go#L21

}
}

func (s *tiltfileState) link(thread *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
Copy link
Member

Choose a reason for hiding this comment

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

can you put this in an extension? i don't have strong opinions about which extension it is. just would like to keep the tiltfileState kitchen sink from growing

Copy link
Contributor Author

@maiamcc maiamcc Oct 6, 2020

Choose a reason for hiding this comment

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

I mean theoretically yes? but it feels weird to me to hide what the constructor of what is theoretically a first class Tiltfile object in an extension. I feel like we should be encouraging everyone to uses local_resource.links to name their links for self-documenting-ness, so the less friction we have there, the better. wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

i think you might be misunderstanding my comment. local_resource should eventually go in an extension too. how the code is organized shouldn't change the syntax.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh whoops yeah -- I thought you meant an extension

@@ -87,6 +90,11 @@ func (s *tiltfileState) localResource(thread *starlark.Thread, fn *starlark.Buil
return nil, fmt.Errorf("local_resource must have a cmd and/or a serve_cmd, but both were empty")
}

links, err := convertLinks(linksVal)
Copy link
Member

Choose a reason for hiding this comment

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

once this is an Unpacker, this will go away (since starlark will be able to correctly identify which argument failed to parse)

}, nil
}

type link struct {
Copy link
Member

Choose a reason for hiding this comment

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

should we embed a Starlark Struct for this?
https://pkg.go.dev/go.starlark.net/starlarkstruct#Struct

e.g.,

type link struct {
  Struct
  
  model.Link
}

Struct comes out of the box with a bunch of semantics that make sense for this value, rather than hand-implementing Truth(), Hash(), etc yourself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ooh neat, I was just cribbing from portForward that sgtm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm do we have an example of this somewhere in the code? (I can't see one.) i'm running into some trouble with pointer receivers and i'm going to leave this for now.

Copy link
Member

Choose a reason for hiding this comment

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

sgtm, i can poke at it later

@maiamcc maiamcc requested a review from nicks October 7, 2020 21:01
@maiamcc
Copy link
Contributor Author

maiamcc commented Oct 7, 2020

@nicks @landism ready for re-review

@maiamcc maiamcc merged commit cde9ad2 into master Oct 7, 2020
@maiamcc maiamcc deleted the maiamcc/local-resource-link-tiltfile branch October 7, 2020 21:16
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.

None yet

2 participants