This commit is contained in:
Lennart Kats 2024-12-21 09:49:23 +01:00
parent 0acb2223bc
commit 204d3b08d1
No known key found for this signature in database
GPG Key ID: 1EB8B57673197023
3 changed files with 12 additions and 8 deletions

View File

@ -240,7 +240,7 @@ func addCatalogSchemaParameters(b *bundle.Bundle, key string, job *resources.Job
if param.Name == "catalog" { if param.Name == "catalog" {
hasCatalog = true hasCatalog = true
diags = diags.Extend(diag.Diagnostics{{ 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, Severity: diag.Warning,
Locations: b.Config.GetLocations("resources.jobs." + key + ".parameters"), Locations: b.Config.GetLocations("resources.jobs." + key + ".parameters"),
}}) }})
@ -248,7 +248,7 @@ func addCatalogSchemaParameters(b *bundle.Bundle, key string, job *resources.Job
if param.Name == "schema" { if param.Name == "schema" {
hasSchema = true hasSchema = true
diags = diags.Extend(diag.Diagnostics{{ 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, Severity: diag.Warning,
Locations: []dyn.Location{b.Config.GetLocation("resources.jobs." + key + ".parameters")}, Locations: []dyn.Location{b.Config.GetLocation("resources.jobs." + key + ".parameters")},
}}) }})

View File

@ -27,6 +27,8 @@ type recordedField struct {
Expected string 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 { func mockPresetsCatalogSchema() *bundle.Bundle {
return &bundle.Bundle{ return &bundle.Bundle{
Config: config.Root{ Config: config.Root{
@ -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{ var ignoredFields = map[string]string{
"resources.pipelines.key.schema": "schema is still in private preview", "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", "resources.jobs.key.tasks[0].notebook_task.base_parameters": "catalog/schema are passed via job parameters",
@ -266,7 +269,7 @@ func TestApplyPresetsCatalogSchemaCompleteness(t *testing.T) {
// Find all catalog/schema fields that we think should be covered based // Find all catalog/schema fields that we think should be covered based
// on all properties in config.Resources. // 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)) 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 // Verify that all expected fields are there
@ -307,9 +310,10 @@ func recordPlaceholderFields(t *testing.T, b *bundle.Bundle) []recordedField {
return recordedFields return recordedFields
} }
// findCatalogSchemaFields finds all fields in config.Resources that might refer // findAllPossibleCatalogSchemaFields finds all fields in config.Resources that might refer
// to a catalog or schema. Returns a slice of field paths. // to a catalog or schema. Returns a slice of field paths like
func findCatalogSchemaFields() []string { // "resources.pipelines.key.catalog".
func findAllPossibleCatalogSchemaFields() []string {
visited := make(map[reflect.Type]struct{}) visited := make(map[reflect.Type]struct{})
var results []string var results []string

View File

@ -59,7 +59,7 @@ type translateContext struct {
seen map[string]string 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 "". // If it's an absolute path, we treat it as a workspace path and return "".
// //
// Arguments: // Arguments: