Skip to content

Commit

Permalink
feature: turn on events for everyone, but leave flag in for back comp…
Browse files Browse the repository at this point in the history
…at (#1856)

This reverts commit 218c48e.

This reverts commit 499f67d.
  • Loading branch information
Dan Miller authored Jul 15, 2019
1 parent 218c48e commit 0918877
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
5 changes: 5 additions & 0 deletions internal/engine/event_watch_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func NewEventWatchManager(kClient k8s.Client, clock clockwork.Clock, f feature.F
}

func (m *EventWatchManager) needsWatch(st store.RStore) bool {
enabled := m.f.IsEnabled(feature.Events)
if !enabled {
return false
}

state := st.RLockState()
defer st.RUnlockState()

Expand Down
1 change: 1 addition & 0 deletions internal/engine/event_watch_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ func newEWMFixture(t *testing.T) *ewmFixture {

clock := clockwork.NewFakeClock()
f := feature.ProvideFeature()
f.Enable("events")

ret := &ewmFixture{
kClient: kClient,
Expand Down
13 changes: 9 additions & 4 deletions internal/engine/upper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1787,7 +1787,7 @@ func TestUpper_PodLogs(t *testing.T) {
}

func TestK8sEventGlobalLogAndManifestLog(t *testing.T) {
f := newTestFixture(t)
f := newTestFixture(t).EnableK8sEvents()
defer f.TearDown()

entityUID := "someEntity"
Expand Down Expand Up @@ -1844,7 +1844,7 @@ func TestK8sEventGlobalLogAndManifestLog(t *testing.T) {
}

func TestK8sEventNotLoggedIfNoManifestForUID(t *testing.T) {
f := newTestFixture(t)
f := newTestFixture(t).EnableK8sEvents()
defer f.TearDown()

entityUID := "someEntity"
Expand All @@ -1871,7 +1871,7 @@ func TestK8sEventNotLoggedIfNoManifestForUID(t *testing.T) {
}

func TestK8sEventDoNotLogNormalEvents(t *testing.T) {
f := newTestFixture(t)
f := newTestFixture(t).EnableK8sEvents()
defer f.TearDown()

entityUID := "someEntity"
Expand Down Expand Up @@ -1904,7 +1904,7 @@ func TestK8sEventDoNotLogNormalEvents(t *testing.T) {
}

func TestK8sEventLogTimestamp(t *testing.T) {
f := newTestFixture(t)
f := newTestFixture(t).EnableK8sEvents()
defer f.TearDown()

st := f.store.LockMutableStateForTesting()
Expand Down Expand Up @@ -2643,6 +2643,11 @@ func newTestFixture(t *testing.T) *testFixture {
return ret
}

func (f *testFixture) EnableK8sEvents() *testFixture {
f.feature.Enable(feature.Events)
return f
}

func (f *testFixture) Start(manifests []model.Manifest, watchFiles bool, initOptions ...initOption) {
f.startWithInitManifests(nil, manifests, watchFiles, initOptions...)
}
Expand Down
2 changes: 2 additions & 0 deletions internal/feature/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import (
)

const MultipleContainersPerPod = "multiple_containers_per_pod"
const Events = "events"

type Defaults map[string]bool

// All feature flags need to be defined here with their default values
var flags = Defaults{
MultipleContainersPerPod: false,
Events: true,
}

type Feature interface {
Expand Down
6 changes: 0 additions & 6 deletions internal/tiltfile/features.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package tiltfile

import (
"fmt"

"go.starlark.net/starlark"
)

Expand All @@ -13,10 +11,6 @@ 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: 1 addition & 2 deletions internal/tiltfile/tiltfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3581,9 +3581,8 @@ func TestEnableFeatureThatDoesntExist(t *testing.T) {
f.setupFoo()

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

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

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

0 comments on commit 0918877

Please sign in to comment.