Giter Club home page Giter Club logo

importer's Introduction

Build Status Coverage Status Configured by CloudTruth

Cloudtruth Importer

An importer utility for adding parameters to cloudtruth.

Installation

docker pull cloudtruth/importer

Uninstall

docker rmi --force cloudtruth/importer

Usage

To get the cli usage for the importer:

docker run cloudtruth/importer --help

and then run it for real like:

docker run -v $(pwd):/data -e CLOUDTRUTH_API_KEY=xyz cloudtruth/importer --dry-run /data/some/file.yaml

It scans the given directories and files (or stdin), parsing those that are a form of structured data (json/yaml/dotenv/properties). The structured data is then passed into a transformation template in order to generate parameter definitions that are used to drive the cloudtruth cli to create the actual parameters.

The transformation template is processed using the Liquid template language. The context supplied to each rendering of the template will contain the variables:

Variable Description Type
environment The environment supplied from the --environment cli flag or by using a named capture from --path-selector (i.e. to extract the environment from filenames) string
project The project supplied from the --project cli flag or by using a named capture from --path-selector (i.e. to extract the environment from filenames) string
filename The filename for the data the template is currently being rendered for string
data The structured data parsed from the file that the template is currently being rendered for map or array depending on file contents
<named_capture> Any named captures from applying the --path-selector regular expression to the filename string

The default transformation template treats the data passed in as a simple HashMap, using its keys/value to be the parameter keys and values. It looks like:

{% for entry in data %}
- environment: "{{ environment }}"
  project: "{{ project }}"
  key: "{{ entry[0] }}"
  value: "{{ entry[1] }}"
{% endfor %}

To handle other data structures, your template should produce a yaml document that is a list of parameter definitions of the form:

 - environment: someEnvironment,  # The environment to set the value for
   environment_parent: someParentEnv,  # The environment's parent if using --create-environments
   project: someProject, # The project to create the parameter in
   project_parent: someParentProj,  # The project's parent if using --create-projects
   key: aKey, # The key name of the parameter
   value: aValue, # The value for the parameter.  Don't set this if using FQN+JMES
   secret: false, # (optional) Indicate that the parameter should be created as a secret
   fqn: myFQN, # (optional) Set the parameter value to come from the given FQN (with optional JMES) 
   jmes: myJmesPath # (optional) Set the parameter value to come from the given FQN+JMES

Examples

Read from stdin

cat somefile.yaml | docker run -i -e CLOUDTRUTH_API_KEY=xyz cloudtruth/importer --dry-run --stdin yaml

Development

After checking out the repo, run docker build -t cloudtruth/importer . to build the image.

Run docker run -it --entrypoint "" cloudtruth/importer bundle exec rspec to run the tests.

Run docker run -it --entrypoint "" cloudtruth/importer bundle exec bin/console to get an interactive console.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/cloudtruth/importer.

importer's People

Contributors

dependabot[bot] avatar wr0ngway avatar

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.