bearpush

package module
v0.0.0-...-b113755 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

bearpush

GitHub Workflow Status Go Report GitHub go.mod Go version Lines of code

The poor man's CD pipeline.
Bearpush supplies you with a web server, bring your own scripts and auth (optional)

Download

Binaries for x86-64 Linux are available from the GitHub Actions.

Build from source

go build ./cmd/bearpush/

Usage

To use Bearpush, you need to configure at least one product - a type of entity Bearpush can process. You can scaffold the configuration with bearpush product new [product name].

The newly created configuration file will include a randomly generated token static-value. Feel free to change it. This token has to be provided in your request in order for it to be processed.

To do something with the uploaded file, you have to create a process-script. By default nothing is associated with your product. The simplest shell script could look like this:

#!/bin/bash

mkdir -p /app/foo
cp "${ARTIFACT_PATH}" /app/foo/my-file.txt

Note that Bearpush provides you with the ARTIFACT_PATH environment variable. Update your config file to include the absolute path to the script: process-script: '/home/foo/bar.sh'.

Run bearpush to start the server.

The simplest way to upload your artifact is to use curl:

curl -X POST http://localhost:44344/v1/upload/your-product-name \
  -H "Content-Type: multipart/form-data" \
  -H "Authorization: Bearer your-token-here" \
  -F "artifact=@your-file.tar"

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfigDir = filepath.Join(defaultUserConfigRoot, "bearpush")

DefaultConfigDir represents a default configuration directory of this application. Can be overridden by the user.

Functions

func LoadAllProducts

func LoadAllProducts(basePath string) (map[string]*Product, error)

LoadAllProducts parses all available product manifests.

Types

type Config

type Config struct {
	Path string
}

Config stores configuration of this application.

func LoadConfig

func LoadConfig(dir string) (*Config, error)

LoadConfig the app configuration. If the config files do not exist on disk, they will be created.

type Context

type Context struct {
	Config   *Config
	Logger   *zap.SugaredLogger
	Products map[string]*Product
}

Context stores current application state.

func ContextFromConfig

func ContextFromConfig(c *Config) (*Context, error)

ContextFromConfig constructs a Context object from a loaded Config.

type Product

type Product struct {
	Script        string        `yaml:"process-script"`
	TokenSettings TokenSettings `yaml:"token"`
}

Product describes a type of entity Bearpush can process.

func LoadProductFromFile

func LoadProductFromFile(path string) (*Product, error)

LoadProductFromFile loads product manifest from a file under a provided path.

func (*Product) VerifyToken

func (p *Product) VerifyToken(token string) bool

VerifyToken checks whether a token can be considered valid, according to current strategy.

type TokenSettings

type TokenSettings struct {
	Strategy TokenStrategy `yaml:"strategy"`
	Value    *string       `yaml:"static-value"`
	Script   *string       `yaml:"token-script"`
}

TokenSettings describes how a Product validates incoming auth tokens.

type TokenStrategy

type TokenStrategy int

TokenStrategy determines how the user tokens get validated.

const (

	// StaticToken means there is a single token that will not change at runtime.
	StaticToken TokenStrategy
	// RetrieveToken means the possible tokens will be provided by a script.
	RetrieveToken
	// VerifyToken means each token will get verified by a script.
	VerifyToken
)

func (TokenStrategy) String

func (s TokenStrategy) String() string

String converts a Strategy to a string.

func (*TokenStrategy) UnmarshalYAML

func (s *TokenStrategy) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals YAML value to a TokenStrategy,

Directories

Path Synopsis
cmd
config
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL