tiltfile: add yaml function#1111
Merged
Merged
Conversation
nicks
reviewed
Feb 5, 2019
| def fail(msg: str) -> None: | ||
| """Raises an error that cannot be intercepted. Can be used anywhere in a Tiltfile.""" | ||
|
|
||
| def blob(input: str) -> Blob: |
Contributor
There was a problem hiding this comment.
i'm still concerned that blob is a bad name for this function, but not sure i can come up with a better one
|
|
||
| func (s *tiltfileState) blob(thread *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { | ||
| var input starlark.String | ||
| err := starlark.UnpackArgs(fn.Name(), args, kwargs, "path", &input) |
| var input starlark.String | ||
| err := starlark.UnpackArgs(fn.Name(), args, kwargs, "path", &input) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("Argument 0 (path): %v", err) |
Contributor
There was a problem hiding this comment.
i don't think you need this fmt.Error? UnpackArgs should already give you a far better and more descriptive message.
Contributor
|
i guess the Go way to do this would be to have k8s_yaml accept a YAML type, and make the conversion from blob -> yaml implicit. So the function would be |
nicks
approved these changes
Feb 5, 2019
Contributor
Author
|
@nicks I like that approach better, I'm going to do that. |
jazzdan
force-pushed
the
dmiller/ch1459/add-blob-function
branch
from
February 5, 2019 20:54
d804f4c to
21b7918
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So that you can take a Starlark string and pass it in to
k8s_yaml, as demonstrated in the unit test.This is the last part of #894.