config

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceName  = "StreamNativeMCP"
	KeychainName = "snmcp"
)
View Source
const (
	EnvConfigDir               = "SNMCP_CONFIG_DIR"
	GlobalDefaultIssuer        = "https://auth.streamnative.cloud/"
	GlobalDefaultClientID      = "AJYEdHWi9EFekEaUXkPWA2MqQ3lq1NrI"
	GlobalDefaultAudience      = "https://api.streamnative.cloud"
	GlobalDefaultAPIServer     = "https://api.streamnative.cloud"
	GlobalDefaultProxyLocation = "https://proxy.streamnative.cloud"
	GlobalDefaultLogLocation   = "https://log.streamnative.cloud"

	// Environment variable prefix
	EnvPrefix = "SNMCP"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	// the OAuth 2.0 issuer endpoint
	IssuerEndpoint string `yaml:"issuer"`
	// the audience identifier for the API server (default: server URL)
	Audience string `yaml:"audience"`
	// the client ID to use for authorization grants (note: not used for service accounts)
	ClientID string `yaml:"client-id"`
}

func (*Auth) Issuer

func (a *Auth) Issuer() auth.Issuer

func (*Auth) Validate

func (a *Auth) Validate() error

type AuthOptions

type AuthOptions struct {
	BackendOverride string

	// AuthOptions is a facade for the token store
	// note: call Complete before using the token store methods
	store.Store
	// contains filtered or unexported fields
}

func NewDefaultAuthOptions

func NewDefaultAuthOptions() AuthOptions

func (*AuthOptions) AddFlags

func (o *AuthOptions) AddFlags(cmd *cobra.Command)

func (*AuthOptions) Complete

func (o *AuthOptions) Complete(storage Storage) error

type Context

type Context struct {
	Organization   string `yaml:"organization,omitempty"`
	PulsarInstance string `yaml:"pulsar-instance,omitempty"`
	PulsarCluster  string `yaml:"pulsar-cluster,omitempty"`
}

type ExternalKafka

type ExternalKafka struct {
	BootstrapServers  string
	AuthType          string
	AuthMechanism     string
	AuthUser          string
	AuthPass          string
	UseTLS            bool
	ClientKeyFile     string
	ClientCertFile    string
	CaFile            string
	SchemaRegistryURL string

	SchemaRegistryAuthUser    string
	SchemaRegistryAuthPass    string
	SchemaRegistryBearerToken string
}

type ExternalPulsar

type ExternalPulsar struct {
	ServiceURL                    string
	WebServiceURL                 string
	Token                         string
	AuthPlugin                    string
	AuthParams                    string
	TLSAllowInsecureConnection    bool
	TLSEnableHostnameVerification bool
	TLSTrustCertsFilePath         string
	TLSCertFile                   string
	TLSKeyFile                    string
}

type JWTTokenSource added in v0.1.11

type JWTTokenSource struct {
	// contains filtered or unexported fields
}

JWTTokenSource implements oauth2.TokenSource interface for static JWT tokens

func NewJWTTokenSource added in v0.1.11

func NewJWTTokenSource(jwtToken string) *JWTTokenSource

NewJWTTokenSource creates a new token source for static JWT tokens

func (*JWTTokenSource) Token added in v0.1.11

func (j *JWTTokenSource) Token() (*oauth2.Token, error)

Token implements the oauth2.TokenSource interface for static JWT tokens

type OAuth2TokenRefresher

type OAuth2TokenRefresher struct {
	// contains filtered or unexported fields
}

OAuth2TokenRefresher implements oauth2.TokenSource interface for refreshing OAuth2 tokens This is now a wrapper around the cache.CachingTokenSource to leverage the existing token caching

func NewOAuth2TokenRefresher

func NewOAuth2TokenRefresher(tokenStore store.Store, audience string, refresher auth.AuthorizationGrantRefresher) (*OAuth2TokenRefresher, error)

NewOAuth2TokenRefresher creates a new token refresher that uses the stored token cache

func (*OAuth2TokenRefresher) Token

func (t *OAuth2TokenRefresher) Token() (*oauth2.Token, error)

Token implements the oauth2.TokenSource interface, leveraging the cached token

type Options

type Options struct {
	AuthOptions
	ConfigDir  string
	ConfigPath string
	Server     string
	// the OAuth 2.0 issuer endpoint
	IssuerEndpoint string
	// the audience identifier for the API server (default: server URL)
	Audience string
	// the client ID to use for authorization grants (note: not used for service accounts)
	ClientID       string
	Organization   string
	PulsarInstance string
	PulsarCluster  string
	ProxyLocation  string
	LogLocation    string
	KeyFile        string

	UseExternalKafka  bool
	UseExternalPulsar bool
	Kafka             ExternalKafka
	Pulsar            ExternalPulsar
}

Options represents the common options used throughout the program.

func NewConfigOptions

func NewConfigOptions() *Options

NewConfigOptions creates and returns a new Options instance with default values

func (*Options) AddFlags

func (o *Options) AddFlags(cmd *cobra.Command)

AddFlags adds command-line flags for Options

func (*Options) Complete

func (o *Options) Complete() error

Complete completes options from the provided values

func (*Options) GetConfigDirectory

func (o *Options) GetConfigDirectory() string

func (*Options) LoadConfig

func (o *Options) LoadConfig() (*SnConfig, error)

func (*Options) LoadConfigOrDie

func (o *Options) LoadConfigOrDie() *SnConfig

func (*Options) SaveConfig

func (o *Options) SaveConfig(config *SnConfig) error

type SNCloudContext added in v0.1.11

type SNCloudContext struct {
	IssuerURL      string
	Audience       string
	KeyFilePath    string
	JWTToken       string
	APIURL         string
	LogAPIURL      string
	Timeout        time.Duration
	Organization   string
	TokenStore     store.Store
	PulsarInstance string
	PulsarCluster  string
}

SNCloudContext represents the configuration context for StreamNative Cloud session

type Session added in v0.1.11

type Session struct {
	Ctx            SNCloudContext
	APIClient      *sncloud.APIClient
	LogClient      *http.Client
	TokenRefresher *OAuth2TokenRefresher
	TokenSource    oauth2.TokenSource
	Configuration  *sncloud.Configuration
	// contains filtered or unexported fields
}

Session represents a StreamNative Cloud session with managed clients

func NewSNCloudSession added in v0.1.11

func NewSNCloudSession(ctx SNCloudContext) (*Session, error)

NewSNCloudSession creates a new StreamNative Cloud session with the provided context

func NewSNCloudSessionFromOptions added in v0.1.11

func NewSNCloudSessionFromOptions(options *Options) (*Session, error)

NewSNCloudSessionFromOptions creates a new StreamNative Cloud session from configuration options

func (*Session) Close added in v0.1.11

func (s *Session) Close() error

Close closes the session and cleans up resources

func (*Session) GetAPIClient added in v0.1.11

func (s *Session) GetAPIClient() (*sncloud.APIClient, error)

GetAPIClient returns the API client for the session, initializing it if necessary

func (*Session) GetLogClient added in v0.1.11

func (s *Session) GetLogClient() (*http.Client, error)

GetLogClient returns the log client for the session, initializing it if necessary

type SnConfig

type SnConfig struct {
	// the API server endpoint
	Server string `yaml:"server"`
	// CA bundle (base64, PEM)
	CertificateAuthorityData string `yaml:"certificate-authority-data"`
	// indicates whether to skip TLS verification
	InsecureSkipTLSVerify bool `yaml:"insecure-skip-tls-verify"`
	// user auth information
	Auth Auth `yaml:"auth"`
	// settable context
	Context       Context `yaml:"context"`
	ProxyLocation string  `yaml:"proxy-location"`
	LogLocation   string  `yaml:"log-location"`
	KeyFile       string  `yaml:"key-file"`

	ExternalKafka  *ExternalKafka  `yaml:"external-kafka"`
	ExternalPulsar *ExternalPulsar `yaml:"external-pulsar"`
}

type Storage

type Storage interface {
	// Gets the config directory for configuration files, credentials and caches
	GetConfigDirectory() string

	// LoadConfig loads the raw configuration from storage.
	LoadConfig() (*SnConfig, error)

	// LoadConfigOrDie loads the raw configuration from storage, or dies if unable to.
	LoadConfigOrDie() *SnConfig

	// SaveConfig saves the given configuration to storage, overwriting any previous configuration.
	SaveConfig(config *SnConfig) error
}

Jump to

Keyboard shortcuts

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