profile

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

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

Go to latest
Published: Feb 13, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package profile contains profile related code

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResetRCProvider

func ResetRCProvider()

ResetRCProvider destroys the singleton instance. This should only be used in tests. TODO Turn this back into a proper Component so that we can mock it instead of using a singleton.

func SetGlobalProfileConfigMap

func SetGlobalProfileConfigMap(configMap ProfileConfigMap)

SetGlobalProfileConfigMap sets global globalProfileConfigMap

Types

type ProfileConfig

type ProfileConfig struct {
	DefinitionFile string                              `yaml:"definition_file"`
	Definition     profiledefinition.ProfileDefinition `yaml:"definition"`

	IsUserProfile bool `yaml:"-"`
}

ProfileConfig represents a profile configuration.

func (ProfileConfig) Clone

func (p ProfileConfig) Clone() ProfileConfig

Clone duplicates a ProfileConfig

type ProfileConfigMap

type ProfileConfigMap map[string]ProfileConfig

ProfileConfigMap is a set of ProfileConfig instances each identified by name.

func GetGlobalProfileConfigMap

func GetGlobalProfileConfigMap() ProfileConfigMap

GetGlobalProfileConfigMap gets global globalProfileConfigMap

func (ProfileConfigMap) Clone

func (pcm ProfileConfigMap) Clone() ProfileConfigMap

Clone duplicates a ProfileConfigMap

type Provider

type Provider interface {
	// HasProfile returns true if and only if we have a profile by this name.
	HasProfile(profileName string) bool
	// GetProfile returns the profile with this name, or nil if there isn't one.
	GetProfile(profileName string) *ProfileConfig
	// GetProfileForSysObjectID returns the best matching profile for this sysObjectID, or nil if there isn't one.
	GetProfileForSysObjectID(sysObjectID string) (*ProfileConfig, error)
	// LastUpdated returns when this Provider last changed
	LastUpdated() time.Time
}

Provider is an interface that provides profiles by name

func GetProfileProvider

func GetProfileProvider(initConfigProfiles ProfileConfigMap) (Provider, error)

GetProfileProvider returns a Provider that knows the on-disk profiles as well as any overrides from the initConfig.

func NewRCProvider

func NewRCProvider(client rcclient.Component) (Provider, error)

NewRCProvider returns a profile provider that subscribes to remote configuration and receives profile updates from the backend. Multiple calls will return the same singleton object.

func StaticProvider

func StaticProvider(profiles ProfileConfigMap) Provider

StaticProvider makes a provider that serves the static data from this config map.

type UpdatableProvider

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

UpdatableProvider is a thread-safe Provider that supports updating the default/user profiles

func (*UpdatableProvider) GetProfile

func (up *UpdatableProvider) GetProfile(profileName string) *ProfileConfig

GetProfile implements Provider.GetProfile

func (*UpdatableProvider) GetProfileForSysObjectID

func (up *UpdatableProvider) GetProfileForSysObjectID(sysObjectID string) (*ProfileConfig, error)

GetProfileForSysObjectID implements Provider.GetProfileForSysObjectID

func (*UpdatableProvider) HasProfile

func (up *UpdatableProvider) HasProfile(profileName string) bool

HasProfile implements Provider.HasProfile

func (*UpdatableProvider) LastUpdated

func (up *UpdatableProvider) LastUpdated() time.Time

LastUpdated implements Provider.LastUpdated

func (*UpdatableProvider) Update

func (up *UpdatableProvider) Update(userProfiles, defaultProfiles ProfileConfigMap, now time.Time)

Update installs new user and default profiles.

Jump to

Keyboard shortcuts

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