Define identified configuration resources
This commit is contained in:
@@ -18,20 +18,21 @@ import (
|
||||
|
||||
type document struct {
|
||||
Version *string `yaml:"version"`
|
||||
Backends map[string]backendConfig `yaml:"backends"`
|
||||
Profiles map[string]profileConfig `yaml:"profiles"`
|
||||
Prompts map[string]promptConfig `yaml:"prompts"`
|
||||
Backends []backendConfig `yaml:"backends"`
|
||||
Profiles []profileConfig `yaml:"profiles"`
|
||||
Prompts []promptConfig `yaml:"prompts"`
|
||||
Collections map[string]collectionConfig `yaml:"collections"`
|
||||
}
|
||||
|
||||
type collectionConfig struct {
|
||||
ReleaseVersion *string `yaml:"release_version"`
|
||||
Backends map[string]backendConfig `yaml:"backends"`
|
||||
Profiles map[string]profileConfig `yaml:"profiles"`
|
||||
Prompts map[string]promptConfig `yaml:"prompts"`
|
||||
ReleaseVersion *string `yaml:"release_version"`
|
||||
Backends []backendConfig `yaml:"backends"`
|
||||
Profiles []profileConfig `yaml:"profiles"`
|
||||
Prompts []promptConfig `yaml:"prompts"`
|
||||
}
|
||||
|
||||
type backendConfig struct {
|
||||
ID string `yaml:"id"`
|
||||
Endpoint *string `yaml:"endpoint"`
|
||||
APIKeyEnv *string `yaml:"api_key_env"`
|
||||
ConcurrencyLimit *int `yaml:"concurrency_limit"`
|
||||
@@ -56,6 +57,7 @@ type authenticationProbeConfig struct {
|
||||
}
|
||||
|
||||
type profileConfig struct {
|
||||
ID string `yaml:"id"`
|
||||
Backend *string `yaml:"backend"`
|
||||
Endpoint *string `yaml:"endpoint"`
|
||||
Model *string `yaml:"model"`
|
||||
@@ -71,7 +73,7 @@ type profileConfig struct {
|
||||
}
|
||||
|
||||
type promptConfig struct {
|
||||
Version *string `yaml:"version"`
|
||||
ID string `yaml:"id"`
|
||||
DefaultProfile *string `yaml:"default_profile"`
|
||||
Description *string `yaml:"description"`
|
||||
SessionID *string `yaml:"session_id"`
|
||||
@@ -141,9 +143,9 @@ type resourceSet struct {
|
||||
isCollection bool
|
||||
namespace string
|
||||
bases resourceBases
|
||||
backends map[string]backendConfig
|
||||
profiles map[string]profileConfig
|
||||
prompts map[string]promptConfig
|
||||
backends []backendConfig
|
||||
profiles []profileConfig
|
||||
prompts []promptConfig
|
||||
}
|
||||
|
||||
func rootResourceBases() resourceBases {
|
||||
@@ -230,6 +232,14 @@ func load(main configkit.Input, underlays []configkit.Underlay) (*loaded, error)
|
||||
Underlays: underlays,
|
||||
SourceVersionMode: configkit.SourceVersionModeIfPresent,
|
||||
Definition: configkit.Definition[document]{
|
||||
SequenceIdentities: []configkit.SequenceIdentity{
|
||||
configkit.SequenceIdentityAt(configkit.Keys("backends"), "id"),
|
||||
configkit.SequenceIdentityAt(configkit.Keys("profiles"), "id"),
|
||||
configkit.SequenceIdentityAt(configkit.Keys("prompts"), "id"),
|
||||
configkit.SequenceIdentityMatching(configkit.SequenceSelector{configkit.SequenceLiteralKey("collections"), configkit.SequenceAnyMappingKey(), configkit.SequenceLiteralKey("backends")}, "id"),
|
||||
configkit.SequenceIdentityMatching(configkit.SequenceSelector{configkit.SequenceLiteralKey("collections"), configkit.SequenceAnyMappingKey(), configkit.SequenceLiteralKey("profiles")}, "id"),
|
||||
configkit.SequenceIdentityMatching(configkit.SequenceSelector{configkit.SequenceLiteralKey("collections"), configkit.SequenceAnyMappingKey(), configkit.SequenceLiteralKey("prompts")}, "id"),
|
||||
},
|
||||
Version: &configkit.VersionRule{
|
||||
Path: configkit.Keys("version"),
|
||||
Check: checkConfigurationVersion,
|
||||
@@ -302,7 +312,7 @@ func checkConfigurationVersion(version configkit.Version, validation *configkit.
|
||||
if !version.Present {
|
||||
return nil
|
||||
}
|
||||
if version.Null || version.Text != "1" {
|
||||
if version.Null || version.Text != "2" {
|
||||
validation.Error(configkit.Keys("version"), "unsupported configuration specification version")
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user