config

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CLI_NAME                    = "kinde"
	USER_AGENT                  = "Kinde CLI"
	ConfigContextKey contextKey = "config"
)

Variables

This section is empty.

Functions

func Ctx

func Ctx(ctx context.Context, config IConfig) context.Context

Ctx returns a new context with the Config instance stored in it.

func FromContext

func FromContext[T any](ctx context.Context) *T

NewContext retrieves the Config instance from the context.

func RedactSecret added in v0.1.20

func RedactSecret(secret string) string

RedactSecret returns a redacted version of the secret for display purposes

Types

type Config

type Config struct {
	CurrentEnvironment string                 `json:"current"`
	Environments       map[string]Environment `json:"environments"`
}

func (*Config) GetEnvironment

func (i *Config) GetEnvironment() *Environment

GetEnvironment implements IConfig.

func (*Config) PersistConfig

func (c *Config) PersistConfig() error

PersistConfig writes the current configuration to the config file.

func (*Config) SetEnvironment

func (i *Config) SetEnvironment(f func(e *Environment)) error

func (*Config) SwitchEnvironment

func (c *Config) SwitchEnvironment(val string) error

SwitchEnvironment sets the current environment to the specified value, creating it if it doesn't exist.

func (*Config) Validate

func (c *Config) Validate() (error, bool)

type Environment

type Environment struct {
	DomainName   string `json:"domain_name"`
	ClientID     string `json:"client_id,omitempty"`
	ClientSecret string `json:"client_secret,omitempty"`
}

func (*Environment) ClearClientSecretFromSession added in v0.1.20

func (env *Environment) ClearClientSecretFromSession() error

ClearClientSecretFromSession removes the client secret from the CLI session

func (*Environment) GetClientSecretFromSession added in v0.1.20

func (env *Environment) GetClientSecretFromSession() (string, error)

GetClientSecretFromSession retrieves the client secret from the CLI session

func (*Environment) NewClientCredentialsFlow

func (env *Environment) NewClientCredentialsFlow() (client_credentials.IClientCredentialsFlow, error)

func (*Environment) NewDeviceAuthorizationFlow

func (env *Environment) NewDeviceAuthorizationFlow() (authorization_code.IDeviceAuthorizationFlow, error)

NewDeviceAuthorizationFlow creates a new Device Authorization Flow with the given options.

func (*Environment) StoreClientSecretInSession added in v0.1.20

func (env *Environment) StoreClientSecretInSession(secret string) error

StoreClientSecretInSession stores the client secret in the CLI session

type IConfig

type IConfig interface {
	Validate() (error, bool)
	SwitchEnvironment(val string) error
	PersistConfig() error
	GetEnvironment() *Environment
	SetEnvironment(f func(e *Environment)) error
}

used for testing

func NewConfig

func NewConfig() (IConfig, error)

NewConfig initializes a new Config instance, reading from the config file if it exists.

type IEnvironment

type IEnvironment interface {
	NewDeviceAuthorizationFlow() (authorization_code.IDeviceAuthorizationFlow, error)
	NewClientCredentialsFlow() (client_credentials.IClientCredentialsFlow, error)
}

Jump to

Keyboard shortcuts

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