// GetClient returns a postfinance vault client.
// The context is used to detect the calling user and loading his vault
// approleId
GetClient returns a postfinance vault client.
The context is used to detect the calling user and loading his vault
approleId
// GetClient returns a postfinance vault client . // The context is used to detect the calling user and loading his vault // approleId
func GetClient(ctx context.Context) (*pfvault.Client, error) {
	conf := api.DefaultConfig()
	a := viper.GetString("store.vault.addr")
	conf.Address = a
	if len(a) >= 5 && a[:5] == "https" {
		if err := configureTLS(conf); err != nil {
			log.WithFields(log.Fields{
				"address": a,
				"err":     err}).Fatal("got error while configuring TLS, shutting down")
		}
	}
	vc, err := api.NewClient(conf) 
	if err != nil {
		return nil, err
	}
	u, err := sfsfh.GetUserFromContext(ctx)
	if err != nil {
		return nil, err
	}
	approleId, err := getApproleId(u)
	if err != nil {
		return nil, err
	}
	accessToken, err := VaultApproleLogin(vc, approleId)
	if err != nil {
		return nil, err
	}
	vc.SetToken(accessToken)
	pfc, err := pfvault.New(vc, KVMountPath) 
	if err != nil {
		log.WithFields(log.Fields{
			"clientconf":    conf,
			"user":          u,
			"pfvaultclient": pfc,
			"error":         err}).Error("got error while creating new pfc")
		return nil, err
	}
	if pfc == nil {
		log.WithFields(log.Fields{
			"clientconf":    conf,
			"user":          u,
			"pfvaultclient": pfc,
			"KVMountPath":   KVMountPath,
			"error":         err}).Error("pfc is unexpectedly nil, probably not enough permissions to list KVMountPath")
		return nil, fmt.Errorf("msg=\"pfc is unexpectedly nil, probably not enough permissions to list '%v' on vault server\"\n", KVMountPath)
	}
	log.WithFields(log.Fields{
		"clientconf":    conf,
		"user":          u,
		"pfvaultclient": pfc,
		"KVMountPath":   KVMountPath}).Debug("log values")
	return pfc, err
}
func GetClient ( ctx context . Context ) ( * pfvault . Client , error ) { conf := api . DefaultConfig ( ) a := viper . GetString ( " " ) conf . Address = a if len ( a ) >= 5 && a [ : 5 ] == " " { if err := configureTLS ( conf ) ; err != nil { log . WithFields ( log . Fields { " " : a , " " : err } ) . Fatal ( " " ) } } vc , err := api . NewClient ( conf ) if err != nil { return nil , err } u , err := sfsfh . GetUserFromContext ( ctx ) if err != nil { return nil , err } approleId , err := getApproleId ( u ) if err != nil { return nil , err } accessToken , err := VaultApproleLogin ( vc , approleId ) if err != nil { return nil , err } vc . SetToken ( accessToken ) pfc , err := pfvault . New ( vc , KVMountPath ) if err != nil { log . WithFields ( log . Fields { " " : conf , " " : u , " " : pfc , " " : err } ) . Error ( " " ) return nil , err } if pfc == nil { log . WithFields ( log . Fields { " " : conf , " " : u , " " : pfc , " " : KVMountPath , " " : err } ) . Error ( " " ) return nil , fmt . Errorf ( " \" \" \n " , KVMountPath ) } log . WithFields ( log . Fields { " " : conf , " " : u , " " : pfc , " " : KVMountPath } ) . Debug ( " " ) return pfc , err }
GetClient returns a postfinance vault client.
GetClient returns a postfinance vault client .
// Get default vault client configuration // check TLS settings // Create new vault client with vault configuration // VaultClient // Get user doing the filesystem request // Read approleId from configfile // Login with approleId, get accessToken // Set accessToken and return pfvault Client // Create new pfvault client with vault client //PostFinanceClient