settings

package
v0.0.0-...-4c964c4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// KeySecretScanningEnabled [bool] enables secret scanning if set to true.
	KeySecretScanningEnabled     Key = "secret_scanning_enabled"
	DefaultSecretScanningEnabled     = false
	KeyAIReviewEnabled           Key = "ai_review_enabled"
	DefaultAIReviewEnabled           = false
	KeyFileSizeLimit             Key = "file_size_limit"
	DefaultFileSizeLimit             = int64(5e+8) // 500MB

	// ContainerReadOnly [bool] disable write operates, used for gc
	ContainerReadOnly Key = "container_read_only"

	KeyInstallID     Key = "install_id"
	DefaultInstallID     = string("")
)

Functions

func RepoGet

func RepoGet[T any](
	ctx context.Context,
	s *Service,
	repoID int64,
	key Key,
	dflt T,
) (T, error)

RepoGet is a helper method for getting a setting of a specific type for a repo.

func RepoGetRequired

func RepoGetRequired[T any](
	ctx context.Context,
	s *Service,
	repoID int64,
	key Key,
) (T, error)

RepoGetRequired is a helper method for getting a setting of a specific type for a repo. If the setting isn't found, an error is returned.

func SystemGet

func SystemGet[T any](
	ctx context.Context,
	s *Service,
	key Key,
	dflt T,
) (T, error)

Types

type Key

type Key string

type KeyValue

type KeyValue struct {
	Key   Key
	Value any
}

KeyValue is a struct used for upserting many entries.

type Service

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

Service is used to enhance interaction with the settings store.

func NewService

func NewService(
	settingsStore appstore.SettingsStore,
	ruleStore appstore.RuleStore,
) *Service

func ProvideService

func ProvideService(
	settingsStore store.SettingsStore,
	ruleStore store.RuleStore,
) *Service

func (*Service) Get

func (s *Service) Get(
	ctx context.Context,
	scope enum.SettingsScope,
	scopeID int64,
	key Key,
	out any,
) (bool, error)

Get returns the value of the setting with the given key for the given scope.

func (*Service) Map

func (s *Service) Map(
	ctx context.Context,
	scope enum.SettingsScope,
	scopeID int64,
	handlers ...SettingHandler,
) error

Map maps all available settings using the provided handlers for the given scope.

func (*Service) RepoGet

func (s *Service) RepoGet(
	ctx context.Context,
	repoID int64,
	key Key,
	out any,
) (bool, error)

RepoGet returns the value of the setting with the given key for the given repo.

func (*Service) RepoMap

func (s *Service) RepoMap(
	ctx context.Context,
	repoID int64,
	handlers ...SettingHandler,
) error

RepoMap maps all available settings using the provided handlers for the given repo.

func (*Service) RepoSet

func (s *Service) RepoSet(
	ctx context.Context,
	repoID int64,
	key Key,
	value any,
) error

RepoSet sets the value of the setting with the given key for the given repo.

func (*Service) RepoSetMany

func (s *Service) RepoSetMany(
	ctx context.Context,
	repoID int64,
	keyValues ...KeyValue,
) error

RepoSetMany sets the value of the settings with the given keys for the given repo.

func (*Service) Set

func (s *Service) Set(
	ctx context.Context,
	scope enum.SettingsScope,
	scopeID int64,
	key Key,
	value any,
) error

Set sets the value of the setting with the given key for the given scope.

func (*Service) SetMany

func (s *Service) SetMany(
	ctx context.Context,
	scope enum.SettingsScope,
	scopeID int64,
	keyValues ...KeyValue,
) error

SetMany sets the value of the settings with the given keys for the given scope.

func (*Service) SystemGet

func (s *Service) SystemGet(
	ctx context.Context,
	key Key,
	out any,
) (bool, error)

SystemGet returns the value of the setting with the given key for the system.

func (*Service) SystemMap

func (s *Service) SystemMap(
	ctx context.Context,
	handlers ...SettingHandler,
) error

SystemMap maps all available settings using the provided handlers for the system.

func (*Service) SystemSet

func (s *Service) SystemSet(
	ctx context.Context,
	key Key,
	value any,
) error

SystemSet sets the value of the setting with the given key for the system.

func (*Service) SystemSetMany

func (s *Service) SystemSetMany(
	ctx context.Context,
	keyValues ...KeyValue,
) error

SystemSetMany sets the values of the settings with the given keys for the system.

type SettingHandler

type SettingHandler interface {
	Key() Key
	Required() bool
	Handle(ctx context.Context, raw []byte) error
}

SettingHandler is an abstraction of a component that's handling a single setting value as part of calling service.Map.

func Mapping

func Mapping[T any](key Key, target *T) SettingHandler

Mapping returns a SettingHandler that maps the value of the setting with the given key to the target.

func MappingRequired

func MappingRequired[T any](key Key, target *T) SettingHandler

MappingRequired returns a SettingHandler that maps the value of the setting with the given key to the target. If the setting wasn't found an error is returned.

Jump to

Keyboard shortcuts

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