Use allowlist for Git-related fields to include in metadata (#1187)

## Changes

When new fields are added they should not automatically propagate to the
bundle metadata.

## Tests

Test passes.
This commit is contained in:
Pieter Noordhuis 2024-02-08 13:23:14 +01:00 committed by GitHub
parent b1b5ad8acd
commit f7d1a5862d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import (
"path/filepath" "path/filepath"
"github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config"
"github.com/databricks/cli/bundle/metadata" "github.com/databricks/cli/bundle/metadata"
) )
@ -25,8 +26,13 @@ func (m *compute) Apply(_ context.Context, b *bundle.Bundle) error {
Config: metadata.Config{}, Config: metadata.Config{},
} }
// Set git details in metadata // Set Git details in metadata
b.Metadata.Config.Bundle.Git = b.Config.Bundle.Git 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 // Set job config paths in metadata
jobsMetadata := make(map[string]*metadata.Job) jobsMetadata := make(map[string]*metadata.Job)

View File

@ -30,6 +30,7 @@ func TestComputeMetadataMutator(t *testing.T) {
OriginURL: "www.host.com", OriginURL: "www.host.com",
Commit: "abcd", Commit: "abcd",
BundleRootPath: "a/b/c/d", BundleRootPath: "a/b/c/d",
Inferred: true,
}, },
}, },
Resources: config.Resources{ Resources: config.Resources{
@ -76,6 +77,9 @@ func TestComputeMetadataMutator(t *testing.T) {
OriginURL: "www.host.com", OriginURL: "www.host.com",
Commit: "abcd", Commit: "abcd",
BundleRootPath: "a/b/c/d", BundleRootPath: "a/b/c/d",
// Test that this field doesn't carry over into the metadata.
Inferred: false,
}, },
}, },
Resources: metadata.Resources{ Resources: metadata.Resources{