You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Docstrings generation was requested by @JakeSCahill.
* #133 (comment)
The following files were modified:
* `tools/cloud-regions/generate-cloud-regions.js`
* `tools/cloud-tier-table/generate-cloud-tier-table.js`
* `tools/cloud-tier-table/generate-discrepancy-report.js`
Copy file name to clipboardExpand all lines: tools/cloud-regions/generate-cloud-regions.js
+12-13Lines changed: 12 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -193,11 +193,10 @@ function processCloudRegions(yamlText) {
193
193
}
194
194
195
195
/**
196
-
* Processes cloud regions data and organizes it by cluster type (BYOC/Dedicated) for tabs output.
197
-
*
198
-
* @param {string} yamlText - The YAML content to parse and process.
199
-
* @return {Object} An object with clusterTypes array, each containing providers organized by cluster type.
200
-
* @throws {Error} If the YAML is malformed or missing the required `regions` array.
196
+
* Parse cloud-regions YAML and group available regions by cluster type (BYOC or Dedicated) and provider for tabbed output.
197
+
* @param {string} yamlText - YAML document containing `regions` and optional `products`; regions must include `cloudProvider`, `name`, and `redpandaProductAvailability` entries.
198
+
* @returns {{clusterTypes: Array<{name: string, providers: Array<{name: string, regions: Array<{name: string}>}>}>}} An object with a `clusterTypes` array; each entry lists a cluster type (`BYOC` or `Dedicated`) and its providers (only providers with at least one region), each containing sorted region names.
199
+
* @throws {Error} If the YAML is malformed or does not contain a top-level `regions` array.
201
200
*/
202
201
functionprocessCloudRegionsForTabs(yamlText){
203
202
letdata;
@@ -297,10 +296,10 @@ function processCloudRegionsForTabs(yamlText) {
297
296
}
298
297
299
298
/**
300
-
* Fetches, processes, and renders cloud region and tier data from a GitHub YAML file.
299
+
* Generate rendered cloud region and tier output from a GitHub-hosted YAML file.
301
300
*
302
-
* Retrieves YAML data from GitHub using the GitHub API (to avoid caching issues),
303
-
* parses and filters it to include only public cloud regions and tiers, and renders the result in the requested format.
301
+
* Fetches the YAML from the specified repository path, parses and filters it to include only public providers/regions/tiers,
302
+
* and renders the result in the requested format. When `options.tabs` is true, returns separate rendered outputs per cluster type.
304
303
*
305
304
* @param {Object} options - Options for generating cloud regions.
* @param {boolean} [options.tabs=false] - Whether to generate AsciiDoc with tabs organized by cluster type.
314
-
* @returns {string} The rendered cloud regions output.
315
-
* @throws {Error} If fetching, processing, or rendering fails, or if no valid providers or regions are found.
311
+
* @param {string} [options.template] - Optional path to a custom Handlebars template.
312
+
* @param {boolean} [options.tabs=false] - When true, produce separate rendered outputs organized by cluster type (keys are cluster type names lowercased).
313
+
* @returns {string|Object} Rendered output as a string, or when `options.tabs` is true an object mapping lowercase cluster type names to rendered strings.
314
+
* @throws {Error} If fetching, parsing, processing, or rendering fails, or if no valid providers/regions remain after filtering.
Copy file name to clipboardExpand all lines: tools/cloud-tier-table/generate-cloud-tier-table.js
+89-8Lines changed: 89 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,11 @@ const LIMIT_KEYS = [
36
36
'kafka_topics_max',
37
37
];
38
38
39
-
// Map header keys to human readable labels
39
+
/**
40
+
* Map a header key to a human-readable label.
41
+
* @param {string} key - The header key to convert.
42
+
* @returns {string} The human-readable label for `key`, or `key` unchanged if no mapping exists.
43
+
*/
40
44
functionhumanLabel(key){
41
45
if(key==='cloud_provider')return'Cloud Provider';
42
46
if(key==='machine_type')return'Machine Type';
@@ -48,14 +52,24 @@ function humanLabel(key) {
48
52
returnkey;
49
53
}
50
54
51
-
// Map provider values to human readable
55
+
/**
56
+
* Convert a provider identifier into a human-friendly provider name.
57
+
* @param {*} val - Provider identifier (e.g., 'aws', 'gcp', 'azure'); comparison is case-insensitive. Falsy values produce an empty string.
58
+
* @returns {string} `'AWS'`, `'GCP'`, or `'Azure'` for known providers; empty string for falsy input; otherwise returns the original value.
59
+
*/
52
60
functionhumanProvider(val){
53
61
if(!val)return'';
54
62
constmap={aws: 'AWS',gcp: 'GCP',azure: 'Azure'};
55
63
returnmap[String(val).toLowerCase()]||val;
56
64
}
57
65
58
-
// Fetch public tiers from master-data.yaml
66
+
/**
67
+
* Loads master-data.yaml (from an HTTP URL or local path), validates its products list, and returns a normalized list of public tiers.
68
+
*
69
+
* @param {string} masterDataUrl - HTTP URL (GitHub API file response expected) or local filesystem path to the master-data.yaml file.
70
+
* @returns {Array<Object>} An array of public tier objects with the following fields: `displayName`, `configProfileName`, `cloudProvider`, `advertisedMaxIngress`, `advertisedMaxEgress`, `advertisedMaxPartitionCount`, and `advertisedMaxClientCount`.
71
+
* @throws {Error} If masterDataUrl is missing or not a string, fetching or file reading fails, YAML parsing fails, the products array is missing/invalid, or no valid public tiers are found.
@@ -161,6 +175,15 @@ async function fetchPublicTiers(masterDataUrl) {
161
175
}
162
176
}
163
177
178
+
/**
179
+
* Load and parse YAML from a local file path, HTTP(S) URL, or the special GitHub install-pack API directory.
180
+
*
181
+
* When given the GitHub install-pack API directory URL, selects the latest versioned YAML file (names like `1.2.yml` or `1.2.3.yaml`) and parses it. For HTTP(S) inputs, fetches the URL and parses the response body. For local file paths, reads and parses the file contents. If GITHUB_TOKEN is set, requests include Authorization and User-Agent headers.
182
+
*
183
+
* @param {string} input - Local filesystem path, HTTP(S) URL, or the GitHub API directory URL 'https://api.github.com/repos/redpanda-data/cloudv2/contents/install-pack'.
184
+
* @returns {Object} The parsed YAML content as a JavaScript object.
185
+
* @throws {Error} If `input` is not a valid string, the network or filesystem access fails, no suitable versioned YAML is found in the install-pack directory, or the YAML content cannot be parsed into an object.
186
+
*/
164
187
asyncfunctionparseYaml(input){
165
188
try{
166
189
if(!input||typeofinput!=='string'){
@@ -333,10 +356,11 @@ function extractVersion(profileName) {
333
356
}
334
357
335
358
/**
336
-
* Find the highest version config profile for a given base name
337
-
* @param {Object} configProfiles - All config profiles
338
-
* @param {string} targetProfile - The target profile name from master data
339
-
* @returns {string} The highest version profile name
359
+
* Selects the highest-versioned config profile name matching the given target profile.
360
+
*
361
+
* @param {Object} configProfiles - Map of profile names to profile definitions.
362
+
* @param {string} targetProfile - The target profile name to match (from master data).
363
+
* @returns {string} The matching profile name with the largest numeric `-vN` suffix, or `targetProfile` if no versioned variants are found or on failure.
@@ -384,6 +408,18 @@ function findHighestVersionProfile(configProfiles, targetProfile) {
384
408
}
385
409
}
386
410
411
+
/**
412
+
* Builds table row objects by merging public tier metadata with matching config profiles.
413
+
*
414
+
* Each returned row maps the tier display name to the requested limit keys (either `customLimits` or the module's default keys).
415
+
* Missing values are represented as the string "N/A". Duplicate rows with the same tier name and resolved config profile are removed.
416
+
*
417
+
* @param {Object} tiers - Parsed tiers YAML object; must contain a `config_profiles` object mapping profile names to definitions.
418
+
* @param {Array<Object>} publicTiers - Array of public tier descriptors; each entry must include `displayName` and `configProfileName`.
419
+
* @param {Array<string>} [customLimits] - Optional list of limit keys to extract; when omitted the module's default LIMIT_KEYS are used.
420
+
* @returns {Array<Object>} An array of row objects. Each row has a `tier` property (display name) and entries for each requested limit key.
421
+
* @throws {Error} If inputs are invalid or row construction fails (e.g., missing `config_profiles`, non-array `publicTiers`, or other fatal processing errors).
// Use custom limits if provided, otherwise use default LIMIT_KEYS
@@ -519,6 +555,13 @@ function buildTableRows(tiers, publicTiers, customLimits) {
519
555
}
520
556
}
521
557
558
+
/**
559
+
* Render an array of tier rows as a Markdown table.
560
+
*
561
+
* @param {Array<Object>} rows - Array of row objects where each row has a `tier` property and keys matching entries in `limitKeys`.
562
+
* @param {Array<string>} [limitKeys=LIMIT_KEYS] - Ordered list of keys to include as columns after the "Tier" column; each key's value is taken from the corresponding property on a row.
563
+
* @returns {string} A Markdown-formatted table with a header row ("Tier" followed by the provided keys' labels) and one row per entry in `rows`.
* Generate a cloud tier table from local or remote YAML input and master-data, rendered in the requested format.
653
+
*
654
+
* @param {Object} options - Function options.
655
+
* @param {string} options.input - Path or URL to the input YAML (or the special GitHub install-pack API directory URL) containing tiers/config profiles.
656
+
* @param {string} [options.output] - Output destination (not used by this function; included for CLI compatibility).
* @param {string} [options.template] - Path to a Handlebars template to use for rendering; for 'html' format a default template is used when this is not provided.
659
+
* @param {string} [options.masterData] - URL or filesystem path to master-data.yaml used to fetch public tier definitions.
660
+
* @param {string[]} [options.limits] - Custom ordered list of limit keys to include; when omitted the default LIMIT_KEYS set is used.
661
+
* @returns {string} Generated table content in the requested format (HTML, Markdown, AsciiDoc, or CSV).
* Classifies a percentage difference into a severity level.
46
+
* @param {number} percentDiff - Percentage difference (positive if actual > advertised, negative if actual < advertised).
47
+
* @returns {string} `unknown` if `percentDiff` is null or undefined; otherwise `minor` for absolute percentage <= 5, `moderate` for <= 25, `major` for <= 50, and `critical` for > 50.
0 commit comments