mirror of https://github.com/databricks/cli.git
Allow target overrides for sync section (#856)
## Changes Allow target overrides for sync section ## Tests Added tests
This commit is contained in:
parent
803ecb5efd
commit
943ea89728
|
@ -280,5 +280,12 @@ func (r *Root) MergeTargetOverrides(target *Target) error {
|
||||||
git.OriginURL = target.Git.OriginURL
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@ type Target struct {
|
||||||
Git Git `json:"git,omitempty"`
|
Git Git `json:"git,omitempty"`
|
||||||
|
|
||||||
RunAs *jobs.JobRunAs `json:"run_as,omitempty"`
|
RunAs *jobs.JobRunAs `json:"run_as,omitempty"`
|
||||||
|
|
||||||
|
Sync *Sync `json:"sync,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -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/
|
|
@ -0,0 +1,22 @@
|
||||||
|
bundle:
|
||||||
|
name: override_sync
|
||||||
|
|
||||||
|
workspace:
|
||||||
|
host: https://acme.cloud.databricks.com/
|
||||||
|
|
||||||
|
targets:
|
||||||
|
development:
|
||||||
|
sync:
|
||||||
|
include:
|
||||||
|
- tests/*
|
||||||
|
exclude:
|
||||||
|
- dist
|
||||||
|
|
||||||
|
staging:
|
||||||
|
sync:
|
||||||
|
include:
|
||||||
|
- fixtures/*
|
||||||
|
|
||||||
|
prod:
|
||||||
|
workspace:
|
||||||
|
host: https://acme-prod.cloud.databricks.com/
|
|
@ -0,0 +1,43 @@
|
||||||
|
package config_tests
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestOverrideSyncTarget(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)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOverrideSyncTargetNoRootSync(t *testing.T) {
|
||||||
|
b := load(t, "./override_sync_no_root")
|
||||||
|
assert.ElementsMatch(t, []string{}, b.Config.Sync.Include)
|
||||||
|
assert.ElementsMatch(t, []string{}, b.Config.Sync.Exclude)
|
||||||
|
|
||||||
|
b = loadTarget(t, "./override_sync_no_root", "development")
|
||||||
|
assert.ElementsMatch(t, []string{"tests/*"}, b.Config.Sync.Include)
|
||||||
|
assert.ElementsMatch(t, []string{"dist"}, b.Config.Sync.Exclude)
|
||||||
|
|
||||||
|
b = loadTarget(t, "./override_sync_no_root", "staging")
|
||||||
|
assert.ElementsMatch(t, []string{"fixtures/*"}, b.Config.Sync.Include)
|
||||||
|
assert.ElementsMatch(t, []string{}, b.Config.Sync.Exclude)
|
||||||
|
|
||||||
|
b = loadTarget(t, "./override_sync_no_root", "prod")
|
||||||
|
assert.ElementsMatch(t, []string{}, b.Config.Sync.Include)
|
||||||
|
assert.ElementsMatch(t, []string{}, b.Config.Sync.Exclude)
|
||||||
|
}
|
Loading…
Reference in New Issue