Adopt Notarius configuration overlays
This commit is contained in:
@@ -305,7 +305,7 @@ type NotariusConfig struct {
|
||||
Enabled bool `yaml:"enabled" json:"enabled"`
|
||||
Binary string `yaml:"binary" json:"binary"`
|
||||
Credentials []configkit.Secret `yaml:"credentials,omitempty" json:"credentials,omitempty"`
|
||||
ConfigProfile *string `yaml:"config_profile,omitempty" json:"config_profile,omitempty"`
|
||||
ConfigOverlay *string `yaml:"config_overlay,omitempty" json:"config_overlay,omitempty"`
|
||||
Resume bool `yaml:"resume,omitempty" json:"resume,omitempty"`
|
||||
ChunkCache string `yaml:"chunk_cache,omitempty" json:"chunk_cache,omitempty"`
|
||||
ConfigPath string `yaml:"config_path" json:"config_path"`
|
||||
|
||||
@@ -54,7 +54,7 @@ func (cfg NotariusConfig) MarshalYAML() (any, error) {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Binary string `yaml:"binary"`
|
||||
Credentials []string `yaml:"credentials,omitempty"`
|
||||
ConfigProfile *string `yaml:"config_profile,omitempty"`
|
||||
ConfigOverlay *string `yaml:"config_overlay,omitempty"`
|
||||
Resume bool `yaml:"resume,omitempty"`
|
||||
ChunkCache string `yaml:"chunk_cache,omitempty"`
|
||||
ConfigPath string `yaml:"config_path"`
|
||||
@@ -66,7 +66,7 @@ func (cfg NotariusConfig) MarshalYAML() (any, error) {
|
||||
}
|
||||
return safeNotarius{
|
||||
Enabled: cfg.Enabled, Binary: cfg.Binary, Credentials: secretReferenceNames(cfg.Credentials),
|
||||
ConfigProfile: cfg.ConfigProfile,
|
||||
ConfigOverlay: cfg.ConfigOverlay,
|
||||
Resume: cfg.Resume, ChunkCache: cfg.ChunkCache,
|
||||
ConfigPath: cfg.ConfigPath, PipelineID: cfg.PipelineID, Timeout: cfg.Timeout,
|
||||
WorkingDirectory: cfg.WorkingDirectory, References: cfg.References, Outputs: cfg.Outputs,
|
||||
|
||||
@@ -103,7 +103,7 @@ storage:
|
||||
notarius:
|
||||
enabled: false
|
||||
credentials: [NARRATIO_TEST_NOTARIUS_KEY]
|
||||
config_profile: ""
|
||||
config_overlay: ""
|
||||
`
|
||||
pipelinePath, _ := writeConfigFiles(t, pipelineYAML, testSessionBaseYAML)
|
||||
|
||||
@@ -141,20 +141,20 @@ notarius:
|
||||
}
|
||||
}
|
||||
}
|
||||
if !strings.Contains(string(firstYAML), "config_profile: \"\"\n") {
|
||||
t.Fatalf("effective YAML omitted explicit empty Notarius config profile: %q", firstYAML)
|
||||
if !strings.Contains(string(firstYAML), "config_overlay: \"\"\n") {
|
||||
t.Fatalf("effective YAML omitted explicit empty Notarius config overlay: %q", firstYAML)
|
||||
}
|
||||
var roundTrip struct {
|
||||
Notarius *struct {
|
||||
Credentials []string `yaml:"credentials"`
|
||||
ConfigProfile *string `yaml:"config_profile"`
|
||||
ConfigOverlay *string `yaml:"config_overlay"`
|
||||
} `yaml:"notarius"`
|
||||
}
|
||||
if err := yaml.Unmarshal(firstYAML, &roundTrip); err != nil {
|
||||
t.Fatalf("round-trip effective YAML: %v", err)
|
||||
}
|
||||
if roundTrip.Notarius == nil || roundTrip.Notarius.ConfigProfile == nil || *roundTrip.Notarius.ConfigProfile != "" {
|
||||
t.Fatalf("round-trip config profile = %#v, want explicit empty", roundTrip.Notarius)
|
||||
if roundTrip.Notarius == nil || roundTrip.Notarius.ConfigOverlay == nil || *roundTrip.Notarius.ConfigOverlay != "" {
|
||||
t.Fatalf("round-trip config overlay = %#v, want explicit empty", roundTrip.Notarius)
|
||||
}
|
||||
if len(roundTrip.Notarius.Credentials) != 1 || roundTrip.Notarius.Credentials[0] != "NARRATIO_TEST_NOTARIUS_KEY" {
|
||||
t.Fatalf("round-trip credential reference = %#v, want safe public name", roundTrip.Notarius.Credentials)
|
||||
|
||||
@@ -238,7 +238,14 @@ func TestNotariusCredentialOverlayReplacementAndProvenance(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotariusConfigProfileComposition(t *testing.T) {
|
||||
func TestNotariusRetiredConfigProfileRejected(t *testing.T) {
|
||||
root := writePipelineFixture(t, t.TempDir(), "pipeline.yml", "whisperx:\n transcribe_url: https://transcription.example.test/transcribe\nnotarius:\n config_profile: testing\n")
|
||||
if _, err := LoadPipelineWithOptions(root, PipelineLoadOptions{}); err == nil {
|
||||
t.Fatal("retired Notarius config_profile field was accepted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotariusConfigOverlayComposition(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
baseValue string
|
||||
@@ -250,15 +257,15 @@ func TestNotariusConfigProfileComposition(t *testing.T) {
|
||||
{name: "explicit empty", baseValue: `""`, want: stringPointer("")},
|
||||
{name: "explicit default", baseValue: "default", want: stringPointer("default")},
|
||||
{name: "base named selection", baseValue: "production", want: stringPointer("production")},
|
||||
{name: "profile replaces named selection", baseValue: "production", overlayName: "testing", overlay: "notarius:\n config_profile: inexpensive\n", want: stringPointer("inexpensive")},
|
||||
{name: "profile clears named selection", baseValue: "production", overlayName: "testing", overlay: "notarius:\n config_profile: null\n"},
|
||||
{name: "profile replaces named selection", baseValue: "production", overlayName: "testing", overlay: "notarius:\n config_overlay: inexpensive\n", want: stringPointer("inexpensive")},
|
||||
{name: "profile clears named selection", baseValue: "production", overlayName: "testing", overlay: "notarius:\n config_overlay: null\n"},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
rootYAML := "whisperx:\n transcribe_url: https://transcription.example.test/transcribe\nnotarius:\n enabled: false\n"
|
||||
if test.baseValue != "" {
|
||||
rootYAML += " config_profile: " + test.baseValue + "\n"
|
||||
rootYAML += " config_overlay: " + test.baseValue + "\n"
|
||||
}
|
||||
root := writePipelineFixture(t, dir, "pipeline.yml", rootYAML)
|
||||
options := PipelineLoadOptions{}
|
||||
@@ -270,8 +277,8 @@ func TestNotariusConfigProfileComposition(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.Notarius == nil || !reflect.DeepEqual(cfg.Notarius.ConfigProfile, test.want) {
|
||||
t.Fatalf("config profile = %#v, want %#v", cfg.Notarius.ConfigProfile, test.want)
|
||||
if cfg.Notarius == nil || !reflect.DeepEqual(cfg.Notarius.ConfigOverlay, test.want) {
|
||||
t.Fatalf("config overlay = %#v, want %#v", cfg.Notarius.ConfigOverlay, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user