github.com/databricks/cli@v0.203.0/bundle/phases/phase.go (about)

     1  // Package phases defines build phases as logical groups of [bundle.Mutator] instances.
     2  package phases
     3  
     4  import (
     5  	"context"
     6  
     7  	"github.com/databricks/cli/bundle"
     8  	"github.com/databricks/cli/libs/log"
     9  )
    10  
    11  // This phase type groups mutators that belong to a lifecycle phase.
    12  // It expands into the specific mutators when applied.
    13  type phase struct {
    14  	name     string
    15  	mutators []bundle.Mutator
    16  }
    17  
    18  func newPhase(name string, mutators []bundle.Mutator) bundle.Mutator {
    19  	return &phase{
    20  		name:     name,
    21  		mutators: mutators,
    22  	}
    23  }
    24  
    25  func (p *phase) Name() string {
    26  	return p.name
    27  }
    28  
    29  func (p *phase) Apply(ctx context.Context, b *bundle.Bundle) error {
    30  	log.Infof(ctx, "Phase: %s", p.Name())
    31  	return bundle.Apply(ctx, b, bundle.Seq(p.mutators...))
    32  }