Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow target overrides for sync section #856

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 7 additions & 0 deletions bundle/config/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,5 +280,12 @@ func (r *Root) MergeTargetOverrides(target *Target) error {
git.OriginURL = target.Git.OriginURL
}

if target.Sync != nil {
err = mergo.Merge(&r.Sync, target.Sync, mergo.WithAppendSlice)
if err != nil {
return err
}
}

return nil
}
2 changes: 2 additions & 0 deletions bundle/config/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type Target struct {
Git Git `json:"git,omitempty"`

RunAs *jobs.JobRunAs `json:"run_as,omitempty"`

Sync *Sync `json:"sync,omitempty"`
}

const (
Expand Down
26 changes: 26 additions & 0 deletions bundle/tests/override_sync/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
bundle:
name: override_sync

workspace:
host: https://acme.cloud.databricks.com/

sync:
include:
- src/*

targets:
development:
sync:
include:
- tests/*
exclude:
- dist

staging:
sync:
include:
- fixtures/*

prod:
workspace:
host: https://acme-prod.cloud.databricks.com/
25 changes: 25 additions & 0 deletions bundle/tests/override_sync_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package config_tests

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestOverrideSyncDevTarget(t *testing.T) {
b := load(t, "./override_sync")
assert.ElementsMatch(t, []string{"src/*"}, b.Config.Sync.Include)
assert.ElementsMatch(t, []string{}, b.Config.Sync.Exclude)

b = loadTarget(t, "./override_sync", "development")
assert.ElementsMatch(t, []string{"src/*", "tests/*"}, b.Config.Sync.Include)
assert.ElementsMatch(t, []string{"dist"}, b.Config.Sync.Exclude)

b = loadTarget(t, "./override_sync", "staging")
assert.ElementsMatch(t, []string{"src/*", "fixtures/*"}, b.Config.Sync.Include)
assert.ElementsMatch(t, []string{}, b.Config.Sync.Exclude)

b = loadTarget(t, "./override_sync", "prod")
assert.ElementsMatch(t, []string{"src/*"}, b.Config.Sync.Include)
assert.ElementsMatch(t, []string{}, b.Config.Sync.Exclude)
}