github.com/databricks/cli@v0.203.0/bundle/config/mutator/process_include.go (about)

     1  package mutator
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	"github.com/databricks/cli/bundle"
     8  	"github.com/databricks/cli/bundle/config"
     9  )
    10  
    11  type processInclude struct {
    12  	fullPath string
    13  	relPath  string
    14  }
    15  
    16  // ProcessInclude loads the configuration at [fullPath] and merges it into the configuration.
    17  func ProcessInclude(fullPath, relPath string) bundle.Mutator {
    18  	return &processInclude{
    19  		fullPath: fullPath,
    20  		relPath:  relPath,
    21  	}
    22  }
    23  
    24  func (m *processInclude) Name() string {
    25  	return fmt.Sprintf("ProcessInclude(%s)", m.relPath)
    26  }
    27  
    28  func (m *processInclude) Apply(_ context.Context, b *bundle.Bundle) error {
    29  	this, err := config.Load(m.fullPath)
    30  	if err != nil {
    31  		return err
    32  	}
    33  	return b.Config.Merge(this)
    34  }