pshregistry-parser
Advanced tools
Comparing version 1.0.4 to 1.1.0
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
@@ -7,8 +8,44 @@ | ||
## [1.1.0] - 2019-09-25 | ||
### Added | ||
- A block is added to `makeImageInstances()` that filters service and runtime images into the object properties `services` and `runtimes`, respectively, which are subsets of `images`. | ||
- Two methods were added, `makeSupportedVersionsTables()` and `makeSupportedVersionTable(imageGroup)`. The first generates two files - `<saveDir>/tables/runtimes_supported.md` and `<saveDir>/tables/services_supported.md` - by calling the second for the `imageGroup`s `"runtimes"` and `"services"`. These two files contain markdown formatted tables that contain the supported versions for all runtimes and all services, respectively, links to their documentation, and their type. "Additional types" (e.g. `mysql`, `redis-persistent`) are not included in in these tables, only their primary types (e.g. `mariadb`, `redis`), so as not to generate duplicates. The table is sorted alphabetically by type. As an example, the testing registry in `test/testdata/valid.json` includes 8 services, and generates the following table in `test/testdata/tables/services_supported.md` after excluding the two `additionalTypes`: | ||
| **Service** | **`type`** | **Supported `version`** | | ||
|----------------------------------|---------------|-------------------------| | ||
| [Elasticsearch](/configuration/services/elasticsearch.html) | `elasticsearch` | 6.5, 7.2 | | ||
| [Kafka](/configuration/services/kafka.html) | `kafka` | 2.1, 2.2 | | ||
| [MariaDB](/configuration/services/mysql.html) | `mariadb` | 10.0, 10.1, 10.2 | | ||
| [Network Storage](/configuration/services/network-storage.html) | `network-storage` | 1.0 | | ||
| [Redis](/configuration/services/redis.html) | `redis` | 3.2, 4.0, 5.0 | | ||
| [Varnish](/configuration/services/varnish.html) | `varnish` | 5.6, 6.0 | | ||
The purpose of this change was to enable DevRel to include these tables directly within the documentation, as is done in the [Getting Started guides](https://docs.platform.sh/gettingstarted/own-code/service-configuration.html) for services and runtimes, without having a separate section that needed to be updated each time a new image was released. For example, including the table above with Gitbook on the page linked (`src/gettingstarted/own-code/service-configuration.md`) is done with the following: | ||
``` | ||
{% include "../../registry/images/tables/service_supported.md" %} | ||
``` | ||
Hugo has similar `include` shortcodes, so when we migrate to Hugo this command can be substituted to the same effect. | ||
- `makeSupportedVersionsTables()` is called by `write()` only when not supplied with an individual image type (when configuration files for each image in the Registry are generated). | ||
### Changed | ||
- Testing instances are renamed `registry` to match examples in the README. | ||
- There are **breaking changes** to how generated subdirectories are created when `saveDir` is specified to a `RegistryParser` instance. | ||
- If no `saveDir` is given, and it is instead inferred from the location of `registrySource`, the behavior has not changed. | ||
- The logic around `deriveSaveLocations()` and `ensureSaveLocations()` has been changed. Because these "Supported Versions" tables have little to do with the generated configuration YAML files, they do not save to the same `<saveDir>/examples/` subdirectory, but instead to their own subdirectory `<saveDir>/tables/`. | ||
- Previously, if the `saveDir` parameter was given to a `RegistryParser` instance, that `saveDir` would take the place of the `examples` subdirectory, and each `commented`, `snippet`, and `full` examples directory would be generated directly within it. Now, in order to support the `tables` save location, supplying a `saveDir` does not make this same assumption, and both `examples` and `tables` are generated within it. | ||
## [1.0.4] - 2019-09-09 | ||
### Changed | ||
- The relationship and service name for `redis-persistent` are updated to match new naming convention for Platform.sh documentation. | ||
## [1.0.3] - 2019-09-09 | ||
### Added | ||
- `CHANGELOG.md` added. | ||
@@ -18,13 +55,19 @@ - Runtime type definition includes quotes around string. | ||
## [1.0.2] - 2019-09-03 | ||
### Added | ||
- Yaml generation functions for making a copy of `registry.json` in a `registry.yaml` file during `write()`. | ||
## [1.0.1] - 2019-08-30 | ||
### Removed | ||
- Removed testing block in `registry-parser.js` that prevented imports. | ||
## [1.0.0] - 2019-08-30 | ||
### Changed | ||
- Migrated from GitHub initial project. | ||
- Major refactor around Image, Runtime, Service and Special Case classes. | ||
- Individual image instances are accessible through `registry.images['elasticsearch']` after `RegistryParser` is instantiated as `registry`. |
@@ -93,9 +93,16 @@ 'use strict'; | ||
this.services = {}; | ||
this.runtimes = {}; | ||
this.images = this.makeImageInstances(registrySource); | ||
this.contentFileName = "content.json"; | ||
this.tableFileNames = { | ||
"runtimes": "runtimes_supported.md", | ||
"services": "services_supported.md" | ||
}; | ||
this.directoryContent = { | ||
"commented": [], | ||
"full": [], | ||
"snippet": [] | ||
"snippet": [], | ||
"tables": [] | ||
} | ||
@@ -179,2 +186,8 @@ } | ||
images[currentImage] = new psh[className](registry[currentImage]); | ||
// Filter individual images by imageGroup as the instances are created. | ||
if (images[currentImage].runtime) { | ||
this.runtimes[currentImage] = images[currentImage]; | ||
} else { | ||
this.services[currentImage] = images[currentImage]; | ||
} | ||
} | ||
@@ -233,11 +246,17 @@ return images; | ||
}; | ||
if (!fs.existsSync(saveDir + 'commented/')){ | ||
fs.mkdirSync(saveDir + 'commented/'); | ||
if (!fs.existsSync(saveDir + 'examples/')){ | ||
fs.mkdirSync(saveDir + 'examples/'); | ||
}; | ||
if (!fs.existsSync(saveDir + 'full/')){ | ||
fs.mkdirSync(saveDir + 'full/'); | ||
if (!fs.existsSync(saveDir + 'examples/commented/')){ | ||
fs.mkdirSync(saveDir + 'examples/commented/'); | ||
}; | ||
if (!fs.existsSync(saveDir + 'snippet/')){ | ||
fs.mkdirSync(saveDir + 'snippet/'); | ||
if (!fs.existsSync(saveDir + 'examples/full/')){ | ||
fs.mkdirSync(saveDir + 'examples/full/'); | ||
}; | ||
if (!fs.existsSync(saveDir + 'examples/snippet/')){ | ||
fs.mkdirSync(saveDir + 'examples/snippet/'); | ||
}; | ||
if (!fs.existsSync(saveDir.split('/').slice(0, -1).join('/') + "/" + 'tables/')){ | ||
fs.mkdirSync(saveDir.split('/').slice(0, -1).join('/') + "/" + 'tables/'); | ||
}; | ||
} | ||
@@ -254,3 +273,2 @@ | ||
split.splice(-1,1); | ||
split.push('examples'); | ||
saveDir = split.join('/') + '/'; | ||
@@ -262,5 +280,6 @@ } | ||
return { | ||
"commented": saveDir + 'commented/', | ||
"full": saveDir + 'full/', | ||
"snippet": saveDir + 'snippet/' | ||
"commented": saveDir + 'examples/commented/', | ||
"full": saveDir + 'examples/full/', | ||
"snippet": saveDir + 'examples/snippet/', | ||
"tables": saveDir + 'tables/' | ||
}; | ||
@@ -290,2 +309,47 @@ } | ||
/** | ||
* Constructs the supported versions table (markdown) for the give image group. | ||
* | ||
* @param {string} imageGroup | ||
* Image group, can be either "runtimes" or "services". | ||
* @return {string} | ||
* A markdown formatted supported versions table. | ||
*/ | ||
makeSupportedVersionsTable(imageGroup) { | ||
// Construct the table. | ||
let table = ""; | ||
if (imageGroup == "runtimes") { | ||
table += "| **Language** | **`runtime`** | **Supported `version`** |"; | ||
} else if (imageGroup == "services") { | ||
table += "| **Service** | **`type`** | **Supported `version`** |"; | ||
} | ||
table += "\n|----------------------------------|---------------|-------------------------|"; | ||
// Add rows for each image to the table. | ||
let images = this[imageGroup]; | ||
Object.keys(images) | ||
// Filter out the additional types. | ||
.filter(image => !(Object.keys(this.additionalTypes).includes(image))) | ||
// Sort alphabetically by type. | ||
.sort() | ||
// Create and append the row. | ||
.forEach((image, index) => { | ||
table += `\n| [${images[image].name}](${images[image].docs.url}) | \`${images[image].type}\` | ${images[image].supportedString} |`; | ||
}); | ||
return table; | ||
} | ||
/** | ||
* Generates the supported versions table (markdown) files for runtime and service images. | ||
* | ||
*/ | ||
makeSupportedVersionsTables() { | ||
for (let tableFileName in this.tableFileNames) { | ||
// Make the content string. | ||
let tableContent = this.makeSupportedVersionsTable(tableFileName); | ||
// Write the file. | ||
this.writeFile("tables", this.tableFileNames[tableFileName], tableContent); | ||
} | ||
} | ||
/** | ||
* Generates all of the example YAML files for a given image. | ||
@@ -323,2 +387,3 @@ * | ||
} | ||
this.makeSupportedVersionsTables(); | ||
this.generateContentJSONFiles(); | ||
@@ -325,0 +390,0 @@ } else { |
{ | ||
"name": "pshregistry-parser", | ||
"version": "1.0.4", | ||
"version": "1.1.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", |
@@ -14,3 +14,3 @@ # Platform.sh Registry Parser | ||
You can find the current up-to-date version of this file in the public docs repo located here: https://github.com/platformsh/platformsh-docs/blob/master/src/registry/images/registry.json | ||
You can find the current up-to-date version of this file in the deployed [public documentation](https://docs.platform.sh/registry/images/registry.json). | ||
@@ -134,2 +134,4 @@ ### Generating example configuration files | ||
### Accessing all images | ||
Each Registry image is an instance of a child of an `Image` object, and is accessible directly from the config generator instance through the `images` property. For example, `registry.images["php"]` returns | ||
@@ -178,16 +180,80 @@ | ||
### Recommended versions | ||
#### Recommended versions | ||
For each example configuration YAML file, a "recommended" supported version is chosen and used in each file where a version must be specified. In this case, the _newest_ supported release is considered the recommended version, and is determined with `registry.images["elasticsearch"].recommended`. | ||
For each example configuration YAML file, a "recommended" supported version is chosen and used in each file where a version must be specified. In this case, the _newest_ supported release is considered the recommended version, and is accessible with `registry.images["elasticsearch"].recommended`. | ||
### Accessing subsets of images | ||
It is also possible to access a subset of the Registry's images, namely by accessing objects that include only those that are service or runtime images, with the properties `registry.services` and `registry.runtimes`. Individual runtime and service images can be accessed identically to `images` (e.g. `registry.services["elasticsearch"]`), as well as that individual image's properties (e.g. `registry.services["elasticsearch"].recommended`). | ||
## Future work | ||
1. Use other places in the docs | ||
### Use in the documentation | ||
`pshregistry-parser` functions for accessing formatted image versions that are not currently used. They return the content that will be useful for filling out other areas of the docs with version information (i.e. Getting Started tables and Supported/Deprecated sections of each image page). | ||
`pshregistry-parser` generates up-to-date example configuration YAML files that are currently pulled into the public documentation. Since 1.1.0, it generates additional markdown files that contain "Supported Version" tables for both service and runtime images that can also be included, that forego the necessity to create them during the doc's build process (aside from calling `write()`). | ||
`registry.images["elasticsearch"].supportedString` is a raw string of supported versions (`"6.5, 7.2"`), whereas `registry.images["elasticsearch"].supportedHTML` is an HTML unordered list (`"<ul><li>6.5</li><li>7.2</li></ul>"`). `deprecatedString` and `deprecatedHTML` are available as well. | ||
Currently, each image has the associated `supportedHTML` and `deprecatedHTML` properties meant to be pulled into the documentation at some point, specifically on each image's primary documentation page (e.g. Elasticsearch's [supported](https://docs.platform.sh/configuration/services/elasticsearch.html#supported-versions) and [deprecated](https://docs.platform.sh/configuration/services/elasticsearch.html#deprecated-versions) versions). | ||
2. Generating the registry | ||
The adoption of pre-generated tables in 1.1.0 may influence how these supported/deprecated sections are handled moving forward. Namely, that another subdirectory is added (i.e. `<saveDir>/versions` or `<saveDir>/lists`) to the output of `write()` that writes files that contain these strings for each image (e.g. `elasticsearch_supported.md`), and that they are similarly included into the documentation. | ||
Right now we will have to edit the `registry.json` by hand, but ideally this library will point at a "ground truth" repo somewhere else (that updates regularly) to get its data. When that happens, the `registry.json` file will be eliminated from docs altogether, and calling `write()` will also call an `update()` command to the ground truth `registry.json` in its final repo, sync up, and write the files using that data rather than a local source. | ||
They could include section headers (so that reference to an image's deprecated version's that does not have any will not generate that header despite the shortcode being included in the documentation) as well as descriptive text (I'm thinking specifically about the block of text commonly included in the "Deprecated" regarding upstreams). That way, each image's documentation page would look very similar: | ||
```markdown | ||
# Elasticsearch | ||
< Short description of Elasticsearch > | ||
{% include "../../registry/images/lists/elasticsearch_supported.md" %} | ||
{% include "../../registry/images/lists/elasticsearch_deprecated.md" %} | ||
## Relationship | ||
The format exposed in the `$PLATFORM_RELATIONSHIPS` [environment variable](/development/variables.md#platformsh-provided-variables): | ||
{% codesnippet "https://examples.docs.platform.sh/relationships/elasticsearch", language="json" %}{% endcodesnippet %} | ||
## Usage example | ||
In your `.platform/services.yaml`: | ||
{% codesnippet "/registry/images/examples/full/elasticsearch.services.yaml", language="yaml" %}{% endcodesnippet %} | ||
In your `.platform.app.yaml`: | ||
{% codesnippet "/registry/images/examples/full/elasticsearch.app.yaml", language="yaml" %}{% endcodesnippet %} | ||
You can then use the service in a configuration file of your application with something like: | ||
{% codetabs name="Java", type="java", url="https://examples.docs.platform.sh/java/elasticsearch" -%} | ||
{%- language name="Node.js", type="js", url="https://examples.docs.platform.sh/nodejs/elasticsearch" -%} | ||
{%- language name="PHP", type="php", url="https://examples.docs.platform.sh/php/elasticsearch" -%} | ||
{%- language name="Python", type="py", url="https://examples.docs.platform.sh/python/elasticsearch" -%} | ||
{%- endcodetabs %} | ||
``` | ||
### Generating the registry | ||
Right now we will have to edit the `registry.json` by hand, but ideally this library will point at a "ground truth" repo somewhere else (that updates regularly) to get its data. When that happens, the `registry.json` file will be eliminated from docs altogether, and calling `write()` will also call an `update()` command to the ground truth `registry.json` in its final repo, sync up, and write the files using that data rather than a local source. | ||
The decision that remains - that will influence how the final Registry is designed - is whether a project using `pshregistry-parser` places a call to: | ||
* The `registry.json` within that repository (GitLab API call, requires a token) to make the request. | ||
* A `registry.json` that is served by an application built by that repository connected to a Platform.sh project. In that case, keeping the Registry private (as it goes on to include more sensitive information about `images/` repository locations) would require some other kind of authentication for that request. | ||
#### Consequences | ||
Currently, `pshregistry-parser` requires a local copy of the Registry and for that to be provided to the `RegistryParser` instance. The location of that file is used to determine the save locations of the generated files, unless an alternative `saveDir` is also passed to it. | ||
Removing the ability to define a local `registrySource` at all is a logical option once this change is made, but then this save directory logic will need to be reworked. | ||
At this stage, I'm thinking the following: | ||
* `registrySource` as a parameter is disabled entirely, and instead the request to the generated source elsewhere is added to the `constructor` to define `images`. | ||
* `saveDir` becomes the only parameter to `RegistryParser`, with a default value of `null`. From there, it wouldn't be necessary for projects that are interested in just accessing `images`. | ||
* If generating files is the purpose of that project (i.e. the public docs), `saveDir` can be either passed to the `constructor` or with a new `set` method. |
@@ -93,9 +93,16 @@ 'use strict'; | ||
this.services = {}; | ||
this.runtimes = {}; | ||
this.images = this.makeImageInstances(registrySource); | ||
this.contentFileName = "content.json"; | ||
this.tableFileNames = { | ||
"runtimes": "runtimes_supported.md", | ||
"services": "services_supported.md" | ||
}; | ||
this.directoryContent = { | ||
"commented": [], | ||
"full": [], | ||
"snippet": [] | ||
"snippet": [], | ||
"tables": [] | ||
} | ||
@@ -179,2 +186,8 @@ } | ||
images[currentImage] = new psh[className](registry[currentImage]); | ||
// Filter individual images by imageGroup as the instances are created. | ||
if (images[currentImage].runtime) { | ||
this.runtimes[currentImage] = images[currentImage]; | ||
} else { | ||
this.services[currentImage] = images[currentImage]; | ||
} | ||
} | ||
@@ -233,11 +246,17 @@ return images; | ||
}; | ||
if (!fs.existsSync(saveDir + 'commented/')){ | ||
fs.mkdirSync(saveDir + 'commented/'); | ||
if (!fs.existsSync(saveDir + 'examples/')){ | ||
fs.mkdirSync(saveDir + 'examples/'); | ||
}; | ||
if (!fs.existsSync(saveDir + 'full/')){ | ||
fs.mkdirSync(saveDir + 'full/'); | ||
if (!fs.existsSync(saveDir + 'examples/commented/')){ | ||
fs.mkdirSync(saveDir + 'examples/commented/'); | ||
}; | ||
if (!fs.existsSync(saveDir + 'snippet/')){ | ||
fs.mkdirSync(saveDir + 'snippet/'); | ||
if (!fs.existsSync(saveDir + 'examples/full/')){ | ||
fs.mkdirSync(saveDir + 'examples/full/'); | ||
}; | ||
if (!fs.existsSync(saveDir + 'examples/snippet/')){ | ||
fs.mkdirSync(saveDir + 'examples/snippet/'); | ||
}; | ||
if (!fs.existsSync(saveDir.split('/').slice(0, -1).join('/') + "/" + 'tables/')){ | ||
fs.mkdirSync(saveDir.split('/').slice(0, -1).join('/') + "/" + 'tables/'); | ||
}; | ||
} | ||
@@ -254,3 +273,2 @@ | ||
split.splice(-1,1); | ||
split.push('examples'); | ||
saveDir = split.join('/') + '/'; | ||
@@ -262,5 +280,6 @@ } | ||
return { | ||
"commented": saveDir + 'commented/', | ||
"full": saveDir + 'full/', | ||
"snippet": saveDir + 'snippet/' | ||
"commented": saveDir + 'examples/commented/', | ||
"full": saveDir + 'examples/full/', | ||
"snippet": saveDir + 'examples/snippet/', | ||
"tables": saveDir + 'tables/' | ||
}; | ||
@@ -290,2 +309,47 @@ } | ||
/** | ||
* Constructs the supported versions table (markdown) for the give image group. | ||
* | ||
* @param {string} imageGroup | ||
* Image group, can be either "runtimes" or "services". | ||
* @return {string} | ||
* A markdown formatted supported versions table. | ||
*/ | ||
makeSupportedVersionsTable(imageGroup) { | ||
// Construct the table. | ||
let table = ""; | ||
if (imageGroup == "runtimes") { | ||
table += "| **Language** | **`runtime`** | **Supported `version`** |"; | ||
} else if (imageGroup == "services") { | ||
table += "| **Service** | **`type`** | **Supported `version`** |"; | ||
} | ||
table += "\n|----------------------------------|---------------|-------------------------|"; | ||
// Add rows for each image to the table. | ||
let images = this[imageGroup]; | ||
Object.keys(images) | ||
// Filter out the additional types. | ||
.filter(image => !(Object.keys(this.additionalTypes).includes(image))) | ||
// Sort alphabetically by type. | ||
.sort() | ||
// Create and append the row. | ||
.forEach((image, index) => { | ||
table += `\n| [${images[image].name}](${images[image].docs.url}) | \`${images[image].type}\` | ${images[image].supportedString} |`; | ||
}); | ||
return table; | ||
} | ||
/** | ||
* Generates the supported versions table (markdown) files for runtime and service images. | ||
* | ||
*/ | ||
makeSupportedVersionsTables() { | ||
for (let tableFileName in this.tableFileNames) { | ||
// Make the content string. | ||
let tableContent = this.makeSupportedVersionsTable(tableFileName); | ||
// Write the file. | ||
this.writeFile("tables", this.tableFileNames[tableFileName], tableContent); | ||
} | ||
} | ||
/** | ||
* Generates all of the example YAML files for a given image. | ||
@@ -323,2 +387,3 @@ * | ||
} | ||
this.makeSupportedVersionsTables(); | ||
this.generateContentJSONFiles(); | ||
@@ -325,0 +390,0 @@ } else { |
257
test/test.js
@@ -12,4 +12,4 @@ 'use strict'; | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
cg.write(); | ||
let registry = new psh.RegistryParser(registrySource); | ||
registry.write(); | ||
done(); | ||
@@ -24,3 +24,3 @@ }); | ||
() => { | ||
let cg = new psh.RegistryParser(validRegistrySource); | ||
let registry = new psh.RegistryParser(validRegistrySource); | ||
}, | ||
@@ -35,3 +35,3 @@ psh.InvalidRegistryError | ||
() => { | ||
let cg = new psh.RegistryParser(invalidRegistrySource); | ||
let registry = new psh.RegistryParser(invalidRegistrySource); | ||
}, | ||
@@ -42,2 +42,15 @@ psh.InvalidRegistryError | ||
it('Test filtered Registry for Runtimes only contains runtimes', function () { | ||
let registrySource = "test/testdata/valid.json"; | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(Object.keys(registry.runtimes).length, 1); | ||
assert.equal(Object.keys(registry.runtimes)[0], "golang"); | ||
}); | ||
it('Test filtered Registry for Services only contains services', function () { | ||
let registrySource = "test/testdata/valid.json"; | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(Object.keys(registry.services).length, 8); | ||
assert.equal("golang" in registry.services, false); | ||
}); | ||
}) | ||
@@ -49,4 +62,4 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
cg.writeRegistryYAML(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
registry.writeRegistryYAML(registrySource); | ||
let yamlRegistry = yaml.safeLoad(fs.readFileSync('test/testdata/valid.yaml', 'utf8')); | ||
@@ -60,2 +73,31 @@ assert.equal(yamlRegistry.elasticsearch.disk, true); | ||
describe('Supported Versions table generation', function() { | ||
it('Test that Runtimes supported version table content generates', function() { | ||
let registrySource = "test/testdata/valid.json"; | ||
let registry = new psh.RegistryParser(registrySource); | ||
let expected = ` | ||
| **Language** | **\`runtime\`** | **Supported \`version\`** | | ||
|----------------------------------|---------------|-------------------------| | ||
| [Go](/languages/go.html) | \`golang\` | 1.11, 1.12 |`.trim(); | ||
assert.equal(registry.makeSupportedVersionsTable("runtimes"), expected); | ||
}); | ||
it('Test that Services supported version table content generates', function() { | ||
let registrySource = "test/testdata/valid.json"; | ||
let registry = new psh.RegistryParser(registrySource); | ||
let expected = ` | ||
| **Service** | **\`type\`** | **Supported \`version\`** | | ||
|----------------------------------|---------------|-------------------------| | ||
| [Elasticsearch](/configuration/services/elasticsearch.html) | \`elasticsearch\` | 6.5, 7.2 | | ||
| [Kafka](/configuration/services/kafka.html) | \`kafka\` | 2.1, 2.2 | | ||
| [MariaDB](/configuration/services/mysql.html) | \`mariadb\` | 10.0, 10.1, 10.2 | | ||
| [Network Storage](/configuration/services/network-storage.html) | \`network-storage\` | 1.0 | | ||
| [Redis](/configuration/services/redis.html) | \`redis\` | 3.2, 4.0, 5.0 | | ||
| [Varnish](/configuration/services/varnish.html) | \`varnish\` | 5.6, 6.0 |`.trim(); | ||
assert.equal(registry.makeSupportedVersionsTable("services"), expected); | ||
}); | ||
}) | ||
describe('Save directories', function() { | ||
@@ -65,7 +107,8 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let saveLocations = cg.saveLocations; | ||
assert.equal(cg.saveLocations.commented, "test/testdata/examples/commented/"); | ||
assert.equal(cg.saveLocations.full, "test/testdata/examples/full/"); | ||
assert.equal(cg.saveLocations.snippet, "test/testdata/examples/snippet/"); | ||
let registry = new psh.RegistryParser(registrySource); | ||
let saveLocations = registry.saveLocations; | ||
assert.equal(registry.saveLocations.commented, "test/testdata/examples/commented/"); | ||
assert.equal(registry.saveLocations.full, "test/testdata/examples/full/"); | ||
assert.equal(registry.saveLocations.snippet, "test/testdata/examples/snippet/"); | ||
assert.equal(registry.saveLocations.tables, "test/testdata/tables/"); | ||
}); | ||
@@ -75,8 +118,9 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let saveDir = "test/examples/"; | ||
let cg = new psh.RegistryParser(registrySource, saveDir); | ||
let saveLocations = cg.saveLocations; | ||
assert.equal(cg.saveLocations.commented, "test/examples/commented/"); | ||
assert.equal(cg.saveLocations.full, "test/examples/full/"); | ||
assert.equal(cg.saveLocations.snippet, "test/examples/snippet/"); | ||
let saveDir = "test/"; | ||
let registry = new psh.RegistryParser(registrySource, saveDir); | ||
let saveLocations = registry.saveLocations; | ||
assert.equal(registry.saveLocations.commented, "test/examples/commented/"); | ||
assert.equal(registry.saveLocations.full, "test/examples/full/"); | ||
assert.equal(registry.saveLocations.snippet, "test/examples/snippet/"); | ||
assert.equal(registry.saveLocations.tables, "test/tables/"); | ||
}); | ||
@@ -89,4 +133,5 @@ }) | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.equal(cg.images["elasticsearch"].runtime, false); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(registry.images["elasticsearch"].runtime, false); | ||
assert.equal(registry.services["elasticsearch"].runtime, false); | ||
}); | ||
@@ -96,4 +141,5 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.equal(cg.images["elasticsearch"].disk, true); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(registry.images["elasticsearch"].disk, true); | ||
assert.equal(registry.services["elasticsearch"].disk, true); | ||
}); | ||
@@ -103,5 +149,7 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.equal(cg.images["elasticsearch"].min_disk_size, 256); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(registry.images["elasticsearch"].min_disk_size, 256); | ||
assert.equal(registry.services["elasticsearch"].min_disk_size, 256); | ||
}); | ||
}) | ||
@@ -113,4 +161,5 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.equal(cg.images["golang"].runtime, true); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(registry.images["golang"].runtime, true); | ||
assert.equal(registry.runtimes["golang"].runtime, true); | ||
}); | ||
@@ -120,4 +169,5 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.equal(cg.images["golang"].disk, false); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(registry.images["golang"].disk, false); | ||
assert.equal(registry.runtimes["golang"].disk, false); | ||
}); | ||
@@ -127,5 +177,7 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.strictEqual(cg.images["golang"].type, 'golang'); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.strictEqual(registry.images["golang"].type, 'golang'); | ||
assert.strictEqual(registry.runtimes["golang"].type, 'golang'); | ||
}); | ||
}) | ||
@@ -137,5 +189,7 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.equal(cg.images["mysql"].endpoint, "mysql"); | ||
assert.equal(cg.images["mysql"].name, "MariaDB"); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(registry.images["mysql"].endpoint, "mysql"); | ||
assert.equal(registry.images["mysql"].name, "MariaDB"); | ||
assert.equal(registry.services["mysql"].endpoint, "mysql"); | ||
assert.equal(registry.services["mysql"].name, "MariaDB"); | ||
}); | ||
@@ -145,4 +199,5 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.equal(cg.images["mysql"].type, "mysql"); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(registry.images["mysql"].type, "mysql"); | ||
assert.equal(registry.services["mysql"].type, "mysql"); | ||
}); | ||
@@ -152,5 +207,7 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.equal(cg.images["redis-persistent"].endpoint, "redis"); | ||
assert.equal(cg.images["redis-persistent"].repo_name, "redis"); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(registry.images["redis-persistent"].endpoint, "redis"); | ||
assert.equal(registry.images["redis-persistent"].repo_name, "redis"); | ||
assert.equal(registry.services["redis-persistent"].endpoint, "redis"); | ||
assert.equal(registry.services["redis-persistent"].repo_name, "redis"); | ||
}); | ||
@@ -160,7 +217,11 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.equal(cg.images["redis-persistent"].type, "redis-persistent"); | ||
assert.equal(cg.images["redis-persistent"].disk, true); | ||
assert.equal(cg.images["redis-persistent"].docs.relationship_name, "redisdata"); | ||
assert.equal(cg.images["redis-persistent"].docs.service_name, "data"); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(registry.images["redis-persistent"].type, "redis-persistent"); | ||
assert.equal(registry.images["redis-persistent"].disk, true); | ||
assert.equal(registry.images["redis-persistent"].docs.relationship_name, "redisdata"); | ||
assert.equal(registry.images["redis-persistent"].docs.service_name, "data"); | ||
assert.equal(registry.services["redis-persistent"].type, "redis-persistent"); | ||
assert.equal(registry.services["redis-persistent"].disk, true); | ||
assert.equal(registry.services["redis-persistent"].docs.relationship_name, "redisdata"); | ||
assert.equal(registry.services["redis-persistent"].docs.service_name, "data"); | ||
}); | ||
@@ -173,4 +234,4 @@ }) | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.equal(cg.images["elasticsearch"].supportedString, "6.5, 7.2"); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(registry.images["elasticsearch"].supportedString, "6.5, 7.2"); | ||
}); | ||
@@ -180,4 +241,4 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.equal(cg.images["golang"].deprecatedString, "1.1, 1.8, 1.9"); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(registry.images["golang"].deprecatedString, "1.1, 1.8, 1.9"); | ||
}); | ||
@@ -187,4 +248,4 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.equal(cg.images["elasticsearch"].supportedHTML, "<ul><li>6.5</li><li>7.2</li></ul>"); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(registry.images["elasticsearch"].supportedHTML, "<ul><li>6.5</li><li>7.2</li></ul>"); | ||
}); | ||
@@ -194,4 +255,4 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.equal(cg.images["golang"].deprecatedHTML, "<ul><li>1.1</li><li>1.8</li><li>1.9</li></ul>"); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(registry.images["golang"].deprecatedHTML, "<ul><li>1.1</li><li>1.8</li><li>1.9</li></ul>"); | ||
}); | ||
@@ -204,4 +265,5 @@ }) | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.equal(cg.images["elasticsearch"].recommended, "7.2"); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(registry.images["elasticsearch"].recommended, "7.2"); | ||
assert.equal(registry.services["elasticsearch"].recommended, "7.2"); | ||
}); | ||
@@ -211,4 +273,5 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.equal(cg.images["golang"].recommended, "1.12"); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.equal(registry.images["golang"].recommended, "1.12"); | ||
assert.equal(registry.runtimes["golang"].recommended, "1.12"); | ||
}); | ||
@@ -218,5 +281,7 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
assert.strictEqual(cg.images["varnish"].recommended, "6.0"); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.strictEqual(registry.images["varnish"].recommended, "6.0"); | ||
assert.strictEqual(registry.services["varnish"].recommended, "6.0"); | ||
}); | ||
}) | ||
@@ -228,7 +293,7 @@ | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
let invalid_image = "something" | ||
assert.throws( | ||
() => { | ||
throw cg.write(invalid_image); | ||
throw registry.write(invalid_image); | ||
}, | ||
@@ -241,6 +306,6 @@ psh.NotValidImageError | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
assert.doesNotThrow( | ||
() => { | ||
cg.write("elasticsearch"); | ||
registry.write("elasticsearch"); | ||
}, | ||
@@ -251,3 +316,3 @@ psh.NotValidImageError | ||
() => { | ||
cg.write("golang"); | ||
registry.write("golang"); | ||
}, | ||
@@ -264,4 +329,4 @@ psh.NotValidImageError | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
cg.write(); | ||
let registry = new psh.RegistryParser(registrySource); | ||
registry.write(); | ||
@@ -272,5 +337,5 @@ let commentedContents = JSON.parse(fs.readFileSync('test/testdata/examples/commented/content.json', 'utf8')); | ||
assert.deepStrictEqual(commentedContents.files, cg.directoryContent.commented); | ||
assert.deepStrictEqual(fullContents.files, cg.directoryContent.full); | ||
assert.deepStrictEqual(snippetContents.files, cg.directoryContent.snippet); | ||
assert.deepStrictEqual(commentedContents.files, registry.directoryContent.commented); | ||
assert.deepStrictEqual(fullContents.files, registry.directoryContent.full); | ||
assert.deepStrictEqual(snippetContents.files, registry.directoryContent.snippet); | ||
done(); | ||
@@ -281,3 +346,3 @@ }); | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
let expected = `# The runtime the application uses. The 'type' key defines the base container | ||
@@ -290,3 +355,3 @@ # image that will be used to run the application. There is a separate base | ||
type: 'golang:1.12'`; | ||
assert.equal(expected, cg.images["golang"].config.app.commented); | ||
assert.equal(expected, registry.images["golang"].config.app.commented); | ||
assert.equal(expected, fs.readFileSync('test/testdata/examples/commented/golang.app.yaml', 'utf8')) | ||
@@ -297,3 +362,3 @@ }); | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
let expected = `# The name given to the Elasticsearch service (lowercase alphanumeric only). | ||
@@ -309,3 +374,3 @@ mysearch: | ||
disk: 256`; | ||
assert.equal(expected, cg.images["elasticsearch"].config.services.commented); | ||
assert.equal(expected, registry.images["elasticsearch"].config.services.commented); | ||
assert.equal(expected, fs.readFileSync('test/testdata/examples/commented/elasticsearch.services.yaml', 'utf8')); | ||
@@ -316,6 +381,6 @@ }); | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
let expected = `relationships: | ||
elasticsearch: "mysearch:elasticsearch"`; | ||
assert.equal(expected, cg.images["elasticsearch"].config.app.full) | ||
assert.equal(expected, registry.images["elasticsearch"].config.app.full) | ||
assert.equal(expected, fs.readFileSync('test/testdata/examples/full/elasticsearch.app.yaml', 'utf8')); | ||
@@ -326,7 +391,7 @@ }); | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
let expected = `mysearch: | ||
type: elasticsearch:7.2 | ||
disk: 256` | ||
assert.equal(expected, cg.images["elasticsearch"].config.services.full); | ||
assert.equal(expected, registry.images["elasticsearch"].config.services.full); | ||
assert.equal(expected, fs.readFileSync('test/testdata/examples/full/elasticsearch.services.yaml', 'utf8')); | ||
@@ -337,5 +402,5 @@ }); | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
let expected = ` elasticsearch: "mysearch:elasticsearch"`; | ||
assert.equal(expected, cg.images["elasticsearch"].config.app.snippet); | ||
assert.equal(expected, registry.images["elasticsearch"].config.app.snippet); | ||
assert.equal(expected, fs.readFileSync('test/testdata/examples/snippet/elasticsearch.app.yaml', 'utf8')); | ||
@@ -346,7 +411,7 @@ }); | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
let expected = `mysearch: | ||
type: elasticsearch:7.2 | ||
disk: 256`; | ||
assert.equal(expected, cg.images["elasticsearch"].config.services.snippet); | ||
assert.equal(expected, registry.images["elasticsearch"].config.services.snippet); | ||
assert.equal(expected, fs.readFileSync('test/testdata/examples/snippet/elasticsearch.services.yaml', 'utf8')); | ||
@@ -360,3 +425,3 @@ }); | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
let expected = `# The name given to the Varnish service (lowercase alphanumeric only). | ||
@@ -381,3 +446,3 @@ varnish: | ||
path: config.vcl`; | ||
assert.equal(expected, cg.images["varnish"].config.services.commented); | ||
assert.equal(expected, registry.images["varnish"].config.services.commented); | ||
assert.equal(expected, fs.readFileSync('test/testdata/examples/commented/varnish.services.yaml', 'utf8')); | ||
@@ -388,6 +453,6 @@ }); | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
var expected = `relationships: | ||
varnishstats: "varnish:http+stats"`; | ||
assert.equal(expected, cg.images["varnish"].config.app.full); | ||
assert.equal(expected, registry.images["varnish"].config.app.full); | ||
assert.equal(expected, fs.readFileSync('test/testdata/examples/full/varnish.app.yaml', 'utf8')); | ||
@@ -398,3 +463,3 @@ }); | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
var expected = `"https://{default}/": | ||
@@ -405,3 +470,3 @@ type: upstream | ||
enabled: false`; | ||
assert.equal(expected, cg.images["varnish"].config.routes.snippet); | ||
assert.equal(expected, registry.images["varnish"].config.routes.snippet); | ||
assert.equal(expected, fs.readFileSync('test/testdata/examples/snippet/varnish.routes.yaml', 'utf8')); | ||
@@ -412,3 +477,3 @@ }); | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
var expected = `# Network Storage allows you to define a file store that can be shared between different application containers. | ||
@@ -431,3 +496,3 @@ # The service enables a new kind of 'mount' that refers to a shared service rather than to a local directory. | ||
source_path: files`; | ||
assert.equal(expected, cg.images["network-storage"].config.app.commented); | ||
assert.equal(expected, registry.images["network-storage"].config.app.commented); | ||
assert.equal(expected, fs.readFileSync('test/testdata/examples/commented/network-storage.app.yaml', 'utf8')); | ||
@@ -438,7 +503,7 @@ }); | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
var expected = `files: | ||
type: network-storage:1.0 | ||
disk: 256`; | ||
assert.equal(expected, cg.images["network-storage"].config.services.full); | ||
assert.equal(expected, registry.images["network-storage"].config.services.full); | ||
assert.equal(expected, fs.readFileSync('test/testdata/examples/full/network-storage.services.yaml', 'utf8')); | ||
@@ -449,3 +514,3 @@ }); | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
var expected = ` 'my/files': | ||
@@ -455,3 +520,3 @@ source: service | ||
source_path: files`; | ||
assert.equal(expected, cg.images["network-storage"].config.app.snippet); | ||
assert.equal(expected, registry.images["network-storage"].config.app.snippet); | ||
assert.equal(expected, fs.readFileSync('test/testdata/examples/snippet/network-storage.app.yaml', 'utf8')); | ||
@@ -465,7 +530,7 @@ }); | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
let expected = `mydatabase: | ||
type: mysql:10.2 | ||
disk: 256`; | ||
assert.equal(expected, cg.images["mysql"].config.services.snippet); | ||
assert.equal(expected, registry.images["mysql"].config.services.snippet); | ||
assert.equal(expected, fs.readFileSync('test/testdata/examples/snippet/mysql.services.yaml', 'utf8')); | ||
@@ -476,7 +541,7 @@ }); | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
let expected = `data: | ||
type: redis-persistent:5.0 | ||
disk: 256`; | ||
assert.equal(expected, cg.images["redis-persistent"].config.services.snippet); | ||
assert.equal(expected, registry.images["redis-persistent"].config.services.snippet); | ||
assert.equal(expected, fs.readFileSync('test/testdata/examples/snippet/redis-persistent.services.yaml', 'utf8')); | ||
@@ -487,3 +552,3 @@ }); | ||
let registrySource = "test/testdata/valid.json"; | ||
let cg = new psh.RegistryParser(registrySource); | ||
let registry = new psh.RegistryParser(registrySource); | ||
let expected = `# The relationships block defines how services are mapped within your application. | ||
@@ -496,3 +561,3 @@ relationships: | ||
redisdata: "data:redis"`; | ||
assert.equal(expected, cg.images["redis-persistent"].config.app.commented); | ||
assert.equal(expected, registry.images["redis-persistent"].config.app.commented); | ||
assert.equal(expected, fs.readFileSync('test/testdata/examples/commented/redis-persistent.app.yaml', 'utf8')); | ||
@@ -499,0 +564,0 @@ }); |
{ | ||
"elasticsearch": { | ||
"description": "A manufacture service for Elasticsearch", | ||
"disk": true, | ||
"docs": { | ||
"relationship_name": "elasticsearch", | ||
"service_name": "mysearch", | ||
"url": "\/configuration\/services\/elasticsearch.html" | ||
}, | ||
"endpoint": "elasticsearch", | ||
"min_disk_size": 256, | ||
"name": "Elasticsearch", | ||
"repo_name": "elasticsearch", | ||
"runtime": false, | ||
"type": "elasticsearch", | ||
"versions": { | ||
"deprecated": [ | ||
"0.9", | ||
"1.4", | ||
"1.7", | ||
"2.4", | ||
"5.2", | ||
"5.4" | ||
], | ||
"supported": [ | ||
"6.5", | ||
"7.2" | ||
] | ||
} | ||
}, | ||
"golang": { | ||
@@ -178,3 +149,32 @@ "description": "", | ||
} | ||
}, | ||
"elasticsearch": { | ||
"description": "A manufacture service for Elasticsearch", | ||
"disk": true, | ||
"docs": { | ||
"relationship_name": "elasticsearch", | ||
"service_name": "mysearch", | ||
"url": "\/configuration\/services\/elasticsearch.html" | ||
}, | ||
"endpoint": "elasticsearch", | ||
"min_disk_size": 256, | ||
"name": "Elasticsearch", | ||
"repo_name": "elasticsearch", | ||
"runtime": false, | ||
"type": "elasticsearch", | ||
"versions": { | ||
"deprecated": [ | ||
"0.9", | ||
"1.4", | ||
"1.7", | ||
"2.4", | ||
"5.2", | ||
"5.4" | ||
], | ||
"supported": [ | ||
"6.5", | ||
"7.2" | ||
] | ||
} | ||
} | ||
} |
110474
2104
257