factoryvault

package
v0.0.0-...-947c8b3 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewVaultInDevelopmentMode

func NewVaultInDevelopmentMode(
	containerName string,
	version VaultVersionTag,

	pullStatus *chan iotmakerdocker.ContainerPullStatusSendToChannel,
) (
	err error,
	containerId string,
	ApiAddress string,
	ClusterAddress string,
	vaultRootToken string,
	vaultUnsealKey string,
)

NewVaultInDevelopmentMode (English): Manage Secrets and Protect Sensitive Data Site: https://www.vaultproject.io/

NewVaultInDevelopmentMode (Português): Gerencia segredos e protege dados sensíveis Site: https://www.vaultproject.io/

Example

this example install an vault container and test https://www.vaultproject.io/

var err error
var containerID string
var ApiAddress string
var ClusterAddress string
var vaultRootToken string
var vaultUnsealKey string

var pullStatusChannel = iotmakerdocker.NewImagePullStatusChannel()

go func(c chan iotmakerdocker.ContainerPullStatusSendToChannel) {

	for {
		select {
		case status := <-c:
			//fmt.Printf("image pull status: %+v\n", status.Stream)

			if status.Closed == true {
				//fmt.Println("image pull complete!")
			}
		}
	}

}(*pullStatusChannel)

err = tools_garbage_collector.RemoveAllByNameContains("vaultContainer")
if err != nil {
	panic(err)
}

err, containerID, ApiAddress, ClusterAddress, vaultRootToken, vaultUnsealKey = NewVaultInDevelopmentMode(
	"vaultContainer",
	KVaultVersionTag_latest,
	pullStatusChannel,
)
if err != nil {
	panic(err)
}
_ = ClusterAddress
_ = vaultUnsealKey

if containerID == "" {
	err = errors.New("container id not found")
	panic(err)
}

var httpClient = &http.Client{
	Timeout: 10 * time.Second,
}
var client *api.Client
var dataFromValt *api.Secret
client, err = api.NewClient(&api.Config{Address: "http://" + ApiAddress, HttpClient: httpClient})
if err != nil {
	panic(err)
}

client.SetToken(vaultRootToken)

var dataToVault = make(map[string]interface{})
var yourData = make(map[string]interface{})
yourData["your_key"] = "please understand: put your data inside the \"data\" key or the vault will return the error >>no data provided<<"
dataToVault["data"] = yourData

_, err = client.Logical().Write("secret/data/my-secret", dataToVault)
if err != nil {
	panic(err)
}

dataFromValt, err = client.Logical().Read("secret/data/my-secret")
if err != nil {
	panic(err)
}

if dataFromValt != nil {
	d := dataFromValt.Data
	fmt.Printf("vault data: %v\n", d["data"])
}

// stop and remove a container
var dockerSys = iotmakerdocker.DockerSystem{}
err = dockerSys.Init()
if err != nil {
	panic(err)
}

err = dockerSys.ContainerStopAndRemove(containerID, true, false, false)
if err != nil {
	panic(err)
}

err = tools_garbage_collector.RemoveAllByNameContains("vaultContainer")
if err != nil {
	panic(err)
}
Output:

vault data: map[your_key:please understand: put your data inside the "data" key or the vault will return the error >>no data provided<<]

Types

type VaultVersionTag

type VaultVersionTag int

VaultVersionTag (English): Vault version. Example: KVaultVersionTag_latest

VaultVersionTag (Português): versão do Vault. Exemplo: KVaultVersionTag_latest

const (
	KVaultVersionTag_latest VaultVersionTag = iota
	KVaultVersionTag_1_5_0
	KVaultVersionTag_1_5_0_rc
	KVaultVersionTag_1_4_3
	KVaultVersionTag_1_3_7
	KVaultVersionTag_1_4_2
	KVaultVersionTag_1_3_6
	KVaultVersionTag_1_4_1
	KVaultVersionTag_1_3_5
	KVaultVersionTag_1_4_0
	KVaultVersionTag_1_4_0_rc1
	KVaultVersionTag_1_3_4
	KVaultVersionTag_1_3_3
	KVaultVersionTag_1_4_0_beta1
	KVaultVersionTag_1_3_2
	KVaultVersionTag_1_3_1
	KVaultVersionTag_1_3_0
	KVaultVersionTag_1_2_4
	KVaultVersionTag_1_3_0_beta1
	KVaultVersionTag_1_2_3
	KVaultVersionTag_1_2_2
	KVaultVersionTag_1_2_1
	KVaultVersionTag_1_2_0
	KVaultVersionTag_1_1_5
	KVaultVersionTag_1_2_0_beta2
	KVaultVersionTag_1_2_0_beta1
	KVaultVersionTag_1_1_3
	KVaultVersionTag_1_1_2
	KVaultVersionTag_1_1_1
	KVaultVersionTag_1_1_0
	KVaultVersionTag_1_1_0_beta2
	KVaultVersionTag_1_0_3
	KVaultVersionTag_0_11_6
	KVaultVersionTag_1_0_2
	KVaultVersionTag_1_0_1
	KVaultVersionTag_1_0_0
	KVaultVersionTag_1_0_0_beta2
	KVaultVersionTag_0_11_5
	KVaultVersionTag_1_0_0_beta1
	KVaultVersionTag_0_11_4
	KVaultVersionTag_0_11_3
	KVaultVersionTag_0_11_2
	KVaultVersionTag_0_11_1
	KVaultVersionTag_0_11_0
	KVaultVersionTag_0_11_0_beta1
	KVaultVersionTag_0_10_4
	KVaultVersionTag_0_10_3
	KVaultVersionTag_0_10_2
	KVaultVersionTag_0_10_1
	KVaultVersionTag_0_10_0
	KVaultVersionTag_0_10_0_rc1
	KVaultVersionTag_0_9_6
	KVaultVersionTag_0_10_0_beta1
	KVaultVersionTag_0_9_5
	KVaultVersionTag_0_9_4
	KVaultVersionTag_0_9_3
	KVaultVersionTag_0_9_2
	KVaultVersionTag_0_9_1
	KVaultVersionTag_0_9_0
	KVaultVersionTag_0_8_3
	KVaultVersionTag_0_8_2
	KVaultVersionTag_0_8_1
	KVaultVersionTag_0_8_0
	KVaultVersionTag_0_7_3
	KVaultVersionTag_0_7_2
	KVaultVersionTag_0_7_0
	KVaultVersionTag_0_6_5
	KVaultVersionTag_0_6_4
	KVaultVersionTag_0_8_0_rc1
	KVaultVersionTag_0_8_0_beta1
	KVaultVersionTag_0_6_3
	KVaultVersionTag_0_6_2
	KVaultVersionTag_0_6
	KVaultVersionTag_0_6_1
	KVaultVersionTag_0_6_0
	KVaultVersionTag_v0_6_0
)

func (VaultVersionTag) String

func (el VaultVersionTag) String() string

Directories

Path Synopsis
Este código lê o dockerhub e reescreve o arquivo typeMongoDBVersionTag.go
Este código lê o dockerhub e reescreve o arquivo typeMongoDBVersionTag.go

Jump to

Keyboard shortcuts

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