Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lennartkats-db committed Dec 21, 2024
1 parent 0acb222 commit 204d3b0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions bundle/config/mutator/apply_presets_catalog_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,15 @@ func addCatalogSchemaParameters(b *bundle.Bundle, key string, job *resources.Job
if param.Name == "catalog" {
hasCatalog = true
diags = diags.Extend(diag.Diagnostics{{
Summary: fmt.Sprintf("job %s already has 'catalog' parameter defined; ignoring preset value", key),
Summary: fmt.Sprintf("job '%s' already has 'catalog' parameter defined; ignoring preset value", key),
Severity: diag.Warning,
Locations: b.Config.GetLocations("resources.jobs." + key + ".parameters"),
}})
}
if param.Name == "schema" {
hasSchema = true
diags = diags.Extend(diag.Diagnostics{{
Summary: fmt.Sprintf("job %s already has 'schema' parameter defined; ignoring preset value", key),
Summary: fmt.Sprintf("job '%s' already has 'schema' parameter defined; ignoring preset value", key),
Severity: diag.Warning,
Locations: []dyn.Location{b.Config.GetLocation("resources.jobs." + key + ".parameters")},
}})
Expand Down
14 changes: 9 additions & 5 deletions bundle/config/mutator/apply_presets_catalog_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type recordedField struct {
Expected string
}

// mockPresetsCatalogSchema returns a mock bundle with all known resources
// that have catalog/schema fields, with those fields filled in as placeholders.
func mockPresetsCatalogSchema() *bundle.Bundle {
return &bundle.Bundle{
Config: config.Root{
Expand Down Expand Up @@ -162,7 +164,8 @@ func mockPresetsCatalogSchema() *bundle.Bundle {
}
}

// ignoredFields are fields that should be ignored in the completeness check
// ignoredFields are all paths to fields in resources where we don't want to
// apply the catalog/schema presets.
var ignoredFields = map[string]string{
"resources.pipelines.key.schema": "schema is still in private preview",
"resources.jobs.key.tasks[0].notebook_task.base_parameters": "catalog/schema are passed via job parameters",
Expand Down Expand Up @@ -266,7 +269,7 @@ func TestApplyPresetsCatalogSchemaCompleteness(t *testing.T) {

// Find all catalog/schema fields that we think should be covered based
// on all properties in config.Resources.
expectedFields := findCatalogSchemaFields()
expectedFields := findAllPossibleCatalogSchemaFields()
assert.GreaterOrEqual(t, len(expectedFields), 42, "expected at least 42 catalog/schema fields, but got %d", len(expectedFields))

// Verify that all expected fields are there
Expand Down Expand Up @@ -307,9 +310,10 @@ func recordPlaceholderFields(t *testing.T, b *bundle.Bundle) []recordedField {
return recordedFields
}

// findCatalogSchemaFields finds all fields in config.Resources that might refer
// to a catalog or schema. Returns a slice of field paths.
func findCatalogSchemaFields() []string {
// findAllPossibleCatalogSchemaFields finds all fields in config.Resources that might refer
// to a catalog or schema. Returns a slice of field paths like
// "resources.pipelines.key.catalog".
func findAllPossibleCatalogSchemaFields() []string {
visited := make(map[reflect.Type]struct{})
var results []string

Expand Down
2 changes: 1 addition & 1 deletion bundle/config/mutator/translate_paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type translateContext struct {
seen map[string]string
}

// GetLocalPath returns the local file system paths for a path referenced from a resource..
// GetLocalPath returns the local file system paths for a path referenced from a resource.
// If it's an absolute path, we treat it as a workspace path and return "".
//
// Arguments:
Expand Down

0 comments on commit 204d3b0

Please sign in to comment.