Skip to content

Commit

Permalink
web: remove more dead fields (#4504)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicks committed May 3, 2021
1 parent 8940de2 commit a5e364f
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 301 deletions.
14 changes: 0 additions & 14 deletions internal/hud/webview/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package webview
import (
"os"
"path/filepath"
"sort"
"testing"
"time"

Expand Down Expand Up @@ -65,12 +64,6 @@ func TestStateToWebViewRelativeEditPaths(t *testing.T) {
v := stateToProtoView(t, *state)

require.Len(t, v.Resources, 2)

r, _ := findResource(m.Name, v)
assert.ElementsMatch(t, []string{"foo", filepath.Join("d", "e")}, lastBuild(r).Edits)

sort.Strings(r.CurrentBuild.Edits)
assert.ElementsMatch(t, []string{"foo", filepath.Join("d", "e")}, r.CurrentBuild.Edits)
}

func TestStateToWebViewPortForwards(t *testing.T) {
Expand Down Expand Up @@ -313,11 +306,6 @@ func TestBuildHistory(t *testing.T) {
BuildTypes: []model.BuildType{model.BuildTypeImage, model.BuildTypeK8s},
}
buildRecords := []model.BuildRecord{br1, br2, br3}
expectedUpdateTypes := [][]proto_webview.UpdateType{
[]proto_webview.UpdateType{proto_webview.UpdateType_UPDATE_TYPE_IMAGE, proto_webview.UpdateType_UPDATE_TYPE_K8S},
[]proto_webview.UpdateType{proto_webview.UpdateType_UPDATE_TYPE_LIVE_UPDATE},
[]proto_webview.UpdateType{proto_webview.UpdateType_UPDATE_TYPE_IMAGE, proto_webview.UpdateType_UPDATE_TYPE_K8S},
}

m := model.Manifest{Name: "foo"}.WithDeployTarget(model.K8sTarget{})
state := newState([]model.Manifest{m})
Expand All @@ -331,11 +319,9 @@ func TestBuildHistory(t *testing.T) {

for i, actual := range r.BuildHistory {
expected := buildRecords[i]
require.Equal(t, expected.Edits, actual.Edits)
require.Equal(t, mustTimeToProto(expected.StartTime), actual.StartTime)
require.Equal(t, mustTimeToProto(expected.FinishTime), actual.FinishTime)
require.Equal(t, i == 2, actual.IsCrashRebuild)
require.ElementsMatch(t, expectedUpdateTypes[i], actual.UpdateTypes)
}
}

Expand Down
35 changes: 0 additions & 35 deletions internal/hud/webview/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,6 @@ func timeToProto(t time.Time) (*timestamp.Timestamp, error) {
return ts, nil
}

func buildTypesToProtoUpdateTypes(bts []model.BuildType) ([]proto_webview.UpdateType, error) {
result := make([]proto_webview.UpdateType, len(bts))
for i, bt := range bts {
protoType, err := buildTypeToProto(bt)
if err != nil {
return nil, err
}
result[i] = protoType
}
return result, nil
}

func buildTypeToProto(bt model.BuildType) (proto_webview.UpdateType, error) {
switch bt {
case model.BuildTypeImage:
return proto_webview.UpdateType_UPDATE_TYPE_IMAGE, nil
case model.BuildTypeLiveUpdate:
return proto_webview.UpdateType_UPDATE_TYPE_LIVE_UPDATE, nil
case model.BuildTypeDockerCompose:
return proto_webview.UpdateType_UPDATE_TYPE_DOCKER_COMPOSE, nil
case model.BuildTypeK8s:
return proto_webview.UpdateType_UPDATE_TYPE_K8S, nil
case model.BuildTypeLocal:
return proto_webview.UpdateType_UPDATE_TYPE_LOCAL, nil
default:
return proto_webview.UpdateType_UPDATE_TYPE_UNSPECIFIED, fmt.Errorf("unknown build type '%v'", bt)
}
}

func targetSpecToProto(spec model.TargetSpec) (proto_webview.TargetSpec, error) {
switch typ := spec.(type) {
case model.ImageTarget:
Expand Down Expand Up @@ -127,18 +98,12 @@ func ToProtoBuildRecord(br model.BuildRecord, logStore *logstore.LogStore) (*pro
warnings = logStore.Warnings(br.SpanID)
}

updateTypes, err := buildTypesToProtoUpdateTypes(br.BuildTypes)
if err != nil {
return nil, err
}
return &proto_webview.BuildRecord{
Edits: br.Edits,
Error: e,
// TODO(nick): Remove this, and compute it client-side.
Warnings: warnings,
StartTime: start,
FinishTime: finish,
UpdateTypes: updateTypes,
IsCrashRebuild: br.Reason.IsCrashOnly(),
SpanId: string(br.SpanID),
}, nil
Expand Down

0 comments on commit a5e364f

Please sign in to comment.