majordomo

package module
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

README

go-majordomo

Tag License GoDoc Travis CI codecov.io Go Report Card

Central access to resources, locally or from secret managers.

Table of Contents

Install

go-majordomo is a standard Go module which can be installed with:

go get github.com/bliiitz/go-majordomo

Usage

Majordomo manages confidants. A confidant is a module that holds secrets that can be accessed through a custom URL. Confidants includes in this module are:

  • direct secrets that are simple values
  • file secrets that are held in a named file
  • asm secrets that are stored on Amazon secrets manager
  • gsm secrets that are stored on Google secrets manager
  • http secrets that are stored on a remote server accessed by HTTP or HTTPS

Details about how to configure each confidant are in the relevant confidant's go docs.

Creating new confidants should be a relatively simple task; all that is required is to implement the Confidant interface.

Majordomo itself is defined as an interface. This is to allow more complicated implementations (load balancing, retries, caching etc.) if required. The standard implementation is in 'standard'

Example
Fetching a secret using the file confidant.
package main

import (
	"context"
	"fmt"

	"github.com/bliiitz/go-majordomo/confidants/file"
	standardmajordomo "github.com/bliiitz/go-majordomo/standard"
)

func main() {
	ctx := context.Background()
	// Create the majordomo service.
	service, err := standardmajordomo.New(ctx)
	if err != nil {
		panic(err)
	}

	// Create and register the file confidant.
	confidant, err := file.New(ctx)
	if err != nil {
		panic(err)
	}
	err = service.RegisterConfidant(ctx, confidant)
	if err != nil {
		panic(err)
	}

	// Fetch a value from the service.
	value, err := service.Fetch(ctx, "file:///home/me/secrets/password.txt")
	if err != nil {
		panic(err)
	}
	fmt.Printf("Value is %s\n", string(value))
}

Maintainers

Jim McDonald: @mcdee.

Contribute

Contributions welcome. Please check out the issues.

License

Apache-2.0 © 2019 - 2022 Weald Technology Trading Ltd

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("key not known")

ErrNotFound is returned when a key cannot be found.

View Source
var ErrSchemeUnknown = errors.New("no confidants registered to handle that scheme")

ErrSchemeUnknown is returned when a confidant scheme is not found.

View Source
var ErrURLInvalid = errors.New("supplied URL is invalid")

ErrURLInvalid is returned when a URL is in some way invalid.

Functions

This section is empty.

Types

type Confidant

type Confidant interface {
	// SupportedURLSchemes provides the list of schemes supported by this confidant.
	SupportedURLSchemes(ctx context.Context) ([]string, error)
	// Fetch fetches a value given its URL.
	Fetch(ctx context.Context, url *url.URL) ([]byte, error)
}

Confidant is the interface for services that hold secrets.

type Service

type Service interface {
	// Fetch fetches a value given its key.
	// The key is usually defined as a URL, although it is possible that some
	// confidants may require or accept a different format.
	Fetch(ctx context.Context, key string) ([]byte, error)
}

Service is the interface for a majordomo. A majordomo takes key requests in the form of custom URLs and returns the related value.

Directories

Path Synopsis
confidants
asm
gsm
testing

Jump to

Keyboard shortcuts

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