Code Monkey home page Code Monkey logo

lp-api-resource's Introduction

GitHub: fourdollars/lp-api-resource License: MIT Bash Docker Docker Pulls

lp-api-resource

concourse-ci's lp-api-resource to interact with https://api.launchpad.net/ by using https://github.com/fourdollars/lp-api.

Config

Resource Type

resource_types:
- name: lp-api
  type: registry-image
  source:
    repository: fourdollars/lp-api-resource
  defaults:
    oauth_consumer_key: test
    oauth_token: csjrGznX4Jq59CB8941N
    oauth_token_secret: wxDNqsCLxzrmhb2K27FRGjc7hdp3zQk0b4N8cnfRzVHnJfCFlHgkGHxDk5qMPTSdQFSsllS4dwGBD18Q

or

resource_types:
- name: lp-api
  type: registry-image
  source:
    repository: ghcr.io/fourdollars/lp-api-resource
  defaults:
    oauth_consumer_key: test
    oauth_token: csjrGznX4Jq59CB8941N
    oauth_token_secret: wxDNqsCLxzrmhb2K27FRGjc7hdp3zQk0b4N8cnfRzVHnJfCFlHgkGHxDk5qMPTSdQFSsllS4dwGBD18Q

Resource

  • oauth_consumer_key: optional, choose what you like.
  • oauth_token: optional, run lp-api -key oauth_consumer_key to get it in ~/.config/lp-api.toml.
  • oauth_token_secret: optional, run lp-api -key oauth_consumer_key to get it in ~/.config/lp-api.toml.

You need to export the proper payload content variable to make it work. https://concourse-ci.org/implementing-resource-types.html

check step

  • check: inline script (via source)
resources:
- name: bug
  icon: bug-outline
  type: lp-api
  source:
    check: |
      #!/bin/bash
      set -exuo pipefail
      IFS=$'\n\t'
      lp-api get bugs/123 > payload.json
      digest=$(jq -S -M < payload.json | sha256sum | awk '{print $1}')
      payload=$(cat <<ENDLINE
        [
          {
            "digest": "sha256:${digest}"
          }
        ]
      ENDLINE
      )
      export payload

get step

  • get: inline script (via source or params)
resources:
- name: bug
  icon: bug-outline
  type: lp-api
  check_every: 10m
  source:
    get: |
      #!/bin/bash
      set -exuo pipefail
      IFS=$'\n\t'
      lp-api get bugs/123 > payload.json
      digest=$(jq -S -M < payload.json | sha256sum | awk '{print $1}')
      payload=$(cat <<ENDLINE
      {
        "version": {
          "digest": "sha256:${digest}"
        },
        "metadata": [
          {
            "name": "Bug #$(jq -r .id < payload.json)",
            "value": "$(jq -r .title < payload.json | sed 's/\\/\\\\/g' | sed 's/"/\\"/g')"
          }
        ]
      }
      ENDLINE
      )
      export payload

put step

You need to provide one of them at least.

  • put: inline script (via source or params)
  • script: script file (via params)
resources:
- name: bug
  icon: bug-outline
  type: lp-api
  check_every: 10m
  source:
    put: |
      #!/bin/bash
      set -exuo pipefail
      IFS=$'\n\t'
      lp-api post bugs/123 ws.op=newMessage content="New comment"
      lp-api get bugs/123 > payload.json
      digest=$(jq -S -M < payload.json | sha256sum | awk '{print $1}')
      payload=$(cat <<ENDLINE
      {
        "version": {
          "digest": "sha256:${digest}"
        },
        "metadata": [
          {
            "name": "Bug #$(jq -r .id < payload.json)",
            "value": "$(jq -r .title < payload.json | sed 's/\\/\\\\/g' | sed 's/"/\\"/g')"
          }
        ]
      }
      ENDLINE
      )
      export payload

or

jobs:
- name: check-bug
  plan:
  - get: bug
    timeout: 1m
  - task: check
    timeout: 1m
    config:
      platform: linux
      image_resource:
        type: registry-image
        source:
          repository: fourdollars/lp-api-resource
      outputs:
        - name: comment
      run:
        path: bash
        args:
        - -exc
        - |
          mkdir -p comment
          echo "Another comment" > comment/comment.log
  - put: bug
    timeout: 1m
    params:
      put: |
        #!/bin/bash
        set -exuo pipefail
        IFS=$'\n\t'
        COMMENT=$(cat comment/comment.log)
        lp-api post bugs/123 ws.op=newMessage content="$COMMENT"
        lp-api get bugs/123 > payload.json
        digest=$(jq -S -M < payload.json | sha256sum | awk '{print $1}')
        payload=$(cat <<ENDLINE
        {
          "version": {
            "digest": "sha256:${digest}"
          },
          "metadata": [
            {
              "name": "Bug #$(jq -r .id < payload.json)",
              "value": "$(jq -r .title < payload.json | sed 's/\\/\\\\/g' | sed 's/"/\\"/g')"
            }
          ]
        }
        ENDLINE
        )
        export payload

or

jobs:
- name: check-bug
  plan:
  - get: bug
    timeout: 1m
  - task: check
    timeout: 1m
    config:
      platform: linux
      image_resource:
        type: registry-image
        source:
          repository: fourdollars/lp-api-resource
      outputs:
        - name: comment
      run:
        path: bash
        args:
        - -exc
        - |
          mkdir -p comment
          echo "Another comment" > comment/comment.log
  - get: some-script-repo
  - put: bug
    timeout: 1m
    params:
      script: some-script-repo/comment.sh

lp-api-resource's People

Contributors

fourdollars avatar

Watchers

 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.