mirror of https://github.com/databricks/cli.git
Add `--validate-only` flag to run validate-only pipeline update (#1251)
## Changes This flag starts a "validation-only" update. ## Tests Unit and manual confirmation it does what it should.
This commit is contained in:
parent
58e1db58b1
commit
04827688fb
|
@ -22,6 +22,9 @@ type PipelineOptions struct {
|
|||
|
||||
// List of tables to reset and recompute.
|
||||
FullRefresh []string
|
||||
|
||||
// Perform an update to validate graph correctness.
|
||||
ValidateOnly bool
|
||||
}
|
||||
|
||||
func (o *PipelineOptions) Define(fs *flag.FlagSet) {
|
||||
|
@ -29,6 +32,7 @@ func (o *PipelineOptions) Define(fs *flag.FlagSet) {
|
|||
fs.StringSliceVar(&o.Refresh, "refresh", nil, "List of tables to update.")
|
||||
fs.BoolVar(&o.FullRefreshAll, "full-refresh-all", false, "Perform a full graph reset and recompute.")
|
||||
fs.StringSliceVar(&o.FullRefresh, "full-refresh", nil, "List of tables to reset and recompute.")
|
||||
fs.BoolVar(&o.ValidateOnly, "validate-only", false, "Perform an update to validate graph correctness.")
|
||||
}
|
||||
|
||||
// Validate returns if the combination of options is valid.
|
||||
|
@ -46,6 +50,9 @@ func (o *PipelineOptions) Validate(pipeline *resources.Pipeline) error {
|
|||
if len(o.FullRefresh) > 0 {
|
||||
set = append(set, "--full-refresh")
|
||||
}
|
||||
if o.ValidateOnly {
|
||||
set = append(set, "--validate-only")
|
||||
}
|
||||
if len(set) > 1 {
|
||||
return fmt.Errorf("pipeline run arguments are mutually exclusive (got %s)", strings.Join(set, ", "))
|
||||
}
|
||||
|
@ -63,6 +70,7 @@ func (o *PipelineOptions) toPayload(pipeline *resources.Pipeline, pipelineID str
|
|||
RefreshSelection: o.Refresh,
|
||||
FullRefresh: o.FullRefreshAll,
|
||||
FullRefreshSelection: o.FullRefresh,
|
||||
ValidateOnly: o.ValidateOnly,
|
||||
}
|
||||
return payload, nil
|
||||
}
|
||||
|
|
|
@ -43,12 +43,20 @@ func TestPipelineOptionsFullRefresh(t *testing.T) {
|
|||
assert.Equal(t, []string{"arg1", "arg2", "arg3"}, opts.FullRefresh)
|
||||
}
|
||||
|
||||
func TestPipelineOptionsValidateOnly(t *testing.T) {
|
||||
fs, opts := setupPipelineOptions(t)
|
||||
err := fs.Parse([]string{`--validate-only`})
|
||||
require.NoError(t, err)
|
||||
assert.True(t, opts.ValidateOnly)
|
||||
}
|
||||
|
||||
func TestPipelineOptionsValidateSuccessWithSingleOption(t *testing.T) {
|
||||
args := []string{
|
||||
`--refresh-all`,
|
||||
`--refresh=arg1,arg2,arg3`,
|
||||
`--full-refresh-all`,
|
||||
`--full-refresh=arg1,arg2,arg3`,
|
||||
`--validate-only`,
|
||||
}
|
||||
for _, arg := range args {
|
||||
fs, opts := setupPipelineOptions(t)
|
||||
|
@ -65,6 +73,7 @@ func TestPipelineOptionsValidateFailureWithMultipleOptions(t *testing.T) {
|
|||
`--refresh=arg1,arg2,arg3`,
|
||||
`--full-refresh-all`,
|
||||
`--full-refresh=arg1,arg2,arg3`,
|
||||
`--validate-only`,
|
||||
}
|
||||
for i := range args {
|
||||
for j := range args {
|
||||
|
|
Loading…
Reference in New Issue