@redpanda-data/docs-extensions-and-macros 4.6.3 → 4.6.5
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/bin/doc-tools.js
CHANGED
|
@@ -485,7 +485,16 @@ automation
|
|
|
485
485
|
.option('--template-examples <path>', 'Examples section partial template', path.resolve(__dirname, '../tools/redpanda-connect/templates/examples-partials.hbs'))
|
|
486
486
|
.option('--overrides <path>', 'Optional JSON file with overrides')
|
|
487
487
|
.action(async (options) => {
|
|
488
|
-
|
|
488
|
+
requireTool('rpk', {
|
|
489
|
+
versionFlag: '--version',
|
|
490
|
+
help: 'rpk is not installed. Install rpk: https://docs.redpanda.com/current/get-started/rpk-install/'
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
requireTool('rpk connect', {
|
|
494
|
+
versionFlag: '--version',
|
|
495
|
+
help: 'rpk connect is not installed. Run rpk connect install before continuing.'
|
|
496
|
+
});
|
|
497
|
+
|
|
489
498
|
const dataDir = path.resolve(process.cwd(), options.dataDir);
|
|
490
499
|
fs.mkdirSync(dataDir, { recursive: true });
|
|
491
500
|
|
|
@@ -495,7 +504,6 @@ automation
|
|
|
495
504
|
let dataFile;
|
|
496
505
|
if (options.fetchConnectors) {
|
|
497
506
|
try {
|
|
498
|
-
execSync('rpk --version', { stdio: 'ignore' });
|
|
499
507
|
newVersion = getRpkConnectVersion();
|
|
500
508
|
const tmpFile = path.join(dataDir, `connect-${newVersion}.tmp.json`);
|
|
501
509
|
const finalFile = path.join(dataDir, `connect-${newVersion}.json`);
|
|
@@ -512,7 +520,7 @@ automation
|
|
|
512
520
|
console.log(`✅ Fetched and saved: ${finalFile}`);
|
|
513
521
|
} catch (err) {
|
|
514
522
|
console.error(`❌ Failed to fetch connectors: ${err.message}`);
|
|
515
|
-
|
|
523
|
+
process.exit(1);
|
|
516
524
|
}
|
|
517
525
|
} else {
|
|
518
526
|
const candidates = fs.readdirSync(dataDir).filter(f => /^connect-\d+\.\d+\.\d+\.json$/.test(f));
|
|
@@ -542,7 +550,7 @@ automation
|
|
|
542
550
|
partialFiles = result.partialFiles;
|
|
543
551
|
} catch (err) {
|
|
544
552
|
console.error(`❌ Failed to generate partials: ${err.message}`);
|
|
545
|
-
|
|
553
|
+
process.exit(1);
|
|
546
554
|
}
|
|
547
555
|
|
|
548
556
|
if (options.draftMissing) {
|
|
@@ -613,7 +621,7 @@ automation
|
|
|
613
621
|
}
|
|
614
622
|
} catch (err) {
|
|
615
623
|
console.error(`❌ Could not draft missing: ${err.message}`);
|
|
616
|
-
|
|
624
|
+
process.exit(1);
|
|
617
625
|
}
|
|
618
626
|
}
|
|
619
627
|
|
|
@@ -667,8 +675,7 @@ automation
|
|
|
667
675
|
console.log('\n📄 Summary:');
|
|
668
676
|
console.log(` • Run time: ${timestamp}`);
|
|
669
677
|
console.log(` • Version used: ${newVersion}`);
|
|
670
|
-
|
|
671
|
-
process.exit(success ? 0 : 1);
|
|
678
|
+
process.exit(0);
|
|
672
679
|
});
|
|
673
680
|
|
|
674
681
|
automation
|
|
@@ -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
|
|
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(
|
|
110
|
-
|
|
111
|
-
logger.info(
|
|
112
|
-
logger.info(
|
|
113
|
-
|
|
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,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
|
-
};
|