@@ -21,6 +21,7 @@ import (
2121 "github.com/gruntwork-io/terratest/modules/k8s"
2222 . "github.com/onsi/ginkgo/v2"
2323 . "github.com/onsi/gomega"
24+ "k8s.io/utils/ptr"
2425)
2526
2627// requireDeleteKafkaTopic deletes kafkaTopic resource.
@@ -34,14 +35,29 @@ func requireDeleteKafkaTopic(kubectlOptions k8s.KubectlOptions, topicName string
3435// requireDeployingKafkaTopic deploys a kafkaTopic resource from a template
3536func requireDeployingKafkaTopic (kubectlOptions k8s.KubectlOptions , topicName string ) {
3637 It ("Deploying KafkaTopic CR" , func () {
37- err := applyK8sResourceFromTemplate (kubectlOptions ,
38- kafkaTopicTemplate ,
39- map [string ]interface {}{
40- "Name" : topicName ,
41- "TopicName" : topicName ,
42- "Namespace" : kubectlOptions .Namespace ,
38+ // err := applyK8sResourceFromTemplate(kubectlOptions,
39+ // kafkaTopicTemplate,
40+ // map[string]interface{}{
41+ // "Name": topicName,
42+ // "TopicName": topicName,
43+ // "Namespace": kubectlOptions.Namespace,
44+ // },
45+ // )
46+ values := kafkaTopicTemplateData {
47+ Annotations : []string {"managedBy: koperator" },
48+ ClusterRef : kafkaTopicClusterRef {
49+ Name : kafkaClusterName ,
50+ Namespace : kubectlOptions .Namespace ,
4351 },
44- )
52+ Name : topicName ,
53+ Namespace : kubectlOptions .Namespace ,
54+ Partitions : ptr .To (int32 (2 )),
55+ ReplicationFactor : ptr .To (int32 (2 )),
56+ TopicName : topicName ,
57+ }
58+
59+ err := applyK8sResourceFromTemplate_2 (kubectlOptions , kafkaTopicTemplate , values )
60+
4561 Expect (err ).ShouldNot (HaveOccurred ())
4662
4763 err = waitK8sResourceCondition (kubectlOptions , kafkaTopicKind ,
@@ -82,3 +98,23 @@ func requireDeployingKafkaUser(kubectlOptions k8s.KubectlOptions, userName strin
8298 }, defaultUserCreationWaitTime , 3 * time .Second ).Should (Equal (true ))
8399 })
84100}
101+
102+ // kafkaTopicTemplateData is a struct that holds the relevant information and structure
103+ // to fill out the template used to generate KafkaTopics.
104+ // TODO: long term we should use the structs in the api module instead of these local structs.
105+ type kafkaTopicTemplateData struct {
106+ Annotations []string
107+ ClusterRef kafkaTopicClusterRef
108+ Name string
109+ Namespace string
110+ Partitions * int32
111+ ReplicationFactor * int32
112+ TopicName string
113+ }
114+
115+ // kafkaTopicClusterRef holds the information relevant to identifying a KafkaCluster within a KafkaTopic CR.
116+ // TODO: Long term, we should use the structs in the api module instead of these local structs.
117+ type kafkaTopicClusterRef struct {
118+ Name string
119+ Namespace string
120+ }
0 commit comments