Roll back failed dynamic descriptor builds

This commit is contained in:
2026-10-25 21:20:41 +00:00
parent 2736ddfbf2
commit deb9aa5c69
4 changed files with 109 additions and 0 deletions

View File

@@ -113,6 +113,7 @@ func buildSchema(root reflect.Type, secrets SecretBinding) (*schemaDescriptor, *
type schemaBuilder struct {
cache map[reflect.Type]*typeDescriptor
building map[reflect.Type]bool
journal []reflect.Type
secrets SecretBinding
}
@@ -122,6 +123,7 @@ func (b *schemaBuilder) describe(current reflect.Type, path Path) (*typeDescript
}
descriptor := &typeDescriptor{typeOf: current}
b.cache[current] = descriptor
b.journal = append(b.journal, current)
b.building[current] = true
defer delete(b.building, current)
@@ -210,6 +212,13 @@ func (b *schemaBuilder) describe(current reflect.Type, path Path) (*typeDescript
return descriptor, nil
}
func (b *schemaBuilder) rollback() {
for _, current := range b.journal {
delete(b.cache, current)
}
b.journal = nil
}
func (binding SecretBinding) validate() {
if binding.Type == nil {
return