@redpanda-data/docs-extensions-and-macros 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.adoc
CHANGED
|
@@ -287,7 +287,7 @@ To enable and configure the extension, add it to the `antora.extensions` section
|
|
|
287
287
|
----
|
|
288
288
|
antora:
|
|
289
289
|
extensions:
|
|
290
|
-
- require: '@redpanda-data/docs-extensions-and-macros/extensions/end-of-life'
|
|
290
|
+
- require: '@redpanda-data/docs-extensions-and-macros/extensions/compute-end-of-life'
|
|
291
291
|
data:
|
|
292
292
|
eol_settings:
|
|
293
293
|
- component: 'ROOT'
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches the latest version tag from Docker Hub for a given repository.
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* @param {string} dockerNamespace - The Docker Hub namespace (organization or username)
|
|
6
|
+
* @param {string} dockerRepo - The repository name on Docker Hub
|
|
7
|
+
* @returns {Promise<string|null>} The latest version tag or null if none is found.
|
|
8
|
+
*/
|
|
9
|
+
module.exports = async (dockerNamespace, dockerRepo) => {
|
|
10
|
+
const { default: fetch } = await import('node-fetch');
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
// Fetch a list of tags from Docker Hub.
|
|
14
|
+
const url = `https://hub.docker.com/v2/repositories/${dockerNamespace}/${dockerRepo}/tags?page_size=100`;
|
|
15
|
+
const response = await fetch(url);
|
|
16
|
+
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
throw new Error(`Docker Hub API responded with status ${response.status}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const data = await response.json();
|
|
22
|
+
|
|
23
|
+
// Define a regular expression to capture the major and minor version numbers.
|
|
24
|
+
// The regex /^v(\d+)\.(\d+)/ matches tags that start with "v", followed by digits (major),
|
|
25
|
+
// a period, and more digits (minor). It works for tags like "v2.3.8-24.3.6" or "v25.1-k8s4".
|
|
26
|
+
const versionRegex = /^v(\d+)\.(\d+)/;
|
|
27
|
+
|
|
28
|
+
// Filter the list of tags to include only those that match our expected version pattern.
|
|
29
|
+
// This helps ensure we work only with tags that represent valid version numbers.
|
|
30
|
+
let versionTags = data.results.filter(tag => versionRegex.test(tag.name));
|
|
31
|
+
|
|
32
|
+
// If the repository is "redpanda-operator", ignore any tags starting with the old "v22 or "v23" versions.
|
|
33
|
+
if (dockerRepo === 'redpanda-operator') {
|
|
34
|
+
versionTags = versionTags.filter(tag => !/^(v22|v23)/.test(tag.name));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (versionTags.length === 0) {
|
|
38
|
+
console.warn('No version tags found.');
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Sort the filtered tags in descending order based on their major and minor version numbers.
|
|
43
|
+
// This sorting ignores any additional patch or suffix details and focuses only on the major.minor value.
|
|
44
|
+
versionTags.sort((a, b) => {
|
|
45
|
+
const aMatch = a.name.match(versionRegex);
|
|
46
|
+
const bMatch = b.name.match(versionRegex);
|
|
47
|
+
const aMajor = parseInt(aMatch[1], 10);
|
|
48
|
+
const aMinor = parseInt(aMatch[2], 10);
|
|
49
|
+
const bMajor = parseInt(bMatch[1], 10);
|
|
50
|
+
const bMinor = parseInt(bMatch[2], 10);
|
|
51
|
+
|
|
52
|
+
// Compare by major version first; if equal, compare by minor version.
|
|
53
|
+
if (aMajor !== bMajor) {
|
|
54
|
+
return bMajor - aMajor;
|
|
55
|
+
}
|
|
56
|
+
return bMinor - aMinor;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Return the name of the tag with the highest major.minor version.
|
|
60
|
+
return versionTags[0].name;
|
|
61
|
+
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error('Error fetching latest Docker tag:', error);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module.exports.register = function ({ config }) {
|
|
4
4
|
const GetLatestRedpandaVersion = require('./get-latest-redpanda-version');
|
|
5
5
|
const GetLatestConsoleVersion = require('./get-latest-console-version');
|
|
6
|
-
const GetLatestOperatorVersion = require('./
|
|
6
|
+
const GetLatestOperatorVersion = require('./fetch-latest-docker-tag');
|
|
7
7
|
const GetLatestHelmChartVersion = require('./get-latest-redpanda-helm-version');
|
|
8
8
|
const GetLatestConnectVersion = require('./get-latest-connect');
|
|
9
9
|
const logger = this.getLogger('set-latest-version-extension');
|
|
@@ -25,6 +25,7 @@ module.exports.register = function ({ config }) {
|
|
|
25
25
|
auth: process.env.REDPANDA_GITHUB_TOKEN || undefined,
|
|
26
26
|
};
|
|
27
27
|
const github = new OctokitWithRetries(githubOptions);
|
|
28
|
+
const dockerNamespace = 'redpandadata'
|
|
28
29
|
|
|
29
30
|
try {
|
|
30
31
|
const [
|
|
@@ -36,7 +37,7 @@ module.exports.register = function ({ config }) {
|
|
|
36
37
|
] = await Promise.allSettled([
|
|
37
38
|
GetLatestRedpandaVersion(github, owner, 'redpanda'),
|
|
38
39
|
GetLatestConsoleVersion(github, owner, 'console'),
|
|
39
|
-
GetLatestOperatorVersion(
|
|
40
|
+
GetLatestOperatorVersion(dockerNamespace, 'redpanda-operator'),
|
|
40
41
|
GetLatestHelmChartVersion(github, owner, 'helm-charts', 'charts/redpanda/Chart.yaml'),
|
|
41
42
|
GetLatestConnectVersion(github, owner, 'connect'),
|
|
42
43
|
]);
|
|
@@ -49,6 +50,8 @@ module.exports.register = function ({ config }) {
|
|
|
49
50
|
connect: latestConnectResult.status === 'fulfilled' ? latestConnectResult.value : undefined,
|
|
50
51
|
};
|
|
51
52
|
|
|
53
|
+
console.log(latestVersions)
|
|
54
|
+
|
|
52
55
|
const components = await contentCatalog.getComponents();
|
|
53
56
|
components.forEach(component => {
|
|
54
57
|
const prerelease = component.latestPrerelease;
|
|
@@ -58,24 +61,25 @@ module.exports.register = function ({ config }) {
|
|
|
58
61
|
asciidoc.attributes['page-component-version-is-prerelease'] = 'true';
|
|
59
62
|
}
|
|
60
63
|
|
|
61
|
-
// Set operator and helm chart attributes
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
asciidoc.attributes['latest-redpanda-helm-chart-version'] = latestVersions.helmChart;
|
|
67
|
-
}
|
|
64
|
+
// Set operator and helm chart attributes via helper function
|
|
65
|
+
updateAttributes(asciidoc, [
|
|
66
|
+
{ condition: latestVersions.operator, key: 'latest-operator-version', value: latestVersions.operator },
|
|
67
|
+
{ condition: latestVersions.helmChart, key: 'latest-redpanda-helm-chart-version', value: latestVersions.helmChart }
|
|
68
|
+
]);
|
|
68
69
|
|
|
69
70
|
// Set attributes for console and connect versions
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
[
|
|
72
|
+
{ condition: latestVersions.console, baseName: 'latest-console', value: latestVersions.console?.latestStableRelease },
|
|
73
|
+
{ condition: latestVersions.connect, baseName: 'latest-connect', value: latestVersions.connect }
|
|
74
|
+
].forEach(mapping => {
|
|
75
|
+
if (mapping.condition && mapping.value) {
|
|
76
|
+
setVersionAndTagAttributes(asciidoc, mapping.baseName, mapping.value, name, version);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
76
80
|
// Special handling for Redpanda RC versions if in beta
|
|
77
81
|
if (latestVersions.redpanda?.latestRcRelease?.version) {
|
|
78
|
-
setVersionAndTagAttributes(asciidoc, 'redpanda-beta', latestVersions.redpanda.latestRcRelease.version, name, version)
|
|
82
|
+
setVersionAndTagAttributes(asciidoc, 'redpanda-beta', latestVersions.redpanda.latestRcRelease.version, name, version);
|
|
79
83
|
setVersionAndTagAttributes(asciidoc, 'console-beta', latestVersions.console.latestBetaRelease, name, version);
|
|
80
84
|
asciidoc.attributes['redpanda-beta-commit'] = latestVersions.redpanda.latestRcRelease.commitHash;
|
|
81
85
|
}
|
|
@@ -127,4 +131,13 @@ module.exports.register = function ({ config }) {
|
|
|
127
131
|
function sanitizeVersion(version) {
|
|
128
132
|
return version.replace(/^v/, '');
|
|
129
133
|
}
|
|
130
|
-
|
|
134
|
+
|
|
135
|
+
// Helper function to update multiple attributes based on a list of mappings
|
|
136
|
+
function updateAttributes(asciidoc, mappings) {
|
|
137
|
+
mappings.forEach(({ condition, key, value }) => {
|
|
138
|
+
if (condition) {
|
|
139
|
+
asciidoc.attributes[key] = value;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redpanda-data/docs-extensions-and-macros",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Antora extensions and macros developed for Redpanda documentation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antora",
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"js-yaml": "^4.1.0",
|
|
76
76
|
"lodash": "^4.17.21",
|
|
77
77
|
"micromatch": "^4.0.8",
|
|
78
|
+
"node-fetch": "^3.3.2",
|
|
78
79
|
"node-html-parser": "5.4.2-0",
|
|
79
80
|
"papaparse": "^5.4.1",
|
|
80
81
|
"semver": "^7.6.0",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
module.exports = async (github, owner, repo) => {
|
|
2
|
-
try {
|
|
3
|
-
const release = await github.rest.repos.getLatestRelease({ owner, repo });
|
|
4
|
-
latestOperatorReleaseVersion = release.data.tag_name;
|
|
5
|
-
return latestOperatorReleaseVersion;
|
|
6
|
-
} catch (error) {
|
|
7
|
-
console.error(error);
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
};
|