@redpanda-data/docs-extensions-and-macros 4.6.4 → 4.6.6

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.
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Fetches the latest Helm chart version from the redpanda-operator repository
3
+ * by converting docker tag format v<major>.<minor>.<patch> to release/v<major>.<minor>.x
4
+ * and checking the Chart.yaml file in that branch.
5
+ *
6
+ * @param {object} github - The GitHub API client.
7
+ * @param {string} owner - The repository owner.
8
+ * @param {string} repo - The repository name (redpanda-operator).
9
+ * @param {string} stableDockerTag - The stable docker tag in format v<major>.<minor>.<patch>.
10
+ * @param {string} betaDockerTag - Optional beta docker tag in format v<major>.<minor>.<patch>-beta.
11
+ * @returns {Promise<{ latestStableRelease: string|null, latestBetaRelease: string|null }>}
12
+ */
13
+ module.exports = async (github, owner, repo, stableDockerTag, betaDockerTag) => {
14
+ const yaml = require('js-yaml');
15
+ const path = 'charts/redpanda/Chart.yaml';
16
+
17
+ /**
18
+ * Helper function to fetch chart version from a branch derived from a docker tag
19
+ * @param {string} dockerTag - The docker tag to derive branch from
20
+ * @returns {Promise<string|null>} - The chart version or null if not found
21
+ */
22
+ const getChartVersionFromTag = async (dockerTag) => {
23
+ if (!dockerTag) return null;
24
+
25
+ try {
26
+
27
+ // Parse the docker tag to extract major and minor versions
28
+ // Support both v2.4.2 format and v25.1.3 format
29
+ const versionMatch = dockerTag.match(/^v(\d+)\.(\d+)(?:\.(\d+))?(?:-beta.*)?$/);
30
+
31
+ if (!versionMatch) {
32
+ console.error(`Invalid docker tag format: ${dockerTag}`);
33
+ return null;
34
+ }
35
+
36
+ const major = versionMatch[1];
37
+ const minor = versionMatch[2];
38
+
39
+ // Convert to release/v<major>.<minor>.x format
40
+ const branchName = `release/v${major}.${minor}.x`;
41
+
42
+ try {
43
+
44
+ // Fetch Chart.yaml from the specified branch
45
+ const contentResponse = await github.repos.getContent({
46
+ owner,
47
+ repo,
48
+ path,
49
+ ref: branchName,
50
+ });
51
+
52
+ const contentBase64 = contentResponse.data.content;
53
+ const contentDecoded = Buffer.from(contentBase64, 'base64').toString('utf8');
54
+ const chartYaml = yaml.load(contentDecoded);
55
+ const version = chartYaml.version || null;
56
+ return version;
57
+ } catch (error) {
58
+ console.error(`Failed to fetch Chart.yaml for branch ${branchName}:`, error.message);
59
+ return null;
60
+ }
61
+ } catch (error) {
62
+ console.error(`Error processing docker tag ${dockerTag}:`, error.message);
63
+ return null;
64
+ }
65
+ };
66
+ try {
67
+ // Get chart versions for both stable and beta tags in parallel
68
+ const [stableChartVersion, betaChartVersion] = await Promise.all([
69
+ getChartVersionFromTag(stableDockerTag),
70
+ getChartVersionFromTag(betaDockerTag)
71
+ ]);
72
+
73
+ return {
74
+ latestStableRelease: stableChartVersion,
75
+ latestBetaRelease: betaChartVersion
76
+ };
77
+ } catch (error) {
78
+ console.error('Failed to fetch chart versions:', error.message);
79
+ return {
80
+ latestStableRelease: null,
81
+ latestBetaRelease: null
82
+ };
83
+ }
84
+ };
@@ -4,7 +4,7 @@ module.exports.register = function ({ config }) {
4
4
  const GetLatestRedpandaVersion = require('./get-latest-redpanda-version');
5
5
  const GetLatestConsoleVersion = require('./get-latest-console-version');
6
6
  const GetLatestDockerTag = require('./fetch-latest-docker-tag');
7
- const GetLatestHelmChartVersion = require('./get-latest-redpanda-helm-version');
7
+ const GetLatestHelmChartVersionFromOperator = require('./get-latest-redpanda-helm-version-from-operator');
8
8
  const GetLatestConnectVersion = require('./get-latest-connect');
9
9
  const logger = this.getLogger('set-latest-version-extension');
10
10
 
@@ -32,15 +32,41 @@ module.exports.register = function ({ config }) {
32
32
  latestRedpandaResult,
33
33
  latestConsoleResult,
34
34
  latestOperatorResult,
35
- latestHelmChartResult,
36
35
  latestConnectResult,
37
36
  ] = await Promise.allSettled([
38
37
  GetLatestRedpandaVersion(github, owner, 'redpanda'),
39
38
  GetLatestDockerTag(dockerNamespace, 'console'),
40
39
  GetLatestDockerTag(dockerNamespace, 'redpanda-operator'),
41
- GetLatestHelmChartVersion(github, owner, 'helm-charts', 'charts/redpanda/Chart.yaml'),
42
40
  GetLatestConnectVersion(github, owner, 'connect'),
43
41
  ]);
42
+
43
+ // Get the Helm chart version after we have the operator version (for both stable and beta)
44
+ let latestHelmChartResult = { status: 'rejected', reason: 'Operator result not fulfilled' };
45
+
46
+ if (latestOperatorResult.status === 'fulfilled') {
47
+ try {
48
+ const helmChartVersions = await GetLatestHelmChartVersionFromOperator(
49
+ github,
50
+ owner,
51
+ 'redpanda-operator',
52
+ latestOperatorResult.value?.latestStableRelease,
53
+ latestOperatorResult.value?.latestBetaRelease
54
+ );
55
+
56
+ latestHelmChartResult = {
57
+ status: 'fulfilled',
58
+ value: helmChartVersions
59
+ };
60
+ } catch (error) {
61
+ latestHelmChartResult = {
62
+ status: 'rejected',
63
+ reason: error.message || 'Unknown error fetching Helm chart version'
64
+ };
65
+ logger.error(`Helm chart lookup failed: ${error.message || error}`);
66
+ }
67
+ } else {
68
+ logger.error(`Helm chart lookup failed: Operator version not available`);
69
+ }
44
70
 
45
71
  const latestVersions = {
46
72
  redpanda: latestRedpandaResult.status === 'fulfilled' ? latestRedpandaResult.value : {},
@@ -105,14 +131,12 @@ module.exports.register = function ({ config }) {
105
131
  }
106
132
  });
107
133
 
108
- logger.info('Updated Redpanda documentation versions successfully.');
109
- logger.info(`Latest Redpanda version: ${latestVersions.redpanda.latestRedpandaRelease.version}`);
110
- if (latestVersions.redpanda.latestRCRelease) logger.info(`Latest Redpanda beta version: ${latestVersions.redpanda.latestRCRelease.version}`);
111
- logger.info(`Latest Connect version: ${latestVersions.connect}`);
112
- logger.info(`Latest Console version: ${latestVersions.console.latestStableRelease}`);
113
- if (latestVersions.console.latestBetaRelease) logger.info(`Latest Console beta version: ${latestVersions.console.latestBetaRelease}`);
114
- logger.info(`Latest Redpanda Helm chart version: ${latestVersions.helmChart}`);
115
- logger.info(`Latest Operator version: ${latestVersions.operator}`);
134
+ logger.info('Updated Redpanda documentation versions successfully:');
135
+ logger.info(`- Redpanda: ${latestVersions.redpanda.latestRedpandaRelease.version}${latestVersions.redpanda.latestRcRelease ? ', beta: ' + latestVersions.redpanda.latestRcRelease.version : ''}`);
136
+ logger.info(`- Connect: ${latestVersions.connect}`);
137
+ logger.info(`- Console: ${latestVersions.console.latestStableRelease}${latestVersions.console.latestBetaRelease ? ', beta: ' + latestVersions.console.latestBetaRelease : ''}`);
138
+ logger.info(`- Operator: ${latestVersions.operator?.latestStableRelease || 'unknown'}${latestVersions.operator?.latestBetaRelease ? ', beta: ' + latestVersions.operator.latestBetaRelease : ''}`);
139
+ logger.info(`- Helm chart: ${latestVersions.helmChart?.latestStableRelease || 'unknown'}${latestVersions.helmChart?.latestBetaRelease ? ', beta: ' + latestVersions.helmChart.latestBetaRelease : ''}`);
116
140
  } catch (error) {
117
141
  logger.error(`Error updating versions: ${error}`);
118
142
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redpanda-data/docs-extensions-and-macros",
3
- "version": "4.6.4",
3
+ "version": "4.6.6",
4
4
  "description": "Antora extensions and macros developed for Redpanda documentation.",
5
5
  "keywords": [
6
6
  "antora",
@@ -26,12 +26,10 @@ module.exports = function renderConnectFields(children, prefix = '') {
26
26
  sorted.forEach(child => {
27
27
  if (child.is_deprecated || !child.name) return;
28
28
 
29
- // Normalize type: arrays and unknown-map as object
29
+ // Normalize types
30
30
  let displayType;
31
31
  if (child.type === 'string' && child.kind === 'array') {
32
32
  displayType = 'array';
33
- } else if (child.type === 'unknown' && child.kind === 'map') {
34
- displayType = 'object';
35
33
  } else {
36
34
  displayType = child.type;
37
35
  }
@@ -1,122 +0,0 @@
1
- /**
2
- * Fetches the latest Helm chart version from GitHub releases.
3
- *
4
- * This function looks for releases with tags following these patterns:
5
- * - Stable: "redpanda-5.9.21" or "25.1-k8s4" (without "beta" anywhere)
6
- * - Beta: "redpanda-5.9.21-beta", "redpanda-5.9.21-beta.1", or "25.1-k8s4-beta"
7
- *
8
- * It selects the highest version for each category, fetches the file at the provided path
9
- * (typically Chart.yaml) using the tag as the Git ref, parses it, and returns an object with
10
- * the chart version from the highest stable release and the highest beta release.
11
- *
12
- * @param {object} github - The GitHub API client.
13
- * @param {string} owner - The repository owner.
14
- * @param {string} repo - The repository name.
15
- * @param {string} path - The path to the Chart.yaml file in the repository.
16
- * @returns {Promise<{ latestStableRelease: string|null, latestBetaRelease: string|null }>}
17
- */
18
- module.exports = async (github, owner, repo, path) => {
19
- const yaml = require('js-yaml');
20
- try {
21
- // Fetch up to 20 releases from GitHub.
22
- const releasesResponse = await github.repos.listReleases({
23
- owner,
24
- repo,
25
- per_page: 20,
26
- });
27
- const releases = releasesResponse.data;
28
-
29
- // Regex patterns:
30
- // Stable regex: "redpanda-" prefix, then major.minor with an optional patch,
31
- // and no "beta" anywhere in the tag.
32
- const stableRegex = /^(?:redpanda-)(\d+)\.(\d+)(?:\.(\d+))?(?!.*beta)/i;
33
- // Beta regex: "redpanda-" prefix, then major.minor with an optional patch,
34
- // and later somewhere "beta" with an optional numeric qualifier.
35
- const betaRegex = /^(?:redpanda-)(\d+)\.(\d+)(?:\.(\d+))?.*beta(?:\.(\d+))?$/i;
36
-
37
- // Filter releases into stable and beta arrays based on tag matching.
38
- const stableReleases = releases.filter(release => stableRegex.test(release.tag_name));
39
- const betaReleases = releases.filter(release => betaRegex.test(release.tag_name));
40
-
41
- // Sorting function for stable releases.
42
- const sortStable = (a, b) => {
43
- const aMatch = a.tag_name.match(stableRegex);
44
- const bMatch = b.tag_name.match(stableRegex);
45
- if (!aMatch || !bMatch) return 0;
46
- const aMajor = parseInt(aMatch[1], 10);
47
- const aMinor = parseInt(aMatch[2], 10);
48
- const aPatch = aMatch[3] ? parseInt(aMatch[3], 10) : 0;
49
- const bMajor = parseInt(bMatch[1], 10);
50
- const bMinor = parseInt(bMatch[2], 10);
51
- const bPatch = bMatch[3] ? parseInt(bMatch[3], 10) : 0;
52
- if (aMajor !== bMajor) return bMajor - aMajor;
53
- if (aMinor !== bMinor) return bMinor - aMinor;
54
- return bPatch - aPatch;
55
- };
56
-
57
- // Sorting function for beta releases.
58
- const sortBeta = (a, b) => {
59
- const aMatch = a.tag_name.match(betaRegex);
60
- const bMatch = b.tag_name.match(betaRegex);
61
- if (!aMatch || !bMatch) return 0;
62
- const aMajor = parseInt(aMatch[1], 10);
63
- const aMinor = parseInt(aMatch[2], 10);
64
- const aPatch = aMatch[3] ? parseInt(aMatch[3], 10) : 0;
65
- // Optional beta number; if not provided, assume 0.
66
- const aBeta = aMatch[4] ? parseInt(aMatch[4], 10) : 0;
67
- const bMajor = parseInt(bMatch[1], 10);
68
- const bMinor = parseInt(bMatch[2], 10);
69
- const bPatch = bMatch[3] ? parseInt(bMatch[3], 10) : 0;
70
- const bBeta = bMatch[4] ? parseInt(bMatch[4], 10) : 0;
71
- if (aMajor !== bMajor) return bMajor - aMajor;
72
- if (aMinor !== bMinor) return bMinor - aMinor;
73
- if (aPatch !== bPatch) return bPatch - aPatch;
74
- return bBeta - aBeta;
75
- };
76
-
77
- // Sort both arrays in descending order.
78
- stableReleases.sort(sortStable);
79
- betaReleases.sort(sortBeta);
80
-
81
- // Get the highest tag from each group, if available.
82
- const latestStableTag = stableReleases.length ? stableReleases[0].tag_name : null;
83
- const latestBetaTag = betaReleases.length ? betaReleases[0].tag_name : null;
84
-
85
- // Helper function to fetch and parse Chart.yaml from a given tag.
86
- const fetchChartVersion = async (tag) => {
87
- if (!tag) return null;
88
- try {
89
- const contentResponse = await github.repos.getContent({
90
- owner,
91
- repo,
92
- path,
93
- ref: tag,
94
- });
95
- const contentBase64 = contentResponse.data.content;
96
- const contentDecoded = Buffer.from(contentBase64, 'base64').toString('utf8');
97
- const chartYaml = yaml.load(contentDecoded);
98
- return chartYaml.version || null;
99
- } catch (error) {
100
- console.error(`Failed to fetch Chart.yaml for tag ${tag}:`, error.message);
101
- return null;
102
- }
103
- };
104
-
105
- const [latestStableReleaseVersion, latestBetaReleaseVersion] = await Promise.all([
106
- fetchChartVersion(latestStableTag),
107
- fetchChartVersion(latestBetaTag)
108
- ]);
109
-
110
- return {
111
- latestStableRelease: latestStableReleaseVersion,
112
- latestBetaRelease: latestBetaReleaseVersion
113
- };
114
-
115
- } catch (error) {
116
- console.error('Failed to fetch chart version:', error.message);
117
- return {
118
- latestStableRelease: null,
119
- latestBetaRelease: null
120
- };
121
- }
122
- };