Roll back failed dynamic descriptor builds
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user