Skip to content

Commit a7389bb

Browse files
fix notification cr kind
1 parent bd89367 commit a7389bb

File tree

1 file changed

+30
-53
lines changed

1 file changed

+30
-53
lines changed

tests/@setup/src/notifications.ts

Lines changed: 30 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,6 @@ async function getUUIDFromBackbeat(k8sClient: KubernetesClient, namespace: strin
160160
`app.kubernetes.io/name=backbeat-config,app.kubernetes.io/instance=${zenkoName}`
161161
);
162162

163-
logger.info('Found secrets for UUID extraction', {
164-
count: secrets.length,
165-
namespace,
166-
instanceId,
167-
zenkoName
168-
});
169-
170163
if (!secrets.length) {
171164
throw new Error(`No backbeat config secret found with Zenko name ${zenkoName} (instanceId: ${instanceId}) in namespace ${namespace}`);
172165
}
@@ -175,13 +168,6 @@ async function getUUIDFromBackbeat(k8sClient: KubernetesClient, namespace: strin
175168
const configJson = k8sClient.getSecretData(secrets[0], 'config.json');
176169
const config: BackbeatConfig = JSON.parse(configJson);
177170

178-
logger.info('Backbeat config structure', {
179-
hasKafka: !!config.kafka,
180-
hasExtensions: !!config.extensions,
181-
hasReplication: !!config.extensions?.replication,
182-
replicationTopic: config.extensions?.replication?.topic
183-
});
184-
185171
// Extract UUID from replication topic
186172
let uuid = config.extensions.replication.topic.replace(/"/g, ''); // Remove quotes
187173
logger.debug('UUID before processing', { rawUuid: uuid });
@@ -208,57 +194,48 @@ async function applyNotificationDestinations(k8sClient: KubernetesClient, namesp
208194
const notifDestTopic = process.env[kafkaTopicsConfig.notificationTopics[0].envVar] || kafkaTopicsConfig.notificationTopics[0].default;
209195
const notifAltDestTopic = process.env[kafkaTopicsConfig.notificationTopics[1].envVar] || kafkaTopicsConfig.notificationTopics[1].default;
210196

211-
// Create notification config ConfigMap
212-
const notificationConfigMap = {
213-
apiVersion: 'v1',
214-
kind: 'ConfigMap',
197+
// Create ZenkoNotificationTarget resources (the correct CRD that actually exists)
198+
const zenkoName = process.env.ZENKO_NAME || 'end2end';
199+
const [kafkaHostOnly, kafkaPortOnly] = kafkaHost.split(':');
200+
201+
const primaryNotificationTarget = {
202+
apiVersion: 'zenko.io/v1alpha2',
203+
kind: 'ZenkoNotificationTarget',
215204
metadata: {
216-
name: 'notification-config',
217-
namespace
205+
name: 'kafka-destination',
206+
namespace,
207+
labels: {
208+
'app.kubernetes.io/instance': zenkoName
209+
}
218210
},
219-
data: {
220-
'destinations.yaml': `destinations:
221-
- name: kafka-destination
222-
type: kafka
223-
config:
224-
bootstrapServers: "${kafkaHost.split(':')[0]}:${kafkaPort}"
225-
topic: "${notifDestTopic}"
226-
securityProtocol: PLAINTEXT
227-
- name: kafka-alt-destination
228-
type: kafka
229-
config:
230-
bootstrapServers: "${kafkaHost.split(':')[0]}:${kafkaPort}"
231-
topic: "${notifAltDestTopic}"
232-
securityProtocol: PLAINTEXT`
211+
spec: {
212+
type: 'kafka',
213+
host: kafkaHostOnly,
214+
port: parseInt(kafkaPortOnly || kafkaPort, 10),
215+
destinationTopic: notifDestTopic
233216
}
234217
};
235218

236-
// Create BucketNotificationConfiguration custom resource
237-
const bucketNotificationConfig = {
238-
apiVersion: 'zenko.io/v1alpha1',
239-
kind: 'BucketNotificationConfiguration',
219+
const altNotificationTarget = {
220+
apiVersion: 'zenko.io/v1alpha2',
221+
kind: 'ZenkoNotificationTarget',
240222
metadata: {
241-
name: 'notification-destinations',
242-
namespace
223+
name: 'kafka-alt-destination',
224+
namespace,
225+
labels: {
226+
'app.kubernetes.io/instance': zenkoName
227+
}
243228
},
244229
spec: {
245-
configurations: [
246-
{
247-
name: 'primary',
248-
destination: 'kafka-destination',
249-
events: ['s3:ObjectCreated:*', 's3:ObjectRemoved:*']
250-
},
251-
{
252-
name: 'alternative',
253-
destination: 'kafka-alt-destination',
254-
events: ['s3:ObjectCreated:Put', 's3:ObjectCreated:Post']
255-
}
256-
]
230+
type: 'kafka',
231+
host: kafkaHostOnly,
232+
port: parseInt(kafkaPortOnly || kafkaPort, 10),
233+
destinationTopic: notifAltDestTopic
257234
}
258235
};
259236

260237
try {
261-
await k8sClient.applyManifests([notificationConfigMap, bucketNotificationConfig], namespace);
238+
await k8sClient.applyManifests([primaryNotificationTarget, altNotificationTarget], namespace);
262239

263240
logger.info('Notification destinations applied successfully');
264241
} catch (error) {

0 commit comments

Comments
 (0)