Skip to content

Commit

Permalink
tiltfile: unknown feature flag checks are warnings (#1855)
Browse files Browse the repository at this point in the history
I realized that this will be annoying now that we are deleting our first
feature flag. Once someone started tilt on a project that checks an old
feature flag it would crash. This changes unknown feature flags to be
warnings in the Tiltfile instead of errors.
  • Loading branch information
Dan Miller authored Jul 15, 2019
1 parent 4b5da4e commit 218c48e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions internal/tiltfile/features.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package tiltfile

import (
"fmt"

"go.starlark.net/starlark"
)

Expand All @@ -11,6 +13,10 @@ func (s *tiltfileState) enableFeature(thread *starlark.Thread, fn *starlark.Buil
return nil, err
}

if _, ok := s.f.GetAllFlags()[flag]; !ok {
s.warnings = append(s.warnings, fmt.Sprintf("Unknown feature flag used in check: %s", flag))
return starlark.None, nil
}
err = s.f.Enable(flag)
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion internal/tiltfile/tiltfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3581,8 +3581,9 @@ func TestEnableFeatureThatDoesntExist(t *testing.T) {
f.setupFoo()

f.file("Tiltfile", `enable_feature('testflag')`)
f.loadAllowWarnings()

f.loadErrString("Unknown feature flag: testflag")
f.assertWarnings("Unknown feature flag used in check: testflag")
}

func TestDisableFeatureThatDoesntExist(t *testing.T) {
Expand Down

0 comments on commit 218c48e

Please sign in to comment.