2022-12-12 11:49:25 +00:00
|
|
|
// Package phases defines build phases as logical groups of [bundle.Mutator] instances.
|
|
|
|
package phases
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-05-16 16:35:39 +00:00
|
|
|
"github.com/databricks/cli/bundle"
|
2024-03-25 14:18:47 +00:00
|
|
|
"github.com/databricks/cli/libs/diag"
|
2023-05-16 16:35:39 +00:00
|
|
|
"github.com/databricks/cli/libs/log"
|
2022-12-12 11:49:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// This phase type groups mutators that belong to a lifecycle phase.
|
|
|
|
// It expands into the specific mutators when applied.
|
|
|
|
type phase struct {
|
|
|
|
name string
|
|
|
|
mutators []bundle.Mutator
|
|
|
|
}
|
|
|
|
|
|
|
|
func newPhase(name string, mutators []bundle.Mutator) bundle.Mutator {
|
|
|
|
return &phase{
|
|
|
|
name: name,
|
|
|
|
mutators: mutators,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *phase) Name() string {
|
|
|
|
return p.name
|
|
|
|
}
|
|
|
|
|
2024-03-25 14:18:47 +00:00
|
|
|
func (p *phase) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
|
2023-03-22 16:02:22 +00:00
|
|
|
log.Infof(ctx, "Phase: %s", p.Name())
|
2023-05-24 12:45:19 +00:00
|
|
|
return bundle.Apply(ctx, b, bundle.Seq(p.mutators...))
|
2022-12-12 11:49:25 +00:00
|
|
|
}
|