Protect operator schema files from output collisions
This commit is contained in:
@@ -20,22 +20,28 @@ func capturedSourcePaths(loaded *ck.Result[appconfig.Config]) ([]string, error)
|
||||
}
|
||||
}
|
||||
metadata := loaded.Metadata()
|
||||
captureFile := func(fieldPath ck.Path, filename *string) {
|
||||
if filename == nil {
|
||||
return
|
||||
}
|
||||
field, ok := metadata.Lookup(fieldPath)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
for _, location := range field.Origin.Locations {
|
||||
if host := hostByID[location.SourceID]; host != "" {
|
||||
paths[filepath.Join(filepath.Dir(host), filepath.FromSlash(*filename))] = struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
capture := func(base ck.Path, prompts []pk.PromptSettings) {
|
||||
for i, prompt := range prompts {
|
||||
messages := base.Index(i).Key("messages")
|
||||
record := base.Index(i)
|
||||
if prompt.Output != nil {
|
||||
captureFile(record.Key("output").Key("schema_file"), prompt.Output.SchemaFile)
|
||||
}
|
||||
for j, message := range prompt.Messages {
|
||||
if message.ContentFile == nil {
|
||||
continue
|
||||
}
|
||||
field, ok := metadata.Lookup(messages.Index(j).Key("content_file"))
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
for _, location := range field.Origin.Locations {
|
||||
if host := hostByID[location.SourceID]; host != "" {
|
||||
paths[filepath.Join(filepath.Dir(host), filepath.FromSlash(*message.ContentFile))] = struct{}{}
|
||||
}
|
||||
}
|
||||
captureFile(record.Key("messages").Index(j).Key("content_file"), message.ContentFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user