func (r *Client) Client() *v.Client {
	return r.client
}
Clients returns the underlining client
package vault
import (
	"crypto/tls"
	"fmt"
	"net/http"
	"strings"
	"time"
	"github.com/cloudwatt/vault-sync/pkg/api"
	"github.com/cloudwatt/vault-sync/pkg/utils"
	log "github.com/Sirupsen/logrus"
	v "github.com/hashicorp/vault/api"
)
const (
	apiVersion = "v1"
)
func New(hostname, username, password, filename, token string) (*Client, error) {
	log.Debugf("create vault client to host: %s", hostname)
	config := v.DefaultConfig()
	config.Address = hostname
	config.HttpClient = &http.Client{
		Timeout: time.Duration(15) * time.Second,
		Transport: &http.Transport{
			TLSClientConfig: &tls.Config{
				InsecureSkipVerify: true,
			},
		},
	}
	client, err := v.NewClient(config)
	if err != nil {
		return nil, err
	}
	service := &Client{
		client: client,
	}
	if filename != "" {
		creds := new(api.UserPass)
		if err := utils.DecodeFile(filename, creds); err != nil {
			return nil, err
		}
		if err := creds.IsValid(); err != nil {
			return nil, err
		}
		token, err := service.userLogin(creds)
		if err != nil {
			return nil, err
		}
		client.SetToken(token)
	} else if username != "" && password != "" {
		token, err := service.userLogin(&api.UserPass{
			Username: username,
			Password: password,
		})
		if err != nil {
			return nil, err
		}
		client.SetToken(token)
	} else {
		client.SetToken(token)
	}
	return &Client{
		client: client,
	}, nil
}