2023-12-19 07:38:52 +00:00
|
|
|
package metadata
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"path"
|
|
|
|
|
|
|
|
"github.com/databricks/cli/bundle"
|
2024-03-25 14:18:47 +00:00
|
|
|
"github.com/databricks/cli/libs/diag"
|
2023-12-19 07:38:52 +00:00
|
|
|
"github.com/databricks/databricks-sdk-go/service/jobs"
|
|
|
|
)
|
|
|
|
|
|
|
|
type annotateJobs struct{}
|
|
|
|
|
|
|
|
func AnnotateJobs() bundle.Mutator {
|
|
|
|
return &annotateJobs{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *annotateJobs) Name() string {
|
|
|
|
return "metadata.AnnotateJobs"
|
|
|
|
}
|
|
|
|
|
2024-03-25 14:18:47 +00:00
|
|
|
func (m *annotateJobs) Apply(_ context.Context, b *bundle.Bundle) diag.Diagnostics {
|
2023-12-19 07:38:52 +00:00
|
|
|
for _, job := range b.Config.Resources.Jobs {
|
|
|
|
if job.JobSettings == nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
job.JobSettings.Deployment = &jobs.JobDeployment{
|
|
|
|
Kind: jobs.JobDeploymentKindBundle,
|
|
|
|
MetadataFilePath: path.Join(b.Config.Workspace.StatePath, MetadataFileName),
|
|
|
|
}
|
|
|
|
job.JobSettings.EditMode = jobs.JobSettingsEditModeUiLocked
|
|
|
|
job.JobSettings.Format = jobs.FormatMultiTask
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|