config

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Overview

Package config contains the wmctl CLI tool configuration.

Package config contains the wmctl CLI tool configuration.

Index

Constants

View Source
const (
	// APIVersion is the version of the API to use.
	APIVersion = "webmesh.io/v1"
	// Kind is the kind of the configuration. It should always be "Config".
	Kind = "Config"
)

Variables

View Source
var (
	// DefaultConfigPath is the default path to the CLI configuration file.
	DefaultConfigPath = filepath.Join(".wmctl", "config.yaml")
)

Functions

func LeaderStreamClientInterceptor

func LeaderStreamClientInterceptor() grpc.StreamClientInterceptor

LeaderStreamClientInterceptor returns a gRPC stream client interceptor that adds the prefer-leader metadata to the outgoing context.

func LeaderUnaryClientInterceptor

func LeaderUnaryClientInterceptor() grpc.UnaryClientInterceptor

LeaderUnaryClientInterceptor returns a gRPC unary client interceptor that adds the prefer-leader metadata to the outgoing context.

func RequestTimeoutStreamClientInterceptor

func RequestTimeoutStreamClientInterceptor(timeout time.Duration) grpc.StreamClientInterceptor

RequestTimeoutStreamClientInterceptor returns a gRPC stream client interceptor that adds a timeout to the outgoing context.

func RequestTimeoutUnaryClientInterceptor

func RequestTimeoutUnaryClientInterceptor(timeout time.Duration) grpc.UnaryClientInterceptor

RequestTimeoutUnaryClientInterceptor returns a gRPC unary client interceptor that adds a timeout to the outgoing context.

Types

type Cluster

type Cluster struct {
	// Name is the name of the Cluster.
	Name string `yaml:"name" json:"name"`
	// Cluster is the configuration for the cluster.
	Cluster ClusterConfig `yaml:"cluster,omitempty" json:"cluster,omitempty"`
}

Cluster is the named configuration for a cluster.

type ClusterConfig

type ClusterConfig struct {
	// Server is the URL of a discovery node in the cluster.
	Server string `yaml:"server,omitempty" json:"server,omitempty"`
	// Insecure controls whether TLS should be disabled for the cluster connection.
	Insecure bool `yaml:"insecure,omitempty" json:"insecure,omitempty"`
	// TLSVerifyChainOnly controls whether only the cluster's TLS chain should be verified.
	TLSVerifyChainOnly bool `yaml:"tls-verify-chain-only,omitempty" json:"tls-verify-chain-only,omitempty"`
	// TLSSkipVerify controls whether the cluster's TLS certificate should be verified.
	TLSSkipVerify bool `yaml:"tls-skip-verify,omitempty" json:"tls-skip-verify,omitempty"`
	// CertificateAuthorityData is the base64-encoded certificate authority data for the cluster.
	CertificateAuthorityData string `yaml:"certificate-authority-data,omitempty" json:"certificate-authority-data,omitempty"`
	// PreferLeader controls whether the client should prefer to connect to the cluster leader.
	PreferLeader bool `yaml:"prefer-leader,omitempty" json:"prefer-leader,omitempty"`
	// ConnectTimeout is the timeout for connecting to the cluster.
	ConnectTimeout Duration `yaml:"connect-timeout,omitempty" json:"connect-timeout,omitempty"`
	// RequestTimeout is the timeout for requests to the cluster.
	RequestTimeout Duration `yaml:"request-timeout,omitempty" json:"request-timeout,omitempty"`
}

ClusterConfig is the configuration for a cluster.

type Config

type Config struct {
	// APIVersion is the version of the API to use.
	APIVersion string `yaml:"apiVersion" json:"apiVersion"`
	// Kind is the kind of the configuration. It should always be "Config".
	Kind string `yaml:"kind" json:"kind"`
	// Clusters is the list of clusters to connect to.
	Clusters []Cluster `yaml:"clusters,omitempty" json:"clusters,omitempty"`
	// Users is the list of users to connect as.
	Users []User `yaml:"users,omitempty" json:"users,omitempty"`
	// Contexts is the list of contexts to connect with.
	Contexts []Context `yaml:"contexts,omitempty" json:"contexts,omitempty"`
	// CurrentContext is the name of the current context.
	CurrentContext string `yaml:"current-context,omitempty" json:"current-context,omitempty"`
}

Config is the wmctl CLI tool configuration.

func FromFile

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

FromFile creates a configuration from the given filename.

func FromReader

func FromReader(r io.Reader) (*Config, error)

FromReader creates a configuration from the given reader.

func New

func New() *Config

New creates a new configuration.

func (*Config) BindFlags

func (c *Config) BindFlags(flags *pflag.FlagSet)

BindFlags binds the configuration to the given flagset. It should be called before flags are parsed.

func (*Config) DialCurrent

func (c *Config) DialCurrent() (*grpc.ClientConn, error)

DialCurrent connects to the current context.

func (*Config) GetCluster

func (c *Config) GetCluster(name string) *ClusterConfig

GetCluster gets a cluster by name.

func (*Config) GetContext

func (c *Config) GetContext(name string) *ContextConfig

GetContext gets a context by name.

func (*Config) GetCurrentCluster

func (c *Config) GetCurrentCluster() *ClusterConfig

GetCurrentCluster returns the current cluster.

func (*Config) GetCurrentContext

func (c *Config) GetCurrentContext() *ContextConfig

GetCurrentContext returns the current context.

func (*Config) GetCurrentUser

func (c *Config) GetCurrentUser() *UserConfig

GetCurrentUser returns the current user.

func (*Config) GetUser

func (c *Config) GetUser(name string) *UserConfig

GetUser gets a user by name.

func (*Config) LoadFile

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

LoadFile loads the configuration from the given filename.

func (*Config) Marshal

func (c *Config) Marshal(w io.Writer) error

Marshal marshals the configuration to a writer.

func (*Config) NewAdminClient

func (c *Config) NewAdminClient() (v1.AdminClient, io.Closer, error)

NewAdminClient creates a new Admin gRPC client for the current context.

func (*Config) NewMeshClient

func (c *Config) NewMeshClient() (v1.MeshClient, io.Closer, error)

NewMeshClient creates a new Mesh gRPC client for the current context.

func (*Config) NewNodeClient

func (c *Config) NewNodeClient() (v1.NodeClient, io.Closer, error)

NewNodeClient creates a new Node gRPC client for the current context.

func (*Config) NewWebRTCClient

func (c *Config) NewWebRTCClient() (v1.WebRTCClient, io.Closer, error)

NewWebRTCClient creates a new WebRTC gRPC client for the current context.

func (*Config) SetCurrentContext

func (c *Config) SetCurrentContext(name string)

SetCurrentContext sets the current context.

func (*Config) TLSConfig

func (c *Config) TLSConfig() (*tls.Config, error)

TLSConfig returns the TLS configuration for the current context.

func (*Config) Unmarshal

func (c *Config) Unmarshal(r io.Reader) error

Unmarshal unmarshals the configuration from the given reader.

func (*Config) WriteTo

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

WriteTo writes the configuration to a file.

type Context

type Context struct {
	// Name is the name of the context.
	Name string `yaml:"name" json:"name"`
	// Context is the configuration for the context.
	Context ContextConfig `yaml:"context,omitempty" json:"context,omitempty"`
}

Context is the named configuration for a context.

type ContextConfig

type ContextConfig struct {
	// Cluster is the name of the cluster to connect to.
	Cluster string `yaml:"cluster,omitempty" json:"cluster,omitempty"`
	// User is the name of the user to connect as.
	User string `yaml:"user,omitempty" json:"user,omitempty"`
}

ContextConfig is the configuration for a context.

type Duration

type Duration struct{ time.Duration }

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (interface{}, error)

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(data []byte) error

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(value *yaml.Node) error

type User

type User struct {
	// Name is the name of the user.
	Name string `yaml:"name" json:"name"`
	// User is the configuration for the user.
	User UserConfig `yaml:"user,omitempty" json:"user,omitempty"`
}

User is the named configuration for a user.

type UserConfig

type UserConfig struct {
	// ClientCertificateData is the base64-encoded client certificate data for the user.
	ClientCertificateData string `yaml:"client-certificate-data,omitempty" json:"client-certificate-data,omitempty"`
	// ClientKeyData is the base64-encoded client key data for the user.
	ClientKeyData string `yaml:"client-key-data,omitempty" json:"client-key-data,omitempty"`
	// BasicAuthUsername is the username for basic authentication.
	BasicAuthUsername string `yaml:"basic-auth-username,omitempty" json:"basic-auth-username,omitempty"`
	// BasicAuthPassword is the password for basic authentication.
	BasicAuthPassword string `yaml:"basic-auth-password,omitempty" json:"basic-auth-password,omitempty"`
	// LDAPUsername is the username for LDAP authentication.
	LDAPUsername string `yaml:"ldap-username,omitempty" json:"ldap-username,omitempty"`
	// LDAPPassword is the password for LDAP authentication.
	LDAPPassword string `yaml:"ldap-password,omitempty" json:"ldap-password,omitempty"`
}

UserConfig is the configuration for a user.

Jump to

Keyboard shortcuts

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