@@ -40,21 +40,14 @@ func (s *FakeWorkspace) PipelineCreate(req Request) Response {
40
40
r .Spec = & spec
41
41
42
42
pipelineId := uuid .New ().String ()
43
- spec .Id = pipelineId
44
43
r .PipelineId = pipelineId
45
44
r .CreatorUserName = "tester@databricks.com"
46
45
r .LastModified = time .Now ().UnixMilli ()
47
46
r .Name = r .Spec .Name
48
47
r .RunAsUserName = "tester@databricks.com"
49
48
r .State = "IDLE"
50
49
51
- // If the pipeline definition does not specify a catalog, it switches to Hive metastore mode
52
- // and if the storage location is not specified, API automatically generates a storage location
53
- // (ref: https://docs.databricks.com/gcp/en/dlt/hive-metastore#specify-a-storage-location)
54
- if spec .Storage == "" && spec .Catalog == "" {
55
- spec .Storage = "dbfs:/pipelines/" + pipelineId
56
- }
57
- s .Pipelines [pipelineId ] = r
50
+ setSpecDefaults (& spec , pipelineId )
58
51
59
52
return Response {
60
53
Body : pipelines.CreatePipelineResponse {
@@ -63,6 +56,16 @@ func (s *FakeWorkspace) PipelineCreate(req Request) Response {
63
56
}
64
57
}
65
58
59
+ func setSpecDefaults (spec * pipelines.PipelineSpec , pipelineId string ) {
60
+ spec .Id = pipelineId
61
+ // If the pipeline definition does not specify a catalog, it switches to Hive metastore mode
62
+ // and if the storage location is not specified, API automatically generates a storage location
63
+ // (ref: https://docs.databricks.com/gcp/en/dlt/hive-metastore#specify-a-storage-location)
64
+ if spec .Storage == "" && spec .Catalog == "" {
65
+ spec .Storage = "dbfs:/pipelines/" + pipelineId
66
+ }
67
+ }
68
+
66
69
func (s * FakeWorkspace ) PipelineUpdate (req Request , pipelineId string ) Response {
67
70
defer s .LockUnlock ()()
68
71
@@ -82,10 +85,7 @@ func (s *FakeWorkspace) PipelineUpdate(req Request, pipelineId string) Response
82
85
}
83
86
}
84
87
85
- spec .Id = pipelineId
86
- if spec .Storage == "" && spec .Catalog == "" {
87
- spec .Storage = "dbfs:/pipelines/" + pipelineId
88
- }
88
+ setSpecDefaults (& spec , pipelineId )
89
89
90
90
item .Spec = & spec
91
91
s .Pipelines [pipelineId ] = item
0 commit comments