Code Monkey home page Code Monkey logo

taskrun's Introduction

taskrun

Simple cli that helps to create jobs from configurable commands for different stages.

Installation

go install github.com/Drafteame/taskrun@latest

Usage

taskrun -h

Job file definition

jobs:
  stage1:
    - name: some-job
      command: echo
      args:
        - '"Hello, World!"'
      env:
        # This remote loads the values from the specified source and key. If the source is not specified
        # it will be omitted.
        #
        # Remote is the first to be loaded, so if there is a conflict with the vars, the remote value will be
        # overwritten.
        remote:
          source: secretsmanager
          key: secret-name
          
        # This vars will be loaded after the remote. The resolve order for var sources is env, ssm and static.
        # If there are dependencies between vars, these are resolved at the end by replacing the collected values
        # and resolving recursively all missing vars at that moment.
        vars:
          # This is a hardcoded value
          SOME_VAR:
            value: "some-value"
            
          # This is a value from SSM
          SOME_SSM_VAR:
            source: ssm
            key: /path/to/ssm/parameter

          # This is a value from environment variable
          SOME_ENV_VAR:
            source: env
            key: SOME_ENV_VAR_NAME

Stages

Stages are a way to configure different behavior for different environments. For example, you can have a stage for development, another for testing, and another for production.

You should define at least one stage in the job file, so it can be executed as the default stage.

If you have more than one stage defined, you can execute a specific stage using the -s flag.

taskrun print job-name -s stage1

When you have defined more than one stage, if you don't specify the stage, the default stage will be taken as the first stage defined:

jobs:
  stage1:
    - name: some-job
      command: echo
      args:
        - '"Hello, World! default"'

  stage2:
    - name: some-job
      command: echo
      args:
            - '"Hello, World!"'
taskrun print same-job

# This will execute the stage1

If you want to define a different stage as the default stage, you can use the default_stage configuration.

default_stage: stage2

jobs:
  stage1:
    - name: some-job
      command: echo
      args:
        - '"Hello, World! default"'

  stage2:
    - name: some-job
      command: echo
      args:
        - '"Hello, World!"'
taskrun print same-job

# This will execute the stage2

Templating

Jobs file supports variable replacing using notation similar to serverless framework.

jobs:
  stage1:
    - name: some-job
      command: echo
      args:
        - '"${env:MY_ENV_VAR} ${sys:cwd}"'
      env:
        vars:
          MY_ENV_VAR:
            value: "Hello from"

Supported replacing vars

Notation Description
${env:<some-env>} Replace the value of the environment variable after source resolution
${sys:cwd} It sets the value of the current working directory as absolute path
${self:stage} Sets the current selected stage and replace it on templates

taskrun's People

Contributors

danteay avatar draftea-bot avatar dependabot[bot] avatar

Stargazers

Fabio Ribeiro avatar

Watchers

Joe Cohen avatar Ian Butelmann avatar Gabriel Browarnik avatar Ignacio Daniel Alvarez avatar Agustin de Sautu Riestra avatar Yonatan Andres Montoya Mejia avatar Ariel Santos 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.