Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions internal/app/apiserverapp/apiserverapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,21 @@ func NewScheme() *runtime.Scheme {
utilruntime.Must(metav1.AddMetaToScheme(scheme))
utilruntime.Must(metainternalversion.AddToScheme(scheme))
utilruntime.Must(aggregationv1alpha1.AddToScheme(scheme))

// Register aggregation types for the internal hub version so the generic API
// server can convert SSA requests between v1alpha1 and __internal.
aggregationInternalGroupVersion := schema.GroupVersion{
Group: aggregationv1alpha1.SchemeGroupVersion.Group,
Version: runtime.APIVersionInternal,
}
scheme.AddKnownTypes(
aggregationInternalGroupVersion,
&aggregationv1alpha1.CoderWorkspace{},
&aggregationv1alpha1.CoderWorkspaceList{},
&aggregationv1alpha1.CoderTemplate{},
&aggregationv1alpha1.CoderTemplateList{},
)

return scheme
}

Expand Down
10 changes: 10 additions & 0 deletions internal/app/apiserverapp/apiserverapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/util/managedfields"
Expand All @@ -31,11 +32,20 @@ func TestNewSchemeRegistersAggregationKinds(t *testing.T) {
t.Fatal("expected non-nil scheme")
}

aggregationInternalGroupVersion := schema.GroupVersion{
Group: aggregationv1alpha1.SchemeGroupVersion.Group,
Version: runtime.APIVersionInternal,
}

for _, gvk := range []schema.GroupVersionKind{
aggregationv1alpha1.SchemeGroupVersion.WithKind("CoderWorkspace"),
aggregationv1alpha1.SchemeGroupVersion.WithKind("CoderWorkspaceList"),
aggregationv1alpha1.SchemeGroupVersion.WithKind("CoderTemplate"),
aggregationv1alpha1.SchemeGroupVersion.WithKind("CoderTemplateList"),
aggregationInternalGroupVersion.WithKind("CoderWorkspace"),
aggregationInternalGroupVersion.WithKind("CoderWorkspaceList"),
aggregationInternalGroupVersion.WithKind("CoderTemplate"),
aggregationInternalGroupVersion.WithKind("CoderTemplateList"),
} {
if !scheme.Recognizes(gvk) {
t.Fatalf("expected scheme to recognize %s", gvk.String())
Expand Down
Loading