Git Product home page Git Product logo

go-concourse-resource's Introduction

concourse-resource

Go Report Card Go Reference

a Go module to simplify the development of concourse resources

Features

minimal dependencies

Only github.com/stretchr/testify and github.com/go-playground/validator/v10 are directly required by this module.

config validation

To validate your input, simply add the correct validator tags

flexible

Use whatever library you want, do what ever you want. This module takes only care about the communication with concourse. No assumptions beyond that are made.

testable

Test your resources with go test. A full set of testing helpers and a testify suite are provided.

Usage

To develop a new resource, you must provide a type, that fulfills at least one of the following interfaces:

  • types.CheckResource
  • types.InResource
  • types.OutResource

If your resource takes parameters for in or out, the type must implement the types.ParametrizedResource interface.

In addition, a factory function must be provided.

While all arguments to check, in and out are provided by the resource at runtime, the configuration (source) must be provided statically.

All communication with concourse is done by the Handler. For an example of a resource, have a look at the test/dummy implementation.

Inside your main, put all the stuff together and call the Run method.

package main

import (
	"log"

	resource "pkg.loki.codes/concourse-resource"

	"your/resource/implementation"
)

func main() {
	if err := resource.New[implementation.Config](implementation.New).Run(); err != nil {
		log.Fatal(err)
	}
}

Environment variables (metadata)

The Concourse metadata can be accessed with the help of some wrappers.

See metadata

Container build

To build your container image, you may just symlink the binary to the correct locations. For example:

FROM golang:alpine AS builder

RUN apk update && apk add --no-cache git ca-certificates && update-ca-certificates

ADD . /app/
WORKDIR /app
RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o resource .
RUN mkdir -p /target/opt/resource/
RUN cp resource /target/opt/resource/
RUN ln -s resource /target/opt/resource/in
RUN ln -s resource /target/opt/resource/out
RUN ln -s resource /target/opt/resource/check


FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /target/opt /opt

See also

Testing

There is an extensive test framework. See test

go-concourse-resource's People

Contributors

tbe avatar

Watchers

 avatar  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.