lightblue-platform/lightblue-metadata-manager

Name: lightblue-metadata-manager

Owner: Lightblue Platform

Description: A command line tool to manage Lightblue metadata.

Created: 2016-07-05 15:36:53.0

Updated: 2016-11-02 13:57:22.0

Pushed: 2017-08-07 09:00:09.0

Homepage: null

Size: 102

Language: Scala

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

lightblue-metadata-manager

A command line tool to manage Lightblue metadata.

Workflow:

  1. Pull metadata from Lightblue,
  2. make changes, review diff,
  3. push changes back to Lightblue.

Yes, it's similar to working in git.

Usage:
e: MetadataManagerApp$ <operation> <options>

lable operations: list, pull, push, diff and set. Add -h after operation to see options it accepts.

ons:
--help   Prints usage.
Installation

For rpm based distributions, install from rpm (mvn clean install to build the rpm).

Once binary is installed, configure Lightblue environments. You can create as many environments as you like, e.g.:

rt LB_CLIENT_DEV=/home/<user>/lightblue-clients/lightblue-client-dev.properties
rt LB_CLIENT_QA=/home/<user>/lightblue-clients/lightblue-client-qa.properties
rt LB_CLIENT_PROD=/home/<user>/lightblue-clients/lightblue-client-prod.properties

(see lightblue-client for information on client configuration)

Now verify your installation:

 list --env dev

Should print a list of all entities.

Examples
Make changes in metadata
 pull --env dev -e user -v newest # saves newest user.json version in your current directory
user.json # make changes in user metadata
 diff --env dev -e user # diff your local user copy against newest user version in Lightblue
 push --env dev -e user # Update metadata in Lightblue in dev
 push --env qa -e user # Update metadata in Lightblue in qa
Define metadata change as a patch

Convenient for applying the same change to multiple environments where metadata state is unknown (other changes may be present).

RFC 6902 JSON patch

JSON patch works well for all cases which do not involve making changes to array elements. The problem with array elements is that JSON patch diff is refers to array indexes and will produce undesired results when elements in an array were shifted or reordered.

Prepare a patch:

 pull --env dev -e user -v newest # saves newest user.json version in your current directory
user.json # make changes in user metadata
 diff --env dev -e user > patch.json # diff your local user copy against newest user version in Lightblue, save the diff

Apply the patch in higher env:

 pull --env qa -e user -v newest
 apply -e user -jp patch.json # Apply the patch locally
 diff --env qa -e user # diff your local user copy against newest user version in Lightblue, just to make sure
 push --env qa -e user # Update metadata in Lightblue in qa
JavaScript patch

Considering JSON patch limitations, you can choose to describe your metadata changes in javascript.

Example javascript patch:

emove "personalInformation.firstName" projection from notificationsHook
ty.entityInfo.hooks.forEach(function(hook) {

(hook.name != "notificationHook") {
eturn;


k.configuration.includeProjection.remove(function(p) {
eturn p.field=="personalInformation.firstName";



The remove function was added to Array.prototype for convinience. See util.js for other embedded utilities.

The logic refers to array elements by unique field values, so it will produce desired results regardless of the order.

To apply javascript patch to your local copy:

 apply -e user -jsp patch.js
More pull examples
 pull --env dev -e user -v 0.0.2 # download user entity version 0.0.2
 pull --env dev -e user -v default # download default user entity version
 pull --env dev -e \$all -v newest # download all newest versions
 pull --env dev -e \$local -v newest # refresh all entities in local working directory with remote newest versions
 pull --env dev -e "/^(user|legalEntity).*/" -v newest # download all entities starting with user or legalEntity entity
More push examples
 push --env qa -e user --schemaOnly # upload schema only
 push --env qa -e user --entityInfoOnly # upload entityInfoOnly
 push --env qa -e \$all # upload all entities in your local working directory
Debug

See /tmp/lightblue-metadata-manager-debug.log. This is where all debug statements are logged, including lightblue-client logs.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.