address comments

This commit is contained in:
Shreyas Goenka 2025-01-16 14:08:22 +01:00
parent ba3a36ea0d
commit 5eb7f4ab2f
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
1 changed files with 10 additions and 15 deletions

View File

@ -26,6 +26,10 @@ func (m *captureSchemaDependency) Name() string {
return "CaptureSchemaDependency" return "CaptureSchemaDependency"
} }
func schemaNameRef(key string) string {
return fmt.Sprintf("${resources.schemas.%s.name}", key)
}
func findSchema(b *bundle.Bundle, catalogName, schemaName string) (string, *resources.Schema) { func findSchema(b *bundle.Bundle, catalogName, schemaName string) (string, *resources.Schema) {
if catalogName == "" || schemaName == "" { if catalogName == "" || schemaName == "" {
return "", nil return "", nil
@ -40,10 +44,7 @@ func findSchema(b *bundle.Bundle, catalogName, schemaName string) (string, *reso
} }
func resolveVolume(v *resources.Volume, b *bundle.Bundle) { func resolveVolume(v *resources.Volume, b *bundle.Bundle) {
if v == nil { if v == nil || v.CreateVolumeRequestContent == nil {
return
}
if v.CreateVolumeRequestContent == nil {
return return
} }
schemaK, schema := findSchema(b, v.CatalogName, v.SchemaName) schemaK, schema := findSchema(b, v.CatalogName, v.SchemaName)
@ -51,14 +52,11 @@ func resolveVolume(v *resources.Volume, b *bundle.Bundle) {
return return
} }
v.SchemaName = fmt.Sprintf("${resources.schemas.%s.name}", schemaK) v.SchemaName = schemaNameRef(schemaK)
} }
func resolvePipelineSchema(p *resources.Pipeline, b *bundle.Bundle) { func resolvePipelineSchema(p *resources.Pipeline, b *bundle.Bundle) {
if p == nil { if p == nil || p.PipelineSpec == nil {
return
}
if p.PipelineSpec == nil {
return return
} }
if p.Schema == "" { if p.Schema == "" {
@ -69,14 +67,11 @@ func resolvePipelineSchema(p *resources.Pipeline, b *bundle.Bundle) {
return return
} }
p.Schema = fmt.Sprintf("${resources.schemas.%s.name}", schemaK) p.Schema = schemaNameRef(schemaK)
} }
func resolvePipelineTarget(p *resources.Pipeline, b *bundle.Bundle) { func resolvePipelineTarget(p *resources.Pipeline, b *bundle.Bundle) {
if p == nil { if p == nil || p.PipelineSpec == nil {
return
}
if p.PipelineSpec == nil {
return return
} }
if p.Target == "" { if p.Target == "" {
@ -86,7 +81,7 @@ func resolvePipelineTarget(p *resources.Pipeline, b *bundle.Bundle) {
if schema == nil { if schema == nil {
return return
} }
p.Target = fmt.Sprintf("${resources.schemas.%s.name}", schemaK) p.Target = schemaNameRef(schemaK)
} }
func (m *captureSchemaDependency) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics { func (m *captureSchemaDependency) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {