database

package module
v0.0.0-...-8eba0c9 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2020 License: GPL-3.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package database is a pure go client for dealing with Ankr KMS.it includes a high-level API for easy generate database secrets.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func (*Client) Get

func (c *Client) Get(roleName string) (string, string, error)

Get generate database secret by role name role name get from Ankr organization

Example
package main

import (
	"fmt"
	"log"

	"github.com/Ankr-network/go-kms/database"
)

func main() {
	c := database.NewClient("127.0.0.1")
	username, password, err := c.Get("ankr-user")
	if err != nil {
		fmt.Println(err)
		return
	}
	log.Printf("username: %s password: %s \n", username, password)
}
Output:
username: v-approle-ankr-sms-r-P3OkFNmSZJr password: A1a-wfOtfVAmex12y9Su

type Database

type Database interface {
	// get user name and password by role name
	// argument one: user name
	// argument two: password
	Get(roleName string) (string, string, error)
}

func NewClient

func NewClient(kmsAddr string) Database

NewClient create new client by address argument kmsAddr should be remote kms server addr which looks like "127.0.0.1:8200"

type DbRsp

type DbRsp struct {
	Auth interface{} `json:"auth"`
	Data struct {
		Password string `json:"password"`
		Username string `json:"username"`
	} `json:"data"`
	LeaseDuration int64       `json:"lease_duration"`
	LeaseID       string      `json:"lease_id"`
	Renewable     bool        `json:"renewable"`
	RequestID     string      `json:"request_id"`
	Warnings      interface{} `json:"warnings"`
	WrapInfo      interface{} `json:"wrap_info"`
}

type ErrRsp

type ErrRsp struct {
	Errors []string `json:"errors"`
}

func (ErrRsp) Error

func (e ErrRsp) Error() string

Jump to

Keyboard shortcuts

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