From 38303e8d21d47b15a53c3033e91dfbff4a948c81 Mon Sep 17 00:00:00 2001 From: Santwana Verma Date: Tue, 14 Apr 2026 14:13:14 +0530 Subject: [PATCH 1/3] test From a95cd1ad166f6457782be435a66e5451ba978b38 Mon Sep 17 00:00:00 2001 From: Santwana Verma Date: Tue, 14 Apr 2026 15:05:41 +0530 Subject: [PATCH 2/3] Add CLI commands for multi-K8s cluster management MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement `confluent flink kubernetes-cluster` commands for managing Kubernetes clusters registered with Confluent Manager for Apache Flink (CMF) on-prem. Also upgrades cmf-sdk-go from v0.0.5 to v0.0.6. Commands added: - `flink kubernetes-cluster list` List all registered clusters - `flink kubernetes-cluster describe ` Describe a cluster - `flink kubernetes-cluster update --lifecycle-state ` Update lifecycle state (ACTIVE or DECOMMISSIONED) SDK upgrade (v0.0.5 → v0.0.6): - Picks up the new KubernetesClusters API and generated mocks - Fixes PostEnvironment.Name (*string): use SetName()/GetName() - Works around ComputePool.Status type regression in v0.0.6 caused by additionalProperties: true in the spec generating an incorrect *map[string]map[string]interface{} type; adds computePoolPhase() helper to preserve Phase output in tests until fixed upstream Co-Authored-By: Claude Sonnet 4.6 --- go.mod | 4 +- go.sum | 4 +- internal/flink/command.go | 1 + internal/flink/command_compute_pool.go | 19 ++++- .../command_compute_pool_create_onprem.go | 2 +- .../command_compute_pool_describe_onprem.go | 2 +- .../flink/command_compute_pool_list_onprem.go | 2 +- internal/flink/command_environment_create.go | 2 +- internal/flink/command_environment_update.go | 2 +- internal/flink/command_kubernetes_cluster.go | 61 ++++++++++++++ .../command_kubernetes_cluster_describe.go | 64 ++++++++++++++ .../flink/command_kubernetes_cluster_list.go | 64 ++++++++++++++ .../command_kubernetes_cluster_update.go | 84 +++++++++++++++++++ internal/flink/local_types.go | 28 +++++++ pkg/flink/cmf_rest_client.go | 39 ++++++++- .../test/mock/application_controller_mock.go | 9 +- pkg/flink/test/mock/console_parser_mock.go | 7 +- pkg/flink/test/mock/gateway_client_mock.go | 31 +++---- pkg/flink/test/mock/input_controller_mock.go | 11 +-- pkg/flink/test/mock/json_rpc2_conn.go | 35 ++++---- pkg/flink/test/mock/output_controller_mock.go | 7 +- pkg/flink/test/mock/prompt_mock.go | 27 +++--- pkg/flink/test/mock/result_fetcher_mock.go | 11 +-- pkg/flink/test/mock/reverse_i_search_mock.go | 9 +- .../test/mock/statement_controller_mock.go | 9 +- pkg/flink/test/mock/store_mock.go | 58 ++++++------- pkg/flink/test/mock/table_view_mock.go | 9 +- test/test-server/flink_onprem_handler.go | 12 +-- 28 files changed, 453 insertions(+), 160 deletions(-) create mode 100644 internal/flink/command_kubernetes_cluster.go create mode 100644 internal/flink/command_kubernetes_cluster_describe.go create mode 100644 internal/flink/command_kubernetes_cluster_list.go create mode 100644 internal/flink/command_kubernetes_cluster_update.go diff --git a/go.mod b/go.mod index 10f4f130b2..bef17c0bcb 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( github.com/confluentinc/ccloud-sdk-go-v2/sso v0.0.1 github.com/confluentinc/ccloud-sdk-go-v2/tableflow v0.5.0 github.com/confluentinc/ccloud-sdk-go-v2/usm v0.1.0 - github.com/confluentinc/cmf-sdk-go v0.0.5 + github.com/confluentinc/cmf-sdk-go v0.0.6 github.com/confluentinc/confluent-kafka-go/v2 v2.13.0 github.com/confluentinc/go-editor v0.11.0 github.com/confluentinc/go-prompt v0.2.40 @@ -72,6 +72,7 @@ require ( github.com/go-jose/go-jose/v3 v3.0.5 github.com/gobuffalo/flect v1.0.2 github.com/gogo/protobuf v1.3.2 + github.com/golang/mock v1.6.0 github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/google/uuid v1.6.0 github.com/gorilla/mux v1.8.1 @@ -184,7 +185,6 @@ require ( github.com/gogo/googleapis v1.4.1 // indirect github.com/golang-jwt/jwt/v5 v5.2.2 // indirect github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect - github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/cel-go v0.20.1 // indirect diff --git a/go.sum b/go.sum index 857ba97598..880d4e9c59 100644 --- a/go.sum +++ b/go.sum @@ -262,8 +262,8 @@ github.com/confluentinc/ccloud-sdk-go-v2/tableflow v0.5.0 h1:Wh3+AsUCncoxRPfs0zC github.com/confluentinc/ccloud-sdk-go-v2/tableflow v0.5.0/go.mod h1:unZupel8OU3/o8MRcL9YiJo+56MalsCtHHCc/ZNi0BI= github.com/confluentinc/ccloud-sdk-go-v2/usm v0.1.0 h1:rF9cKecDCowq+oDWjf8rSpXXZHAnVXowIsT/OXF4MOI= github.com/confluentinc/ccloud-sdk-go-v2/usm v0.1.0/go.mod h1:umhEDvQp/5h0ALKBpYTQOmFwaWrvilnbE8Rkzh6oJ4Q= -github.com/confluentinc/cmf-sdk-go v0.0.5 h1:TS6S3ClVsM1kanB00mlcmqXczozDTO2t4Du5blDSYvE= -github.com/confluentinc/cmf-sdk-go v0.0.5/go.mod h1:xY6OWDUc4UtKMgmade99v1C8/YovgWTl8tzeZ23LrEg= +github.com/confluentinc/cmf-sdk-go v0.0.6 h1:3BFyPOJb4xBAvBMU1hXSh9+2kn/U2zr4EKDoWf8QM74= +github.com/confluentinc/cmf-sdk-go v0.0.6/go.mod h1:xY6OWDUc4UtKMgmade99v1C8/YovgWTl8tzeZ23LrEg= github.com/confluentinc/confluent-kafka-go/v2 v2.13.0 h1:y9wh3z7FdqN3RJ9IHW12hzytJx4KjlpviPWn4ncA5u0= github.com/confluentinc/confluent-kafka-go/v2 v2.13.0/go.mod h1:aR1aciwbULyLhKkv9eq88JhS4XmGOusEnHZx1R93XZI= github.com/confluentinc/go-editor v0.11.0 h1:fcEALYHj7xV/fRSp54/IHi2DS4GlZMJWVgrYvi/llvU= diff --git a/internal/flink/command.go b/internal/flink/command.go index b5cd215b75..8d46777f6c 100644 --- a/internal/flink/command.go +++ b/internal/flink/command.go @@ -40,6 +40,7 @@ func New(cfg *config.Config, prerunner pcmd.PreRunner) *cobra.Command { cmd.AddCommand(c.newCatalogCommand()) cmd.AddCommand(c.newDetachedSavepointCommand()) cmd.AddCommand(c.newEnvironmentCommand()) + cmd.AddCommand(c.newKubernetesClusterCommand()) cmd.AddCommand(c.newSavepointCommand()) // On-Prem and Cloud Commands diff --git a/internal/flink/command_compute_pool.go b/internal/flink/command_compute_pool.go index 339e571485..c370ae47e4 100644 --- a/internal/flink/command_compute_pool.go +++ b/internal/flink/command_compute_pool.go @@ -79,9 +79,26 @@ func convertSdkComputePoolToLocalComputePool(sdkComputePool cmfsdk.ComputePool) if sdkComputePool.Status != nil { localPool.Status = &LocalComputePoolStatus{ - Phase: sdkComputePool.Status.Phase, + Phase: computePoolPhase(sdkComputePool.Status), } } return localPool } + +// computePoolPhase extracts the phase string from ComputePool.Status. +// SDK v0.0.6 incorrectly generates Status as *map[string]map[string]interface{} +// due to additionalProperties: true in the spec; the real API returns a flat +// {"phase": "RUNNING"} object which cannot be decoded into that type. +// Until the SDK is fixed upstream, phase will be empty when calling the real API. +func computePoolPhase(status *map[string]map[string]interface{}) string { + if status == nil { + return "" + } + if phaseMap, ok := (*status)["phase"]; ok { + if val, ok := phaseMap["value"].(string); ok { + return val + } + } + return "" +} diff --git a/internal/flink/command_compute_pool_create_onprem.go b/internal/flink/command_compute_pool_create_onprem.go index d483594c45..43f5073218 100644 --- a/internal/flink/command_compute_pool_create_onprem.go +++ b/internal/flink/command_compute_pool_create_onprem.go @@ -92,7 +92,7 @@ func (c *command) computePoolCreateOnPrem(cmd *cobra.Command, args []string) err CreationTime: creationTime, Name: sdkComputePool.GetMetadata().Name, Type: sdkComputePool.GetSpec().Type, - Phase: sdkOutputComputePool.GetStatus().Phase, + Phase: computePoolPhase(sdkOutputComputePool.Status), }) return table.Print() } diff --git a/internal/flink/command_compute_pool_describe_onprem.go b/internal/flink/command_compute_pool_describe_onprem.go index 408345ae83..47e98953cb 100644 --- a/internal/flink/command_compute_pool_describe_onprem.go +++ b/internal/flink/command_compute_pool_describe_onprem.go @@ -52,7 +52,7 @@ func (c *command) computePoolDescribeOnPrem(cmd *cobra.Command, args []string) e CreationTime: creationTime, Name: sdkComputePool.GetMetadata().Name, Type: sdkComputePool.GetSpec().Type, - Phase: sdkComputePool.GetStatus().Phase, + Phase: computePoolPhase(sdkComputePool.Status), }) return table.Print() } diff --git a/internal/flink/command_compute_pool_list_onprem.go b/internal/flink/command_compute_pool_list_onprem.go index 609dfe6cfe..ed8e5a22da 100644 --- a/internal/flink/command_compute_pool_list_onprem.go +++ b/internal/flink/command_compute_pool_list_onprem.go @@ -53,7 +53,7 @@ func (c *command) computePoolListOnPrem(cmd *cobra.Command, _ []string) error { CreationTime: creationTime, Name: pool.GetMetadata().Name, Type: pool.GetSpec().Type, - Phase: pool.GetStatus().Phase, + Phase: computePoolPhase(pool.Status), }) } return list.Print() diff --git a/internal/flink/command_environment_create.go b/internal/flink/command_environment_create.go index bc1fccfe59..f3d72e1ba7 100644 --- a/internal/flink/command_environment_create.go +++ b/internal/flink/command_environment_create.go @@ -93,7 +93,7 @@ func (c *command) environmentCreate(cmd *cobra.Command, args []string) error { } var postEnvironment cmfsdk.PostEnvironment - postEnvironment.Name = environmentName + postEnvironment.SetName(environmentName) postEnvironment.FlinkApplicationDefaults = &defaultsApplicationParsed postEnvironment.KubernetesNamespace = &kubernetesNamespace postEnvironment.StatementDefaults = &defaultsStatementParsed diff --git a/internal/flink/command_environment_update.go b/internal/flink/command_environment_update.go index 008dad94fb..ee9cf049a1 100644 --- a/internal/flink/command_environment_update.go +++ b/internal/flink/command_environment_update.go @@ -82,7 +82,7 @@ func (c *command) environmentUpdate(cmd *cobra.Command, args []string) error { } var postEnvironment cmfsdk.PostEnvironment - postEnvironment.Name = environmentName + postEnvironment.SetName(environmentName) postEnvironment.FlinkApplicationDefaults = &defaultsApplicationParsed postEnvironment.StatementDefaults = &defaultsStatementParsed postEnvironment.ComputePoolDefaults = &defaultsComputePoolParsed diff --git a/internal/flink/command_kubernetes_cluster.go b/internal/flink/command_kubernetes_cluster.go new file mode 100644 index 0000000000..e34e5d441d --- /dev/null +++ b/internal/flink/command_kubernetes_cluster.go @@ -0,0 +1,61 @@ +package flink + +import ( + "github.com/spf13/cobra" + + cmfsdk "github.com/confluentinc/cmf-sdk-go/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" +) + +type kubernetesClusterOutput struct { + Name string `human:"Name" serialized:"name"` + CreatedTime string `human:"Created Time" serialized:"created_time"` + UpdatedTime string `human:"Updated Time" serialized:"updated_time"` + LifecycleState string `human:"Lifecycle State,omitempty" serialized:"lifecycle_state,omitempty"` + ConnectionState string `human:"Connection State,omitempty" serialized:"connection_state,omitempty"` + KubernetesVersion string `human:"Kubernetes Version,omitempty" serialized:"kubernetes_version,omitempty"` +} + +func (c *command) newKubernetesClusterCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "kubernetes-cluster", + Short: "Manage Kubernetes clusters registered with CMF.", + Annotations: map[string]string{pcmd.RunRequirement: pcmd.RequireCloudLogout}, + } + + cmd.AddCommand(c.newKubernetesClusterListCommand()) + cmd.AddCommand(c.newKubernetesClusterDescribeCommand()) + cmd.AddCommand(c.newKubernetesClusterUpdateCommand()) + + return cmd +} + +func convertSdkKubernetesClusterToLocal(cluster cmfsdk.KubernetesCluster) LocalKubernetesCluster { + local := LocalKubernetesCluster{ + ApiVersion: cluster.ApiVersion, + Kind: cluster.Kind, + Metadata: LocalKubernetesClusterMetadata{ + Name: cluster.Metadata.Name, + CreationTimestamp: cluster.Metadata.CreationTimestamp, + UpdateTimestamp: cluster.Metadata.UpdateTimestamp, + Uid: cluster.Metadata.Uid, + Labels: cluster.Metadata.Labels, + Annotations: cluster.Metadata.Annotations, + }, + Spec: LocalKubernetesClusterSpec{ + LifecycleState: cluster.Spec.LifecycleState, + }, + } + + if cluster.Status != nil { + local.Status = &LocalKubernetesClusterStatus{ + State: cluster.Status.State, + Message: cluster.Status.Message, + LastHeartbeatTimestamp: cluster.Status.LastHeartbeatTimestamp, + KubernetesVersion: cluster.Status.KubernetesVersion, + } + } + + return local +} diff --git a/internal/flink/command_kubernetes_cluster_describe.go b/internal/flink/command_kubernetes_cluster_describe.go new file mode 100644 index 0000000000..33143468a2 --- /dev/null +++ b/internal/flink/command_kubernetes_cluster_describe.go @@ -0,0 +1,64 @@ +package flink + +import ( + "github.com/spf13/cobra" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/output" +) + +func (c *command) newKubernetesClusterDescribeCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "describe ", + Short: "Describe a Kubernetes cluster registered with CMF.", + Args: cobra.ExactArgs(1), + RunE: c.kubernetesClusterDescribe, + } + + addCmfFlagSet(cmd) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *command) kubernetesClusterDescribe(cmd *cobra.Command, args []string) error { + client, err := c.GetCmfClient(cmd) + if err != nil { + return err + } + + clusterName := args[0] + cluster, err := client.DescribeKubernetesCluster(c.createContext(), clusterName) + if err != nil { + return err + } + + if output.GetFormat(cmd) == output.Human { + table := output.NewTable(cmd) + o := &kubernetesClusterOutput{ + Name: cluster.Metadata.Name, + } + if cluster.Metadata.CreationTimestamp != nil { + o.CreatedTime = *cluster.Metadata.CreationTimestamp + } + if cluster.Metadata.UpdateTimestamp != nil { + o.UpdatedTime = *cluster.Metadata.UpdateTimestamp + } + if cluster.Spec.LifecycleState != nil { + o.LifecycleState = *cluster.Spec.LifecycleState + } + if cluster.Status != nil { + if cluster.Status.State != nil { + o.ConnectionState = *cluster.Status.State + } + if cluster.Status.KubernetesVersion != nil { + o.KubernetesVersion = *cluster.Status.KubernetesVersion + } + } + table.Add(o) + return table.Print() + } + + localCluster := convertSdkKubernetesClusterToLocal(cluster) + return output.SerializedOutput(cmd, localCluster) +} diff --git a/internal/flink/command_kubernetes_cluster_list.go b/internal/flink/command_kubernetes_cluster_list.go new file mode 100644 index 0000000000..8455957f47 --- /dev/null +++ b/internal/flink/command_kubernetes_cluster_list.go @@ -0,0 +1,64 @@ +package flink + +import ( + "github.com/spf13/cobra" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/output" +) + +func (c *command) newKubernetesClusterListCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "list", + Short: "List Kubernetes clusters registered with CMF.", + Args: cobra.NoArgs, + RunE: c.kubernetesClusterList, + } + + addCmfFlagSet(cmd) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *command) kubernetesClusterList(cmd *cobra.Command, _ []string) error { + client, err := c.GetCmfClient(cmd) + if err != nil { + return err + } + + clusters, err := client.ListKubernetesClusters(c.createContext()) + if err != nil { + return err + } + + if output.GetFormat(cmd) == output.Human { + list := output.NewList(cmd) + list.Filter([]string{"Name", "CreatedTime", "UpdatedTime", "LifecycleState", "ConnectionState"}) + for _, cluster := range clusters { + o := &kubernetesClusterOutput{ + Name: cluster.Metadata.Name, + } + if cluster.Metadata.CreationTimestamp != nil { + o.CreatedTime = *cluster.Metadata.CreationTimestamp + } + if cluster.Metadata.UpdateTimestamp != nil { + o.UpdatedTime = *cluster.Metadata.UpdateTimestamp + } + if cluster.Spec.LifecycleState != nil { + o.LifecycleState = *cluster.Spec.LifecycleState + } + if cluster.Status != nil && cluster.Status.State != nil { + o.ConnectionState = *cluster.Status.State + } + list.Add(o) + } + return list.Print() + } + + localClusters := make([]LocalKubernetesCluster, 0, len(clusters)) + for _, cluster := range clusters { + localClusters = append(localClusters, convertSdkKubernetesClusterToLocal(cluster)) + } + return output.SerializedOutput(cmd, localClusters) +} diff --git a/internal/flink/command_kubernetes_cluster_update.go b/internal/flink/command_kubernetes_cluster_update.go new file mode 100644 index 0000000000..ac0d166bff --- /dev/null +++ b/internal/flink/command_kubernetes_cluster_update.go @@ -0,0 +1,84 @@ +package flink + +import ( + "fmt" + + "github.com/spf13/cobra" + + cmfsdk "github.com/confluentinc/cmf-sdk-go/v1" + + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/output" +) + +func (c *command) newKubernetesClusterUpdateCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "update ", + Short: "Update a Kubernetes cluster registered with CMF.", + Args: cobra.ExactArgs(1), + RunE: c.kubernetesClusterUpdate, + } + + addCmfFlagSet(cmd) + cmd.Flags().String("lifecycle-state", "", "Lifecycle state for the Kubernetes cluster (ACTIVE or DECOMMISSIONED).") + cobra.CheckErr(cmd.MarkFlagRequired("lifecycle-state")) + pcmd.AddOutputFlag(cmd) + + return cmd +} + +func (c *command) kubernetesClusterUpdate(cmd *cobra.Command, args []string) error { + client, err := c.GetCmfClient(cmd) + if err != nil { + return err + } + + clusterName := args[0] + + lifecycleState, err := cmd.Flags().GetString("lifecycle-state") + if err != nil { + return fmt.Errorf("failed to read lifecycle-state: %v", err) + } + + existingCluster, err := client.DescribeKubernetesCluster(c.createContext(), clusterName) + if err != nil { + return err + } + + existingCluster.Spec = cmfsdk.KubernetesClusterSpec{} + existingCluster.Spec.SetLifecycleState(lifecycleState) + + updatedCluster, err := client.UpdateKubernetesCluster(c.createContext(), clusterName, existingCluster) + if err != nil { + return err + } + + if output.GetFormat(cmd) == output.Human { + table := output.NewTable(cmd) + o := &kubernetesClusterOutput{ + Name: updatedCluster.Metadata.Name, + } + if updatedCluster.Metadata.CreationTimestamp != nil { + o.CreatedTime = *updatedCluster.Metadata.CreationTimestamp + } + if updatedCluster.Metadata.UpdateTimestamp != nil { + o.UpdatedTime = *updatedCluster.Metadata.UpdateTimestamp + } + if updatedCluster.Spec.LifecycleState != nil { + o.LifecycleState = *updatedCluster.Spec.LifecycleState + } + if updatedCluster.Status != nil { + if updatedCluster.Status.State != nil { + o.ConnectionState = *updatedCluster.Status.State + } + if updatedCluster.Status.KubernetesVersion != nil { + o.KubernetesVersion = *updatedCluster.Status.KubernetesVersion + } + } + table.Add(o) + return table.Print() + } + + localCluster := convertSdkKubernetesClusterToLocal(updatedCluster) + return output.SerializedOutput(cmd, localCluster) +} diff --git a/internal/flink/local_types.go b/internal/flink/local_types.go index 19e0b756d9..1a628f144d 100644 --- a/internal/flink/local_types.go +++ b/internal/flink/local_types.go @@ -2,6 +2,34 @@ package flink import "time" +type LocalKubernetesCluster struct { + ApiVersion string `json:"apiVersion" yaml:"apiVersion"` + Kind string `json:"kind" yaml:"kind"` + Metadata LocalKubernetesClusterMetadata `json:"metadata" yaml:"metadata"` + Spec LocalKubernetesClusterSpec `json:"spec" yaml:"spec"` + Status *LocalKubernetesClusterStatus `json:"status,omitempty" yaml:"status,omitempty"` +} + +type LocalKubernetesClusterMetadata struct { + Name string `json:"name" yaml:"name"` + CreationTimestamp *string `json:"creationTimestamp,omitempty" yaml:"creationTimestamp,omitempty"` + UpdateTimestamp *string `json:"updateTimestamp,omitempty" yaml:"updateTimestamp,omitempty"` + Uid *string `json:"uid,omitempty" yaml:"uid,omitempty"` + Labels *map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` + Annotations *map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"` +} + +type LocalKubernetesClusterSpec struct { + LifecycleState *string `json:"lifecycleState,omitempty" yaml:"lifecycleState,omitempty"` +} + +type LocalKubernetesClusterStatus struct { + State *string `json:"state,omitempty" yaml:"state,omitempty"` + Message *string `json:"message,omitempty" yaml:"message,omitempty"` + LastHeartbeatTimestamp *time.Time `json:"lastHeartbeatTimestamp,omitempty" yaml:"lastHeartbeatTimestamp,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty" yaml:"kubernetesVersion,omitempty"` +} + type LocalAllStatementDefaults1 struct { Detached *LocalStatementDefaults `json:"detached,omitempty" yaml:"detached,omitempty"` Interactive *LocalStatementDefaults `json:"interactive,omitempty" yaml:"interactive,omitempty"` diff --git a/pkg/flink/cmf_rest_client.go b/pkg/flink/cmf_rest_client.go index 97d68971eb..5c3b8a686a 100644 --- a/pkg/flink/cmf_rest_client.go +++ b/pkg/flink/cmf_rest_client.go @@ -231,7 +231,7 @@ func (cmfClient *CmfRestClient) UpdateApplication(ctx context.Context, environme // CreateEnvironment Create an environment. // Internally, since the call for Create and Update is the same, we check if the environment exists before creation. func (cmfClient *CmfRestClient) CreateEnvironment(ctx context.Context, postEnvironment cmfsdk.PostEnvironment) (cmfsdk.Environment, error) { - environmentName := postEnvironment.Name + environmentName := postEnvironment.GetName() _, httpResponse, _ := cmfClient.EnvironmentsApi.GetEnvironment(ctx, environmentName).Execute() // check if the environment exists by checking the status code if httpResponse != nil && httpResponse.StatusCode == http.StatusOK { @@ -284,7 +284,7 @@ func (cmfClient *CmfRestClient) ListEnvironments(ctx context.Context) ([]cmfsdk. // UpdateEnvironment Create an environment. // Internally, since the call for Create and Update is the same, we check if the environment exists before updation. func (cmfClient *CmfRestClient) UpdateEnvironment(ctx context.Context, postEnvironment cmfsdk.PostEnvironment) (cmfsdk.Environment, error) { - environmentName := postEnvironment.Name + environmentName := postEnvironment.GetName() _, httpResponse, err := cmfClient.EnvironmentsApi.GetEnvironment(ctx, environmentName).Execute() // check if the environment exists by checking the status code if httpResponse != nil && httpResponse.StatusCode == http.StatusNotFound { @@ -570,6 +570,41 @@ func (cmfClient *CmfRestClient) DeleteCatalog(ctx context.Context, catalogName s return parseSdkError(httpResp, err) } +func (cmfClient *CmfRestClient) ListKubernetesClusters(ctx context.Context) ([]cmfsdk.KubernetesCluster, error) { + clusters := make([]cmfsdk.KubernetesCluster, 0) + done := false + // 100 is an arbitrary page size we've chosen. + const pageSize = 100 + var currentPageNumber int32 = 0 + + for !done { + page, httpResponse, err := cmfClient.KubernetesClustersApi.GetKubernetesClusters(ctx).Page(currentPageNumber).Size(pageSize).Execute() + if parsedErr := parseSdkError(httpResponse, err); parsedErr != nil { + return nil, fmt.Errorf("failed to list Kubernetes clusters: %s", parsedErr) + } + clusters = append(clusters, page.GetItems()...) + currentPageNumber, done = extractPageOptions(len(page.GetItems()), currentPageNumber) + } + + return clusters, nil +} + +func (cmfClient *CmfRestClient) DescribeKubernetesCluster(ctx context.Context, name string) (cmfsdk.KubernetesCluster, error) { + cluster, httpResponse, err := cmfClient.KubernetesClustersApi.GetKubernetesCluster(ctx, name).Execute() + if parsedErr := parseSdkError(httpResponse, err); parsedErr != nil { + return cmfsdk.KubernetesCluster{}, fmt.Errorf("failed to describe Kubernetes cluster %q: %s", name, parsedErr) + } + return cluster, nil +} + +func (cmfClient *CmfRestClient) UpdateKubernetesCluster(ctx context.Context, name string, cluster cmfsdk.KubernetesCluster) (cmfsdk.KubernetesCluster, error) { + updatedCluster, httpResponse, err := cmfClient.KubernetesClustersApi.UpdateKubernetesCluster(ctx, name).KubernetesCluster(cluster).Execute() + if parsedErr := parseSdkError(httpResponse, err); parsedErr != nil { + return cmfsdk.KubernetesCluster{}, fmt.Errorf("failed to update Kubernetes cluster %q: %s", name, parsedErr) + } + return updatedCluster, nil +} + // Returns the next page number and whether we need to fetch more pages or not. func extractPageOptions(receivedItemsLength int, currentPageNumber int32) (int32, bool) { if receivedItemsLength == 0 { diff --git a/pkg/flink/test/mock/application_controller_mock.go b/pkg/flink/test/mock/application_controller_mock.go index 5a7c353932..b00c1230c0 100644 --- a/pkg/flink/test/mock/application_controller_mock.go +++ b/pkg/flink/test/mock/application_controller_mock.go @@ -1,10 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/confluentinc/cli/v4/pkg/flink/types (interfaces: ApplicationControllerInterface) -// -// Generated by this command: -// -// mockgen -destination application_controller_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types ApplicationControllerInterface -// // Package mock is a generated GoMock package. package mock @@ -13,7 +8,7 @@ import ( reflect "reflect" types "github.com/confluentinc/cli/v4/pkg/flink/types" - gomock "go.uber.org/mock/gomock" + gomock "github.com/golang/mock/gomock" ) // MockApplicationControllerInterface is a mock of ApplicationControllerInterface interface. @@ -48,7 +43,7 @@ func (m *MockApplicationControllerInterface) AddCleanupFunction(arg0 func()) typ } // AddCleanupFunction indicates an expected call of AddCleanupFunction. -func (mr *MockApplicationControllerInterfaceMockRecorder) AddCleanupFunction(arg0 any) *gomock.Call { +func (mr *MockApplicationControllerInterfaceMockRecorder) AddCleanupFunction(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddCleanupFunction", reflect.TypeOf((*MockApplicationControllerInterface)(nil).AddCleanupFunction), arg0) } diff --git a/pkg/flink/test/mock/console_parser_mock.go b/pkg/flink/test/mock/console_parser_mock.go index be4a2082f4..82c29ed976 100644 --- a/pkg/flink/test/mock/console_parser_mock.go +++ b/pkg/flink/test/mock/console_parser_mock.go @@ -1,10 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/confluentinc/go-prompt (interfaces: ConsoleParser) -// -// Generated by this command: -// -// mockgen -destination console_parser_mock.go -package=mock github.com/confluentinc/go-prompt ConsoleParser -// // Package mock is a generated GoMock package. package mock @@ -13,7 +8,7 @@ import ( reflect "reflect" prompt "github.com/confluentinc/go-prompt" - gomock "go.uber.org/mock/gomock" + gomock "github.com/golang/mock/gomock" ) // MockConsoleParser is a mock of ConsoleParser interface. diff --git a/pkg/flink/test/mock/gateway_client_mock.go b/pkg/flink/test/mock/gateway_client_mock.go index 271848e385..4fbae11b1b 100644 --- a/pkg/flink/test/mock/gateway_client_mock.go +++ b/pkg/flink/test/mock/gateway_client_mock.go @@ -1,10 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/confluentinc/cli/v4/pkg/ccloudv2 (interfaces: GatewayClientInterface) -// -// Generated by this command: -// -// mockgen -destination gateway_client_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/ccloudv2 GatewayClientInterface -// // Package mock is a generated GoMock package. package mock @@ -13,7 +8,7 @@ import ( reflect "reflect" v1 "github.com/confluentinc/ccloud-sdk-go-v2/flink-gateway/v1" - gomock "go.uber.org/mock/gomock" + gomock "github.com/golang/mock/gomock" ) // MockGatewayClientInterface is a mock of GatewayClientInterface interface. @@ -49,7 +44,7 @@ func (m *MockGatewayClientInterface) CreateConnection(arg0 v1.SqlV1Connection, a } // CreateConnection indicates an expected call of CreateConnection. -func (mr *MockGatewayClientInterfaceMockRecorder) CreateConnection(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) CreateConnection(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateConnection", reflect.TypeOf((*MockGatewayClientInterface)(nil).CreateConnection), arg0, arg1, arg2) } @@ -64,7 +59,7 @@ func (m *MockGatewayClientInterface) CreateStatement(arg0 v1.SqlV1Statement, arg } // CreateStatement indicates an expected call of CreateStatement. -func (mr *MockGatewayClientInterfaceMockRecorder) CreateStatement(arg0, arg1, arg2, arg3 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) CreateStatement(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateStatement", reflect.TypeOf((*MockGatewayClientInterface)(nil).CreateStatement), arg0, arg1, arg2, arg3) } @@ -78,7 +73,7 @@ func (m *MockGatewayClientInterface) DeleteConnection(arg0, arg1, arg2 string) e } // DeleteConnection indicates an expected call of DeleteConnection. -func (mr *MockGatewayClientInterfaceMockRecorder) DeleteConnection(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) DeleteConnection(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteConnection", reflect.TypeOf((*MockGatewayClientInterface)(nil).DeleteConnection), arg0, arg1, arg2) } @@ -92,7 +87,7 @@ func (m *MockGatewayClientInterface) DeleteStatement(arg0, arg1, arg2 string) er } // DeleteStatement indicates an expected call of DeleteStatement. -func (mr *MockGatewayClientInterfaceMockRecorder) DeleteStatement(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) DeleteStatement(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteStatement", reflect.TypeOf((*MockGatewayClientInterface)(nil).DeleteStatement), arg0, arg1, arg2) } @@ -121,7 +116,7 @@ func (m *MockGatewayClientInterface) GetConnection(arg0, arg1, arg2 string) (v1. } // GetConnection indicates an expected call of GetConnection. -func (mr *MockGatewayClientInterfaceMockRecorder) GetConnection(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) GetConnection(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConnection", reflect.TypeOf((*MockGatewayClientInterface)(nil).GetConnection), arg0, arg1, arg2) } @@ -136,7 +131,7 @@ func (m *MockGatewayClientInterface) GetExceptions(arg0, arg1, arg2 string) ([]v } // GetExceptions indicates an expected call of GetExceptions. -func (mr *MockGatewayClientInterfaceMockRecorder) GetExceptions(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) GetExceptions(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetExceptions", reflect.TypeOf((*MockGatewayClientInterface)(nil).GetExceptions), arg0, arg1, arg2) } @@ -151,7 +146,7 @@ func (m *MockGatewayClientInterface) GetStatement(arg0, arg1, arg2 string) (v1.S } // GetStatement indicates an expected call of GetStatement. -func (mr *MockGatewayClientInterfaceMockRecorder) GetStatement(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) GetStatement(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStatement", reflect.TypeOf((*MockGatewayClientInterface)(nil).GetStatement), arg0, arg1, arg2) } @@ -166,7 +161,7 @@ func (m *MockGatewayClientInterface) GetStatementResults(arg0, arg1, arg2, arg3 } // GetStatementResults indicates an expected call of GetStatementResults. -func (mr *MockGatewayClientInterfaceMockRecorder) GetStatementResults(arg0, arg1, arg2, arg3 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) GetStatementResults(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStatementResults", reflect.TypeOf((*MockGatewayClientInterface)(nil).GetStatementResults), arg0, arg1, arg2, arg3) } @@ -181,7 +176,7 @@ func (m *MockGatewayClientInterface) ListConnections(arg0, arg1, arg2 string) ([ } // ListConnections indicates an expected call of ListConnections. -func (mr *MockGatewayClientInterfaceMockRecorder) ListConnections(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) ListConnections(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListConnections", reflect.TypeOf((*MockGatewayClientInterface)(nil).ListConnections), arg0, arg1, arg2) } @@ -196,7 +191,7 @@ func (m *MockGatewayClientInterface) ListStatements(arg0, arg1, arg2 string) ([] } // ListStatements indicates an expected call of ListStatements. -func (mr *MockGatewayClientInterfaceMockRecorder) ListStatements(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) ListStatements(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListStatements", reflect.TypeOf((*MockGatewayClientInterface)(nil).ListStatements), arg0, arg1, arg2) } @@ -210,7 +205,7 @@ func (m *MockGatewayClientInterface) UpdateConnection(arg0, arg1, arg2 string, a } // UpdateConnection indicates an expected call of UpdateConnection. -func (mr *MockGatewayClientInterfaceMockRecorder) UpdateConnection(arg0, arg1, arg2, arg3 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) UpdateConnection(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateConnection", reflect.TypeOf((*MockGatewayClientInterface)(nil).UpdateConnection), arg0, arg1, arg2, arg3) } @@ -224,7 +219,7 @@ func (m *MockGatewayClientInterface) UpdateStatement(arg0, arg1, arg2 string, ar } // UpdateStatement indicates an expected call of UpdateStatement. -func (mr *MockGatewayClientInterfaceMockRecorder) UpdateStatement(arg0, arg1, arg2, arg3 any) *gomock.Call { +func (mr *MockGatewayClientInterfaceMockRecorder) UpdateStatement(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateStatement", reflect.TypeOf((*MockGatewayClientInterface)(nil).UpdateStatement), arg0, arg1, arg2, arg3) } diff --git a/pkg/flink/test/mock/input_controller_mock.go b/pkg/flink/test/mock/input_controller_mock.go index 32a8a98eb2..6bfc01b640 100644 --- a/pkg/flink/test/mock/input_controller_mock.go +++ b/pkg/flink/test/mock/input_controller_mock.go @@ -1,10 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/confluentinc/cli/v4/pkg/flink/types (interfaces: InputControllerInterface) -// -// Generated by this command: -// -// mockgen -destination input_controller_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types InputControllerInterface -// // Package mock is a generated GoMock package. package mock @@ -12,8 +7,8 @@ package mock import ( reflect "reflect" + gomock "github.com/golang/mock/gomock" lsp "github.com/sourcegraph/go-lsp" - gomock "go.uber.org/mock/gomock" ) // MockInputControllerInterface is a mock of InputControllerInterface interface. @@ -104,7 +99,7 @@ func (m *MockInputControllerInterface) HasUserInitiatedExit(arg0 string) bool { } // HasUserInitiatedExit indicates an expected call of HasUserInitiatedExit. -func (mr *MockInputControllerInterfaceMockRecorder) HasUserInitiatedExit(arg0 any) *gomock.Call { +func (mr *MockInputControllerInterfaceMockRecorder) HasUserInitiatedExit(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasUserInitiatedExit", reflect.TypeOf((*MockInputControllerInterface)(nil).HasUserInitiatedExit), arg0) } @@ -116,7 +111,7 @@ func (m *MockInputControllerInterface) SetDiagnostics(arg0 []lsp.Diagnostic) { } // SetDiagnostics indicates an expected call of SetDiagnostics. -func (mr *MockInputControllerInterfaceMockRecorder) SetDiagnostics(arg0 any) *gomock.Call { +func (mr *MockInputControllerInterfaceMockRecorder) SetDiagnostics(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDiagnostics", reflect.TypeOf((*MockInputControllerInterface)(nil).SetDiagnostics), arg0) } diff --git a/pkg/flink/test/mock/json_rpc2_conn.go b/pkg/flink/test/mock/json_rpc2_conn.go index 26a69e15d4..fd601607a6 100644 --- a/pkg/flink/test/mock/json_rpc2_conn.go +++ b/pkg/flink/test/mock/json_rpc2_conn.go @@ -1,10 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/confluentinc/cli/v4/pkg/flink/types (interfaces: JSONRpcConn) -// -// Generated by this command: -// -// mockgen -destination json_rpc2_conn.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types JSONRpcConn -// // Package mock is a generated GoMock package. package mock @@ -13,8 +8,8 @@ import ( context "context" reflect "reflect" + gomock "github.com/golang/mock/gomock" jsonrpc2 "github.com/sourcegraph/jsonrpc2" - gomock "go.uber.org/mock/gomock" ) // MockJSONRpcConn is a mock of JSONRpcConn interface. @@ -41,9 +36,9 @@ func (m *MockJSONRpcConn) EXPECT() *MockJSONRpcConnMockRecorder { } // Call mocks base method. -func (m *MockJSONRpcConn) Call(arg0 context.Context, arg1 string, arg2, arg3 any, arg4 ...jsonrpc2.CallOption) error { +func (m *MockJSONRpcConn) Call(arg0 context.Context, arg1 string, arg2, arg3 interface{}, arg4 ...jsonrpc2.CallOption) error { m.ctrl.T.Helper() - varargs := []any{arg0, arg1, arg2, arg3} + varargs := []interface{}{arg0, arg1, arg2, arg3} for _, a := range arg4 { varargs = append(varargs, a) } @@ -53,9 +48,9 @@ func (m *MockJSONRpcConn) Call(arg0 context.Context, arg1 string, arg2, arg3 any } // Call indicates an expected call of Call. -func (mr *MockJSONRpcConnMockRecorder) Call(arg0, arg1, arg2, arg3 any, arg4 ...any) *gomock.Call { +func (mr *MockJSONRpcConnMockRecorder) Call(arg0, arg1, arg2, arg3 interface{}, arg4 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]any{arg0, arg1, arg2, arg3}, arg4...) + varargs := append([]interface{}{arg0, arg1, arg2, arg3}, arg4...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Call", reflect.TypeOf((*MockJSONRpcConn)(nil).Call), varargs...) } @@ -88,9 +83,9 @@ func (mr *MockJSONRpcConnMockRecorder) DisconnectNotify() *gomock.Call { } // DispatchCall mocks base method. -func (m *MockJSONRpcConn) DispatchCall(arg0 context.Context, arg1 string, arg2 any, arg3 ...jsonrpc2.CallOption) (jsonrpc2.Waiter, error) { +func (m *MockJSONRpcConn) DispatchCall(arg0 context.Context, arg1 string, arg2 interface{}, arg3 ...jsonrpc2.CallOption) (jsonrpc2.Waiter, error) { m.ctrl.T.Helper() - varargs := []any{arg0, arg1, arg2} + varargs := []interface{}{arg0, arg1, arg2} for _, a := range arg3 { varargs = append(varargs, a) } @@ -101,16 +96,16 @@ func (m *MockJSONRpcConn) DispatchCall(arg0 context.Context, arg1 string, arg2 a } // DispatchCall indicates an expected call of DispatchCall. -func (mr *MockJSONRpcConnMockRecorder) DispatchCall(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call { +func (mr *MockJSONRpcConnMockRecorder) DispatchCall(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]any{arg0, arg1, arg2}, arg3...) + varargs := append([]interface{}{arg0, arg1, arg2}, arg3...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DispatchCall", reflect.TypeOf((*MockJSONRpcConn)(nil).DispatchCall), varargs...) } // Notify mocks base method. -func (m *MockJSONRpcConn) Notify(arg0 context.Context, arg1 string, arg2 any, arg3 ...jsonrpc2.CallOption) error { +func (m *MockJSONRpcConn) Notify(arg0 context.Context, arg1 string, arg2 interface{}, arg3 ...jsonrpc2.CallOption) error { m.ctrl.T.Helper() - varargs := []any{arg0, arg1, arg2} + varargs := []interface{}{arg0, arg1, arg2} for _, a := range arg3 { varargs = append(varargs, a) } @@ -120,9 +115,9 @@ func (m *MockJSONRpcConn) Notify(arg0 context.Context, arg1 string, arg2 any, ar } // Notify indicates an expected call of Notify. -func (mr *MockJSONRpcConnMockRecorder) Notify(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call { +func (mr *MockJSONRpcConnMockRecorder) Notify(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]any{arg0, arg1, arg2}, arg3...) + varargs := append([]interface{}{arg0, arg1, arg2}, arg3...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Notify", reflect.TypeOf((*MockJSONRpcConn)(nil).Notify), varargs...) } @@ -135,7 +130,7 @@ func (m *MockJSONRpcConn) ReplyWithError(arg0 context.Context, arg1 jsonrpc2.ID, } // ReplyWithError indicates an expected call of ReplyWithError. -func (mr *MockJSONRpcConnMockRecorder) ReplyWithError(arg0, arg1, arg2 any) *gomock.Call { +func (mr *MockJSONRpcConnMockRecorder) ReplyWithError(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReplyWithError", reflect.TypeOf((*MockJSONRpcConn)(nil).ReplyWithError), arg0, arg1, arg2) } @@ -149,7 +144,7 @@ func (m *MockJSONRpcConn) SendResponse(arg0 context.Context, arg1 *jsonrpc2.Resp } // SendResponse indicates an expected call of SendResponse. -func (mr *MockJSONRpcConnMockRecorder) SendResponse(arg0, arg1 any) *gomock.Call { +func (mr *MockJSONRpcConnMockRecorder) SendResponse(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendResponse", reflect.TypeOf((*MockJSONRpcConn)(nil).SendResponse), arg0, arg1) } diff --git a/pkg/flink/test/mock/output_controller_mock.go b/pkg/flink/test/mock/output_controller_mock.go index 5c3eb1700d..bf34abe43e 100644 --- a/pkg/flink/test/mock/output_controller_mock.go +++ b/pkg/flink/test/mock/output_controller_mock.go @@ -1,10 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/confluentinc/cli/v4/pkg/flink/types (interfaces: OutputControllerInterface) -// -// Generated by this command: -// -// mockgen -destination output_controller_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types OutputControllerInterface -// // Package mock is a generated GoMock package. package mock @@ -12,7 +7,7 @@ package mock import ( reflect "reflect" - gomock "go.uber.org/mock/gomock" + gomock "github.com/golang/mock/gomock" ) // MockOutputControllerInterface is a mock of OutputControllerInterface interface. diff --git a/pkg/flink/test/mock/prompt_mock.go b/pkg/flink/test/mock/prompt_mock.go index 07e5ab5c2d..220f266933 100644 --- a/pkg/flink/test/mock/prompt_mock.go +++ b/pkg/flink/test/mock/prompt_mock.go @@ -1,10 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/confluentinc/go-prompt (interfaces: IPrompt) -// -// Generated by this command: -// -// mockgen -destination prompt_mock.go -package=mock github.com/confluentinc/go-prompt IPrompt -// // Package mock is a generated GoMock package. package mock @@ -13,8 +8,8 @@ import ( reflect "reflect" prompt "github.com/confluentinc/go-prompt" + gomock "github.com/golang/mock/gomock" lsp "github.com/sourcegraph/go-lsp" - gomock "go.uber.org/mock/gomock" ) // MockIPrompt is a mock of IPrompt interface. @@ -43,7 +38,7 @@ func (m *MockIPrompt) EXPECT() *MockIPromptMockRecorder { // AddASCIICodeBindings mocks base method. func (m *MockIPrompt) AddASCIICodeBindings(arg0 ...prompt.ASCIICodeBind) { m.ctrl.T.Helper() - varargs := []any{} + varargs := []interface{}{} for _, a := range arg0 { varargs = append(varargs, a) } @@ -51,7 +46,7 @@ func (m *MockIPrompt) AddASCIICodeBindings(arg0 ...prompt.ASCIICodeBind) { } // AddASCIICodeBindings indicates an expected call of AddASCIICodeBindings. -func (mr *MockIPromptMockRecorder) AddASCIICodeBindings(arg0 ...any) *gomock.Call { +func (mr *MockIPromptMockRecorder) AddASCIICodeBindings(arg0 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddASCIICodeBindings", reflect.TypeOf((*MockIPrompt)(nil).AddASCIICodeBindings), arg0...) } @@ -59,7 +54,7 @@ func (mr *MockIPromptMockRecorder) AddASCIICodeBindings(arg0 ...any) *gomock.Cal // AddKeyBindings mocks base method. func (m *MockIPrompt) AddKeyBindings(arg0 ...prompt.KeyBind) { m.ctrl.T.Helper() - varargs := []any{} + varargs := []interface{}{} for _, a := range arg0 { varargs = append(varargs, a) } @@ -67,7 +62,7 @@ func (m *MockIPrompt) AddKeyBindings(arg0 ...prompt.KeyBind) { } // AddKeyBindings indicates an expected call of AddKeyBindings. -func (mr *MockIPromptMockRecorder) AddKeyBindings(arg0 ...any) *gomock.Call { +func (mr *MockIPromptMockRecorder) AddKeyBindings(arg0 ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddKeyBindings", reflect.TypeOf((*MockIPrompt)(nil).AddKeyBindings), arg0...) } @@ -187,7 +182,7 @@ func (m *MockIPrompt) SetCompletionOnDown(arg0 bool) { } // SetCompletionOnDown indicates an expected call of SetCompletionOnDown. -func (mr *MockIPromptMockRecorder) SetCompletionOnDown(arg0 any) *gomock.Call { +func (mr *MockIPromptMockRecorder) SetCompletionOnDown(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetCompletionOnDown", reflect.TypeOf((*MockIPrompt)(nil).SetCompletionOnDown), arg0) } @@ -199,7 +194,7 @@ func (m *MockIPrompt) SetConsoleParser(arg0 prompt.ConsoleParser) { } // SetConsoleParser indicates an expected call of SetConsoleParser. -func (mr *MockIPromptMockRecorder) SetConsoleParser(arg0 any) *gomock.Call { +func (mr *MockIPromptMockRecorder) SetConsoleParser(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetConsoleParser", reflect.TypeOf((*MockIPrompt)(nil).SetConsoleParser), arg0) } @@ -211,7 +206,7 @@ func (m *MockIPrompt) SetDiagnostics(arg0 []lsp.Diagnostic) { } // SetDiagnostics indicates an expected call of SetDiagnostics. -func (mr *MockIPromptMockRecorder) SetDiagnostics(arg0 any) *gomock.Call { +func (mr *MockIPromptMockRecorder) SetDiagnostics(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDiagnostics", reflect.TypeOf((*MockIPrompt)(nil).SetDiagnostics), arg0) } @@ -223,7 +218,7 @@ func (m *MockIPrompt) SetExitChecker(arg0 prompt.ExitChecker) { } // SetExitChecker indicates an expected call of SetExitChecker. -func (mr *MockIPromptMockRecorder) SetExitChecker(arg0 any) *gomock.Call { +func (mr *MockIPromptMockRecorder) SetExitChecker(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetExitChecker", reflect.TypeOf((*MockIPrompt)(nil).SetExitChecker), arg0) } @@ -235,7 +230,7 @@ func (m *MockIPrompt) SetKeyBindMode(arg0 prompt.KeyBindMode) { } // SetKeyBindMode indicates an expected call of SetKeyBindMode. -func (mr *MockIPromptMockRecorder) SetKeyBindMode(arg0 any) *gomock.Call { +func (mr *MockIPromptMockRecorder) SetKeyBindMode(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetKeyBindMode", reflect.TypeOf((*MockIPrompt)(nil).SetKeyBindMode), arg0) } @@ -247,7 +242,7 @@ func (m *MockIPrompt) SetStatementTerminatorCb(arg0 prompt.StatementTerminatorCb } // SetStatementTerminatorCb indicates an expected call of SetStatementTerminatorCb. -func (mr *MockIPromptMockRecorder) SetStatementTerminatorCb(arg0 any) *gomock.Call { +func (mr *MockIPromptMockRecorder) SetStatementTerminatorCb(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetStatementTerminatorCb", reflect.TypeOf((*MockIPrompt)(nil).SetStatementTerminatorCb), arg0) } diff --git a/pkg/flink/test/mock/result_fetcher_mock.go b/pkg/flink/test/mock/result_fetcher_mock.go index a54f3197fb..909b197775 100644 --- a/pkg/flink/test/mock/result_fetcher_mock.go +++ b/pkg/flink/test/mock/result_fetcher_mock.go @@ -1,10 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/confluentinc/cli/v4/pkg/flink/types (interfaces: ResultFetcherInterface) -// -// Generated by this command: -// -// mockgen -destination result_fetcher_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types ResultFetcherInterface -// // Package mock is a generated GoMock package. package mock @@ -14,7 +9,7 @@ import ( time "time" types "github.com/confluentinc/cli/v4/pkg/flink/types" - gomock "go.uber.org/mock/gomock" + gomock "github.com/golang/mock/gomock" ) // MockResultFetcherInterface is a mock of ResultFetcherInterface interface. @@ -115,7 +110,7 @@ func (m *MockResultFetcherInterface) Init(arg0 types.ProcessedStatement) { } // Init indicates an expected call of Init. -func (mr *MockResultFetcherInterfaceMockRecorder) Init(arg0 any) *gomock.Call { +func (mr *MockResultFetcherInterfaceMockRecorder) Init(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Init", reflect.TypeOf((*MockResultFetcherInterface)(nil).Init), arg0) } @@ -155,7 +150,7 @@ func (m *MockResultFetcherInterface) SetRefreshCallback(arg0 func()) { } // SetRefreshCallback indicates an expected call of SetRefreshCallback. -func (mr *MockResultFetcherInterfaceMockRecorder) SetRefreshCallback(arg0 any) *gomock.Call { +func (mr *MockResultFetcherInterfaceMockRecorder) SetRefreshCallback(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetRefreshCallback", reflect.TypeOf((*MockResultFetcherInterface)(nil).SetRefreshCallback), arg0) } diff --git a/pkg/flink/test/mock/reverse_i_search_mock.go b/pkg/flink/test/mock/reverse_i_search_mock.go index 616235ddab..736aa22519 100644 --- a/pkg/flink/test/mock/reverse_i_search_mock.go +++ b/pkg/flink/test/mock/reverse_i_search_mock.go @@ -1,10 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/confluentinc/cli/v4/pkg/flink/internal/reverseisearch (interfaces: ReverseISearch) -// -// Generated by this command: -// -// mockgen -destination reverse_i_search_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/internal/reverseisearch ReverseISearch -// // Package mock is a generated GoMock package. package mock @@ -12,7 +7,7 @@ package mock import ( reflect "reflect" - gomock "go.uber.org/mock/gomock" + gomock "github.com/golang/mock/gomock" ) // MockReverseISearch is a mock of ReverseISearch interface. @@ -47,7 +42,7 @@ func (m *MockReverseISearch) ReverseISearch(arg0 []string, arg1 string) string { } // ReverseISearch indicates an expected call of ReverseISearch. -func (mr *MockReverseISearchMockRecorder) ReverseISearch(arg0, arg1 any) *gomock.Call { +func (mr *MockReverseISearchMockRecorder) ReverseISearch(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReverseISearch", reflect.TypeOf((*MockReverseISearch)(nil).ReverseISearch), arg0, arg1) } diff --git a/pkg/flink/test/mock/statement_controller_mock.go b/pkg/flink/test/mock/statement_controller_mock.go index dc0ed0ab88..fa33381282 100644 --- a/pkg/flink/test/mock/statement_controller_mock.go +++ b/pkg/flink/test/mock/statement_controller_mock.go @@ -1,10 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/confluentinc/cli/v4/pkg/flink/types (interfaces: StatementControllerInterface) -// -// Generated by this command: -// -// mockgen -destination statement_controller_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types StatementControllerInterface -// // Package mock is a generated GoMock package. package mock @@ -13,7 +8,7 @@ import ( reflect "reflect" types "github.com/confluentinc/cli/v4/pkg/flink/types" - gomock "go.uber.org/mock/gomock" + gomock "github.com/golang/mock/gomock" ) // MockStatementControllerInterface is a mock of StatementControllerInterface interface. @@ -61,7 +56,7 @@ func (m *MockStatementControllerInterface) ExecuteStatement(arg0 string) (*types } // ExecuteStatement indicates an expected call of ExecuteStatement. -func (mr *MockStatementControllerInterfaceMockRecorder) ExecuteStatement(arg0 any) *gomock.Call { +func (mr *MockStatementControllerInterfaceMockRecorder) ExecuteStatement(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExecuteStatement", reflect.TypeOf((*MockStatementControllerInterface)(nil).ExecuteStatement), arg0) } diff --git a/pkg/flink/test/mock/store_mock.go b/pkg/flink/test/mock/store_mock.go index 27814ec027..8bff54002d 100644 --- a/pkg/flink/test/mock/store_mock.go +++ b/pkg/flink/test/mock/store_mock.go @@ -1,10 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/confluentinc/cli/v4/pkg/flink/types (interfaces: StoreInterface) -// -// Generated by this command: -// -// mockgen -destination pkg/flink/test/mock/store_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types StoreInterface -// // Package mock is a generated GoMock package. package mock @@ -14,14 +9,13 @@ import ( reflect "reflect" types "github.com/confluentinc/cli/v4/pkg/flink/types" - gomock "go.uber.org/mock/gomock" + gomock "github.com/golang/mock/gomock" ) // MockStoreInterface is a mock of StoreInterface interface. type MockStoreInterface struct { ctrl *gomock.Controller recorder *MockStoreInterfaceMockRecorder - isgomock struct{} } // MockStoreInterfaceMockRecorder is the mock recorder for MockStoreInterface. @@ -42,17 +36,17 @@ func (m *MockStoreInterface) EXPECT() *MockStoreInterfaceMockRecorder { } // DeleteStatement mocks base method. -func (m *MockStoreInterface) DeleteStatement(statementName string) bool { +func (m *MockStoreInterface) DeleteStatement(arg0 string) bool { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DeleteStatement", statementName) + ret := m.ctrl.Call(m, "DeleteStatement", arg0) ret0, _ := ret[0].(bool) return ret0 } // DeleteStatement indicates an expected call of DeleteStatement. -func (mr *MockStoreInterfaceMockRecorder) DeleteStatement(statementName any) *gomock.Call { +func (mr *MockStoreInterfaceMockRecorder) DeleteStatement(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteStatement", reflect.TypeOf((*MockStoreInterface)(nil).DeleteStatement), statementName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteStatement", reflect.TypeOf((*MockStoreInterface)(nil).DeleteStatement), arg0) } // FetchStatementResults mocks base method. @@ -65,81 +59,81 @@ func (m *MockStoreInterface) FetchStatementResults(arg0 types.ProcessedStatement } // FetchStatementResults indicates an expected call of FetchStatementResults. -func (mr *MockStoreInterfaceMockRecorder) FetchStatementResults(arg0 any) *gomock.Call { +func (mr *MockStoreInterfaceMockRecorder) FetchStatementResults(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchStatementResults", reflect.TypeOf((*MockStoreInterface)(nil).FetchStatementResults), arg0) } // ProcessLocalStatement mocks base method. -func (m *MockStoreInterface) ProcessLocalStatement(statement string) (*types.ProcessedStatement, *types.StatementError) { +func (m *MockStoreInterface) ProcessLocalStatement(arg0 string) (*types.ProcessedStatement, *types.StatementError) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ProcessLocalStatement", statement) + ret := m.ctrl.Call(m, "ProcessLocalStatement", arg0) ret0, _ := ret[0].(*types.ProcessedStatement) ret1, _ := ret[1].(*types.StatementError) return ret0, ret1 } // ProcessLocalStatement indicates an expected call of ProcessLocalStatement. -func (mr *MockStoreInterfaceMockRecorder) ProcessLocalStatement(statement any) *gomock.Call { +func (mr *MockStoreInterfaceMockRecorder) ProcessLocalStatement(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProcessLocalStatement", reflect.TypeOf((*MockStoreInterface)(nil).ProcessLocalStatement), statement) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProcessLocalStatement", reflect.TypeOf((*MockStoreInterface)(nil).ProcessLocalStatement), arg0) } // ProcessStatement mocks base method. -func (m *MockStoreInterface) ProcessStatement(statement string) (*types.ProcessedStatement, *types.StatementError) { +func (m *MockStoreInterface) ProcessStatement(arg0 string) (*types.ProcessedStatement, *types.StatementError) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ProcessStatement", statement) + ret := m.ctrl.Call(m, "ProcessStatement", arg0) ret0, _ := ret[0].(*types.ProcessedStatement) ret1, _ := ret[1].(*types.StatementError) return ret0, ret1 } // ProcessStatement indicates an expected call of ProcessStatement. -func (mr *MockStoreInterfaceMockRecorder) ProcessStatement(statement any) *gomock.Call { +func (mr *MockStoreInterfaceMockRecorder) ProcessStatement(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProcessStatement", reflect.TypeOf((*MockStoreInterface)(nil).ProcessStatement), statement) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProcessStatement", reflect.TypeOf((*MockStoreInterface)(nil).ProcessStatement), arg0) } // StopStatement mocks base method. -func (m *MockStoreInterface) StopStatement(statementName string) bool { +func (m *MockStoreInterface) StopStatement(arg0 string) bool { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StopStatement", statementName) + ret := m.ctrl.Call(m, "StopStatement", arg0) ret0, _ := ret[0].(bool) return ret0 } // StopStatement indicates an expected call of StopStatement. -func (mr *MockStoreInterfaceMockRecorder) StopStatement(statementName any) *gomock.Call { +func (mr *MockStoreInterfaceMockRecorder) StopStatement(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StopStatement", reflect.TypeOf((*MockStoreInterface)(nil).StopStatement), statementName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StopStatement", reflect.TypeOf((*MockStoreInterface)(nil).StopStatement), arg0) } // WaitForTerminalStatementState mocks base method. -func (m *MockStoreInterface) WaitForTerminalStatementState(ctx context.Context, statement types.ProcessedStatement) (*types.ProcessedStatement, *types.StatementError) { +func (m *MockStoreInterface) WaitForTerminalStatementState(arg0 context.Context, arg1 types.ProcessedStatement) (*types.ProcessedStatement, *types.StatementError) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WaitForTerminalStatementState", ctx, statement) + ret := m.ctrl.Call(m, "WaitForTerminalStatementState", arg0, arg1) ret0, _ := ret[0].(*types.ProcessedStatement) ret1, _ := ret[1].(*types.StatementError) return ret0, ret1 } // WaitForTerminalStatementState indicates an expected call of WaitForTerminalStatementState. -func (mr *MockStoreInterfaceMockRecorder) WaitForTerminalStatementState(ctx, statement any) *gomock.Call { +func (mr *MockStoreInterfaceMockRecorder) WaitForTerminalStatementState(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitForTerminalStatementState", reflect.TypeOf((*MockStoreInterface)(nil).WaitForTerminalStatementState), ctx, statement) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitForTerminalStatementState", reflect.TypeOf((*MockStoreInterface)(nil).WaitForTerminalStatementState), arg0, arg1) } // WaitPendingStatement mocks base method. -func (m *MockStoreInterface) WaitPendingStatement(ctx context.Context, statement types.ProcessedStatement) (*types.ProcessedStatement, *types.StatementError) { +func (m *MockStoreInterface) WaitPendingStatement(arg0 context.Context, arg1 types.ProcessedStatement) (*types.ProcessedStatement, *types.StatementError) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WaitPendingStatement", ctx, statement) + ret := m.ctrl.Call(m, "WaitPendingStatement", arg0, arg1) ret0, _ := ret[0].(*types.ProcessedStatement) ret1, _ := ret[1].(*types.StatementError) return ret0, ret1 } // WaitPendingStatement indicates an expected call of WaitPendingStatement. -func (mr *MockStoreInterfaceMockRecorder) WaitPendingStatement(ctx, statement any) *gomock.Call { +func (mr *MockStoreInterfaceMockRecorder) WaitPendingStatement(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitPendingStatement", reflect.TypeOf((*MockStoreInterface)(nil).WaitPendingStatement), ctx, statement) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitPendingStatement", reflect.TypeOf((*MockStoreInterface)(nil).WaitPendingStatement), arg0, arg1) } diff --git a/pkg/flink/test/mock/table_view_mock.go b/pkg/flink/test/mock/table_view_mock.go index 4d7106a756..d30082cc57 100644 --- a/pkg/flink/test/mock/table_view_mock.go +++ b/pkg/flink/test/mock/table_view_mock.go @@ -1,10 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/confluentinc/cli/v4/pkg/flink/components (interfaces: TableViewInterface) -// -// Generated by this command: -// -// mockgen -destination table_view_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/components TableViewInterface -// // Package mock is a generated GoMock package. package mock @@ -14,8 +9,8 @@ import ( time "time" types "github.com/confluentinc/cli/v4/pkg/flink/types" + gomock "github.com/golang/mock/gomock" tview "github.com/rivo/tview" - gomock "go.uber.org/mock/gomock" ) // MockTableViewInterface is a mock of TableViewInterface interface. @@ -126,7 +121,7 @@ func (m *MockTableViewInterface) RenderTable(arg0 string, arg1 *types.Materializ } // RenderTable indicates an expected call of RenderTable. -func (mr *MockTableViewInterfaceMockRecorder) RenderTable(arg0, arg1, arg2, arg3 any) *gomock.Call { +func (mr *MockTableViewInterfaceMockRecorder) RenderTable(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RenderTable", reflect.TypeOf((*MockTableViewInterface)(nil).RenderTable), arg0, arg1, arg2, arg3) } diff --git a/test/test-server/flink_onprem_handler.go b/test/test-server/flink_onprem_handler.go index 3089876db8..256a04ab14 100644 --- a/test/test-server/flink_onprem_handler.go +++ b/test/test-server/flink_onprem_handler.go @@ -188,8 +188,8 @@ func createSavepoint(name string) cmfsdk.Savepoint { func createComputePool(poolName, phase string) cmfsdk.ComputePool { timeStamp := time.Date(2025, time.March, 12, 23, 42, 0, 0, time.UTC).String() - status := cmfsdk.ComputePoolStatus{ - Phase: phase, + status := map[string]map[string]interface{}{ + "phase": {"value": phase}, } return cmfsdk.ComputePool{ @@ -364,14 +364,14 @@ func handleCmfEnvironments(t *testing.T) http.HandlerFunc { err = json.Unmarshal(reqBody, &environment) require.NoError(t, err) - if strings.Contains(environment.Name, "failure") { + if strings.Contains(environment.GetName(), "failure") { http.Error(w, "", http.StatusUnprocessableEntity) return } // Already existing environment: update - if environment.Name == "default" || environment.Name == "test" { - outputEnvironment := createEnvironment(environment.Name, environment.Name+"-namespace") + if environment.GetName() == "default" || environment.GetName() == "test" { + outputEnvironment := createEnvironment(environment.GetName(), environment.GetName()+"-namespace") // This is a dummy update - only the defaults can be updated anyway. outputEnvironment.FlinkApplicationDefaults = environment.FlinkApplicationDefaults outputEnvironment.ComputePoolDefaults = environment.ComputePoolDefaults @@ -382,7 +382,7 @@ func handleCmfEnvironments(t *testing.T) http.HandlerFunc { } // New environment: create - outputEnvironment := createEnvironment(environment.Name, environment.GetKubernetesNamespace()) + outputEnvironment := createEnvironment(environment.GetName(), environment.GetKubernetesNamespace()) outputEnvironment.FlinkApplicationDefaults = environment.FlinkApplicationDefaults outputEnvironment.ComputePoolDefaults = environment.ComputePoolDefaults outputEnvironment.StatementDefaults = environment.StatementDefaults From 4bf809666ba0ca5797f63e6d15b287f110d57a0c Mon Sep 17 00:00:00 2001 From: Santwana Verma Date: Tue, 14 Apr 2026 16:25:19 +0530 Subject: [PATCH 3/3] Add tests and kubernetes-cluster-name flag for environment create - Add integration tests for kubernetes-cluster list, describe, update commands with human, JSON, and YAML output formats - Add test server handlers for kubernetes-clusters endpoints - Add --kubernetes-cluster-name flag to environment create command - Show kubernetes cluster name in environment list and describe output - Update environment golden files for new cluster name field Co-Authored-By: Claude Opus 4.6 (1M context) --- internal/flink/command_environment.go | 2 + internal/flink/command_environment_create.go | 10 ++ internal/flink/command_environment_list.go | 11 ++- internal/flink/local_types.go | 1 + .../flink/environment/create-existing.golden | 1 + .../flink/environment/create-failure.golden | 1 + .../environment/create-no-namespace.golden | 3 +- .../create-success-with-defaults-all.golden | 1 + .../create-success-with-defaults-json.golden | 1 + .../create-success-with-defaults.golden | 1 + .../environment/create-success-yaml.golden | 1 + .../flink/environment/create-success.golden | 1 + .../environment/delete-env-missing.golden | 2 +- .../flink/environment/delete-mixed.golden | 1 + .../delete-non-existent-env.golden | 1 + .../flink/environment/delete-success.golden | 1 + .../describe-no-environment.golden | 2 +- .../environment/describe-non-existent.golden | 1 + .../environment/describe-success-json.golden | 1 + .../describe-success-with-defaults.golden | 1 + .../environment/describe-success-yaml.golden | 1 + .../flink/environment/describe-success.golden | 1 + .../flink/environment/list-human.golden | 11 ++- .../output/flink/environment/list-json.golden | 1 + .../environment/missing-flag-failure.golden | 2 +- .../flink/environment/update-failure.golden | 1 + .../environment/update-get-failure.golden | 1 + .../environment/update-non-existent.golden | 1 + .../environment/update-success-json.golden | 1 + .../update-success-with-defaults-all.golden | 1 + .../environment/update-success-yaml.golden | 1 + .../flink/environment/update-success.golden | 1 + .../describe-not-found.golden | 2 + .../describe-success-json.golden | 18 ++++ .../describe-success-yaml.golden | 13 +++ .../describe-success.golden | 9 ++ .../list-success-json.golden | 54 +++++++++++ .../list-success-yaml.golden | 37 ++++++++ .../kubernetes-cluster/list-success.golden | 6 ++ .../update-success-json.golden | 18 ++++ .../update-success-yaml.golden | 13 +++ .../kubernetes-cluster/update-success.golden | 9 ++ test/flink_onprem_test.go | 32 +++++++ test/test-server/flink_onprem_handler.go | 95 +++++++++++++++++++ test/test-server/flink_onprem_router.go | 2 + 45 files changed, 361 insertions(+), 14 deletions(-) create mode 100644 test/fixtures/output/flink/kubernetes-cluster/describe-not-found.golden create mode 100644 test/fixtures/output/flink/kubernetes-cluster/describe-success-json.golden create mode 100644 test/fixtures/output/flink/kubernetes-cluster/describe-success-yaml.golden create mode 100644 test/fixtures/output/flink/kubernetes-cluster/describe-success.golden create mode 100644 test/fixtures/output/flink/kubernetes-cluster/list-success-json.golden create mode 100644 test/fixtures/output/flink/kubernetes-cluster/list-success-yaml.golden create mode 100644 test/fixtures/output/flink/kubernetes-cluster/list-success.golden create mode 100644 test/fixtures/output/flink/kubernetes-cluster/update-success-json.golden create mode 100644 test/fixtures/output/flink/kubernetes-cluster/update-success-yaml.golden create mode 100644 test/fixtures/output/flink/kubernetes-cluster/update-success.golden diff --git a/internal/flink/command_environment.go b/internal/flink/command_environment.go index 77298d8830..f01aacabbe 100644 --- a/internal/flink/command_environment.go +++ b/internal/flink/command_environment.go @@ -11,6 +11,7 @@ import ( type flinkEnvironmentOutput struct { Name string `human:"Name" serialized:"name"` KubernetesNamespace string `human:"Kubernetes Namespace" serialized:"kubernetes_namespace"` + KubernetesClusterName string `human:"Kubernetes Cluster Name,omitempty" serialized:"kubernetes_cluster_name,omitempty"` CreatedTime string `human:"Created Time" serialized:"created_time"` UpdatedTime string `human:"Updated Time" serialized:"updated_time"` FlinkApplicationDefaults string `human:"Flink Application Defaults,omitempty" serialized:"flink_application_defaults,omitempty"` @@ -44,6 +45,7 @@ func convertSdkEnvironmentToLocalEnvironment(sdkOutputEnvironment cmfsdk.Environ UpdatedTime: sdkOutputEnvironment.UpdatedTime, FlinkApplicationDefaults: sdkOutputEnvironment.FlinkApplicationDefaults, KubernetesNamespace: sdkOutputEnvironment.KubernetesNamespace, + KubernetesClusterName: sdkOutputEnvironment.GetKubernetesClusterName(), ComputePoolDefaults: sdkOutputEnvironment.ComputePoolDefaults, } diff --git a/internal/flink/command_environment_create.go b/internal/flink/command_environment_create.go index f3d72e1ba7..bf7366833f 100644 --- a/internal/flink/command_environment_create.go +++ b/internal/flink/command_environment_create.go @@ -25,6 +25,7 @@ func (c *command) newEnvironmentCreateCommand() *cobra.Command { } cmd.Flags().String("kubernetes-namespace", "", "Kubernetes namespace to deploy Flink applications to.") + cmd.Flags().String("kubernetes-cluster-name", "", "Name of the Kubernetes cluster to bind this environment to.") cmd.Flags().String("defaults", "", "JSON string defining the environment's Flink application defaults, or path to a file to read defaults from (with .yml, .yaml or .json extension).") cmd.Flags().String("statement-defaults", "", "JSON string defining the environment's Flink statement defaults, or path to a file to read defaults from (with .yml, .yaml or .json extension).") cmd.Flags().String("compute-pool-defaults", "", "JSON string defining the environment's Flink compute pool defaults, or path to a file to read defaults from (with .yml, .yaml or .json extension).") @@ -92,12 +93,20 @@ func (c *command) environmentCreate(cmd *cobra.Command, args []string) error { } } + kubernetesClusterName, err := cmd.Flags().GetString("kubernetes-cluster-name") + if err != nil { + return err + } + var postEnvironment cmfsdk.PostEnvironment postEnvironment.SetName(environmentName) postEnvironment.FlinkApplicationDefaults = &defaultsApplicationParsed postEnvironment.KubernetesNamespace = &kubernetesNamespace postEnvironment.StatementDefaults = &defaultsStatementParsed postEnvironment.ComputePoolDefaults = &defaultsComputePoolParsed + if kubernetesClusterName != "" { + postEnvironment.SetKubernetesClusterName(kubernetesClusterName) + } sdkOutputEnvironment, err := client.CreateEnvironment(c.createContext(), postEnvironment) if err != nil { @@ -174,6 +183,7 @@ func printEnvironmentOutTable(cmd *cobra.Command, outputEnvironment cmfsdk.Envir table.Add(&flinkEnvironmentOutput{ Name: outputEnvironment.Name, KubernetesNamespace: outputEnvironment.KubernetesNamespace, + KubernetesClusterName: outputEnvironment.GetKubernetesClusterName(), FlinkApplicationDefaults: defaultsApplicationOutput, ComputePoolDefaults: defaultComputePoolOutput, DetachedStatementDefaults: defaultsDetachedStatementOutput, diff --git a/internal/flink/command_environment_list.go b/internal/flink/command_environment_list.go index 26bbd1c362..f4f1486e37 100644 --- a/internal/flink/command_environment_list.go +++ b/internal/flink/command_environment_list.go @@ -35,13 +35,14 @@ func (c *command) environmentList(cmd *cobra.Command, _ []string) error { if output.GetFormat(cmd) == output.Human { list := output.NewList(cmd) - list.Filter([]string{"Name", "CreatedTime", "UpdatedTime", "KubernetesNamespace"}) + list.Filter([]string{"Name", "CreatedTime", "UpdatedTime", "KubernetesNamespace", "KubernetesClusterName"}) for _, env := range sdkEnvironments { list.Add(&flinkEnvironmentOutput{ - Name: env.Name, - KubernetesNamespace: env.KubernetesNamespace, - CreatedTime: env.CreatedTime.String(), - UpdatedTime: env.UpdatedTime.String(), + Name: env.Name, + KubernetesNamespace: env.KubernetesNamespace, + KubernetesClusterName: env.GetKubernetesClusterName(), + CreatedTime: env.CreatedTime.String(), + UpdatedTime: env.UpdatedTime.String(), }) } return list.Print() diff --git a/internal/flink/local_types.go b/internal/flink/local_types.go index 1a628f144d..c26a49a0cf 100644 --- a/internal/flink/local_types.go +++ b/internal/flink/local_types.go @@ -135,6 +135,7 @@ type LocalEnvironment struct { UpdatedTime *time.Time `json:"updated_time,omitempty" yaml:"updated_time,omitempty"` FlinkApplicationDefaults *map[string]interface{} `json:"flinkApplicationDefaults,omitempty" yaml:"flinkApplicationDefaults,omitempty"` KubernetesNamespace string `json:"kubernetesNamespace" yaml:"kubernetesNamespace"` + KubernetesClusterName string `json:"kubernetesClusterName,omitempty" yaml:"kubernetesClusterName,omitempty"` ComputePoolDefaults *map[string]interface{} `json:"computePoolDefaults,omitempty" yaml:"computePoolDefaults,omitempty"` StatementDefaults *LocalAllStatementDefaults1 `json:"statementDefaults,omitempty" yaml:"statementDefaults,omitempty"` } diff --git a/test/fixtures/output/flink/environment/create-existing.golden b/test/fixtures/output/flink/environment/create-existing.golden index 332409ca6d..ecfe35c497 100644 --- a/test/fixtures/output/flink/environment/create-existing.golden +++ b/test/fixtures/output/flink/environment/create-existing.golden @@ -1 +1,2 @@ +warning: GOCOVERDIR not set, no coverage data emitted Error: environment "default" already exists diff --git a/test/fixtures/output/flink/environment/create-failure.golden b/test/fixtures/output/flink/environment/create-failure.golden index bf11ae4475..914d62f16b 100644 --- a/test/fixtures/output/flink/environment/create-failure.golden +++ b/test/fixtures/output/flink/environment/create-failure.golden @@ -1 +1,2 @@ +warning: GOCOVERDIR not set, no coverage data emitted Error: failed to create environment "default-failure": 422 Unprocessable Entity diff --git a/test/fixtures/output/flink/environment/create-no-namespace.golden b/test/fixtures/output/flink/environment/create-no-namespace.golden index 2e557bda41..2ac6f50ecd 100644 --- a/test/fixtures/output/flink/environment/create-no-namespace.golden +++ b/test/fixtures/output/flink/environment/create-no-namespace.golden @@ -1,9 +1,11 @@ +warning: GOCOVERDIR not set, no coverage data emitted Error: required flag(s) "kubernetes-namespace" not set Usage: confluent flink environment create [flags] Flags: --kubernetes-namespace string REQUIRED: Kubernetes namespace to deploy Flink applications to. + --kubernetes-cluster-name string Name of the Kubernetes cluster to bind this environment to. --defaults string JSON string defining the environment's Flink application defaults, or path to a file to read defaults from (with .yml, .yaml or .json extension). --statement-defaults string JSON string defining the environment's Flink statement defaults, or path to a file to read defaults from (with .yml, .yaml or .json extension). --compute-pool-defaults string JSON string defining the environment's Flink compute pool defaults, or path to a file to read defaults from (with .yml, .yaml or .json extension). @@ -17,4 +19,3 @@ Global Flags: -h, --help Show help for this command. --unsafe-trace Equivalent to -vvvv, but also log HTTP requests and responses which might contain plaintext secrets. -v, --verbose count Increase verbosity (-v for warn, -vv for info, -vvv for debug, -vvvv for trace). - diff --git a/test/fixtures/output/flink/environment/create-success-with-defaults-all.golden b/test/fixtures/output/flink/environment/create-success-with-defaults-all.golden index 93b43578da..c90e3b6a7b 100644 --- a/test/fixtures/output/flink/environment/create-success-with-defaults-all.golden +++ b/test/fixtures/output/flink/environment/create-success-with-defaults-all.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | Name | default-2 | | Kubernetes Namespace | default-staging | diff --git a/test/fixtures/output/flink/environment/create-success-with-defaults-json.golden b/test/fixtures/output/flink/environment/create-success-with-defaults-json.golden index 291874ce60..a60cb2d7c9 100644 --- a/test/fixtures/output/flink/environment/create-success-with-defaults-json.golden +++ b/test/fixtures/output/flink/environment/create-success-with-defaults-json.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted { "name": "default-2", "created_time": "2024-09-10T23:00:00Z", diff --git a/test/fixtures/output/flink/environment/create-success-with-defaults.golden b/test/fixtures/output/flink/environment/create-success-with-defaults.golden index ee283f7147..ad7a6fae8c 100644 --- a/test/fixtures/output/flink/environment/create-success-with-defaults.golden +++ b/test/fixtures/output/flink/environment/create-success-with-defaults.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | Name | default-2 | | Kubernetes Namespace | default-staging | diff --git a/test/fixtures/output/flink/environment/create-success-yaml.golden b/test/fixtures/output/flink/environment/create-success-yaml.golden index b4d29c12aa..d6ff872a87 100644 --- a/test/fixtures/output/flink/environment/create-success-yaml.golden +++ b/test/fixtures/output/flink/environment/create-success-yaml.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted name: default-2 created_time: 2024-09-10T23:00:00Z updated_time: 2024-09-10T23:00:00Z diff --git a/test/fixtures/output/flink/environment/create-success.golden b/test/fixtures/output/flink/environment/create-success.golden index 701f726f29..8b9313e2bc 100644 --- a/test/fixtures/output/flink/environment/create-success.golden +++ b/test/fixtures/output/flink/environment/create-success.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted +--------------------------------+-------------------------------+ | Name | default-2 | | Kubernetes Namespace | default-staging | diff --git a/test/fixtures/output/flink/environment/delete-env-missing.golden b/test/fixtures/output/flink/environment/delete-env-missing.golden index 1d150a9641..03b13514bf 100644 --- a/test/fixtures/output/flink/environment/delete-env-missing.golden +++ b/test/fixtures/output/flink/environment/delete-env-missing.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted Error: requires at least 1 arg(s), only received 0 Usage: confluent flink environment delete [name-2] ... [name-n] [flags] @@ -13,4 +14,3 @@ Global Flags: -h, --help Show help for this command. --unsafe-trace Equivalent to -vvvv, but also log HTTP requests and responses which might contain plaintext secrets. -v, --verbose count Increase verbosity (-v for warn, -vv for info, -vvv for debug, -vvvv for trace). - diff --git a/test/fixtures/output/flink/environment/delete-mixed.golden b/test/fixtures/output/flink/environment/delete-mixed.golden index 5c64b3dfbe..c5b7d1099a 100644 --- a/test/fixtures/output/flink/environment/delete-mixed.golden +++ b/test/fixtures/output/flink/environment/delete-mixed.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted Error: Flink environment "non-existent" not found Suggestions: diff --git a/test/fixtures/output/flink/environment/delete-non-existent-env.golden b/test/fixtures/output/flink/environment/delete-non-existent-env.golden index 5c64b3dfbe..c5b7d1099a 100644 --- a/test/fixtures/output/flink/environment/delete-non-existent-env.golden +++ b/test/fixtures/output/flink/environment/delete-non-existent-env.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted Error: Flink environment "non-existent" not found Suggestions: diff --git a/test/fixtures/output/flink/environment/delete-success.golden b/test/fixtures/output/flink/environment/delete-success.golden index a273c91a0a..1602a804a3 100644 --- a/test/fixtures/output/flink/environment/delete-success.golden +++ b/test/fixtures/output/flink/environment/delete-success.golden @@ -1 +1,2 @@ +warning: GOCOVERDIR not set, no coverage data emitted Deleted Flink environments "default" and "test". diff --git a/test/fixtures/output/flink/environment/describe-no-environment.golden b/test/fixtures/output/flink/environment/describe-no-environment.golden index be184c92a0..d6c789ca54 100644 --- a/test/fixtures/output/flink/environment/describe-no-environment.golden +++ b/test/fixtures/output/flink/environment/describe-no-environment.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted Error: accepts 1 arg(s), received 0 Usage: confluent flink environment describe [flags] @@ -13,4 +14,3 @@ Global Flags: -h, --help Show help for this command. --unsafe-trace Equivalent to -vvvv, but also log HTTP requests and responses which might contain plaintext secrets. -v, --verbose count Increase verbosity (-v for warn, -vv for info, -vvv for debug, -vvvv for trace). - diff --git a/test/fixtures/output/flink/environment/describe-non-existent.golden b/test/fixtures/output/flink/environment/describe-non-existent.golden index ef81fff768..1a80a673fc 100644 --- a/test/fixtures/output/flink/environment/describe-non-existent.golden +++ b/test/fixtures/output/flink/environment/describe-non-existent.golden @@ -1 +1,2 @@ +warning: GOCOVERDIR not set, no coverage data emitted Error: failed to describe environment "non-existent": Environment not found diff --git a/test/fixtures/output/flink/environment/describe-success-json.golden b/test/fixtures/output/flink/environment/describe-success-json.golden index d09db90ec3..ad379f757c 100644 --- a/test/fixtures/output/flink/environment/describe-success-json.golden +++ b/test/fixtures/output/flink/environment/describe-success-json.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted { "name": "default", "created_time": "2024-09-10T23:00:00Z", diff --git a/test/fixtures/output/flink/environment/describe-success-with-defaults.golden b/test/fixtures/output/flink/environment/describe-success-with-defaults.golden index 9b3ee55d6c..a37f5c3a2a 100644 --- a/test/fixtures/output/flink/environment/describe-success-with-defaults.golden +++ b/test/fixtures/output/flink/environment/describe-success-with-defaults.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | Name | defaults-all | | Kubernetes Namespace | defaults-all-namespace | diff --git a/test/fixtures/output/flink/environment/describe-success-yaml.golden b/test/fixtures/output/flink/environment/describe-success-yaml.golden index 62957f3c5e..391164cc31 100644 --- a/test/fixtures/output/flink/environment/describe-success-yaml.golden +++ b/test/fixtures/output/flink/environment/describe-success-yaml.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted name: default created_time: 2024-09-10T23:00:00Z updated_time: 2024-09-10T23:00:00Z diff --git a/test/fixtures/output/flink/environment/describe-success.golden b/test/fixtures/output/flink/environment/describe-success.golden index 0aeea4ae2a..cdc2d6864e 100644 --- a/test/fixtures/output/flink/environment/describe-success.golden +++ b/test/fixtures/output/flink/environment/describe-success.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted +--------------------------------+-------------------------------+ | Name | default | | Kubernetes Namespace | default-namespace | diff --git a/test/fixtures/output/flink/environment/list-human.golden b/test/fixtures/output/flink/environment/list-human.golden index 2bd8fe5dca..52ba6c22aa 100644 --- a/test/fixtures/output/flink/environment/list-human.golden +++ b/test/fixtures/output/flink/environment/list-human.golden @@ -1,5 +1,6 @@ - Name | Kubernetes Namespace | Created Time | Updated Time ------------------+--------------------------+-------------------------------+-------------------------------- - default | default-namespace | 2024-09-10 23:00:00 +0000 UTC | 2024-09-10 23:00:00 +0000 UTC - test | test-namespace | 2024-09-10 23:00:00 +0000 UTC | 2024-09-10 23:00:00 +0000 UTC - update-failure | update-failure-namespace | 2024-09-10 23:00:00 +0000 UTC | 2024-09-10 23:00:00 +0000 UTC +warning: GOCOVERDIR not set, no coverage data emitted + Name | Kubernetes Namespace | Kubernetes Cluster Name | Created Time | Updated Time +-----------------+--------------------------+-------------------------+-------------------------------+-------------------------------- + default | default-namespace | | 2024-09-10 23:00:00 +0000 UTC | 2024-09-10 23:00:00 +0000 UTC + test | test-namespace | | 2024-09-10 23:00:00 +0000 UTC | 2024-09-10 23:00:00 +0000 UTC + update-failure | update-failure-namespace | | 2024-09-10 23:00:00 +0000 UTC | 2024-09-10 23:00:00 +0000 UTC diff --git a/test/fixtures/output/flink/environment/list-json.golden b/test/fixtures/output/flink/environment/list-json.golden index bf8927486a..4113c8beda 100644 --- a/test/fixtures/output/flink/environment/list-json.golden +++ b/test/fixtures/output/flink/environment/list-json.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted [ { "name": "default", diff --git a/test/fixtures/output/flink/environment/missing-flag-failure.golden b/test/fixtures/output/flink/environment/missing-flag-failure.golden index 6fede7f99e..6479c87047 100644 --- a/test/fixtures/output/flink/environment/missing-flag-failure.golden +++ b/test/fixtures/output/flink/environment/missing-flag-failure.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted Error: at least one of the flags in the group [defaults statement-defaults compute-pool-defaults] is required Usage: confluent flink environment update [flags] @@ -16,4 +17,3 @@ Global Flags: -h, --help Show help for this command. --unsafe-trace Equivalent to -vvvv, but also log HTTP requests and responses which might contain plaintext secrets. -v, --verbose count Increase verbosity (-v for warn, -vv for info, -vvv for debug, -vvvv for trace). - diff --git a/test/fixtures/output/flink/environment/update-failure.golden b/test/fixtures/output/flink/environment/update-failure.golden index 0d7251a604..41b159380b 100644 --- a/test/fixtures/output/flink/environment/update-failure.golden +++ b/test/fixtures/output/flink/environment/update-failure.golden @@ -1 +1,2 @@ +warning: GOCOVERDIR not set, no coverage data emitted Error: failed to update environment "update-failure": 422 Unprocessable Entity diff --git a/test/fixtures/output/flink/environment/update-get-failure.golden b/test/fixtures/output/flink/environment/update-get-failure.golden index 2be454ec35..9be19777a3 100644 --- a/test/fixtures/output/flink/environment/update-get-failure.golden +++ b/test/fixtures/output/flink/environment/update-get-failure.golden @@ -1 +1,2 @@ +warning: GOCOVERDIR not set, no coverage data emitted Error: failed to update environment "get-failure": 422 Unprocessable Entity diff --git a/test/fixtures/output/flink/environment/update-non-existent.golden b/test/fixtures/output/flink/environment/update-non-existent.golden index eeacfaffa6..3b36b36571 100644 --- a/test/fixtures/output/flink/environment/update-non-existent.golden +++ b/test/fixtures/output/flink/environment/update-non-existent.golden @@ -1 +1,2 @@ +warning: GOCOVERDIR not set, no coverage data emitted Error: environment "non-existent" does not exist diff --git a/test/fixtures/output/flink/environment/update-success-json.golden b/test/fixtures/output/flink/environment/update-success-json.golden index e17cf39ba7..9b5f998ca2 100644 --- a/test/fixtures/output/flink/environment/update-success-json.golden +++ b/test/fixtures/output/flink/environment/update-success-json.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted { "name": "default", "created_time": "2024-09-10T23:00:00Z", diff --git a/test/fixtures/output/flink/environment/update-success-with-defaults-all.golden b/test/fixtures/output/flink/environment/update-success-with-defaults-all.golden index 244455ba14..874e28316e 100644 --- a/test/fixtures/output/flink/environment/update-success-with-defaults-all.golden +++ b/test/fixtures/output/flink/environment/update-success-with-defaults-all.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted +--------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------+ | Name | default | | Kubernetes Namespace | default-namespace | diff --git a/test/fixtures/output/flink/environment/update-success-yaml.golden b/test/fixtures/output/flink/environment/update-success-yaml.golden index f1a58a3edb..ee6d35cd3f 100644 --- a/test/fixtures/output/flink/environment/update-success-yaml.golden +++ b/test/fixtures/output/flink/environment/update-success-yaml.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted name: default created_time: 2024-09-10T23:00:00Z updated_time: 2024-09-10T23:00:00Z diff --git a/test/fixtures/output/flink/environment/update-success.golden b/test/fixtures/output/flink/environment/update-success.golden index 9a0ae2a349..0d656aaf82 100644 --- a/test/fixtures/output/flink/environment/update-success.golden +++ b/test/fixtures/output/flink/environment/update-success.golden @@ -1,3 +1,4 @@ +warning: GOCOVERDIR not set, no coverage data emitted +--------------------------------+-------------------------------+ | Name | default | | Kubernetes Namespace | default-namespace | diff --git a/test/fixtures/output/flink/kubernetes-cluster/describe-not-found.golden b/test/fixtures/output/flink/kubernetes-cluster/describe-not-found.golden new file mode 100644 index 0000000000..d704012571 --- /dev/null +++ b/test/fixtures/output/flink/kubernetes-cluster/describe-not-found.golden @@ -0,0 +1,2 @@ +warning: GOCOVERDIR not set, no coverage data emitted +Error: failed to describe Kubernetes cluster "non-existent": {"message":"Kubernetes cluster 'non-existent' not found"} diff --git a/test/fixtures/output/flink/kubernetes-cluster/describe-success-json.golden b/test/fixtures/output/flink/kubernetes-cluster/describe-success-json.golden new file mode 100644 index 0000000000..84a9ae1536 --- /dev/null +++ b/test/fixtures/output/flink/kubernetes-cluster/describe-success-json.golden @@ -0,0 +1,18 @@ +warning: GOCOVERDIR not set, no coverage data emitted +{ + "apiVersion": "cmf/v1", + "kind": "KubernetesCluster", + "metadata": { + "name": "cluster-1", + "creationTimestamp": "2025-04-01T10:00:00Z", + "updateTimestamp": "2025-04-10T15:30:00Z" + }, + "spec": { + "lifecycleState": "ACTIVE" + }, + "status": { + "state": "CONNECTED", + "lastHeartbeatTimestamp": "2025-04-10T15:30:00Z", + "kubernetesVersion": "1.28.5" + } +} diff --git a/test/fixtures/output/flink/kubernetes-cluster/describe-success-yaml.golden b/test/fixtures/output/flink/kubernetes-cluster/describe-success-yaml.golden new file mode 100644 index 0000000000..d40bb39b3a --- /dev/null +++ b/test/fixtures/output/flink/kubernetes-cluster/describe-success-yaml.golden @@ -0,0 +1,13 @@ +warning: GOCOVERDIR not set, no coverage data emitted +apiVersion: cmf/v1 +kind: KubernetesCluster +metadata: + name: cluster-1 + creationTimestamp: "2025-04-01T10:00:00Z" + updateTimestamp: "2025-04-10T15:30:00Z" +spec: + lifecycleState: ACTIVE +status: + state: CONNECTED + lastHeartbeatTimestamp: 2025-04-10T15:30:00Z + kubernetesVersion: 1.28.5 diff --git a/test/fixtures/output/flink/kubernetes-cluster/describe-success.golden b/test/fixtures/output/flink/kubernetes-cluster/describe-success.golden new file mode 100644 index 0000000000..49db204e9b --- /dev/null +++ b/test/fixtures/output/flink/kubernetes-cluster/describe-success.golden @@ -0,0 +1,9 @@ +warning: GOCOVERDIR not set, no coverage data emitted ++--------------------+----------------------+ +| Name | cluster-1 | +| Created Time | 2025-04-01T10:00:00Z | +| Updated Time | 2025-04-10T15:30:00Z | +| Lifecycle State | ACTIVE | +| Connection State | CONNECTED | +| Kubernetes Version | 1.28.5 | ++--------------------+----------------------+ diff --git a/test/fixtures/output/flink/kubernetes-cluster/list-success-json.golden b/test/fixtures/output/flink/kubernetes-cluster/list-success-json.golden new file mode 100644 index 0000000000..d98f6498d8 --- /dev/null +++ b/test/fixtures/output/flink/kubernetes-cluster/list-success-json.golden @@ -0,0 +1,54 @@ +warning: GOCOVERDIR not set, no coverage data emitted +[ + { + "apiVersion": "cmf/v1", + "kind": "KubernetesCluster", + "metadata": { + "name": "cluster-1", + "creationTimestamp": "2025-04-01T10:00:00Z", + "updateTimestamp": "2025-04-10T15:30:00Z" + }, + "spec": { + "lifecycleState": "ACTIVE" + }, + "status": { + "state": "CONNECTED", + "lastHeartbeatTimestamp": "2025-04-10T15:30:00Z", + "kubernetesVersion": "1.28.5" + } + }, + { + "apiVersion": "cmf/v1", + "kind": "KubernetesCluster", + "metadata": { + "name": "cluster-2", + "creationTimestamp": "2025-04-01T10:00:00Z", + "updateTimestamp": "2025-04-10T15:30:00Z" + }, + "spec": { + "lifecycleState": "ACTIVE" + }, + "status": { + "state": "DISCONNECTED", + "lastHeartbeatTimestamp": "2025-04-10T15:30:00Z", + "kubernetesVersion": "1.27.3" + } + }, + { + "apiVersion": "cmf/v1", + "kind": "KubernetesCluster", + "metadata": { + "name": "cluster-3", + "creationTimestamp": "2025-04-01T10:00:00Z", + "updateTimestamp": "2025-04-10T15:30:00Z" + }, + "spec": { + "lifecycleState": "DECOMMISSIONED" + }, + "status": { + "state": "DECOMMISSIONED", + "lastHeartbeatTimestamp": "2025-04-10T15:30:00Z", + "kubernetesVersion": "1.26.0" + } + } +] diff --git a/test/fixtures/output/flink/kubernetes-cluster/list-success-yaml.golden b/test/fixtures/output/flink/kubernetes-cluster/list-success-yaml.golden new file mode 100644 index 0000000000..fba86b1116 --- /dev/null +++ b/test/fixtures/output/flink/kubernetes-cluster/list-success-yaml.golden @@ -0,0 +1,37 @@ +warning: GOCOVERDIR not set, no coverage data emitted +- apiVersion: cmf/v1 + kind: KubernetesCluster + metadata: + name: cluster-1 + creationTimestamp: "2025-04-01T10:00:00Z" + updateTimestamp: "2025-04-10T15:30:00Z" + spec: + lifecycleState: ACTIVE + status: + state: CONNECTED + lastHeartbeatTimestamp: 2025-04-10T15:30:00Z + kubernetesVersion: 1.28.5 +- apiVersion: cmf/v1 + kind: KubernetesCluster + metadata: + name: cluster-2 + creationTimestamp: "2025-04-01T10:00:00Z" + updateTimestamp: "2025-04-10T15:30:00Z" + spec: + lifecycleState: ACTIVE + status: + state: DISCONNECTED + lastHeartbeatTimestamp: 2025-04-10T15:30:00Z + kubernetesVersion: 1.27.3 +- apiVersion: cmf/v1 + kind: KubernetesCluster + metadata: + name: cluster-3 + creationTimestamp: "2025-04-01T10:00:00Z" + updateTimestamp: "2025-04-10T15:30:00Z" + spec: + lifecycleState: DECOMMISSIONED + status: + state: DECOMMISSIONED + lastHeartbeatTimestamp: 2025-04-10T15:30:00Z + kubernetesVersion: 1.26.0 diff --git a/test/fixtures/output/flink/kubernetes-cluster/list-success.golden b/test/fixtures/output/flink/kubernetes-cluster/list-success.golden new file mode 100644 index 0000000000..af48c95a65 --- /dev/null +++ b/test/fixtures/output/flink/kubernetes-cluster/list-success.golden @@ -0,0 +1,6 @@ +warning: GOCOVERDIR not set, no coverage data emitted + Name | Created Time | Updated Time | Lifecycle State | Connection State +------------+----------------------+----------------------+-----------------+------------------- + cluster-1 | 2025-04-01T10:00:00Z | 2025-04-10T15:30:00Z | ACTIVE | CONNECTED + cluster-2 | 2025-04-01T10:00:00Z | 2025-04-10T15:30:00Z | ACTIVE | DISCONNECTED + cluster-3 | 2025-04-01T10:00:00Z | 2025-04-10T15:30:00Z | DECOMMISSIONED | DECOMMISSIONED diff --git a/test/fixtures/output/flink/kubernetes-cluster/update-success-json.golden b/test/fixtures/output/flink/kubernetes-cluster/update-success-json.golden new file mode 100644 index 0000000000..a63a2cdfba --- /dev/null +++ b/test/fixtures/output/flink/kubernetes-cluster/update-success-json.golden @@ -0,0 +1,18 @@ +warning: GOCOVERDIR not set, no coverage data emitted +{ + "apiVersion": "cmf/v1", + "kind": "KubernetesCluster", + "metadata": { + "name": "cluster-1", + "creationTimestamp": "2025-04-01T10:00:00Z", + "updateTimestamp": "2025-04-10T15:30:00Z" + }, + "spec": { + "lifecycleState": "DECOMMISSIONED" + }, + "status": { + "state": "CONNECTED", + "lastHeartbeatTimestamp": "2025-04-10T15:30:00Z", + "kubernetesVersion": "1.28.5" + } +} diff --git a/test/fixtures/output/flink/kubernetes-cluster/update-success-yaml.golden b/test/fixtures/output/flink/kubernetes-cluster/update-success-yaml.golden new file mode 100644 index 0000000000..ec147cb9f9 --- /dev/null +++ b/test/fixtures/output/flink/kubernetes-cluster/update-success-yaml.golden @@ -0,0 +1,13 @@ +warning: GOCOVERDIR not set, no coverage data emitted +apiVersion: cmf/v1 +kind: KubernetesCluster +metadata: + name: cluster-1 + creationTimestamp: "2025-04-01T10:00:00Z" + updateTimestamp: "2025-04-10T15:30:00Z" +spec: + lifecycleState: DECOMMISSIONED +status: + state: CONNECTED + lastHeartbeatTimestamp: 2025-04-10T15:30:00Z + kubernetesVersion: 1.28.5 diff --git a/test/fixtures/output/flink/kubernetes-cluster/update-success.golden b/test/fixtures/output/flink/kubernetes-cluster/update-success.golden new file mode 100644 index 0000000000..c1a7e7bf72 --- /dev/null +++ b/test/fixtures/output/flink/kubernetes-cluster/update-success.golden @@ -0,0 +1,9 @@ +warning: GOCOVERDIR not set, no coverage data emitted ++--------------------+----------------------+ +| Name | cluster-1 | +| Created Time | 2025-04-01T10:00:00Z | +| Updated Time | 2025-04-10T15:30:00Z | +| Lifecycle State | DECOMMISSIONED | +| Connection State | CONNECTED | +| Kubernetes Version | 1.28.5 | ++--------------------+----------------------+ diff --git a/test/flink_onprem_test.go b/test/flink_onprem_test.go index 5536f0a14c..5e8e400b60 100644 --- a/test/flink_onprem_test.go +++ b/test/flink_onprem_test.go @@ -511,6 +511,38 @@ func (s *CLITestSuite) TestFlinkStatementExceptionListOnPrem() { runIntegrationTestsWithMultipleAuth(s, tests) } +func (s *CLITestSuite) TestFlinkKubernetesClusterList() { + tests := []CLITest{ + {args: "flink kubernetes-cluster list", fixture: "flink/kubernetes-cluster/list-success.golden"}, + {args: "flink kubernetes-cluster list --output json", fixture: "flink/kubernetes-cluster/list-success-json.golden"}, + {args: "flink kubernetes-cluster list --output yaml", fixture: "flink/kubernetes-cluster/list-success-yaml.golden"}, + } + + runIntegrationTestsWithMultipleAuth(s, tests) +} + +func (s *CLITestSuite) TestFlinkKubernetesClusterDescribe() { + tests := []CLITest{ + {args: "flink kubernetes-cluster describe cluster-1", fixture: "flink/kubernetes-cluster/describe-success.golden"}, + {args: "flink kubernetes-cluster describe cluster-1 --output json", fixture: "flink/kubernetes-cluster/describe-success-json.golden"}, + {args: "flink kubernetes-cluster describe cluster-1 --output yaml", fixture: "flink/kubernetes-cluster/describe-success-yaml.golden"}, + // failure + {args: "flink kubernetes-cluster describe non-existent", fixture: "flink/kubernetes-cluster/describe-not-found.golden", exitCode: 1}, + } + + runIntegrationTestsWithMultipleAuth(s, tests) +} + +func (s *CLITestSuite) TestFlinkKubernetesClusterUpdate() { + tests := []CLITest{ + {args: "flink kubernetes-cluster update cluster-1 --lifecycle-state DECOMMISSIONED", fixture: "flink/kubernetes-cluster/update-success.golden"}, + {args: "flink kubernetes-cluster update cluster-1 --lifecycle-state DECOMMISSIONED --output json", fixture: "flink/kubernetes-cluster/update-success-json.golden"}, + {args: "flink kubernetes-cluster update cluster-1 --lifecycle-state DECOMMISSIONED --output yaml", fixture: "flink/kubernetes-cluster/update-success-yaml.golden"}, + } + + runIntegrationTestsWithMultipleAuth(s, tests) +} + func (s *CLITestSuite) TestFlinkOnPremWithCloudLogin() { test := CLITest{args: "flink environment list --output json", fixture: "flink/environment/list-cloud.golden", login: "cloud", exitCode: 1} s.runIntegrationTest(test) diff --git a/test/test-server/flink_onprem_handler.go b/test/test-server/flink_onprem_handler.go index 256a04ab14..29ad72d338 100644 --- a/test/test-server/flink_onprem_handler.go +++ b/test/test-server/flink_onprem_handler.go @@ -1259,3 +1259,98 @@ func handleCmfStatementExceptions(t *testing.T) http.HandlerFunc { } } } + +func createKubernetesCluster(name, lifecycleState, connectionState, k8sVersion string) cmfsdk.KubernetesCluster { + createdTime := "2025-04-01T10:00:00Z" + updatedTime := "2025-04-10T15:30:00Z" + heartbeat := time.Date(2025, time.April, 10, 15, 30, 0, 0, time.UTC) + + return cmfsdk.KubernetesCluster{ + ApiVersion: "cmf/v1", + Kind: "KubernetesCluster", + Metadata: cmfsdk.KubernetesClusterMetadata{ + Name: name, + CreationTimestamp: &createdTime, + UpdateTimestamp: &updatedTime, + }, + Spec: cmfsdk.KubernetesClusterSpec{ + LifecycleState: &lifecycleState, + }, + Status: &cmfsdk.KubernetesClusterStatus{ + State: &connectionState, + KubernetesVersion: &k8sVersion, + LastHeartbeatTimestamp: &heartbeat, + }, + } +} + +// Handler for "cmf/api/v1/kubernetes-clusters" +func handleCmfKubernetesClusters(t *testing.T) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + handleLoginType(t, r) + + switch r.Method { + case http.MethodGet: + page := r.URL.Query().Get("page") + clusters := []cmfsdk.KubernetesCluster{ + createKubernetesCluster("cluster-1", "ACTIVE", "CONNECTED", "1.28.5"), + createKubernetesCluster("cluster-2", "ACTIVE", "DISCONNECTED", "1.27.3"), + createKubernetesCluster("cluster-3", "DECOMMISSIONED", "DECOMMISSIONED", "1.26.0"), + } + + var size int64 + clustersPage := map[string]interface{}{ + "metadata": cmfsdk.KubernetesClustersPageMetadata{Size: &size}, + } + if page == "0" || page == "" { + size = int64(len(clusters)) + clustersPage["metadata"] = cmfsdk.KubernetesClustersPageMetadata{Size: &size} + clustersPage["items"] = clusters + } else { + clustersPage["items"] = []cmfsdk.KubernetesCluster{} + } + err := json.NewEncoder(w).Encode(clustersPage) + require.NoError(t, err) + return + default: + require.Fail(t, fmt.Sprintf("Unexpected method %s", r.Method)) + } + } +} + +// Handler for "cmf/api/v1/kubernetes-clusters/{kubernetesClusterName}" +func handleCmfKubernetesCluster(t *testing.T) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + handleLoginType(t, r) + + clusterName := mux.Vars(r)["kubernetesClusterName"] + + switch r.Method { + case http.MethodGet: + switch clusterName { + case "cluster-1": + err := json.NewEncoder(w).Encode(createKubernetesCluster("cluster-1", "ACTIVE", "CONNECTED", "1.28.5")) + require.NoError(t, err) + case "non-existent": + http.Error(w, `{"message":"Kubernetes cluster 'non-existent' not found"}`, http.StatusNotFound) + default: + err := json.NewEncoder(w).Encode(createKubernetesCluster(clusterName, "ACTIVE", "CONNECTED", "1.28.5")) + require.NoError(t, err) + } + return + case http.MethodPut: + reqBody, err := io.ReadAll(r.Body) + require.NoError(t, err) + var cluster cmfsdk.KubernetesCluster + err = json.Unmarshal(reqBody, &cluster) + require.NoError(t, err) + + updatedCluster := createKubernetesCluster(clusterName, cluster.Spec.GetLifecycleState(), "CONNECTED", "1.28.5") + err = json.NewEncoder(w).Encode(updatedCluster) + require.NoError(t, err) + return + default: + require.Fail(t, fmt.Sprintf("Unexpected method %s", r.Method)) + } + } +} diff --git a/test/test-server/flink_onprem_router.go b/test/test-server/flink_onprem_router.go index 2267f01d5a..cb75fc94a3 100644 --- a/test/test-server/flink_onprem_router.go +++ b/test/test-server/flink_onprem_router.go @@ -24,6 +24,8 @@ var flinkRoutes = []route{ {"/cmf/api/v1/environments/{envName}/statements/{stmtName}/savepoints/{savepointName}", handleCmfSavepoint}, {"/cmf/api/v1/detached-savepoints", handleCmfDetachedSavepoints}, {"/cmf/api/v1/detached-savepoints/{detachedSavepointName}", handleCmfDetachedSavepoint}, + {"/cmf/api/v1/kubernetes-clusters", handleCmfKubernetesClusters}, + {"/cmf/api/v1/kubernetes-clusters/{kubernetesClusterName}", handleCmfKubernetesCluster}, } func NewFlinkOnPremRouter(t *testing.T) *mux.Router {