Documentation ¶
Overview ¶
Package serverclient contains helpers for the server API client.
Index ¶
Constants ¶
const ( // ServerAddr is the address for the Waypoint server. This should be // in the format of "ip:port" for TCP. EnvServerAddr = "WAYPOINT_SERVER_ADDR" // ServerTls should be any value that strconv.ParseBool parses as // true to connect to the server with TLS. EnvServerTls = "WAYPOINT_SERVER_TLS" EnvServerTlsSkipVerify = "WAYPOINT_SERVER_TLS_SKIP_VERIFY" // EnvServerToken is the token for authenticated with the server. EnvServerToken = "WAYPOINT_SERVER_TOKEN" // EnvContext specifies a named context to load. EnvContext = "WAYPOINT_CONTEXT" )
Common environment variables.
Variables ¶
var ErrNoServerConfig = errors.New("no server connection configuration found")
ErrNoServerConfig is the error when there is no server configuration found for connection.
Functions ¶
func Connect ¶
func Connect(ctx context.Context, opts ...ConnectOption) (*grpc.ClientConn, error)
Connect connects to the Waypoint server. This returns the raw gRPC connection. You'll have to wrap it in NewWaypointClient to get the Waypoint client. We return the raw connection so that you have control over how to close it, and to support potentially alternate services in the future.
func ContextConfig ¶
func ContextConfig(opts ...ConnectOption) (*clicontext.Config, error)
ContextConfig will return the context configuration for the given connection options.
Types ¶
type ConnectOption ¶
type ConnectOption func(*connectConfig) error
ConnectOption is used to configure how Waypoint server connection configuration is sourced.
func Auth ¶
func Auth() ConnectOption
Auth specifies that this server should require auth and therefore a token should be sourced from the environment and sent.
func FromContext ¶
func FromContext(st *clicontext.Storage, n string) ConnectOption
FromContext loads the context. This will prefer the given name. If name is empty, we'll respect the WAYPOINT_CONTEXT env var followed by the default context.
func FromContextConfig ¶
func FromContextConfig(cfg *clicontext.Config) ConnectOption
FromContextConfig loads a specific context config.
func FromEnv ¶
func FromEnv() ConnectOption
FromEnv sources the connection information from the environment using standard environment variables.
func Optional ¶
func Optional() ConnectOption
Optional specifies that getting server connection information is optional. If this is specified and no credentials are found, Connect will return (nil, nil). If this is NOT specified and no credentials are found, it is an error.
func Timeout ¶
func Timeout(t time.Duration) ConnectOption
Timeout specifies a connection timeout. This defaults to 5 seconds.
type StaticToken ¶
type StaticToken string
This is a weird type that only exists to satisify the interface required by grpc.WithPerRPCCredentials. That api is designed to incorporate things like OAuth but in our case, we really just want to send this static token through, but we still need to the dance.
func (StaticToken) GetRequestMetadata ¶
func (StaticToken) RequireTransportSecurity ¶
func (t StaticToken) RequireTransportSecurity() bool