@@ -40,20 +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
- }
50
+ setSpecDefaults (& spec , pipelineId )
57
51
s .Pipelines [pipelineId ] = r
58
52
59
53
return Response {
@@ -63,6 +57,16 @@ func (s *FakeWorkspace) PipelineCreate(req Request) Response {
63
57
}
64
58
}
65
59
60
+ func setSpecDefaults (spec * pipelines.PipelineSpec , pipelineId string ) {
61
+ spec .Id = pipelineId
62
+ // If the pipeline definition does not specify a catalog, it switches to Hive metastore mode
63
+ // and if the storage location is not specified, API automatically generates a storage location
64
+ // (ref: https://docs.databricks.com/gcp/en/dlt/hive-metastore#specify-a-storage-location)
65
+ if spec .Storage == "" && spec .Catalog == "" {
66
+ spec .Storage = "dbfs:/pipelines/" + pipelineId
67
+ }
68
+ }
69
+
66
70
func (s * FakeWorkspace ) PipelineUpdate (req Request , pipelineId string ) Response {
67
71
defer s .LockUnlock ()()
68
72
@@ -82,12 +86,8 @@ func (s *FakeWorkspace) PipelineUpdate(req Request, pipelineId string) Response
82
86
}
83
87
}
84
88
85
- spec .Id = pipelineId
86
- if spec .Storage == "" && spec .Catalog == "" {
87
- spec .Storage = "dbfs:/pipelines/" + pipelineId
88
- }
89
-
90
89
item .Spec = & spec
90
+ setSpecDefaults (& spec , pipelineId )
91
91
s .Pipelines [pipelineId ] = item
92
92
93
93
return Response {
0 commit comments