pshregistry-parser
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -33,3 +33,3 @@ 'use strict'; | ||
this.recommended = this.supported[this.getRecommendedVersionIndex()]; | ||
this.recommended = this.getRecommendedVersion(); | ||
this.supportedHTML = this.lifecycleHTML("supported"); | ||
@@ -140,12 +140,19 @@ this.supportedString = this.lifecycleString("supported"); | ||
*/ | ||
getRecommendedVersionIndex() { | ||
getRecommendedVersion() { | ||
// Create the version array with float elements that can be sorted. | ||
let sortableVersions = []; | ||
for(let version of this.supported) { | ||
// Use suported versions, unless there are none | ||
// in which case, use deprecated versions | ||
const versionArray = this.supported.length > 0 ? this.supported : this.deprecated | ||
for(let version of versionArray) { | ||
sortableVersions.push(parseFloat(version)); | ||
} | ||
// Sort to find the most recent version. | ||
let max_value = Math.max.apply(null, sortableVersions); | ||
const recommendedIndex = sortableVersions.indexOf(max_value); | ||
return sortableVersions.indexOf(max_value); | ||
return versionArray[recommendedIndex] | ||
} | ||
@@ -696,2 +703,60 @@ } | ||
/** | ||
* The VaultKms class is a special case of a service. | ||
* | ||
* It modifies the template strings generated for Vault KMS: | ||
* | ||
* - The services.yaml file requires special configuration | ||
* | ||
*/ | ||
class VaultKms extends Service { | ||
constructor(data) { | ||
super(data); | ||
this.config.services.snippet = ` | ||
${this.docs.service_name}: | ||
type: ${this.type}:${this.recommended} | ||
configuration: | ||
endpoints: | ||
manage_keys: | ||
- policy: admin | ||
key: vault-sign | ||
type: sign | ||
- policy: sign | ||
key: vault-sign | ||
type: sign | ||
- policy: verify | ||
key: vault-sign | ||
type: sign | ||
`.trim(); | ||
this.config.services.full = this.config.services.snippet; | ||
this.config.services.commented = ` | ||
# The name given to the ${this.name} service (lowercase alphanumeric only). | ||
${this.docs.service_name}: | ||
# The type of your service (${this.type}), which uses the format | ||
# 'type:version'. Be sure to consult the ${this.name} documentation | ||
# (https://docs.platform.sh${this.docs.url}#supported-versions) | ||
# when choosing a version. If you specify a version number which is not available, | ||
# the CLI will return an error. | ||
type: ${this.type}:${this.recommended} | ||
# The 'configuration' block is required and defines the endpoints available for | ||
# you to use in your app. | ||
configuration: | ||
endpoints: | ||
manage_keys: | ||
- policy: admin | ||
key: vault-sign | ||
type: sign | ||
- policy: sign | ||
key: vault-sign | ||
type: sign | ||
- policy: verify | ||
key: vault-sign | ||
type: sign | ||
`.trim(); | ||
} | ||
} | ||
module.exports = { | ||
@@ -701,3 +766,4 @@ Runtime, | ||
NetworkStorage, | ||
Varnish | ||
Varnish, | ||
VaultKms | ||
}; |
{ | ||
"name": "pshregistry-parser", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Helper for library for accessing image data from the Platform.sh Registry and generating configuration files.", | ||
@@ -5,0 +5,0 @@ "main": "lib/registry-parser.js", |
@@ -33,3 +33,3 @@ 'use strict'; | ||
this.recommended = this.supported[this.getRecommendedVersionIndex()]; | ||
this.recommended = this.getRecommendedVersion(); | ||
this.supportedHTML = this.lifecycleHTML("supported"); | ||
@@ -140,12 +140,19 @@ this.supportedString = this.lifecycleString("supported"); | ||
*/ | ||
getRecommendedVersionIndex() { | ||
getRecommendedVersion() { | ||
// Create the version array with float elements that can be sorted. | ||
let sortableVersions = []; | ||
for(let version of this.supported) { | ||
// Use suported versions, unless there are none | ||
// in which case, use deprecated versions | ||
const versionArray = this.supported.length > 0 ? this.supported : this.deprecated | ||
for(let version of versionArray) { | ||
sortableVersions.push(parseFloat(version)); | ||
} | ||
// Sort to find the most recent version. | ||
let max_value = Math.max.apply(null, sortableVersions); | ||
const recommendedIndex = sortableVersions.indexOf(max_value); | ||
return sortableVersions.indexOf(max_value); | ||
return versionArray[recommendedIndex] | ||
} | ||
@@ -696,2 +703,60 @@ } | ||
/** | ||
* The VaultKms class is a special case of a service. | ||
* | ||
* It modifies the template strings generated for Vault KMS: | ||
* | ||
* - The services.yaml file requires special configuration | ||
* | ||
*/ | ||
class VaultKms extends Service { | ||
constructor(data) { | ||
super(data); | ||
this.config.services.snippet = ` | ||
${this.docs.service_name}: | ||
type: ${this.type}:${this.recommended} | ||
configuration: | ||
endpoints: | ||
manage_keys: | ||
- policy: admin | ||
key: vault-sign | ||
type: sign | ||
- policy: sign | ||
key: vault-sign | ||
type: sign | ||
- policy: verify | ||
key: vault-sign | ||
type: sign | ||
`.trim(); | ||
this.config.services.full = this.config.services.snippet; | ||
this.config.services.commented = ` | ||
# The name given to the ${this.name} service (lowercase alphanumeric only). | ||
${this.docs.service_name}: | ||
# The type of your service (${this.type}), which uses the format | ||
# 'type:version'. Be sure to consult the ${this.name} documentation | ||
# (https://docs.platform.sh${this.docs.url}#supported-versions) | ||
# when choosing a version. If you specify a version number which is not available, | ||
# the CLI will return an error. | ||
type: ${this.type}:${this.recommended} | ||
# The 'configuration' block is required and defines the endpoints available for | ||
# you to use in your app. | ||
configuration: | ||
endpoints: | ||
manage_keys: | ||
- policy: admin | ||
key: vault-sign | ||
type: sign | ||
- policy: sign | ||
key: vault-sign | ||
type: sign | ||
- policy: verify | ||
key: vault-sign | ||
type: sign | ||
`.trim(); | ||
} | ||
} | ||
module.exports = { | ||
@@ -701,3 +766,4 @@ Runtime, | ||
NetworkStorage, | ||
Varnish | ||
Varnish, | ||
VaultKms | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
162893
3524