Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: adapt populateCerts.js to new yaml format #236

Merged
merged 5 commits into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 29 additions & 46 deletions populateCerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,57 +22,40 @@ const sidebarItems = scopes.map((scope) => {
const matrix = {}
const versionsShown = {}
var numOld = 0
var modules = {}
scope.modules.forEach((module) => {
modules[module.id] = module
module.prettyName = module.id.startsWith('scs-') ? `${module.id}: ${module.name}` : module.name
})
scope.timeline.sort((a, b) => b.date.localeCompare(a.date))
const current = scope.timeline.filter((entry) => entry.date <= today)
const lookup = current.length ? current[0].versions : {}
// sort in descending order, so we get the MAX_OLD most recent obsolete versions
scope.versions.sort((a, b) => b.version.localeCompare(a.version));
scope.versions.forEach((version) => {
version.state = lookup[version.version] || 'deprecated'
version.isStable = version.stabilized_at !== undefined && version.stabilized_at <= today
version.isObsolete = version.deprecated_at !== undefined && version.deprecated_at < today
version.isEffective = version.isStable && !version.isObsolete
version.isPreview = version.stabilized_at === undefined || today < version.stabilized_at
if (!version.isEffective && !version.isPreview) {
version.isEffective = version.state == 'effective'
if (['warn', 'effective', 'draft'].indexOf(version.state) == -1) {
numOld += 1
if (numOld > MAX_OLD) return
}
version.state = (
version.stabilized_at === undefined ? 'Draft' :
version.isEffective ? 'Effective' :
version.isObsolete ? 'Deprecated' :
'Stable'
)
if (version.standards === undefined) return
if (version.include === undefined) return
versionsShown[version.version] = version
version.standards.forEach((standard) => {
const components = standard.url.split('/')
const filename = components[components.length - 1]
// first, sensible (but not pretty) defaults
var key = standard.url
var name = standard.name
var ver = '✓'
var url = standard.url
if (filename.startsWith('scs-') && filename.endsWith('.md')) {
// special case for internal standards
const components2 = filename.split('-')
key = `scs-${components2[1]}`
name = `${key}: ${name}`
ver = components2[2]
url = `/standards/${filename.substring(0, filename.length - 3)}`
} else {
// special case mainly for OpenStack Powered Compute, but anything ending in 'vXYZ'
const components2 = name.split(' ')
const v = components2.splice(components2.length - 1)
if (v[0].startsWith('v')) {
key = components2.join(' ')
name = key
ver = v[0]
}
version.include.forEach((include) => {
if (include.ref === undefined) {
include = {ref: include, parameters: {}}
}
if (matrix[key] === undefined) {
matrix[key] = {name, columns: {}}
const module = modules[include.ref]
if (matrix[module.id] === undefined) {
matrix[module.id] = {
name: module.prettyName,
columns: {},
url: module.url,
}
}
matrix[key].columns[version.version] = {
version: ver,
url,
parameters: standard.parameters,
matrix[module.id].columns[version.version] = {
parameters: include.parameters,
}
})
})
Expand All @@ -90,14 +73,14 @@ Note that the state _Stable_ is shown here if _stabilized at_ is in the future,
lines.push('| :-- | ' + columns.map(() => ':--').join(' | ') + ' |')
lines.push('| State | ' + columns.map((c) => versionsShown[c].state).join(' | ') + ' |')
lines.push('| Stabilized at | ' + columns.map((c) => versionsShown[c].stabilized_at || '').join(' | ') + ' |')
lines.push('| Deprecated at | ' + columns.map((c) => versionsShown[c].deprecated_at || '').join(' | ') + ' |')
// lines.push('| Deprecated at | ' + columns.map((c) => versionsShown[c].deprecated_at || '').join(' | ') + ' |')
// md doesn't allow intermediate header rows
// lines.push('| :-- | ' + columns.map(() => ':--').join(' | ') + ' |')
lines.push('| **Standards** | ' + columns.map((c) => ' '.repeat(c.length)).join(' | ') + ' |')
lines.push('| **Modules** | ' + columns.map((c) => ' '.repeat(c.length)).join(' | ') + ' |')
// md doesn't allow intermediate header rows
// lines.push('| :-- | ' + columns.map(() => ':--').join(' | ') + ' |')
rows.forEach((row) => {
lines.push(`| ${row.name} | ` + columns.map((c) => row.columns[c]).map((col) => {
lines.push(`| [${row.name}](${row.url}) | ` + columns.map((c) => row.columns[c]).map((col) => {
if (col === undefined) {
// this version of the cert does not include this standard
return ''
Expand All @@ -106,9 +89,9 @@ Note that the state _Stable_ is shown here if _stabilized at_ is in the future,
entry[1].startsWith('https://') ? `[${entry[0]}](${entry[1]})` : `${entry[0]}=${entry[1]}`
).join(', ')
if (params.length) {
params = `(${params})`
params = ` (${params})`
}
return `[${col.version}](${col.url}) ${params}`
return `X${params}`
}).join(' | ') + ' |')
})
lines.push('') // file should end with a single newline character
Expand Down
Loading