|
80 | 80 | "storage_credential": {`CREATE_EXTERNAL_LOCATION`, `CREATE_EXTERNAL_TABLE`}, |
81 | 81 | "foreign_connection": {`CREATE_FOREIGN_CATALOG`}, |
82 | 82 | } |
| 83 | + ParentDirectoryExtraKey = "parent_directory" |
83 | 84 | ) |
84 | 85 |
|
85 | 86 | func generateMountBody(ic *importContext, body *hclwrite.Body, r *resource) error { |
@@ -1527,20 +1528,14 @@ var resourcesMap map[string]importable = map[string]importable{ |
1527 | 1528 | "notebook_"+ic.Importables["databricks_notebook"].Name(ic, r.Data)) |
1528 | 1529 | // TODO: it's not completely correct condition - we need to make emit smarter - |
1529 | 1530 | // emit only if permissions are different from their parent's permission. |
1530 | | - if idx := strings.LastIndex(r.ID, "/"); idx != -1 { |
1531 | | - directoryPath := r.ID[:idx] |
1532 | | - ic.Emit(&resource{ |
1533 | | - Resource: "databricks_directory", |
1534 | | - ID: directoryPath, |
1535 | | - }) |
1536 | | - } |
| 1531 | + ic.emitWorkspaceObjectParentDirectory(r) |
1537 | 1532 | return r.Data.Set("source", fileName) |
1538 | 1533 | }, |
1539 | 1534 | ShouldOmitField: shouldOmitMd5Field, |
1540 | 1535 | Depends: []reference{ |
1541 | 1536 | {Path: "source", File: true}, |
1542 | | - {Path: "path", Resource: "databricks_directory", |
1543 | | - MatchType: MatchLongestPrefix, SearchValueTransformFunc: appendEndingSlashToDirName}, |
| 1537 | + {Path: "path", Resource: "databricks_directory", MatchType: MatchLongestPrefix, |
| 1538 | + SearchValueTransformFunc: appendEndingSlashToDirName, ExtraLookupKey: ParentDirectoryExtraKey}, |
1544 | 1539 | {Path: "path", Resource: "databricks_user", Match: "home", |
1545 | 1540 | MatchType: MatchPrefix, SearchValueTransformFunc: appendEndingSlashToDirName}, |
1546 | 1541 | {Path: "path", Resource: "databricks_service_principal", Match: "home", |
@@ -1580,21 +1575,15 @@ var resourcesMap map[string]importable = map[string]importable{ |
1580 | 1575 |
|
1581 | 1576 | // TODO: it's not completely correct condition - we need to make emit smarter - |
1582 | 1577 | // emit only if permissions are different from their parent's permission. |
1583 | | - if idx := strings.LastIndex(r.ID, "/"); idx != -1 { |
1584 | | - directoryPath := r.ID[:idx] |
1585 | | - ic.Emit(&resource{ |
1586 | | - Resource: "databricks_directory", |
1587 | | - ID: directoryPath, |
1588 | | - }) |
1589 | | - } |
1590 | | - log.Printf("Creating %s for %s", fileName, r) |
| 1578 | + ic.emitWorkspaceObjectParentDirectory(r) |
| 1579 | + log.Printf("[TRACE] Creating %s for %s", fileName, r) |
1591 | 1580 | return r.Data.Set("source", fileName) |
1592 | 1581 | }, |
1593 | 1582 | ShouldOmitField: shouldOmitMd5Field, |
1594 | 1583 | Depends: []reference{ |
1595 | 1584 | {Path: "source", File: true}, |
1596 | | - {Path: "path", Resource: "databricks_directory", |
1597 | | - MatchType: MatchLongestPrefix, SearchValueTransformFunc: appendEndingSlashToDirName}, |
| 1585 | + {Path: "path", Resource: "databricks_directory", MatchType: MatchLongestPrefix, |
| 1586 | + SearchValueTransformFunc: appendEndingSlashToDirName, ExtraLookupKey: ParentDirectoryExtraKey}, |
1598 | 1587 | {Path: "path", Resource: "databricks_user", Match: "home", |
1599 | 1588 | MatchType: MatchPrefix, SearchValueTransformFunc: appendEndingSlashToDirName}, |
1600 | 1589 | {Path: "path", Resource: "databricks_service_principal", Match: "home", |
|
0 commit comments