-
Notifications
You must be signed in to change notification settings - Fork 310
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: helm builtin #994
tiltfile: helm builtin #994
Conversation
@@ -5,3 +5,10 @@ RUN go get -u github.com/kisielk/errcheck | |||
RUN go get -u github.com/google/wire/cmd/wire | |||
|
|||
RUN go get -u sigs.k8s.io/kustomize | |||
|
|||
USER root |
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.
is this a cool thing to do?
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.
ya
internal/tiltfile/tiltfile_state.go
Outdated
@@ -15,6 +15,12 @@ import ( | |||
"github.com/windmilleng/tilt/internal/model" | |||
) | |||
|
|||
// TODO(dmiller) this needs to add all of the files in the directory as dependencies |
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.
Should we have a add_dir_as_dependencies
function? Or is this a sign that we shouldn't be trying to implement this in Starlark, and should implement it in Go so that we can walk that chart directory and record dependencies?
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 think we need to have lots of thoughts about dependencies, and shouldn't block this change on that.
Are you sure that's the right way to get deps from helm? I don't know enough about it to know how else it could have deps. What does skaffold do?
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 would help me to review the user experience with the docs that describe this.
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.
cool!
internal/tiltfile/tiltfile_state.go
Outdated
// TODO(dmiller) this needs to add all of the files in the directory as dependencies | ||
const helmFunc = ` | ||
def helm(path): | ||
return local("helm template " + path) |
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.
do we also need a way to mark the path as read, so it registers as a config file?
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.
Yeah see TODO, and @dbentley's comment.
internal/tiltfile/tiltfile_state.go
Outdated
r = addBuiltin(r, readFileN, s.skylarkReadFile) | ||
|
||
// TODO(dmiller) this really only needs to be done once, on startup | ||
r, err := starlark.ExecFile(thread, "helm.builtin", helmFunc, r) |
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.
can we use a dummy thread here? i don't see a good reason to pass in an external thread, do you?
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.
also probably don't need to re-exec this every time we exec a new tiltfile
f.setupHelm() | ||
|
||
f.file("Tiltfile", ` | ||
yml = helm('helm') |
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.
can you also add a test that this works with git_repo('.').path('helm')?
3b37186
to
f87c12e
Compare
@dbentley added docs |
@@ -18,6 +18,9 @@ k8s_yaml(['foo.yaml', 'bar.yaml']) | |||
# run kustomize to generate yaml | |||
k8s_yaml(kustomize('config_dir')) | |||
|
|||
# run helm to generate yaml | |||
k8s_yaml(helm('chart_dir')) | |||
|
|||
# run a custom command to generate yaml |
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.
Can we move local (the general case) above the specific cases (helm and kustomize), and then maybe a comment like "we also handle common tools to generate yaml"?
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.
Yeah totally
0890a65
to
472146a
Compare
internal/tiltfile/tiltfile.go
Outdated
@@ -34,9 +34,6 @@ func Load(ctx context.Context, filename string, matching map[string]bool) (manif | |||
tfRoot, _ := filepath.Split(absFilename) | |||
|
|||
s := newTiltfileState(ctx, absFilename, tfRoot) | |||
defer func() { |
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 doesn't seem to do anything, but maybe it has something to do with named returns that I'm not understanding?
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.
seems to work ok for me
https://play.golang.org/p/N2e7s_wsABh
can you give a specific example?
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.
but we're returning s.configFiles
so I don't understand why this is necessary? "It doesn't do anything" was a poor choice of words. It seems superfluous.
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 there's an error, i think this function needs to return non-nil? i can write a test for it to double-check the behavior if you want.
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.
Ohhh I think I get it now. Okay I'll add it back.
fyi @nicks I replaced the python implementation with a Go implementation to make tracking dependencies easier. It was a good experiment and we'll need to support things like this in the future for when people write Tilt libraries but I decided it wasn't worth the effort for now. |
- run: echo 'export PATH="/usr/local/opt/go@1.10/bin:$PATH"' >> $BASH_ENV | ||
key: homebrew_cache_v8 | ||
- run: echo 'export PATH="/usr/local/opt/go@1.11/bin:$PATH"' >> $BASH_ENV | ||
- run: curl --silent --show-error --location --fail --retry 3 --output /tmp/helm.tar.gz https://storage.googleapis.com/kubernetes-helm/helm-v2.12.1-darwin-amd64.tar.gz && |
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.
can you add a comment on why you're not using homebrew here? this seems very brittle
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.
Yes, can do. Basically it looks like homebrew isn't being updated any more, it has a much older verison of helm that actually causes the tests to fail in a minor way (just a capitalization difference).
internal/tiltfile/files.go
Outdated
return nil, fmt.Errorf("Argument 0 (path): %v", err) | ||
} | ||
|
||
cmd := fmt.Sprintf("helm template %s", path) |
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 is going to have major escaping problems because you're passing a thing directly to shell here. can you express this as an argv, i.e., []string{"helm", "template", path}
internal/tiltfile/files.go
Outdated
if err != nil { | ||
return fmt.Errorf("error accessing path (%s): %v", path, err) | ||
} | ||
if !info.IsDir() { |
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.
maybe use IsReg() to avoid catching tempfile symlinks and sockets?
internal/tiltfile/files.go
Outdated
|
||
deps := []string{} | ||
|
||
err = filepath.Walk(localPath.path, func(path string, info os.FileInfo, err error) error { |
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 feel like our watcher library has much more efficient ways of watching directories so that we don't need to do a Walk. Where is this falling down?
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.
Yep this is a good point, let's just add the whole directory as a "configFile". Seems to work just fine.
3640923
to
3f4b0ae
Compare
No description provided.