Skip to content

Commit

Permalink
Remove bundle.git.inferred (#2258)
Browse files Browse the repository at this point in the history
The only use case for it was to emit a warning and based on the
discussion here
https://github.com/databricks/cli/pull/2213/files#r1933558087 the
warning it not useful and logging that with reduced severity is also not
useful.
  • Loading branch information
denik authored Jan 29, 2025
1 parent c3a6e11 commit 38efedc
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 34 deletions.
18 changes: 6 additions & 12 deletions acceptance/bundle/git-permerror/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ Error: unable to load repository specific gitconfig: open config: permission den

Exit code: 1
{
"bundle_root_path": ".",
"inferred": true
"bundle_root_path": "."
}

>>> withdir subdir/a/b $CLI bundle validate -o json
Expand All @@ -31,8 +30,7 @@ Error: unable to load repository specific gitconfig: open config: permission den

Exit code: 1
{
"bundle_root_path": ".",
"inferred": true
"bundle_root_path": "."
}


Expand All @@ -42,14 +40,12 @@ Exit code: 1

>>> $CLI bundle validate -o json
{
"bundle_root_path": ".",
"inferred": true
"bundle_root_path": "."
}

>>> withdir subdir/a/b $CLI bundle validate -o json
{
"bundle_root_path": ".",
"inferred": true
"bundle_root_path": "."
}


Expand All @@ -63,8 +59,7 @@ Error: unable to load repository specific gitconfig: open config: permission den

Exit code: 1
{
"bundle_root_path": ".",
"inferred": true
"bundle_root_path": "."
}

>>> withdir subdir/a/b $CLI bundle validate -o json
Expand All @@ -73,6 +68,5 @@ Error: unable to load repository specific gitconfig: open config: permission den

Exit code: 1
{
"bundle_root_path": ".",
"inferred": true
"bundle_root_path": "."
}
3 changes: 1 addition & 2 deletions acceptance/bundle/variables/prepend-workspace-var/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"bundle": {
"environment": "dev",
"git": {
"bundle_root_path": ".",
"inferred": true
"bundle_root_path": "."
},
"target": "dev",
"terraform": {
Expand Down
3 changes: 0 additions & 3 deletions bundle/config/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ type Git struct {
// Path to bundle root relative to the git repository root.
BundleRootPath string `json:"bundle_root_path,omitempty" bundle:"readonly"`

// Inferred is set to true if the Git details were inferred and weren't set explicitly
Inferred bool `json:"inferred,omitempty" bundle:"readonly"`

// The actual branch according to Git (may be different from the configured branch)
ActualBranch string `json:"actual_branch,omitempty" bundle:"readonly"`
}
1 change: 0 additions & 1 deletion bundle/config/mutator/load_git_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func (m *loadGitDetails) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagn
b.Config.Bundle.Git.ActualBranch = info.CurrentBranch
if b.Config.Bundle.Git.Branch == "" {
// Only load branch if there's no user defined value
b.Config.Bundle.Git.Inferred = true
b.Config.Bundle.Git.Branch = info.CurrentBranch
}

Expand Down
5 changes: 0 additions & 5 deletions bundle/config/mutator/process_target_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ func findNonUserPath(b *bundle.Bundle) string {
}

func validateProductionMode(ctx context.Context, b *bundle.Bundle, isPrincipalUsed bool) diag.Diagnostics {
if b.Config.Bundle.Git.Inferred {
env := b.Config.Bundle.Target
log.Warnf(ctx, "target with 'mode: production' should specify an explicit 'targets.%s.git' configuration", env)
}

r := b.Config.Resources
for i := range r.Pipelines {
if r.Pipelines[i].Development {
Expand Down
4 changes: 0 additions & 4 deletions bundle/deploy/metadata/compute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func TestComputeMetadataMutator(t *testing.T) {
OriginURL: "www.host.com",
Commit: "abcd",
BundleRootPath: "a/b/c/d",
Inferred: true,
},
},
Resources: config.Resources{
Expand Down Expand Up @@ -72,9 +71,6 @@ 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{
Expand Down
2 changes: 0 additions & 2 deletions bundle/tests/environment_git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ import (
func TestGitAutoLoadWithEnvironment(t *testing.T) {
b := load(t, "./environments_autoload_git")
bundle.Apply(context.Background(), b, mutator.LoadGitDetails())
assert.True(t, b.Config.Bundle.Git.Inferred)
validUrl := strings.Contains(b.Config.Bundle.Git.OriginURL, "/cli") || strings.Contains(b.Config.Bundle.Git.OriginURL, "/bricks")
assert.True(t, validUrl, "Expected URL to contain '/cli' or '/bricks', got %s", b.Config.Bundle.Git.OriginURL)
}

func TestGitManuallySetBranchWithEnvironment(t *testing.T) {
b := loadTarget(t, "./environments_autoload_git", "production")
bundle.Apply(context.Background(), b, mutator.LoadGitDetails())
assert.False(t, b.Config.Bundle.Git.Inferred)
assert.Equal(t, "main", b.Config.Bundle.Git.Branch)
validUrl := strings.Contains(b.Config.Bundle.Git.OriginURL, "/cli") || strings.Contains(b.Config.Bundle.Git.OriginURL, "/bricks")
assert.True(t, validUrl, "Expected URL to contain '/cli' or '/bricks', got %s", b.Config.Bundle.Git.OriginURL)
Expand Down
3 changes: 0 additions & 3 deletions bundle/tests/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ import (
func TestGitAutoLoad(t *testing.T) {
b := load(t, "./autoload_git")
bundle.Apply(context.Background(), b, mutator.LoadGitDetails())
assert.True(t, b.Config.Bundle.Git.Inferred)
validUrl := strings.Contains(b.Config.Bundle.Git.OriginURL, "/cli") || strings.Contains(b.Config.Bundle.Git.OriginURL, "/bricks")
assert.True(t, validUrl, "Expected URL to contain '/cli' or '/bricks', got %s", b.Config.Bundle.Git.OriginURL)
}

func TestGitManuallySetBranch(t *testing.T) {
b := loadTarget(t, "./autoload_git", "production")
bundle.Apply(context.Background(), b, mutator.LoadGitDetails())
assert.False(t, b.Config.Bundle.Git.Inferred)
assert.Equal(t, "main", b.Config.Bundle.Git.Branch)
validUrl := strings.Contains(b.Config.Bundle.Git.OriginURL, "/cli") || strings.Contains(b.Config.Bundle.Git.OriginURL, "/bricks")
assert.True(t, validUrl, "Expected URL to contain '/cli' or '/bricks', got %s", b.Config.Bundle.Git.OriginURL)
Expand All @@ -36,7 +34,6 @@ func TestGitBundleBranchValidation(t *testing.T) {

b := load(t, "./git_branch_validation")
bundle.Apply(context.Background(), b, mutator.LoadGitDetails())
assert.False(t, b.Config.Bundle.Git.Inferred)
assert.Equal(t, "feature-a", b.Config.Bundle.Git.Branch)
assert.Equal(t, "feature-b", b.Config.Bundle.Git.ActualBranch)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"exec_path": "/tmp/.../terraform"
},
"git": {
"bundle_root_path": ".",
"inferred": true
"bundle_root_path": "."
},
"mode": "development",
"deployment": {
Expand Down

0 comments on commit 38efedc

Please sign in to comment.