client

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2025 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthUrlKey               = "server"
	AuthCAFileKey            = "certificate-authority"
	AuthRefreshTokenKey      = "refresh-token"
	AuthAccessTokenExpiryKey = "access-token-expiry"
	AuthClientIdKey          = "client-id"
)
View Source
const (
	// TestRootDirEnvKey is the environment variable key used to set the file system root when testing.
	TestRootDirEnvKey = "FLIGHTCTL_TEST_ROOT_DIR"
)

Variables

This section is empty.

Functions

func CreateAuthProvider added in v0.6.0

func CreateAuthProvider(authInfo AuthInfo, insecure bool) (login.AuthProvider, error)

func CreateTLSConfigFromConfig added in v0.4.0

func CreateTLSConfigFromConfig(config *Config) (*tls.Config, error)

func DefaultFlightctlClientConfigPath

func DefaultFlightctlClientConfigPath() (string, error)

DefaultFlightctlClientConfigPath returns the default path to the Flight Control client config file.

func GetAccessToken added in v0.6.0

func GetAccessToken(config *Config, configFilePath string) string

func NewFromConfig

func NewFromConfig(config *Config, configFilePath string, opts ...client.ClientOption) (*client.ClientWithResponses, error)

NewFromConfig returns a new Flight Control API client from the given config.

func NewFromConfigFile

func NewFromConfigFile(filename string, opts ...client.ClientOption) (*client.ClientWithResponses, error)

NewFromConfigFile returns a new Flight Control API client using the config read from the given file. Additional client options may be supplied and will be appended after the defaults.

func NewGRPCClientFromConfig

func NewGRPCClientFromConfig(config *Config, endpoint string) (grpc_v1.RouterServiceClient, error)

NewGRPCClientFromConfig returns a new gRPC Client from the given config.

func NewGrpcClientFromConfigFile

func NewGrpcClientFromConfigFile(filename string, endpoint string) (grpc_v1.RouterServiceClient, error)

NewFromConfigFile returns a new Flight Control API client using the config read from the given file.

func NewHTTPClientFromConfig

func NewHTTPClientFromConfig(config *Config) (*http.Client, error)

NewHTTPClientFromConfig returns a new HTTP Client from the given config.

func WithOrganization added in v0.10.0

func WithOrganization(orgID string) client.ClientOption

WithOrganization sets the organization ID in the request query parameters.

func WithQueryParam added in v0.10.0

func WithQueryParam(key, value string) client.ClientOption

WithQueryParam returns a ClientOption that appends a request editor which sets (or overrides) the given query parameter. If value is empty, the editor is a no-op so callers can pass it unconditionally.

func WriteConfig

func WriteConfig(filename string, server string, tlsServerName string, caCertPEM []byte, client *crypto.TLSCertificateConfig) error

WriteConfig writes a client config file using the given parameters.

Types

type AuthInfo

type AuthInfo struct {
	// ClientCertificate is the path to a client cert file for TLS.
	// +optional
	ClientCertificate string `json:"client-certificate,omitempty"`
	// ClientCertificateData contains PEM-encoded data from a client cert file for TLS. Overrides ClientCertificate.
	// +optional
	ClientCertificateData []byte `json:"client-certificate-data,omitempty"`
	// ClientKey is the path to a client key file for TLS.
	// +optional
	ClientKey string `json:"client-key,omitempty"`
	// ClientKeyData contains PEM-encoded data from a client key file for TLS. Overrides ClientKey.
	// +optional
	ClientKeyData []byte `json:"client-key-data,omitempty" datapolicy:"security-key"`
	// Bearer token for authentication
	// +optional
	Token string `json:"token,omitempty"`
	// The authentication provider (i.e. k8s, OIDC)
	// +optional
	AuthProvider *AuthProviderConfig `json:"auth-provider,omitempty"`
	// Organizations indicates the configured IdP supports organizations.
	// +optional
	OrganizationsEnabled bool `json:"organizations-enabled,omitempty"`
}

AuthInfo contains information for authenticating Flight Control API clients.

func (*AuthInfo) DeepCopy

func (a *AuthInfo) DeepCopy() *AuthInfo

func (*AuthInfo) Equal

func (a *AuthInfo) Equal(a2 *AuthInfo) bool

type AuthProviderConfig added in v0.6.0

type AuthProviderConfig struct {
	// Name is the name of the authentication provider
	Name string `json:"name"`
	// Config is a map of authentication provider-specific configuration
	Config map[string]string `json:"config,omitempty"`
}

func (*AuthProviderConfig) DeepCopy added in v0.6.0

func (a *AuthProviderConfig) DeepCopy() *AuthProviderConfig

func (*AuthProviderConfig) Equal added in v0.6.0

type Config

type Config struct {
	Service      Service  `json:"service"`
	AuthInfo     AuthInfo `json:"authentication"`
	Organization string   `json:"organization,omitempty"`

	// HTTPOptions contains HTTP client configuration options
	HTTPOptions []HTTPClientOption `json:"-"`
	// contains filtered or unexported fields
}

Config holds the information needed to connect to a Flight Control API server

func NewDefault

func NewDefault() *Config

func ParseConfigFile

func ParseConfigFile(filename string) (*Config, error)

func (*Config) AddHTTPOptions added in v0.10.0

func (c *Config) AddHTTPOptions(opts ...HTTPClientOption)

AddHTTPOptions adds HTTP client options to the config

func (*Config) DeepCopy

func (c *Config) DeepCopy() *Config

func (*Config) Equal

func (c *Config) Equal(c2 *Config) bool

func (*Config) Flatten

func (c *Config) Flatten() error

Reads the contents of all referenced files and embeds them in the config.

func (*Config) GetClientCertificatePath

func (c *Config) GetClientCertificatePath() string

func (*Config) GetClientKeyPath

func (c *Config) GetClientKeyPath() string

func (*Config) HasCredentials

func (c *Config) HasCredentials() bool

func (*Config) Persist

func (c *Config) Persist(filename string) error

func (*Config) SetBaseDir

func (c *Config) SetBaseDir(baseDir string)

func (*Config) Validate

func (c *Config) Validate() error

type HTTPClientOption added in v0.10.0

type HTTPClientOption func(*http.Client) error

HTTPClientOption is a functional option for configuring HTTP client behavior.

func WithCachedTransport added in v0.10.0

func WithCachedTransport() HTTPClientOption

WithCachedTransport caches the first transport it sees and replaces all future invocations with this transport. The purpose of this option is to reuse connection pools across areas that may be hard to wire together.

func WithDialer added in v0.10.0

func WithDialer(dialer *net.Dialer) HTTPClientOption

WithDialer configures the HTTP client to use the specified dialer.

func WithMaxIdleConnsPerHost added in v0.10.0

func WithMaxIdleConnsPerHost(conns int) HTTPClientOption

WithMaxIdleConnsPerHost configures the HTTP client to use the specified number of IdleConnsPerHost Also increases the MaxIdleConns configuration if the current setting is less than new configuration for IdleConnsPerHost

type Service

type Service struct {
	// Server is the URL of the Flight Control API server (the part before /api/v1/...).
	Server string `json:"server,omitempty"`
	// TLSServerName is passed to the server for SNI and is used in the client to check server certificates against.
	// If TLSServerName is empty, the hostname used to contact the server is used.
	// +optional
	TLSServerName string `json:"tls-server-name,omitempty"`
	// CertificateAuthority is the path to a cert file for the certificate authority.
	CertificateAuthority string `json:"certificate-authority,omitempty"`
	// CertificateAuthorityData contains PEM-encoded certificate authority certificates. Overrides CertificateAuthority
	CertificateAuthorityData []byte `json:"certificate-authority-data,omitempty"`
	InsecureSkipVerify       bool   `json:"insecureSkipVerify,omitempty"`
}

Service contains information how to connect to and authenticate the Flight Control API server.

func (*Service) DeepCopy

func (s *Service) DeepCopy() *Service

func (*Service) Equal

func (s *Service) Equal(s2 *Service) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL