Giter Club home page Giter Club logo

rules_yaml's Introduction

rules_yaml

This project provides Bazel rules for operating with YAML.

Setup

In your WORKSPACE file, include the following snippets. This will tell Bazel to fetch the YAML rules archive, extract it, and prepare it for use in your application.

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_yaml",
    sha256 = "<see github releases page for checksum>",
    url = "https://github.com/calebfroese/rules_yaml/archive/0.0.1.zip",
)

load("@rules_yaml//:defs.bzl", "yaml_repositories")

# This sets up the dependencies for rules_yaml
yaml_repositories()

Usage

You can pull elements into new YAML files using the yaml_excerpt rule.

# Extract elements nested under the path into a new file
yaml_excerpt(
    name = "first_car_info",
    src = "template.yml",
    path = "config.properties.cars[0].Details",
)
# Which can then be passed in to other rules as ":first_car_info"

rules_yaml's People

Contributors

calebfroese avatar

Watchers

 avatar  avatar

rules_yaml's Issues

A rule to insert YAML into another YAML file

A way to insert YAML into another file would be useful. We can use the yq write subcommand to accomplish this.

This potentially could look something like:

yaml_insert(
    name = "updated",
    src = "input.yaml",
    insert = "snippet.yaml",
    path = "create.here",
)
# snippet.yaml
snippet_data: 5

And would add the contents of snippet.yaml in like this:

# output
hello: world
create:
  here:
    snippet_data: 5

My use case is being able to be able to store my swagger definition for API Gateway in an external file and !Sub in it

Add examples

Add some examples for the yaml_excerpt rule under an examples/ folder.
See rules_nodejs for a good example on how this can be structured.

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.