From 761e98aab9428f610412180280c78367e85080aa Mon Sep 17 00:00:00 2001 From: Gowtham Shanmugasundaram Date: Thu, 1 Aug 2024 18:34:49 +0530 Subject: [PATCH] console: use github.com/openshift/api/console/v1 Signed-off-by: Gowtham Shanmugasundaram --- console/console.go | 39 +++++++++++++++++++++---------------- console/console_test.go | 43 +++++++++++++++++++++++------------------ controllers/manager.go | 4 ++-- 3 files changed, 48 insertions(+), 38 deletions(-) diff --git a/console/console.go b/console/console.go index b63fe066..f87f506c 100644 --- a/console/console.go +++ b/console/console.go @@ -17,7 +17,7 @@ import ( "context" "fmt" - consolev1alpha1 "github.com/openshift/api/console/v1alpha1" + consolev1 "github.com/openshift/api/console/v1" appsv1 "k8s.io/api/apps/v1" apiv1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -70,28 +70,33 @@ func getService(serviceName string, port int, deploymentNamespace string) apiv1. } } -func getConsolePluginCR(consolePort int, serviceName string, deploymentNamespace string) consolev1alpha1.ConsolePlugin { - return consolev1alpha1.ConsolePlugin{ +func getConsolePluginCR(consolePort int, serviceName string, deploymentNamespace string) consolev1.ConsolePlugin { + return consolev1.ConsolePlugin{ ObjectMeta: metav1.ObjectMeta{ Name: odfMulticlusterPluginName, }, - Spec: consolev1alpha1.ConsolePluginSpec{ + Spec: consolev1.ConsolePluginSpec{ DisplayName: pluginDisplayName, - Service: consolev1alpha1.ConsolePluginService{ - Name: serviceName, - Namespace: deploymentNamespace, - Port: int32(consolePort), - BasePath: pluginBasePath, + Backend: consolev1.ConsolePluginBackend{ + Service: &consolev1.ConsolePluginService{ + Name: serviceName, + Namespace: deploymentNamespace, + Port: int32(consolePort), + BasePath: pluginBasePath, + }, + Type: consolev1.Service, }, - Proxy: []consolev1alpha1.ConsolePluginProxy{ + Proxy: []consolev1.ConsolePluginProxy{ { - Type: consolev1alpha1.ProxyTypeService, - Alias: proxyAlias, - Authorize: true, - Service: consolev1alpha1.ConsolePluginProxyServiceConfig{ - Name: proxyServiceName, - Namespace: proxyServiceNamespace, - Port: int32(proxyServicePort), + Alias: proxyAlias, + Authorization: consolev1.UserToken, + Endpoint: consolev1.ConsolePluginProxyEndpoint{ + Type: consolev1.ProxyTypeService, + Service: &consolev1.ConsolePluginProxyServiceConfig{ + Name: proxyServiceName, + Namespace: proxyServiceNamespace, + Port: int32(proxyServicePort), + }, }, }, }, diff --git a/console/console_test.go b/console/console_test.go index 272f2496..5086a8a7 100644 --- a/console/console_test.go +++ b/console/console_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - consolev1alpha1 "github.com/openshift/api/console/v1alpha1" + consolev1 "github.com/openshift/api/console/v1" multiclusterv1alpha1 "github.com/red-hat-storage/odf-multicluster-orchestrator/api/v1alpha1" "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" @@ -29,24 +29,29 @@ type testCase struct { errExpected bool } -func getExpectedConsolePluginSpec() consolev1alpha1.ConsolePluginSpec { - return consolev1alpha1.ConsolePluginSpec{ +func getExpectedConsolePluginSpec() consolev1.ConsolePluginSpec { + return consolev1.ConsolePluginSpec{ DisplayName: pluginDisplayName, - Service: consolev1alpha1.ConsolePluginService{ - Name: odfMulticlusterPluginName, - Namespace: testMulticlusterNamespace, - Port: int32(testPort), - BasePath: pluginBasePath, + Backend: consolev1.ConsolePluginBackend{ + Service: &consolev1.ConsolePluginService{ + Name: odfMulticlusterPluginName, + Namespace: testMulticlusterNamespace, + Port: int32(testPort), + BasePath: pluginBasePath, + }, + Type: consolev1.Service, }, - Proxy: []consolev1alpha1.ConsolePluginProxy{ + Proxy: []consolev1.ConsolePluginProxy{ { - Type: consolev1alpha1.ProxyTypeService, - Alias: proxyAlias, - Authorize: true, - Service: consolev1alpha1.ConsolePluginProxyServiceConfig{ - Name: proxyServiceName, - Namespace: proxyServiceNamespace, - Port: int32(proxyServicePort), + Alias: proxyAlias, + Authorization: consolev1.UserToken, + Endpoint: consolev1.ConsolePluginProxyEndpoint{ + Type: consolev1.ProxyTypeService, + Service: &consolev1.ConsolePluginProxyServiceConfig{ + Name: proxyServiceName, + Namespace: proxyServiceNamespace, + Port: int32(proxyServicePort), + }, }, }, }, @@ -78,9 +83,9 @@ func createFakeScheme(t *testing.T) *runtime.Scheme { if err != nil { assert.Fail(t, "failed to add appsv1 scheme") } - err = consolev1alpha1.AddToScheme(scheme) + err = consolev1.AddToScheme(scheme) if err != nil { - assert.Fail(t, "failed to add consolev1alpha1 scheme") + assert.Fail(t, "failed to add consolev1 scheme") } err = apiv1.AddToScheme(scheme) if err != nil { @@ -120,7 +125,7 @@ func TestInitConsole(t *testing.T) { assert.Error(t, err) } else { assert.NoError(t, err) - consolePlugin := consolev1alpha1.ConsolePlugin{} + consolePlugin := consolev1.ConsolePlugin{} err := client.Get(context.TODO(), types.NamespacedName{ Name: odfMulticlusterPluginName, }, &consolePlugin) diff --git a/controllers/manager.go b/controllers/manager.go index f5e66766..1ce5983e 100644 --- a/controllers/manager.go +++ b/controllers/manager.go @@ -5,7 +5,7 @@ import ( "flag" "os" - consolev1alpha1 "github.com/openshift/api/console/v1alpha1" + consolev1 "github.com/openshift/api/console/v1" "github.com/openshift/library-go/pkg/operator/events" ramenv1alpha1 "github.com/ramendr/ramen/api/v1alpha1" "github.com/red-hat-storage/odf-multicluster-orchestrator/addons/setup" @@ -39,7 +39,7 @@ func init() { utilruntime.Must(multiclusterv1alpha1.AddToScheme(mgrScheme)) utilruntime.Must(addonapiv1alpha1.AddToScheme(mgrScheme)) - utilruntime.Must(consolev1alpha1.AddToScheme(mgrScheme)) + utilruntime.Must(consolev1.AddToScheme(mgrScheme)) utilruntime.Must(ramenv1alpha1.AddToScheme(mgrScheme)) utilruntime.Must(workv1.AddToScheme(mgrScheme))