config

package
v0.1.16-rc.2 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package config provides configuration loading and client setup helpers.

Index

Constants

View Source
const (
	// ServiceName is the name used for keyring service.
	ServiceName = "StreamNativeMCP"
	// KeychainName is the name of the macOS keychain.
	KeychainName = "snmcp"
)
View Source
const (
	// EnvConfigDir overrides the default config directory.
	EnvConfigDir = "SNMCP_CONFIG_DIR"
	// GlobalDefaultIssuer is the default OAuth2 issuer.
	GlobalDefaultIssuer = "https://auth.streamnative.cloud/"
	// GlobalDefaultClientID is the default OAuth2 client ID.
	GlobalDefaultClientID = "AJYEdHWi9EFekEaUXkPWA2MqQ3lq1NrI"
	// GlobalDefaultAudience is the default OAuth2 audience.
	GlobalDefaultAudience = "https://api.streamnative.cloud"
	// GlobalDefaultAPIServer is the default API server URL.
	GlobalDefaultAPIServer = "https://api.streamnative.cloud"
	// GlobalDefaultProxyLocation is the default proxy URL.
	GlobalDefaultProxyLocation = "https://proxy.streamnative.cloud"
	// GlobalDefaultLogLocation is the default log API URL.
	GlobalDefaultLogLocation = "https://log.streamnative.cloud"

	// EnvPrefix is the 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"`
}

Auth holds authentication configuration for the StreamNative API.

func (*Auth) Issuer

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

Issuer builds an auth.Issuer from the configuration.

func (*Auth) Validate

func (a *Auth) Validate() error

Validate validates the auth configuration fields.

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
}

AuthOptions provides configuration options for authentication.

func NewDefaultAuthOptions

func NewDefaultAuthOptions() AuthOptions

NewDefaultAuthOptions creates a new AuthOptions with default values.

func (*AuthOptions) AddFlags

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

AddFlags registers authentication flags on the command.

func (*AuthOptions) Complete

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

Complete initializes the auth backend using the provided storage.

type Context

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

Context holds the default context for cluster connections.

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
}

ExternalKafka holds connection settings for an external Kafka cluster.

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
}

ExternalPulsar holds connection settings for an external Pulsar cluster.

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

GetConfigDirectory returns the directory used for configuration data.

func (*Options) LoadConfig

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

LoadConfig loads configuration from the current in-memory options.

func (*Options) LoadConfigOrDie

func (o *Options) LoadConfigOrDie() *SnConfig

LoadConfigOrDie loads configuration and ignores errors.

func (*Options) SaveConfig

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

SaveConfig persists configuration to disk.

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"`
}

SnConfig holds the StreamNative MCP Server configuration.

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
}

Storage defines the interface for persisting configuration and credentials.

Jump to

Keyboard shortcuts

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