A configuration management framework written in Go

Viaduct CI

A configuration management framework written in Go.

The framework allows you to write configuration in plain Go, compiled and distributed as a binary.

Getting started

Create a project in main.go and import the framework:

import "github.com/surminus/viaduct"

func main() {
}

Add resources as part of the main() function. To create a directory and file:

func main() {
    dir := viaduct.Directory{Path: "test"}.Create()
    viaduct.File{Path: fmt.Sprintf("%s/foo", dir.Path), Content: "bar"}.Create()
}

Resources always return their resource object. In the example above, we use the Directory path as part of the file creation.

This also means we can run whatever action we need to on that resource:

func main() {
    dir := viaduct.Directory{Path: "test"}.Create()
    viaduct.File{Path: fmt.Sprintf("%s/foo", dir.Path), Content: "bar"}.Create()

    dir.Delete()
}

Embedded files and templates

There are helper functions to allow us to use the embed package to flexibly work with files and templates.

To create a template, first create a file in templates/test.txt using Go template syntax:

My name is {{ .Name }}

We can then generate the data to create our file:

import (
    "embed"

    "github.com/surminus/viaduct"
)

//go:embed templates
var templates embed.FS

func main() {
    template := viaduct.NewTemplate(
        templates,
        "templates/test.txt",
        struct{ Name string }{Name: "Bella"},
    )

    viaduct.File{Path: "test/foo", Content: template}.Create()
}

The EmbeddedFile function works in a similar way, but without variables.

Attributes

Like any good configuration management tool, we also have access to node attributes under the Attribute variable:

import (
    "fmt"

    "github.com/surminus/viaduct"
)

func main() {
    dir := viaduct.Directory{Path: "test"}.Create()
    viaduct.File{Path: fmt.Sprintf("%s/foo", dir.Path), Content: "bar"}.Create()

    dir.Delete()

    fmt.Println(viaduct.Attribute.JSON())
}

When you're happy with your configuration, compile and run using go build.

Comments
  • Reconsider Sudo?

    Reconsider Sudo?

    Hmm interesting project you've got here πŸ˜… I posted about it here πŸ˜…

    Anyway, as I can't seem to get to sleep, was thinking about Sudo Support in general and some of the remarks you made in your own README -- I think it might be better to add resources to determine if we're running as Root or not rather than having something like Sudo: true which is platform specific in general.

    What I'm getting at is, viaduct could be really quite nice in so many places if "platform specific" things were kept out in general.

  • [Feature] Dry-run mode

    [Feature] Dry-run mode

    Having a runtime what-if? mode without any client/integration legwork would be handy!

    [I only mention this early in the project's life as (as I understand it!) building this feature is made orders of magnitude easier, the earlier it affects the system design...]

  • Add helpers for temporary directories

    Add helpers for temporary directories

    We should add a function for easily using temporary directories.

    tmpdir := v.NewTmpDir()
    

    This could also just be an attribute:

    v.Attribute.TmpDir
    

    It'd be great if this was automatically cleaned up, but I'm not quite sure how this would work; perhaps we just clean up anything using init() at the beginning of every run.

    Branch started here: https://github.com/surminus/viaduct/compare/tmpdir

  • Ensure execute can handle pipes

    Ensure execute can handle pipes

    Rather than passing arguments straight to exec.Command, ensure they are wrapped in sh -c, or create a temporary file that can be executed.

    It may also be useful if the execute resource was able to handle multi-line blocks of code to run.

  • Specify user or allow sudo for resources

    Specify user or allow sudo for resources

    Since we'll probably run this as root on a Linux system, generally I want to be running resources as the user that runs the command; however, some commands require sudo, such as the Package resource.

    Either way we should be able to specify users when we create files and directories.

Butler CMS (Configuration Management System)
Butler CMS (Configuration Management System)

Butler CMS Butler CMS (Configuration Management System) Overview The Butler CMS (butler) tool is designed to grab any configuration files, defined in

Nov 17, 2021
An opinionated configuration loading framework for Containerized and Cloud-Native applications.
An opinionated configuration loading framework for Containerized and Cloud-Native applications.

Opinionated configuration loading framework for Containerized and 12-Factor compliant applications. Read configurations from Environment Variables, an

Dec 16, 2022
shops is a simple command-line tool written in Go that helps you simplify the way you manage configuration across a set of machines.

shops is a simple command-line tool written in Go that helps you simplify the way you manage configuration across a set of machines. shops is your configuration management tool of choice when Chef, Puppet, Ansible are all too complicated and all you really want to do is run a bunch of regular shell against a set of hosts.

Jul 5, 2021
✨Clean and minimalistic environment configuration reader for Golang

Clean Env Minimalistic configuration reader Overview This is a simple configuration reading tool. It just does the following: reads and parses configu

Jan 8, 2023
12 factor configuration as a typesafe struct in as little as two function calls

Config Manage your application config as a typesafe struct in as little as two function calls. type MyConfig struct { DatabaseUrl string `config:"DAT

Dec 13, 2022
JSON or YAML configuration wrapper with convenient access methods.

Config Package config provides convenient access methods to configuration stored as JSON or YAML. This is a fork of the original version. This version

Dec 16, 2022
Configure is a Go package that gives you easy configuration of your project through redundancy

Configure Configure is a Go package that gives you easy configuration of your project through redundancy. It has an API inspired by negroni and the fl

Sep 26, 2022
Load configuration in cascade from multiple backends into a struct
Load configuration in cascade from multiple backends into a struct

Confita is a library that loads configuration from multiple backends and stores it in a struct. Supported backends Environment variables JSON files Ya

Jan 1, 2023
Small library to read your configuration from environment variables

envconfig envconfig is a library which allows you to parse your configuration from environment variables and fill an arbitrary struct. See the example

Nov 3, 2022
A minimalist Go configuration library
A minimalist Go configuration library

fig fig is a tiny library for loading an application's config file and its environment into a Go struct. Individual fields can have default values def

Dec 23, 2022
go-up! A simple configuration library with recursive placeholders resolution and no magic.

go-up! A simple configuration library with placeholders resolution and no magic. go-up provides a simple way to configure an application from multiple

Nov 23, 2022
goconfig uses a struct as input and populates the fields of this struct with parameters from command line, environment variables and configuration file.

goconfig goconfig uses a struct as input and populates the fields of this struct with parameters from command line, environment variables and configur

Dec 15, 2022
Go configuration made easy!

gofigure Go configuration made easy! Just define a struct and call Gofigure Supports strings, ints/uints/floats, slices and nested structs Supports en

Sep 26, 2022
Harvest configuration, watch and notify subscriber

Harvester Harvester is a configuration library which helps setting up and monitoring configuration values in order to dynamically reconfigure your app

Dec 26, 2022
go implementation of lightbend's HOCON configuration library https://github.com/lightbend/config

HOCON (Human-Optimized Config Object Notation) Configuration library for working with the Lightbend's HOCON format. HOCON is a human-friendly JSON sup

Dec 3, 2022
πŸ›  A configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP
πŸ›  A configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP

config A small configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP. Example func main() {

Dec 11, 2022
Golang library for managing configuration data from environment variables

envconfig import "github.com/kelseyhightower/envconfig" Documentation See godoc Usage Set some environment variables: export MYAPP_DEBUG=false export

Dec 26, 2022
A golang package for parsing ini-style configuration files

Mini Mini is a simple ini configuration file parser. The ini syntax supported includes: The standard name=value Comments on new lines starting with #

Jan 7, 2023
A dead simple configuration manager for Go applications

Store Store is a dead simple configuration manager for Go applications. I didn't like existing configuration management solutions like globalconf, tac

Dec 24, 2022