Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified docs/_build/doctrees/api.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
14 changes: 14 additions & 0 deletions docs/_build/html/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,20 @@
</table>
</dd></dl>

<dl class="function">
<dt id="api.fail">
<code class="descclassname">api.</code><code class="descname">fail</code><span class="sig-paren">(</span><em>msg</em><span class="sig-paren">)</span><a class="headerlink" href="#api.fail" title="Permalink to this definition">¶</a></dt>
<dd><p>Raises an error that cannot be intercepted. Can be used anywhere in a Tiltfile.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><code class="docutils literal notranslate"><span class="pre">None</span></code></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="api.fast_build">
<code class="descclassname">api.</code><code class="descname">fast_build</code><span class="sig-paren">(</span><em>img_name</em>, <em>dockerfile_path</em>, <em>entrypoint=''</em><span class="sig-paren">)</span><a class="headerlink" href="#api.fast_build" title="Permalink to this definition">¶</a></dt>
Expand Down
4 changes: 4 additions & 0 deletions docs/_build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ <h2 id="D">D</h2>

<h2 id="F">F</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="api.html#api.fail">fail() (in module api)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="api.html#api.fast_build">fast_build() (in module api)</a>
</li>
Expand Down
Binary file modified docs/_build/html/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/_build/html/searchindex.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions docs/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,6 @@ def kustomize(pathToDir: str) -> Blob:

def helm(pathToChartDir: Union[str, LocalPath]) -> Blob:
"""Run `helm template <https://docs.helm.sh/helm/#helm-template>`_ on a given directory that contains a chart and return the fully rendered YAML as a Blob"""

def fail(msg: str) -> None:
"""Raises an error that cannot be intercepted. Can be used anywhere in a Tiltfile."""
17 changes: 17 additions & 0 deletions internal/tiltfile/fail.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package tiltfile

import (
"fmt"

"go.starlark.net/starlark"
)

func (s *tiltfileState) fail(thread *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
var msg string
err := starlark.UnpackArgs(fn.Name(), args, kwargs, "msg", &msg)
if err != nil {
return nil, err
}

return nil, fmt.Errorf(msg)
}
4 changes: 4 additions & 0 deletions internal/tiltfile/tiltfile_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ const (
readFileN = "read_file"
kustomizeN = "kustomize"
helmN = "helm"

// other functions
failN = "fail"
)

func (s *tiltfileState) builtins() starlark.StringDict {
Expand All @@ -117,6 +120,7 @@ func (s *tiltfileState) builtins() starlark.StringDict {
addBuiltin(r, localGitRepoN, s.localGitRepo)
addBuiltin(r, kustomizeN, s.kustomize)
addBuiltin(r, helmN, s.helm)
addBuiltin(r, failN, s.fail)

s.builtinsMap = r

Expand Down
13 changes: 13 additions & 0 deletions internal/tiltfile/tiltfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,19 @@ k8s_yaml('foo.yaml')
f.loadErrString("foo", "image gcr.io/foo:stable is not used in any resource")
}

func TestFail(t *testing.T) {
f := newFixture(t)
defer f.TearDown()

f.file("Tiltfile", `
fail("this is an error")
print("not this")
fail("or this")
`)

f.loadErrString("this is an error")
}

type fixture struct {
ctx context.Context
t *testing.T
Expand Down