Giter VIP home page Giter VIP logo

contman's Introduction

contman CircleCI license

Library for high-level control of container system, running commands and prepared receipts. It provides three main abstractions: Manager, Container and Receipt. Manager allow container creation and using images, Container has all basic actions of using specific container. Main and most interesting this is Receipt

Receipt

Receipt is a declarative description of running specific container and copying data from/to it. It useful to make some actions in isolated or remote environment.

type Receipt struct {
	Image            string
	Cmd              string
	Env              map[string]string
	InputCopy        map[string]string
	OutputCopy       map[string]string
	UseControlSocket bool
	OnlyCreate       bool
}

Basic usage of receipts looks like this:

package main

import (
	"log"

	"github.com/elemir/contman"
	"github.com/elemir/contman/docker"
)

var receipt = contman.Receipt{
	Image:      "alpine:latest",
	Cmd:        "sed \"s/README.md/$MD/g\" -i /README.md",
	InputCopy:  map[string]string{"README.md": "/"},
	OutputCopy: map[string]string{"/README.md": "."},
	Env:        map[string]string{"MD": "WRITEYOU.md"},
}

func main() {
	dm, err := docker.NewDockerManager()
	if err != nil {
		log.Println("Cannot create docker manager: ", err)
	}
	err = contman.RunReceipt(dm, receipt)
	if err != nil {
		log.Println("Cannot run receipt: ", err)
	}
}

This code will change all 'README.md' entrances in README.md file to 'WRITEYOU.md'

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.