Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-goenka committed Jan 16, 2025
1 parent ba3a36e commit 5eb7f4a
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions bundle/config/mutator/capture_schema_dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func (m *captureSchemaDependency) Name() string {
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) {
if catalogName == "" || schemaName == "" {
return "", nil
Expand All @@ -40,25 +44,19 @@ func findSchema(b *bundle.Bundle, catalogName, schemaName string) (string, *reso
}

func resolveVolume(v *resources.Volume, b *bundle.Bundle) {
if v == nil {
return
}
if v.CreateVolumeRequestContent == nil {
if v == nil || v.CreateVolumeRequestContent == nil {
return
}
schemaK, schema := findSchema(b, v.CatalogName, v.SchemaName)
if schema == nil {
return
}

v.SchemaName = fmt.Sprintf("${resources.schemas.%s.name}", schemaK)
v.SchemaName = schemaNameRef(schemaK)
}

func resolvePipelineSchema(p *resources.Pipeline, b *bundle.Bundle) {
if p == nil {
return
}
if p.PipelineSpec == nil {
if p == nil || p.PipelineSpec == nil {
return
}
if p.Schema == "" {
Expand All @@ -69,14 +67,11 @@ func resolvePipelineSchema(p *resources.Pipeline, b *bundle.Bundle) {
return
}

p.Schema = fmt.Sprintf("${resources.schemas.%s.name}", schemaK)
p.Schema = schemaNameRef(schemaK)
}

func resolvePipelineTarget(p *resources.Pipeline, b *bundle.Bundle) {
if p == nil {
return
}
if p.PipelineSpec == nil {
if p == nil || p.PipelineSpec == nil {
return
}
if p.Target == "" {
Expand All @@ -86,7 +81,7 @@ func resolvePipelineTarget(p *resources.Pipeline, b *bundle.Bundle) {
if schema == nil {
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 {
Expand Down

0 comments on commit 5eb7f4a

Please sign in to comment.