Skip to content
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

clientset: remove dead code #4399

Merged
merged 1 commit into from
Apr 5, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions internal/hud/server/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/tilt-dev/tilt-apiserver/pkg/server/apiserver"
"github.com/tilt-dev/tilt-apiserver/pkg/server/builder"
"github.com/tilt-dev/tilt/pkg/clientset/tiltapi"
"github.com/tilt-dev/tilt/pkg/logger"
"github.com/tilt-dev/tilt/pkg/model"

Expand All @@ -22,7 +21,6 @@ import (
type APIServerConfig = apiserver.Config

type DynamicInterface = dynamic.Interface
type Interface = tiltapi.Interface

func ProvideMemConn() apiserver.ConnProvider {
return apiserver.NetworkConnProvider(&memconn.Provider{}, "memu")
Expand Down Expand Up @@ -74,11 +72,6 @@ func ProvideTiltServerOptions(ctx context.Context, host model.WebHost, port mode
return o.Config()
}

// Provide a typed API client for the Tilt server.
func ProvideTiltInterface(config *APIServerConfig) (Interface, error) {
return tiltapi.NewForConfig(config.GenericConfig.LoopbackClientConfig)
}

// Provide a dynamic API client for the Tilt server.
func ProvideTiltDynamic(config *APIServerConfig) (DynamicInterface, error) {
return dynamic.NewForConfig(config.GenericConfig.LoopbackClientConfig)
Expand Down
80 changes: 0 additions & 80 deletions internal/hud/server/apiserver_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package server

import (
"context"
"fmt"
"os"
"path/filepath"
Expand All @@ -14,9 +13,6 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/watch"

"github.com/tilt-dev/tilt-apiserver/pkg/server/builder/resource"

"github.com/tilt-dev/tilt/internal/store"
"github.com/tilt-dev/tilt/internal/testutils"
Expand Down Expand Up @@ -86,82 +82,6 @@ func TestAPIServerDynamicClient(t *testing.T) {
}
}

type typedTestCase struct {
Name string
Create func(ctx context.Context, name string, annotations map[string]string) error
Get func(ctx context.Context, name string) (resource.Object, error)
Watch func(ctx context.Context) (watch.Interface, error)
}

// Ensure creating objects works with the typed API clients.
func TestAPIServerTypedClient(t *testing.T) {
ctx, _, _ := testutils.CtxAndAnalyticsForTest()
memconn := ProvideMemConn()
cfg, err := ProvideTiltServerOptions(ctx, "localhost", 0, model.TiltBuild{}, memconn)
require.NoError(t, err)

hudsc := ProvideHeadsUpServerController(0, cfg, &HeadsUpServer{}, assets.NewFakeServer(), model.WebURL{})
st := store.NewTestingStore()
require.NoError(t, hudsc.SetUp(ctx, st))
defer hudsc.TearDown(ctx)

clientset, err := ProvideTiltInterface(cfg)
require.NoError(t, err)

testCases := []typedTestCase{
{
Name: "FileWatch",
Create: func(ctx context.Context, name string, annotations map[string]string) error {
_, err := clientset.TiltV1alpha1().FileWatches().Create(ctx, &v1alpha1.FileWatch{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Annotations: annotations,
},
Spec: v1alpha1.FileWatchSpec{
// this needs to include a valid absolute path for the current GOOS
WatchedPaths: []string{mustCwd(t)},
},
}, metav1.CreateOptions{})
return err
},
Get: func(ctx context.Context, name string) (resource.Object, error) {
return clientset.TiltV1alpha1().FileWatches().Get(ctx, name, metav1.GetOptions{})
},
Watch: func(ctx context.Context) (watch.Interface, error) {
return clientset.TiltV1alpha1().FileWatches().Watch(ctx, metav1.ListOptions{})
},
},
}

for _, testCase := range testCases {
t.Run(testCase.Name, func(t *testing.T) {
objName := fmt.Sprintf("typed-%s", strings.ToLower(testCase.Name))
watcher, err := testCase.Watch(ctx)
require.NoError(t, err)
defer watcher.Stop()

err = testCase.Create(ctx, objName, map[string]string{
"my-random-key": "my-random-value",
})
require.NoError(t, err)

newObj, err := testCase.Get(ctx, objName)
require.NoError(t, err)

metadata, err := meta.Accessor(newObj)
require.NoError(t, err)

assert.Equal(t, objName, metadata.GetName())
assert.Equal(t, "my-random-value", metadata.GetAnnotations()["my-random-key"])

watchEvent := <-watcher.ResultChan()
watchedMetadata, err := meta.Accessor(watchEvent.Object)
require.NoError(t, err)
assert.Equal(t, objName, watchedMetadata.GetName())
})
}
}

func mustCwd(t testing.TB) string {
t.Helper()
cwd, err := os.Getwd()
Expand Down
1 change: 0 additions & 1 deletion internal/hud/server/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
var WireSet = wire.NewSet(
ProvideMemConn,
ProvideTiltServerOptions,
ProvideTiltInterface,
ProvideTiltDynamic,
ProvideHeadsUpServer,
ProvideHeadsUpServerController,
Expand Down
98 changes: 0 additions & 98 deletions pkg/clientset/tiltapi/clientset.go

This file was deleted.

20 changes: 0 additions & 20 deletions pkg/clientset/tiltapi/doc.go

This file was deleted.

83 changes: 0 additions & 83 deletions pkg/clientset/tiltapi/fake/clientset_generated.go

This file was deleted.

20 changes: 0 additions & 20 deletions pkg/clientset/tiltapi/fake/doc.go

This file was deleted.