The name. The name. The name!

This commit is contained in:
Jeff Mitchell committed 2020-08-10 17:15:02 -04:00
1 parent 1c836c430b
commit 6661117d4c
321 files changed
+1295 -1300

No files matched your search

+2 -2
View File
@@ -7,8 +7,8 @@ import (
"net/url"
"time"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/scopes"
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/scopes"
)
type Account struct {
+3 -3
View File
@@ -4,11 +4,11 @@ import (
"context"
"fmt"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/authtokens"
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/authtokens"
)
// TODO: This will need to be changed when we add Auth Method API to watchtower. We'll also need a better
// TODO: This will need to be changed when we add Auth Method API to boundary. We'll also need a better
// way to handle different auth method types.
func (c *authmethodsClient) Authenticate(ctx context.Context, authMethodId, name, password string, opt ...Option) (*authtokens.AuthToken, *api.Error, error) {
if c.client == nil {
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"net/http"
"testing"
"github.com/hashicorp/watchtower/api/authmethods"
"github.com/hashicorp/watchtower/internal/servers/controller"
"github.com/hashicorp/boundary/api/authmethods"
"github.com/hashicorp/boundary/internal/servers/controller"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
+2 -2
View File
@@ -7,8 +7,8 @@ import (
"net/url"
"time"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/scopes"
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/scopes"
)
type AuthMethod struct {
+1 -1
View File
@@ -1,7 +1,7 @@
package authmethods
import (
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/boundary/api"
)
// Option is a func that sets optional attributes for a call. This does not need
+4 -4
View File
@@ -5,10 +5,10 @@ import (
"sort"
"testing"
"github.com/hashicorp/watchtower/api/authmethods"
"github.com/hashicorp/watchtower/api/authtokens"
"github.com/hashicorp/watchtower/internal/authtoken"
"github.com/hashicorp/watchtower/internal/servers/controller"
"github.com/hashicorp/boundary/api/authmethods"
"github.com/hashicorp/boundary/api/authtokens"
"github.com/hashicorp/boundary/internal/authtoken"
"github.com/hashicorp/boundary/internal/servers/controller"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
+2 -2
View File
@@ -6,8 +6,8 @@ import (
"fmt"
"time"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/scopes"
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/scopes"
)
type AuthToken struct {
+1 -1
View File
@@ -1,7 +1,7 @@
package authtokens
import (
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/boundary/api"
)
// Option is a func that sets optional attributes for a call. This does not need
+53 -53
View File
@@ -19,42 +19,42 @@ import (
"time"
"unicode"
"github.com/hashicorp/boundary/api/internal/parseutil"
cleanhttp "github.com/hashicorp/go-cleanhttp"
retryablehttp "github.com/hashicorp/go-retryablehttp"
rootcerts "github.com/hashicorp/go-rootcerts"
"github.com/hashicorp/watchtower/api/internal/parseutil"
"golang.org/x/time/rate"
)
const EnvWatchtowerAddr = "WATCHTOWER_ADDR"
const EnvWatchtowerCACert = "WATCHTOWER_CACERT"
const EnvWatchtowerCAPath = "WATCHTOWER_CAPATH"
const EnvWatchtowerClientCert = "WATCHTOWER_CLIENT_CERT"
const EnvWatchtowerClientKey = "WATCHTOWER_CLIENT_KEY"
const EnvWatchtowerClientTimeout = "WATCHTOWER_CLIENT_TIMEOUT"
const EnvWatchtowerTLSInsecure = "WATCHTOWER_TLS_INSECURE"
const EnvWatchtowerTLSServerName = "WATCHTOWER_TLS_SERVER_NAME"
const EnvWatchtowerMaxRetries = "WATCHTOWER_MAX_RETRIES"
const EnvWatchtowerToken = "WATCHTOWER_TOKEN"
const EnvWatchtowerRateLimit = "WATCHTOWER_RATE_LIMIT"
const EnvWatchtowerSRVLookup = "WATCHTOWER_SRV_LOOKUP"
const EnvWatchtowerScopeId = "WATCHTOWER_SCOPE_ID"
const EnvBoundaryAddr = "BOUNDARY_ADDR"
const EnvBoundaryCACert = "BOUNDARY_CACERT"
const EnvBoundaryCAPath = "BOUNDARY_CAPATH"
const EnvBoundaryClientCert = "BOUNDARY_CLIENT_CERT"
const EnvBoundaryClientKey = "BOUNDARY_CLIENT_KEY"
const EnvBoundaryClientTimeout = "BOUNDARY_CLIENT_TIMEOUT"
const EnvBoundaryTLSInsecure = "BOUNDARY_TLS_INSECURE"
const EnvBoundaryTLSServerName = "BOUNDARY_TLS_SERVER_NAME"
const EnvBoundaryMaxRetries = "BOUNDARY_MAX_RETRIES"
const EnvBoundaryToken = "BOUNDARY_TOKEN"
const EnvBoundaryRateLimit = "BOUNDARY_RATE_LIMIT"
const EnvBoundarySRVLookup = "BOUNDARY_SRV_LOOKUP"
const EnvBoundaryScopeId = "BOUNDARY_SCOPE_ID"
// Config is used to configure the creation of the client
type Config struct {
// Addr is the address of the Watchtower controller. This should be a
// complete URL such as "http://watchtower.example.com". If you need a custom
// Addr is the address of the Boundary controller. This should be a
// complete URL such as "http://boundary.example.com". If you need a custom
// SSL cert or want to enable insecure mode, you need to specify a custom
// HttpClient.
Addr string
// Token is the client token that reuslts from authentication and can be
// used to make calls into Watchtower
// used to make calls into Boundary
Token string
// HttpClient is the HTTP client to use. Watchtower sets sane defaults for
// HttpClient is the HTTP client to use. Boundary sets sane defaults for
// the http.Client and its associated http.Transport created in
// DefaultConfig. If you must modify Watchtower's defaults, it is
// DefaultConfig. If you must modify Boundary's defaults, it is
// suggested that you start with that client and modify as needed rather
// than start with an empty client (or http.DefaultClient).
HttpClient *http.Client
@@ -103,20 +103,20 @@ type Config struct {
}
// TLSConfig contains the parameters needed to configure TLS on the HTTP client
// used to communicate with Watchtower.
// used to communicate with Boundary.
type TLSConfig struct {
// CACert is the path to a PEM-encoded CA cert file to use to verify the
// Watchtower server SSL certificate.
// Boundary server SSL certificate.
CACert string
// CAPath is the path to a directory of PEM-encoded CA cert files to verify
// the Watchtower server SSL certificate.
// the Boundary server SSL certificate.
CAPath string
// ClientCert is the path to the certificate for Watchtower communication
// ClientCert is the path to the certificate for Boundary communication
ClientCert string
// ClientKey is the path to the private key for Watchtower communication
// ClientKey is the path to the private key for Boundary communication
ClientKey string
// ServerName, if set, is used to set the SNI host when connecting via
@@ -131,7 +131,7 @@ type TLSConfig struct {
// safe to modify the return value of this function.
//
// The default Addr is https://127.0.0.1:9200, but this can be overridden by
// setting the `WATCHTOWER_ADDR` environment variable.
// setting the `BOUNDARY_ADDR` environment variable.
//
// If an error is encountered, this will return nil.
func DefaultConfig() (*Config, error) {
@@ -237,7 +237,7 @@ func (c *Config) setAddr(addr string) error {
// Remove trailing or leading slashes
path := strings.Trim(u.Path, "/")
// Remove v1 in front or back (e.g. they could have
// https://watchtower.example.com/myinstall/v1 which would put it at the
// https://boundary.example.com/myinstall/v1 which would put it at the
// back)
path = strings.Trim(path, "v1")
// Finally check again to make sure any slashes are removed before we join
@@ -262,19 +262,19 @@ func (c *Config) ReadEnvironment() error {
var envServerName string
// Parse the environment variables
if v := os.Getenv(EnvWatchtowerAddr); v != "" {
if v := os.Getenv(EnvBoundaryAddr); v != "" {
c.Addr = v
}
if v := os.Getenv(EnvWatchtowerToken); v != "" {
if v := os.Getenv(EnvBoundaryToken); v != "" {
c.Token = v
}
if v := os.Getenv(EnvWatchtowerScopeId); v != "" {
if v := os.Getenv(EnvBoundaryScopeId); v != "" {
c.ScopeId = v
}
if v := os.Getenv(EnvWatchtowerMaxRetries); v != "" {
if v := os.Getenv(EnvBoundaryMaxRetries); v != "" {
maxRetries, err := strconv.ParseUint(v, 10, 32)
if err != nil {
return err
@@ -282,24 +282,24 @@ func (c *Config) ReadEnvironment() error {
c.MaxRetries = int(maxRetries)
}
if v := os.Getenv(EnvWatchtowerSRVLookup); v != "" {
if v := os.Getenv(EnvBoundarySRVLookup); v != "" {
var err error
lookup, err := strconv.ParseBool(v)
if err != nil {
return fmt.Errorf("could not parse %s", EnvWatchtowerSRVLookup)
return fmt.Errorf("could not parse %s", EnvBoundarySRVLookup)
}
c.SRVLookup = lookup
}
if t := os.Getenv(EnvWatchtowerClientTimeout); t != "" {
if t := os.Getenv(EnvBoundaryClientTimeout); t != "" {
clientTimeout, err := parseutil.ParseDurationSecond(t)
if err != nil {
return fmt.Errorf("could not parse %q", EnvWatchtowerClientTimeout)
return fmt.Errorf("could not parse %q", EnvBoundaryClientTimeout)
}
c.Timeout = clientTimeout
}
if v := os.Getenv(EnvWatchtowerRateLimit); v != "" {
if v := os.Getenv(EnvBoundaryRateLimit); v != "" {
rateLimit, burstLimit, err := parseRateLimit(v)
if err != nil {
return err
@@ -310,31 +310,31 @@ func (c *Config) ReadEnvironment() error {
// TLS Config
{
var foundTLSConfig bool
if v := os.Getenv(EnvWatchtowerCACert); v != "" {
if v := os.Getenv(EnvBoundaryCACert); v != "" {
foundTLSConfig = true
envCACert = v
}
if v := os.Getenv(EnvWatchtowerCAPath); v != "" {
if v := os.Getenv(EnvBoundaryCAPath); v != "" {
foundTLSConfig = true
envCAPath = v
}
if v := os.Getenv(EnvWatchtowerClientCert); v != "" {
if v := os.Getenv(EnvBoundaryClientCert); v != "" {
foundTLSConfig = true
envClientCert = v
}
if v := os.Getenv(EnvWatchtowerClientKey); v != "" {
if v := os.Getenv(EnvBoundaryClientKey); v != "" {
foundTLSConfig = true
envClientKey = v
}
if v := os.Getenv(EnvWatchtowerTLSInsecure); v != "" {
if v := os.Getenv(EnvBoundaryTLSInsecure); v != "" {
foundTLSConfig = true
var err error
envInsecure, err = strconv.ParseBool(v)
if err != nil {
return fmt.Errorf("could not parse WATCHTOWER_TLS_INSECURE")
return fmt.Errorf("could not parse BOUNDARY_TLS_INSECURE")
}
}
if v := os.Getenv(EnvWatchtowerTLSServerName); v != "" {
if v := os.Getenv(EnvBoundaryTLSServerName); v != "" {
foundTLSConfig = true
envServerName = v
}
@@ -361,7 +361,7 @@ func parseRateLimit(val string) (rate float64, burst int, err error) {
if err != nil {
rate, err = strconv.ParseFloat(val, 64)
if err != nil {
err = fmt.Errorf("%v was provided but incorrectly formatted", EnvWatchtowerRateLimit)
err = fmt.Errorf("%v was provided but incorrectly formatted", EnvBoundaryRateLimit)
}
burst = int(rate)
}
@@ -369,7 +369,7 @@ func parseRateLimit(val string) (rate float64, burst int, err error) {
return rate, burst, err
}
// Client is the client to the Watchtower API. Create a client with NewClient.
// Client is the client to the Boundary API. Create a client with NewClient.
type Client struct {
modifyLock sync.RWMutex
config *Config
@@ -377,10 +377,10 @@ type Client struct {
// NewClient returns a new client for the given configuration.
//
// If the configuration is nil, Watchtower will use configuration from
// If the configuration is nil, Boundary will use configuration from
// DefaultConfig(), which is the recommended starting configuration.
//
// If the environment variable `WATCHTOWER_TOKEN` is present, the token will be
// If the environment variable `BOUNDARY_TOKEN` is present, the token will be
// automatically added to the client. Otherwise, you must manually call
// `SetToken()`.
func NewClient(c *Config) (*Client, error) {
@@ -421,9 +421,9 @@ func NewClient(c *Config) (*Client, error) {
}, nil
}
// Sets the address of Watchtower in the client. The format of address should
// Sets the address of Boundary in the client. The format of address should
// be "<Scheme>://<Host>:<Port>". Setting this on a client will override the
// value of the WATCHTOWER_ADDR environment variable.
// value of the BOUNDARY_ADDR environment variable.
func (c *Client) SetAddr(addr string) error {
c.modifyLock.Lock()
defer c.modifyLock.Unlock()
@@ -595,7 +595,7 @@ func getBufferForJSON(val interface{}) (*bytes.Buffer, error) {
return bytes.NewBuffer(b), nil
}
// NewRequest creates a new raw request object to query the Watchtower controller
// NewRequest creates a new raw request object to query the Boundary controller
// configured for this client. This is an advanced method and generally
// doesn't need to be called externally.
func (c *Client) NewRequest(ctx context.Context, method, requestPath string, body interface{}, opt ...Option) (*retryablehttp.Request, error) {
@@ -742,7 +742,7 @@ func (c *Client) Do(r *retryablehttp.Request) (*Response, error) {
return !unicode.IsPrint(c)
})
if idx != -1 {
return nil, fmt.Errorf("configured Watchtower token contains non-printable characters and cannot be used")
return nil, fmt.Errorf("configured Boundary token contains non-printable characters and cannot be used")
}
if outputCurlString {
@@ -803,9 +803,9 @@ func (c *Client) Do(r *retryablehttp.Request) (*Response, error) {
"but the client is configured to use TLS. Please either enable TLS\n"+
"on the server or run the client with -address set to an address\n"+
"that uses the http protocol:\n\n"+
" watchtower <command> -address http://<address>\n\n"+
"You can also set the WATCHTOWER_ADDR environment variable:\n\n\n"+
" WATCHTOWER_ADDR=http://<address> watchtower <command>\n\n"+
" boundary <command> -address http://<address>\n\n"+
"You can also set the BOUNDARY_ADDR environment variable:\n\n\n"+
" BOUNDARY_ADDR=http://<address> boundary <command>\n\n"+
"where <address> is replaced by the actual address to the controller.",
err)
}
+2 -2
View File
@@ -10,8 +10,8 @@ import (
"github.com/kr/pretty"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/scopes"
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/scopes"
)
type Group struct {
+6 -6
View File
@@ -5,12 +5,12 @@ import (
"net/http"
"testing"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/groups"
"github.com/hashicorp/watchtower/api/scopes"
"github.com/hashicorp/watchtower/api/users"
"github.com/hashicorp/watchtower/internal/iam"
"github.com/hashicorp/watchtower/internal/servers/controller"
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/groups"
"github.com/hashicorp/boundary/api/scopes"
"github.com/hashicorp/boundary/api/users"
"github.com/hashicorp/boundary/internal/iam"
"github.com/hashicorp/boundary/internal/servers/controller"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
+1 -1
View File
@@ -1,7 +1,7 @@
package groups
import (
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/boundary/api"
)
// Option is a func that sets optional attributes for a call. This does not need
+2 -2
View File
@@ -7,8 +7,8 @@ import (
"net/url"
"time"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/scopes"
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/scopes"
)
type Host struct {
+2 -2
View File
@@ -7,8 +7,8 @@ import (
"net/url"
"time"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/scopes"
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/scopes"
)
type HostCatalog struct {
+1 -1
View File
@@ -1,7 +1,7 @@
package hosts
import (
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/boundary/api"
)
// Option is a func that sets optional attributes for a call. This does not need
+8 -8
View File
@@ -3,14 +3,14 @@ package main
import (
"text/template"
"github.com/hashicorp/watchtower/internal/gen/controller/api"
"github.com/hashicorp/watchtower/internal/gen/controller/api/resources/authmethods"
"github.com/hashicorp/watchtower/internal/gen/controller/api/resources/authtokens"
"github.com/hashicorp/watchtower/internal/gen/controller/api/resources/groups"
"github.com/hashicorp/watchtower/internal/gen/controller/api/resources/hosts"
"github.com/hashicorp/watchtower/internal/gen/controller/api/resources/roles"
"github.com/hashicorp/watchtower/internal/gen/controller/api/resources/scopes"
"github.com/hashicorp/watchtower/internal/gen/controller/api/resources/users"
"github.com/hashicorp/boundary/internal/gen/controller/api"
"github.com/hashicorp/boundary/internal/gen/controller/api/resources/authmethods"
"github.com/hashicorp/boundary/internal/gen/controller/api/resources/authtokens"
"github.com/hashicorp/boundary/internal/gen/controller/api/resources/groups"
"github.com/hashicorp/boundary/internal/gen/controller/api/resources/hosts"
"github.com/hashicorp/boundary/internal/gen/controller/api/resources/roles"
"github.com/hashicorp/boundary/internal/gen/controller/api/resources/scopes"
"github.com/hashicorp/boundary/internal/gen/controller/api/resources/users"
"google.golang.org/protobuf/proto"
)
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"
"github.com/hashicorp/watchtower/internal/gen/controller/protooptions"
"github.com/hashicorp/boundary/internal/gen/controller/protooptions"
"github.com/iancoleman/strcase"
)
+3 -3
View File
@@ -470,8 +470,8 @@ import (
"github.com/kr/pretty"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/scopes"
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/scopes"
)
type {{ .Name }} struct { {{ range .Fields }}
@@ -497,7 +497,7 @@ import (
"fmt"
"time"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/boundary/api"
)
// Option is a func that sets optional attributes for a call. This does not need
+1 -1
View File
@@ -8,9 +8,9 @@ import (
"strings"
"time"
"github.com/hashicorp/boundary/api/internal/strutil"
"github.com/hashicorp/errwrap"
sockaddr "github.com/hashicorp/go-sockaddr"
"github.com/hashicorp/watchtower/api/internal/strutil"
"github.com/mitchellh/mapstructure"
)
+1 -1
View File
@@ -1,7 +1,7 @@
package roles
import (
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/boundary/api"
)
// Option is a func that sets optional attributes for a call. This does not need
+2 -2
View File
@@ -10,8 +10,8 @@ import (
"github.com/kr/pretty"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/scopes"
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/scopes"
)
type Role struct {
+8 -8
View File
@@ -5,14 +5,14 @@ import (
"net/http"
"testing"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/groups"
"github.com/hashicorp/watchtower/api/internal/strutil"
"github.com/hashicorp/watchtower/api/roles"
"github.com/hashicorp/watchtower/api/scopes"
"github.com/hashicorp/watchtower/api/users"
"github.com/hashicorp/watchtower/internal/iam"
"github.com/hashicorp/watchtower/internal/servers/controller"
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/groups"
"github.com/hashicorp/boundary/api/internal/strutil"
"github.com/hashicorp/boundary/api/roles"
"github.com/hashicorp/boundary/api/scopes"
"github.com/hashicorp/boundary/api/users"
"github.com/hashicorp/boundary/internal/iam"
"github.com/hashicorp/boundary/internal/servers/controller"
"github.com/kr/pretty"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
+1 -1
View File
@@ -1,7 +1,7 @@
package scopes
import (
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/boundary/api"
)
// Option is a func that sets optional attributes for a call. This does not need
+3 -3
View File
@@ -5,9 +5,9 @@ import (
"net/http"
"testing"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/scopes"
"github.com/hashicorp/watchtower/internal/servers/controller"
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/scopes"
"github.com/hashicorp/boundary/internal/servers/controller"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"github.com/kr/pretty"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/boundary/api"
)
type Scope struct {
+1 -1
View File
@@ -1,7 +1,7 @@
package users
import (
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/boundary/api"
)
// Option is a func that sets optional attributes for a call. This does not need
+2 -2
View File
@@ -10,8 +10,8 @@ import (
"github.com/kr/pretty"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/scopes"
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/scopes"
)
type User struct {
+4 -4
View File
@@ -5,10 +5,10 @@ import (
"net/http"
"testing"
"github.com/hashicorp/watchtower/api"
"github.com/hashicorp/watchtower/api/users"
"github.com/hashicorp/watchtower/internal/iam"
"github.com/hashicorp/watchtower/internal/servers/controller"
"github.com/hashicorp/boundary/api"
"github.com/hashicorp/boundary/api/users"
"github.com/hashicorp/boundary/internal/iam"
"github.com/hashicorp/boundary/internal/servers/controller"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)