Documentation
¶
Index ¶
- func ProviderDefaults(ctx context.Context, cloudType string, providerGetter ModelConfigProviderFunc) (map[string]any, error)
- type ModelConfigProviderFunc
- type ModelDefaultsProvider
- type ModelDefaultsProviderFunc
- type Service
- func (s *Service) CloudDefaults(ctx context.Context, cloudName string) (modeldefaults.ModelDefaultAttributes, error)
- func (s *Service) ModelDefaults(ctx context.Context, uuid coremodel.UUID) (modeldefaults.Defaults, error)
- func (s *Service) ModelDefaultsProvider(uuid coremodel.UUID) ModelDefaultsProviderFunc
- func (s *Service) RemoveCloudDefaults(ctx context.Context, cloudName string, removeAttrs []string) error
- func (s *Service) RemoveCloudRegionDefaults(ctx context.Context, cloudName, regionName string, removeAttrs []string) error
- func (s *Service) UpdateCloudDefaults(ctx context.Context, cloudName string, updateAttrs map[string]any) error
- func (s *Service) UpdateCloudRegionDefaults(ctx context.Context, cloudName string, regionName string, ...) error
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProviderDefaults ¶
func ProviderDefaults( ctx context.Context, cloudType string, providerGetter ModelConfigProviderFunc, ) (map[string]any, error)
ProviderDefaults is responsible for wrangling and bringing together the model defaults that should be applied to model from a given provider. There are typically two types of defaults a provider has. The first is the defaults for the keys the provider extends model config with. These are generally provider specific keys and only make sense in the context of the provider. The second is defaults the provider can suggest for controller wide attributes. Most commonly this is providing a default for the storage to use in a model.
Types ¶
type ModelConfigProviderFunc ¶
type ModelConfigProviderFunc func(string) (environs.ModelConfigProvider, error)
ModelConfigProviderFunc describes a type that is able to return a environs.ModelConfigProvider for the specified cloud type. If the no model config provider exists for the supplied cloud type then a coreerrors.NotFound error is returned. If the cloud type provider does not support model config then a coreerrors.NotSupported error is returned.
func ProviderModelConfigGetter ¶
func ProviderModelConfigGetter() ModelConfigProviderFunc
ProviderModelConfigGetter returns a ModelConfigProviderFunc for retrieving provider based model config values.
type ModelDefaultsProvider ¶
type ModelDefaultsProvider interface { // ModelDefaults returns the default value to use for a specific model. Any // errors encountered while process a models defaults will be reported // through error. ModelDefaults(context.Context) (modeldefaults.Defaults, error) }
ModelDefaultsProvider represents a provider that will provide model defaults values for a single model. Interfaces of this type are expected to be scoped to a predetermined model already.
type ModelDefaultsProviderFunc ¶
type ModelDefaultsProviderFunc func(context.Context) (modeldefaults.Defaults, error)
ModelDefaultsProviderFunc is a func type that implements ModelDefaultsProvider.
func (ModelDefaultsProviderFunc) ModelDefaults ¶
func (f ModelDefaultsProviderFunc) ModelDefaults( ctx context.Context, ) (modeldefaults.Defaults, error)
ModelDefaults implements ModelDefaultsProvider
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service defines a service for interacting with the underlying default configuration options of a model.
func NewService ¶
func NewService( modelConfigProviderGetter ModelConfigProviderFunc, st State, ) *Service
NewService returns a new Service for interacting with model defaults state.
func (*Service) CloudDefaults ¶
func (s *Service) CloudDefaults( ctx context.Context, cloudName string, ) (modeldefaults.ModelDefaultAttributes, error)
CloudDefaults returns the default attribute details for a specified cloud. It returns an error satisfying clouderrors.NotFound if the cloud doesn't exist.
func (*Service) ModelDefaults ¶
func (s *Service) ModelDefaults( ctx context.Context, uuid coremodel.UUID, ) (modeldefaults.Defaults, error)
ModelDefaults will return the default config values to be used for a model and its config. If no model for uuid is found then a error satisfying github.com/juju/juju/domain/model/errors.NotFound will be returned.
The order in which to provide defaults is a tricky problem to coerce into one place in Juju. Previously this was spread out over many places with no real attempt to document which defaults should override another default. This function follows the principal that we always start with the hard coded defaults defined in Juju and then layer on and overwrite where needed the attributes that a user can change. The attributes defaults that a user can change are layered in the form of a funnel where we apply the most granular specific last. The current order is: - Defaults embedded in this Juju version. - Provider defaults. - Cloud defaults. - Cloud region defaults. - Model metadata information (this is hardcoded information that can never be changed by the user).
func (*Service) ModelDefaultsProvider ¶
func (s *Service) ModelDefaultsProvider( uuid coremodel.UUID, ) ModelDefaultsProviderFunc
ModelDefaultsProvider provides a ModelDefaultsProviderFunc scoped to the supplied model. This can be used in the construction of github.com/juju/juju/domain/modelconfig/service.Service. If no model exists for the specified UUID then the ModelDefaultsProviderFunc will return a error that satisfies github.com/juju/juju/domain/model/errors.NotFound.
func (*Service) RemoveCloudDefaults ¶
func (s *Service) RemoveCloudDefaults( ctx context.Context, cloudName string, removeAttrs []string, ) error
RemoveCloudDefaults deletes the specified default attribute details for a cloud. It returns an error satisfying clouderrors.NotFound if the cloud doesn't exist.
func (*Service) RemoveCloudRegionDefaults ¶
func (s *Service) RemoveCloudRegionDefaults( ctx context.Context, cloudName, regionName string, removeAttrs []string, ) error
RemoveCloudRegionDefaults deletes the specified default attribute details for a cloud region. It returns an error satisfying clouderrors.NotFound if the cloud or region doesn't exist.
func (*Service) UpdateCloudDefaults ¶
func (s *Service) UpdateCloudDefaults( ctx context.Context, cloudName string, updateAttrs map[string]any, ) error
UpdateCloudDefaults saves the specified default attribute details for a cloud. It returns an error satisfying clouderrors.NotFound if the cloud doesn't exist.
func (*Service) UpdateCloudRegionDefaults ¶
func (s *Service) UpdateCloudRegionDefaults( ctx context.Context, cloudName string, regionName string, updateAttrs map[string]any, ) error
UpdateCloudRegionDefaults saves the specified default attribute details for a cloud region. It returns an error satisfying clouderrors.NotFound if the cloud doesn't exist.
type State ¶
type State interface { // GetModelCloudUUID returns the cloud UUID for the given model. // If the model is not found, an error specifying [modelerrors.NotFound] is returned. GetModelCloudUUID(context.Context, coremodel.UUID) (cloud.UUID, error) // GetCloudUUID returns the cloud UUID and region for the given cloud name. // If the cloud is not found, an error specifying [clouderrors.NotFound] is returned. GetCloudUUID(context.Context, string) (cloud.UUID, error) // UpdateCloudDefaults is responsible for updating default config values for a // cloud. This function will allow the addition and updating of attributes. // If the cloud doesn't exist, an error satisfying [clouderrors.NotFound] // is returned. UpdateCloudDefaults(ctx context.Context, cloudUID cloud.UUID, attrs map[string]string) error // DeleteCloudDefaults will delete the specified default config keys from // the cloud if they exist. If the cloud does not exist an error satisfying // [clouderrors.NotFound] will be returned. DeleteCloudDefaults(ctx context.Context, cloudUID cloud.UUID, attrs []string) error // UpdateCloudRegionDefaults is responsible for updating default config values // for a cloud region. This function will allow the addition and updating of // attributes. If the cloud is not found an error satisfying [clouderrors.NotFound] // is returned. If the region is not found, am error satisfying [errors.NotFound] // is returned. UpdateCloudRegionDefaults(ctx context.Context, cloudUID cloud.UUID, regionName string, attrs map[string]string) error // DeleteCloudRegionDefaults deletes the specified default config keys for // the given cloud region. It returns an error satisfying // [clouderrors.NotFound] if the cloud region doesn't exist. DeleteCloudRegionDefaults(ctx context.Context, cloudUID cloud.UUID, regionName string, attrs []string) error // ConfigDefaults returns the default configuration values set in Juju. ConfigDefaults(context.Context) map[string]any // CloudDefaults returns the defaults associated with the given cloud. If // no defaults are found then an empty map will be returned with a nil // error. If no cloud exists for the given id an error satisfying // [clouderrors.NotFound] will be returned. CloudDefaults(context.Context, cloud.UUID) (map[string]string, error) // ModelCloudRegionDefaults returns the defaults associated with the model's cloud region. // It returns an error satisfying [modelerrors.NotFound] if the model doesn't exist. ModelCloudRegionDefaults(ctx context.Context, uuid coremodel.UUID) (map[string]string, error) // CloudAllRegionDefaults returns the defaults associated with all of the // regions for the specified cloud. The result is a map of region name // key values, keyed on the name of the region. // If no defaults are found then an empty map will be returned with nil error. // Note this will not include the defaults set on the cloud itself but // just that of its regions. CloudAllRegionDefaults( ctx context.Context, cloudUUID cloud.UUID, ) (map[string]map[string]string, error) // ModelMetadataDefaults is responsible for providing metadata defaults for // a model's config. These include things like the model's name and uuid. // If no model exists for the provided uuid then a [modelerrors.NotFound] // error is returned. // Deprecated: this is only to support legacy callers. ModelMetadataDefaults(context.Context, coremodel.UUID) (map[string]string, error) // CloudType returns the cloud type of the cloud. // If no cloud exists for the given uuid then an error // satisfying [clouderrors.NotFound] is returned. CloudType(context.Context, cloud.UUID) (string, error) }
State is the model config state required by this service.