Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
bundle:
name: deploy-jobs-check-metadata-$UNIQUE_NAME

targets:
default:
mode: development

workspace:
root_path: ~/.bundle/$UNIQUE_NAME

Expand Down
17 changes: 15 additions & 2 deletions acceptance/bundle/resources/jobs/check-metadata/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ Deployment complete!

=== Assert job 1 is created
{
"name": "test-job-metadata-1-[UNIQUE_NAME]"
"name": "[dev [USERNAME]] test-job-metadata-1-[UNIQUE_NAME]"
}

=== Assert job 2 is created
{
"name": "test-job-metadata-2-[UNIQUE_NAME]"
"name": "[dev [USERNAME]] test-job-metadata-2-[UNIQUE_NAME]"
}

=== Read metadata object from the workspace
Expand All @@ -39,6 +39,9 @@ Deployment complete!
"version": 1,
"config": {
"bundle": {
"name": "deploy-jobs-check-metadata-[UNIQUE_NAME]",
"target": "default",
"mode": "development",
"git": {
"bundle_root_path": "."
}
Expand Down Expand Up @@ -71,6 +74,16 @@ Deployment complete!
>>> cat metadata.json
"id": "[JOB_2_ID]",

=== Check that metadata contains bundle name, target, and mode
>>> cat metadata.json
"deploy-jobs-check-metadata-[UNIQUE_NAME]"

>>> cat metadata.json
"default"

>>> cat metadata.json
"development"

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.jobs.bar
Expand Down
5 changes: 5 additions & 0 deletions acceptance/bundle/resources/jobs/check-metadata/script
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ trace cat metadata.json
title "Check that metadata contains created job ids"
trace cat metadata.json | grep "${JOB_1_ID}"
trace cat metadata.json | grep "${JOB_2_ID}"

title "Check that metadata contains bundle name, target, and mode"
trace cat metadata.json | jq '.config.bundle.name'
trace cat metadata.json | jq '.config.bundle.target'
trace cat metadata.json | jq '.config.bundle.mode'
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@
"version": 1,
"config": {
"bundle": {
"name": "test-bundle",
"target": "default",
"git": {
"bundle_root_path": "."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@
"version": 1,
"config": {
"bundle": {
"name": "test-bundle",
"target": "default",
"git": {
"bundle_root_path": "."
}
Expand Down
5 changes: 5 additions & 0 deletions bundle/deploy/metadata/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func (m *compute) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics
BundleRootPath: b.Config.Bundle.Git.BundleRootPath,
}

// Set bundle name, target, and mode
b.Metadata.Config.Bundle.Name = b.Config.Bundle.Name
b.Metadata.Config.Bundle.Target = b.Config.Bundle.Target
b.Metadata.Config.Bundle.Mode = string(b.Config.Bundle.Mode)

// Set job config paths in metadata
jobsMetadata := make(map[string]*metadata.Resource)
for name, job := range b.Config.Resources.Jobs {
Expand Down
4 changes: 4 additions & 0 deletions bundle/deploy/metadata/compute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func TestComputeMetadataMutator(t *testing.T) {
Bundle: config.Bundle{
Name: "my-bundle",
Target: "development",
Mode: config.Development,
Git: config.Git{
Branch: "my-branch",
OriginURL: "www.host.com",
Expand Down Expand Up @@ -81,6 +82,9 @@ func TestComputeMetadataMutator(t *testing.T) {
FilePath: "/Users/shreyas.goenka@databricks.com/files",
},
Bundle: metadata.Bundle{
Name: "my-bundle",
Target: "development",
Mode: "development",
Git: config.Git{
Branch: "my-branch",
OriginURL: "www.host.com",
Expand Down
5 changes: 4 additions & 1 deletion bundle/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import (
const Version = 1

type Bundle struct {
Git config.Git `json:"git,omitempty"`
Name string `json:"name,omitempty"`
Target string `json:"target,omitempty"`
Mode string `json:"mode,omitempty"`
Git config.Git `json:"git,omitempty"`
}

type Workspace struct {
Expand Down