7fde8b908a
* Light client implementation with get-info and list-buckets commands * Fix client package name * Fix go.mod to work with vgo * Use single `fmt.Printf` for `get-info` output * Use unnamed import to client package * Simplify usage of sha256 and sha512 sums * Remove obsolete test code * Use helper structs for unmarshalling bridge info * Remove LGPL license files and adjust copyright headers * Use github.com/zeebo/errs * Use httptest for test http server * Use viper for env var management * Nested struct for swagger * Add github.com/zeebo/errs to go.mod * More bucket tests * word wrap long line * Use zeebo/errs for crypto errors
39 lines
824 B
Go
39 lines
824 B
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package client
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
// DefaultURL of the Storj Bridge API endpoint
|
|
const DefaultURL = "https://api.storj.io"
|
|
|
|
func init() {
|
|
viper.SetEnvPrefix("storj")
|
|
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
|
|
viper.AutomaticEnv()
|
|
viper.SetDefault("bridge", DefaultURL)
|
|
}
|
|
|
|
// Env contains parameters for accessing the Storj network
|
|
type Env struct {
|
|
URL string
|
|
User string
|
|
Password string
|
|
Mnemonic string
|
|
}
|
|
|
|
// NewEnv creates new Env struct with default values
|
|
func NewEnv() Env {
|
|
return Env{
|
|
URL: viper.GetString("bridge"),
|
|
User: viper.GetString("bridge-user"),
|
|
Password: sha256Sum(viper.GetString("bridge-pass")),
|
|
Mnemonic: viper.GetString("encryption-key"),
|
|
}
|
|
}
|