mirror of https://github.com/databricks/cli.git
address comments
This commit is contained in:
parent
a5243d628a
commit
58aca2a058
|
@ -32,7 +32,7 @@ func findSchema(b *bundle.Bundle, catalogName, schemaName string) (string, *reso
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, s := range b.Config.Resources.Schemas {
|
for k, s := range b.Config.Resources.Schemas {
|
||||||
if s.CreateSchema != nil && s.CatalogName == catalogName && s.Name == schemaName {
|
if s != nil && s.CreateSchema != nil && s.CatalogName == catalogName && s.Name == schemaName {
|
||||||
return k, s
|
return k, s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,9 @@ func findSchema(b *bundle.Bundle, catalogName, schemaName string) (string, *reso
|
||||||
}
|
}
|
||||||
|
|
||||||
func resolveVolume(v *resources.Volume, b *bundle.Bundle) {
|
func resolveVolume(v *resources.Volume, b *bundle.Bundle) {
|
||||||
|
if v == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
if v.CreateVolumeRequestContent == nil {
|
if v.CreateVolumeRequestContent == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -52,6 +55,9 @@ func resolveVolume(v *resources.Volume, b *bundle.Bundle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resolvePipelineSchema(p *resources.Pipeline, b *bundle.Bundle) {
|
func resolvePipelineSchema(p *resources.Pipeline, b *bundle.Bundle) {
|
||||||
|
if p == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
if p.PipelineSpec == nil {
|
if p.PipelineSpec == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -67,6 +73,9 @@ func resolvePipelineSchema(p *resources.Pipeline, b *bundle.Bundle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func resolvePipelineTarget(p *resources.Pipeline, b *bundle.Bundle) {
|
func resolvePipelineTarget(p *resources.Pipeline, b *bundle.Bundle) {
|
||||||
|
if p == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
if p.PipelineSpec == nil {
|
if p.PipelineSpec == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,8 @@ func TestCaptureSchemaDependencyForVolume(t *testing.T) {
|
||||||
Name: "barfoo",
|
Name: "barfoo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"nilschema": {},
|
"nilschema": nil,
|
||||||
"emptyschema": {
|
"emptyschema": {},
|
||||||
CreateSchema: &catalog.CreateSchema{},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Volumes: map[string]*resources.Volume{
|
Volumes: map[string]*resources.Volume{
|
||||||
"volume1": {
|
"volume1": {
|
||||||
|
@ -72,10 +70,8 @@ func TestCaptureSchemaDependencyForVolume(t *testing.T) {
|
||||||
SchemaName: "schemaX",
|
SchemaName: "schemaX",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"nilVolume": {},
|
"nilVolume": nil,
|
||||||
"emptyVolume": {
|
"emptyVolume": {},
|
||||||
CreateVolumeRequestContent: &catalog.CreateVolumeRequestContent{},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -90,8 +86,8 @@ func TestCaptureSchemaDependencyForVolume(t *testing.T) {
|
||||||
assert.Equal(t, "foobar", b.Config.Resources.Volumes["volume4"].CreateVolumeRequestContent.SchemaName)
|
assert.Equal(t, "foobar", b.Config.Resources.Volumes["volume4"].CreateVolumeRequestContent.SchemaName)
|
||||||
assert.Equal(t, "schemaX", b.Config.Resources.Volumes["volume5"].CreateVolumeRequestContent.SchemaName)
|
assert.Equal(t, "schemaX", b.Config.Resources.Volumes["volume5"].CreateVolumeRequestContent.SchemaName)
|
||||||
|
|
||||||
assert.Nil(t, b.Config.Resources.Volumes["nilVolume"].CreateVolumeRequestContent)
|
assert.Nil(t, b.Config.Resources.Volumes["nilVolume"])
|
||||||
assert.Empty(t, b.Config.Resources.Volumes["emptyVolume"].CreateVolumeRequestContent)
|
assert.Nil(t, b.Config.Resources.Volumes["emptyVolume"].CreateVolumeRequestContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCaptureSchemaDependencyForPipelinesWithTarget(t *testing.T) {
|
func TestCaptureSchemaDependencyForPipelinesWithTarget(t *testing.T) {
|
||||||
|
@ -117,10 +113,8 @@ func TestCaptureSchemaDependencyForPipelinesWithTarget(t *testing.T) {
|
||||||
Name: "barfoo",
|
Name: "barfoo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"nilschema": {},
|
"nilschema": nil,
|
||||||
"emptyschema": {
|
"emptyschema": {},
|
||||||
CreateSchema: &catalog.CreateSchema{},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Pipelines: map[string]*resources.Pipeline{
|
Pipelines: map[string]*resources.Pipeline{
|
||||||
"pipeline1": {
|
"pipeline1": {
|
||||||
|
@ -166,10 +160,8 @@ func TestCaptureSchemaDependencyForPipelinesWithTarget(t *testing.T) {
|
||||||
Name: "whatever",
|
Name: "whatever",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"nilPipeline": {},
|
"nilPipeline": nil,
|
||||||
"emptyPipeline": {
|
"emptyPipeline": {},
|
||||||
PipelineSpec: &pipelines.PipelineSpec{},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -186,8 +178,8 @@ func TestCaptureSchemaDependencyForPipelinesWithTarget(t *testing.T) {
|
||||||
assert.Equal(t, "foobar", b.Config.Resources.Pipelines["pipeline6"].Schema)
|
assert.Equal(t, "foobar", b.Config.Resources.Pipelines["pipeline6"].Schema)
|
||||||
assert.Equal(t, "", b.Config.Resources.Pipelines["pipeline7"].Schema)
|
assert.Equal(t, "", b.Config.Resources.Pipelines["pipeline7"].Schema)
|
||||||
|
|
||||||
assert.Nil(t, b.Config.Resources.Pipelines["nilPipeline"].PipelineSpec)
|
assert.Nil(t, b.Config.Resources.Pipelines["nilPipeline"])
|
||||||
assert.Empty(t, b.Config.Resources.Pipelines["emptyPipeline"].PipelineSpec)
|
assert.Nil(t, b.Config.Resources.Pipelines["emptyPipeline"].PipelineSpec)
|
||||||
|
|
||||||
for _, k := range []string{"pipeline1", "pipeline2", "pipeline3", "pipeline4", "pipeline5", "pipeline6", "pipeline7"} {
|
for _, k := range []string{"pipeline1", "pipeline2", "pipeline3", "pipeline4", "pipeline5", "pipeline6", "pipeline7"} {
|
||||||
assert.Empty(t, b.Config.Resources.Pipelines[k].Target)
|
assert.Empty(t, b.Config.Resources.Pipelines[k].Target)
|
||||||
|
@ -217,10 +209,8 @@ func TestCaptureSchemaDependencyForPipelinesWithSchema(t *testing.T) {
|
||||||
Name: "barfoo",
|
Name: "barfoo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"nilschema": {},
|
"nilschema": nil,
|
||||||
"emptyschema": {
|
"emptyschema": {},
|
||||||
CreateSchema: &catalog.CreateSchema{},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Pipelines: map[string]*resources.Pipeline{
|
Pipelines: map[string]*resources.Pipeline{
|
||||||
"pipeline1": {
|
"pipeline1": {
|
||||||
|
|
Loading…
Reference in New Issue