Skip to content

Commit

Permalink
clientset: remove dead code (#4399)
Browse files Browse the repository at this point in the history
Kubernetes in general has moved away from needing generated clients, and
instead now prefers the more dynamic approach. So we can remove all this.
  • Loading branch information
nicks committed Apr 5, 2021
1 parent 3ed62b5 commit 26e7b40
Show file tree
Hide file tree
Showing 38 changed files with 0 additions and 3,035 deletions.
7 changes: 0 additions & 7 deletions internal/hud/server/apiserver.go
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
@@ -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
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.

0 comments on commit 26e7b40

Please sign in to comment.