From d35288c8e3e50236207a66f7f135882c8a795f46 Mon Sep 17 00:00:00 2001 From: tmalik <167480759+tmalikconfluent@users.noreply.github.com> Date: Wed, 4 Sep 2024 12:34:25 +0530 Subject: [PATCH] [APIT-893] Schema Registry on Private Link (#2866) --- go.mod | 2 +- go.sum | 4 ++-- .../schema-registry/command_cluster_describe.go | 6 +++++- pkg/cmd/authenticated_cli_command.go | 6 +++++- .../output/schema-registry/cluster/describe.golden | 2 ++ test/test-server/srcm_handlers.go | 14 ++++++++------ 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 4dcba2e4ca..2a7db7cb99 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/confluentinc/ccloud-sdk-go-v2/networking-privatelink v0.2.0 github.com/confluentinc/ccloud-sdk-go-v2/org v0.9.0 github.com/confluentinc/ccloud-sdk-go-v2/service-quota v0.2.0 - github.com/confluentinc/ccloud-sdk-go-v2/srcm v0.6.0 + github.com/confluentinc/ccloud-sdk-go-v2/srcm v0.7.0 github.com/confluentinc/ccloud-sdk-go-v2/sso v0.0.1 github.com/confluentinc/ccloud-sdk-go-v2/stream-designer v0.3.0 github.com/confluentinc/confluent-kafka-go v1.9.3-RC3 diff --git a/go.sum b/go.sum index 407f4b3670..4c5059e11c 100644 --- a/go.sum +++ b/go.sum @@ -182,8 +182,8 @@ github.com/confluentinc/ccloud-sdk-go-v2/org v0.9.0 h1:FtaqHX0kBTK7fCQK+9SJcOso+ github.com/confluentinc/ccloud-sdk-go-v2/org v0.9.0/go.mod h1:X0uaTYPp+mr19W1R/Z1LuB1ePZJZrH7kxnQckDx6zoc= github.com/confluentinc/ccloud-sdk-go-v2/service-quota v0.2.0 h1:xVSmwdycExze1E2Jta99CaFuMOlL6k6KExOOSY1hSFg= github.com/confluentinc/ccloud-sdk-go-v2/service-quota v0.2.0/go.mod h1:zZWZoGWJuO0Qm4lO6H2KlXMx4OoB/yhD8y6J1ZB/97Q= -github.com/confluentinc/ccloud-sdk-go-v2/srcm v0.6.0 h1:BfhTmbkEWaRbvWZ4mxzkAE9/0DVBClClO34GibG8OkM= -github.com/confluentinc/ccloud-sdk-go-v2/srcm v0.6.0/go.mod h1:qY4Y/QCDKI0eR+HLVJWGFstsTAiI83+sowKOyoRFhF0= +github.com/confluentinc/ccloud-sdk-go-v2/srcm v0.7.0 h1:BFab+P8PHLsmmPfg/K7eguW1wE9mlL1sLYlvZxVzWH8= +github.com/confluentinc/ccloud-sdk-go-v2/srcm v0.7.0/go.mod h1:9JegVbJxJf/F5q5YZKd1GC2fwh1lBvkqXuRG8yk5zV8= github.com/confluentinc/ccloud-sdk-go-v2/sso v0.0.1 h1:WZJYfgXJrvTIYQpCFps/qHF7T8ekgPlX/SFqx4EY2zQ= github.com/confluentinc/ccloud-sdk-go-v2/sso v0.0.1/go.mod h1:kB+MXWYYg9ohrTCb27LlfpTbuexAzyYAmum105ow0ho= github.com/confluentinc/ccloud-sdk-go-v2/stream-designer v0.3.0 h1:zI59UpVm88hQn+dG4KO3TRxD2xdSVQbg5aqSm9/3LXo= diff --git a/internal/schema-registry/command_cluster_describe.go b/internal/schema-registry/command_cluster_describe.go index 3e33cc84a5..12fe164b9a 100644 --- a/internal/schema-registry/command_cluster_describe.go +++ b/internal/schema-registry/command_cluster_describe.go @@ -20,7 +20,9 @@ import ( type clusterOut struct { Name string `human:"Name" serialized:"name"` Cluster string `human:"Cluster" serialized:"cluster"` - EndpointUrl string `human:"Endpoint URL" serialized:"endpoint_url"` + EndpointUrl string `human:"Endpoint URL,omitempty" serialized:"endpoint_url,omitempty"` + PrivateEndpointUrl string `human:"Private Endpoint URL,omitempty" serialized:"private_endpoint_url,omitempty"` + CatalogEndpointUrl string `human:"Catalog Endpoint URL,omitempty" serialized:"catalog_endpoint_url,omitempty"` UsedSchemas string `human:"Used Schemas" serialized:"used_schemas"` AvailableSchemas string `human:"Available Schemas" serialized:"available_schemas"` FreeSchemasLimit int `human:"Free Schemas Limit" serialized:"free_schemas_limit"` @@ -139,6 +141,8 @@ func (c *command) clusterDescribe(cmd *cobra.Command, _ []string) error { Name: cluster.Spec.GetDisplayName(), Cluster: cluster.GetId(), EndpointUrl: cluster.Spec.GetHttpEndpoint(), + PrivateEndpointUrl: cluster.Spec.GetPrivateHttpEndpoint(), + CatalogEndpointUrl: cluster.Spec.GetCatalogHttpEndpoint(), Cloud: cluster.Spec.GetCloud(), Region: cluster.Spec.GetRegion(), Package: cluster.Spec.GetPackage(), diff --git a/pkg/cmd/authenticated_cli_command.go b/pkg/cmd/authenticated_cli_command.go index 23b53945e7..5d469f38d2 100644 --- a/pkg/cmd/authenticated_cli_command.go +++ b/pkg/cmd/authenticated_cli_command.go @@ -252,7 +252,11 @@ func (c *AuthenticatedCLICommand) GetSchemaRegistryClient(cmd *cobra.Command) (* if len(clusters) == 0 { return nil, errors.NewSRNotEnabledError() } - configuration.Servers = srsdk.ServerConfigurations{{URL: clusters[0].Spec.GetHttpEndpoint()}} + if clusters[0].Spec.GetHttpEndpoint() != "" { + configuration.Servers = srsdk.ServerConfigurations{{URL: clusters[0].Spec.GetHttpEndpoint()}} + } else { + configuration.Servers = srsdk.ServerConfigurations{{URL: clusters[0].Spec.GetPrivateHttpEndpoint()}} + } configuration.DefaultHeader = map[string]string{"target-sr-cluster": clusters[0].GetId()} } else { return nil, errors.NewErrorWithSuggestions( diff --git a/test/fixtures/output/schema-registry/cluster/describe.golden b/test/fixtures/output/schema-registry/cluster/describe.golden index 43e6518805..58a400537f 100644 --- a/test/fixtures/output/schema-registry/cluster/describe.golden +++ b/test/fixtures/output/schema-registry/cluster/describe.golden @@ -2,6 +2,8 @@ | Name | account schema-registry | | Cluster | lsrc-1234 | | Endpoint URL | http://127.0.0.1:1027 | +| Private Endpoint URL | http://127.0.0.1:1029 | +| Catalog Endpoint URL | http://127.0.0.1:1030 | | Used Schemas | 0 | | Available Schemas | 1000 | | Free Schemas Limit | 1000 | diff --git a/test/test-server/srcm_handlers.go b/test/test-server/srcm_handlers.go index 485c7eacf1..1a3b899944 100644 --- a/test/test-server/srcm_handlers.go +++ b/test/test-server/srcm_handlers.go @@ -51,12 +51,14 @@ func getSchemaRegistryClusterV3(packageType, endpoint string) srcmv3.SrcmV3Clust return srcmv3.SrcmV3Cluster{ Id: srcmv3.PtrString(srClusterId), Spec: &srcmv3.SrcmV3ClusterSpec{ - DisplayName: srcmv3.PtrString("account schema-registry"), - Package: &packageType, - HttpEndpoint: &endpoint, - Environment: &srcmv3.GlobalObjectReference{Id: SRApiEnvId}, - Region: srcmv3.PtrString(regionSpec), - Cloud: srcmv3.PtrString(cloudSpec), + DisplayName: srcmv3.PtrString("account schema-registry"), + Package: srcmv3.PtrString(packageType), + HttpEndpoint: srcmv3.PtrString(endpoint), + PrivateHttpEndpoint: srcmv3.PtrString("http://127.0.0.1:1029"), + CatalogHttpEndpoint: srcmv3.PtrString("http://127.0.0.1:1030"), + Environment: &srcmv3.GlobalObjectReference{Id: SRApiEnvId}, + Region: srcmv3.PtrString(regionSpec), + Cloud: srcmv3.PtrString(cloudSpec), }, Status: &srcmv3.SrcmV3ClusterStatus{Phase: srClusterStatus}, }