Skip to content

Commit 6db941b

Browse files
committed
Enable fallback to catalog-info.yml
1 parent 8b9ac4c commit 6db941b

4 files changed

Lines changed: 116 additions & 4 deletions

File tree

consumer.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
const Pulsar = require('pulsar-client');
21+
22+
(async () => {
23+
// Create a client
24+
const client = new Pulsar.Client({
25+
serviceUrl: 'pulsar://localhost:6650',
26+
operationTimeoutSeconds: 30,
27+
});
28+
29+
// Create a consumer
30+
const consumer = await client.subscribe({
31+
topic: 'persistent://public/default/my-topic',
32+
subscription: 'sub1',
33+
subscriptionType: 'Shared',
34+
ackTimeoutMs: 10000,
35+
});
36+
37+
// Receive messages
38+
for (let i = 0; i < 10; i += 1) {
39+
const msg = await consumer.receive();
40+
console.log(msg.getData().toString());
41+
consumer.acknowledge(msg);
42+
}
43+
44+
await consumer.close();
45+
await client.close();
46+
})();

producer.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
const Pulsar = require('pulsar-client');
21+
22+
(async () => {
23+
// Create a client
24+
const client = new Pulsar.Client({
25+
serviceUrl: 'pulsar://localhost:6650',
26+
operationTimeoutSeconds: 30,
27+
});
28+
29+
// Create a producer
30+
const producer = await client.createProducer({
31+
topic: 'persistent://public/default/my-topic',
32+
sendTimeoutMs: 30000,
33+
batchingEnabled: true,
34+
});
35+
36+
// Send messages
37+
for (let i = 0; i < 10; i += 1) {
38+
const msg = `my-message-${i}`;
39+
producer.send({
40+
data: Buffer.from(msg),
41+
});
42+
console.log(`Sent message: ${msg}`);
43+
}
44+
await producer.flush();
45+
46+
await producer.close();
47+
await client.close();
48+
})();

src/data.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ const loadData = async ({ notion }) => {
4747
}
4848

4949
let error = false
50-
5150
if (ownerDb && !owners.unknown) {
5251
error = true
5352
core.error('Your owner table does not contain an "unknown" row!')

src/github.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,33 @@ const getRepos = async () => {
2525
const repositoryFilterRegex = new RegExp(repositoryFilter)
2626
const octokit = new Octokit({ auth: GITHUB_TOKEN })
2727

28-
const parseServiceDefinition = async (repo, path) => {
29-
const repoData = []
28+
const getServiceDefinitionFile = async (repo, path) => {
3029
try {
3130
const { data } = await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
3231
owner: repo.full_name.split('/')[0],
3332
repo: repo.name,
3433
path
3534
})
35+
return data
36+
} catch (ex) {
37+
// Try it now with a .yml file instead only for default version!
38+
if (catalogFile === 'catalog-info.yaml') {
39+
const { data } = await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {
40+
owner: repo.full_name.split('/')[0],
41+
repo: repo.name,
42+
path: path.replace('catalog-info.yaml', 'catalog-info.yml')
43+
})
44+
return data
45+
} else {
46+
throw ex
47+
}
48+
}
49+
}
50+
51+
const parseServiceDefinition = async (repo, path) => {
52+
const repoData = []
53+
try {
54+
const data = await getServiceDefinitionFile(repo, path)
3655
if (data) {
3756
const base64content = Buffer.from(data.content, 'base64')
3857
const serviceDefinition = YAML.parse(base64content.toString('utf8'))
@@ -45,7 +64,7 @@ const getRepos = async () => {
4564
repoData.push(serviceDefinition)
4665
}
4766
}
48-
core.debug(`🌟 Processed ${path} in ${repo.name} ...`)
67+
core.debug(`🌟 Processed ${data.name} in ${repo.name} ...`)
4968
} catch (ex) {
5069
if (pushMissing) {
5170
repoData.push({

0 commit comments

Comments
 (0)