databricks-cli/bundle/artifacts/build.go

42 lines
743 B
Go

package artifacts
import (
"context"
"fmt"
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/artifacts/notebook"
)
func BuildAll() bundle.Mutator {
return &all{
name: "Build",
fn: buildArtifactByName,
}
}
type build struct {
name string
}
func buildArtifactByName(name string) (bundle.Mutator, error) {
return &build{name}, nil
}
func (m *build) Name() string {
return fmt.Sprintf("artifacts.Build(%s)", m.name)
}
func (m *build) Apply(ctx context.Context, b *bundle.Bundle) error {
artifact, ok := b.Config.Artifacts[m.name]
if !ok {
return fmt.Errorf("artifact doesn't exist: %s", m.name)
}
if artifact.Notebook != nil {
return bundle.Apply(ctx, b, notebook.Build(m.name))
}
return nil
}