Skip to content

Instantly share code, notes, and snippets.

@drnic
Last active October 12, 2015 21:20
Show Gist options
  • Save drnic/aedad2be18f02879b371 to your computer and use it in GitHub Desktop.
Save drnic/aedad2be18f02879b371 to your computer and use it in GitHub Desktop.

Hieroglyph

"In Neoplatonism, especially during the Renaissance, a 'hieroglyph' was an artistic representation of an esoteric idea" - https://en.wikipedia.org/wiki/Hieroglyph

This Cloud Foundry CLI plugin, and Golang library, allows you to attach and retrieve data for a Cloud Foundry Service Instance, useful for non-core systems to attach data to a service instance (such as the URL for the latest backup of a postgresql or redis database).

As a CLI, first target the org/space:

cf target -o org -s space

To set a key-value pair for a service instance:

cf hieroglyph <service-instance-name> author drnic

To get a value stored for a key on a service instance:

cf hieroglyph <service-instance-name> author
drnic

To delete a key-value pair:

cf hieroglyph <service-instance-name> -d author

To view all key-valye pairs:

cf hieroglyph <service-instance-name>

Implementation details

This data is stored in the only available read-writeable aspect of a service instance: its tags.

cf curl "/v2/service_instances?q=name:<service-instance-name>"
{
   "resources": [
      {
         "entity": {
            "name": "restore-mydb",
            "tags": ["author:drnic"],
            ...
         }
      }
   ]
}

Non-trivial values are first base64 encoded, and the above might appear as:

"tags": ["author:ZHJuaWMK"],

Yeah, that's esoteric. But its the only way we could figure out how to store data against a service instance that was available to the majority of Cloud Foundry installations in 2015.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment