From 061d57bfe48eb9c9608d790dc3d9754b61e2da0e Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 8 Feb 2024 12:17:36 +0100 Subject: [PATCH] Use allowlist for Git-related fields to include in metadata --- bundle/deploy/metadata/compute.go | 10 ++++++++-- bundle/deploy/metadata/compute_test.go | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bundle/deploy/metadata/compute.go b/bundle/deploy/metadata/compute.go index 460a81c938..c612d33a3f 100644 --- a/bundle/deploy/metadata/compute.go +++ b/bundle/deploy/metadata/compute.go @@ -6,6 +6,7 @@ import ( "path/filepath" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/metadata" ) @@ -25,8 +26,13 @@ func (m *compute) Apply(_ context.Context, b *bundle.Bundle) error { Config: metadata.Config{}, } - // Set git details in metadata - b.Metadata.Config.Bundle.Git = b.Config.Bundle.Git + // Set Git details in metadata + b.Metadata.Config.Bundle.Git = config.Git{ + Branch: b.Config.Bundle.Git.Branch, + OriginURL: b.Config.Bundle.Git.OriginURL, + Commit: b.Config.Bundle.Git.Commit, + BundleRootPath: b.Config.Bundle.Git.BundleRootPath, + } // Set job config paths in metadata jobsMetadata := make(map[string]*metadata.Job) diff --git a/bundle/deploy/metadata/compute_test.go b/bundle/deploy/metadata/compute_test.go index c3cb029d15..a1a97aab33 100644 --- a/bundle/deploy/metadata/compute_test.go +++ b/bundle/deploy/metadata/compute_test.go @@ -30,6 +30,7 @@ func TestComputeMetadataMutator(t *testing.T) { OriginURL: "www.host.com", Commit: "abcd", BundleRootPath: "a/b/c/d", + Inferred: true, }, }, Resources: config.Resources{ @@ -76,6 +77,9 @@ func TestComputeMetadataMutator(t *testing.T) { OriginURL: "www.host.com", Commit: "abcd", BundleRootPath: "a/b/c/d", + + // Test that this field doesn't carry over into the metadata. + Inferred: false, }, }, Resources: metadata.Resources{