Giter Site home page Giter Site logo

derek63 / lightblue-metadata-manager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lightblue-platform/lightblue-metadata-manager

0.0 2.0 0.0 102 KB

A command line tool to manage Lightblue metadata.

Shell 0.54% Scala 97.50% JavaScript 1.96%

lightblue-metadata-manager's Introduction

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:

usage: MetadataManagerApp$ <operation> <options>

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

Options:
 -h,--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.:

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

(see lightblue-client for information on client configuration)

Now verify your installation:

lbmd list --env dev

Should print a list of all entities.

Examples

Make changes in metadata

lbmd pull --env dev -e user -v newest # saves newest user.json version in your current directory
vim user.json # make changes in user metadata
lbmd diff --env dev -e user # diff your local user copy against newest user version in Lightblue
lbmd push --env dev -e user # Update metadata in Lightblue in dev
lbmd 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:

lbmd pull --env dev -e user -v newest # saves newest user.json version in your current directory
vim user.json # make changes in user metadata
lbmd 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:

lbmd pull --env qa -e user -v newest
lbmd apply -e user -jp patch.json # Apply the patch locally
lbmd diff --env qa -e user # diff your local user copy against newest user version in Lightblue, just to make sure
lbmd 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:

// remove "personalInformation.firstName" projection from notificationsHook
entity.entityInfo.hooks.forEach(function(hook) {

 if (hook.name != "notificationHook") {
   return;
 }

 hook.configuration.includeProjection.remove(function(p) {
   return 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:

lbmd apply -e user -jsp patch.js

More pull examples

lbmd pull --env dev -e user -v 0.0.2 # download user entity version 0.0.2
lbmd pull --env dev -e user -v default # download default user entity version
lbmd pull --env dev -e \$all -v newest # download all newest versions
lbmd pull --env dev -e \$local -v newest # refresh all entities in local working directory with remote newest versions
lbmd pull --env dev -e "/^(user|legalEntity).*/" -v newest # download all entities starting with user or legalEntity entity

More push examples

lbmd push --env qa -e user --schemaOnly # upload schema only
lbmd push --env qa -e user --entityInfoOnly # upload entityInfoOnly
lbmd 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.