Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Exporter] Ignore databricks_artifact_allowlist with zero artifact_matcher blocks #4019

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions exporter/importables.go
Original file line number Diff line number Diff line change
Expand Up @@ -2518,6 +2518,14 @@ var resourcesMap map[string]importable = map[string]importable{
}
return nil
},
Ignore: func(ic *importContext, r *resource) bool {
numBlocks := r.Data.Get("artifact_matcher.#").(int)
if numBlocks == 0 {
log.Printf("[WARN] Ignoring artifcat allowlist with ID %s", r.ID)
ic.addIgnoredResource(fmt.Sprintf("databricks_artifact_allowlist. id=%s", r.ID))
}
return numBlocks == 0
},
Depends: []reference{
{Path: "artifact_matcher.artifact", Resource: "databricks_volume", Match: "volume_path",
IsValidApproximation: isMatchingAllowListArtifact},
Expand Down
28 changes: 28 additions & 0 deletions exporter/importables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,34 @@ func TestListUcAllowListSuccess(t *testing.T) {
err := resourcesMap["databricks_artifact_allowlist"].List(ic)
assert.NoError(t, err)
assert.Equal(t, len(ic.testEmits), 3)
// Test ignore function
d := tfcatalog.ResourceArtifactAllowlist().ToResource().TestResourceData()
d.MarkNewResource()
d.Set("id", "abc")
res := ic.Importables["databricks_artifact_allowlist"].Ignore(ic, &resource{
ID: "abc",
Data: d,
})
assert.True(t, res)
assert.Contains(t, ic.ignoredResources, "databricks_artifact_allowlist. id=abc")
// Test ignore function, with blocks
err = common.StructToData(
tfcatalog.ArtifactAllowlistInfo{
ArtifactType: "INIT_SCRIPT",
ArtifactMatchers: []catalog.ArtifactMatcher{
{
Artifact: "/Volumes/inits",
MatchType: "PREFIX_MATCH",
},
},
},
tfcatalog.ResourceArtifactAllowlist().Schema, d)
assert.NoError(t, err)
res = ic.Importables["databricks_artifact_allowlist"].Ignore(ic, &resource{
ID: "abc",
Data: d,
})
assert.False(t, res)
}

func TestEmitSqlParent(t *testing.T) {
Expand Down
Loading