secrets

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

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

Go to latest
Published: Oct 21, 2019 License: MIT Imports: 7 Imported by: 9

README

docker-secrets

GoDoc Go Report

Requirements

Go 1.2 or above.

Installation

Run the following command to install the package:

go get github.com/ijustfool/docker-secrets

Usage

package main

import (
    "fmt"
    "github.com/ijustfool/docker-secrets"
)

func main() {
    dockerSecrets, _ := secrets.NewDockerSecrets("")

    // Get all secrets
    fmt.Println(dockerSecrets.GetAll())
    // print: map[secret_1:val_1 secret_2:val_2]

    // Get a single secret
    secret, _ := dockerSecrets.Get("secret_1")
    fmt.Println(secret)
    // print: val_1

    // Custom location
    dsCustomLoc, _ := secrets.NewDockerSecrets("/run/myCustomLocation")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReplaceInFile

func ReplaceInFile(b []byte) (result []byte, err error)

ReplaceInFile another way to get secrets from a config file

Types

type DockerSecrets

type DockerSecrets struct {
	// contains filtered or unexported fields
}

DockerSecrets contains secrets

func NewDockerSecrets

func NewDockerSecrets(secretsDir string) (*DockerSecrets, error)

NewDockerSecrets creates an instance of DockerSecrets The secretsDir argument has a default value of: /run/secrets return os.ErrNotExist if secrets dir not exists

func (*DockerSecrets) Get

func (ds *DockerSecrets) Get(secretName string) (string, error)

Get returns one secret by secretName

func (*DockerSecrets) GetAll

func (ds *DockerSecrets) GetAll() map[string]string

GetAll returns all secrets from memory

func (*DockerSecrets) GetDir

func (ds *DockerSecrets) GetDir() string

GetDir returns the secretsDir

func (*DockerSecrets) Unmarshal

func (ds *DockerSecrets) Unmarshal(output interface{}) error

Unmarshal unmarshals the secrets into a Struct

Jump to

Keyboard shortcuts

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