Deployment Config

QName: f:deployment-config

The Deployment Config feature lets you describe settings that should be considered by one or more Deployment
Handlers during deployment. These settings may describe things such as a mappings of deployed content to file
system paths.

When a node is deployed, if it has the f:deployment-config feature on it, then that feature may instruct the
Deployment Handler about how to deploy.

Configuration

The f:deployment-config feature is utilized by the following handlers:

The default configuration looks like this:

{
    "default": {
        "mappings": [{
            "type": "object-to-file",
            "config": {
                "filepath": "/{{dependency.id}}/{{dependency.typeId}}.json"
            }
        }, {
            "type": "attachment-to-file",
            "config": {
                "attachmentId": "*",
                "filepath": "/{{dependency.id}}/{{attachment.filename}}"
            }
        ]
    }
}

The following mapping types are supported:

  • object-to-file
  • attachment-to-file

object-to-file

This mapping writes the JSON for the importing object to a file on disk.

Parameters

  • filepath - the path where the file should be written

Model

The file path is provided with a model for templated determination. The model looks like this:

  • dependency.id - the _doc ID of the object being imported
  • dependency.type - the type of the object being imported (such as node or association)
  • md5 - an MD5 hash of the object
  • object - the full JSON of the object being imported

As such, it is possible to use the full content of your JSON in determining your file location.

attachment-to-file

This mapping writes an attachment for the importing object to a file on disk.

Parameters

  • filepath - the path where the file should be written
  • attachmentId - (optional) the attachment to work with

If attachmentId is not specified, it is assumed to be the default attachment.
If attachmentId is set to *, then it will apply for all attachments.
If attachmentId is set to a specific attachment ID, then it will only apply for that one attachment ID.

Model

The file path is provided with a model for templated determination. The model looks like this:

  • dependency.id - the _doc ID of the object being imported
  • dependency.type - the type of the object being imported (such as node or association)
  • object - the full JSON of the object being imported
  • md5 - an MD5 hash of the object
  • attachment.id - the ID of the attachment
  • attachment.mimetype - the content type of the attachment (example: image/jpeg)
  • attachment.ext - a calculated extension for the attachment (example: jpg)
  • attachment.length - the length of the attachment in bytes
  • attachment.filename - the internally managed filename for the attachment

Example

Suppose you have a Node like this:

{
    "title": "The Adventures of Willy Beamish",
    "category": "software",
    "sku": "12345"
}

And you set up the following f:deployment-config feature on that node:

{
    "default": {
        "mappings": [{
            "type": "object-to-file",
            "config": {
                "filepath": "/{{object.category}}/{{object.sku}}/game.json"
            }
        }, {
           "type": "attachment-to-file",
           "config": {
               "attachmentId": "cover",
               "filepath": "/{{object.category}}/{{object.sku}}/cover.jpg"
           }
        }]
    }
}

When you deploy this content, the cover attachment (say, the cover art) for the node will be written to disk as:

/software/12345/cover.jpg