diff --git a/pkg/bundle/bundle.go b/pkg/bundle/bundle.go index d86dac0c..4071469d 100644 --- a/pkg/bundle/bundle.go +++ b/pkg/bundle/bundle.go @@ -31,7 +31,6 @@ type Step struct { } type Bundle struct { - Schema string `json:"schema,omitempty" yaml:"schema,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` SourceURL string `json:"source_url,omitempty" yaml:"source_url,omitempty"` diff --git a/pkg/bundle/lint_test.go b/pkg/bundle/lint_test.go index 67b4ade0..b9c7851e 100644 --- a/pkg/bundle/lint_test.go +++ b/pkg/bundle/lint_test.go @@ -25,7 +25,6 @@ func TestLintSchema(t *testing.T) { bun: &bundle.Bundle{ Name: "example", Description: "description", - Schema: "draft-07", Type: "infrastructure", Params: map[string]any{"properties": map[string]any{}}, Connections: map[string]any{"properties": map[string]any{}}, @@ -34,27 +33,6 @@ func TestLintSchema(t *testing.T) { }, want: bundle.LintResult{}, }, - { - name: "Invalid missing schema field", - bun: &bundle.Bundle{ - Name: "example", - Description: "description", - Type: "infrastructure", - Params: map[string]any{"properties": map[string]any{}}, - Connections: map[string]any{"properties": map[string]any{}}, - Artifacts: map[string]any{"properties": map[string]any{}}, - UI: map[string]any{"properties": map[string]any{}}, - }, - want: bundle.LintResult{ - Issues: []bundle.LintIssue{ - { - Rule: "schema-validation", - Severity: bundle.LintError, - Message: "missing property 'schema'", - }, - }, - }, - }, } for _, tc := range tests { @@ -164,8 +142,7 @@ func TestLintInputsMatchProvisioner(t *testing.T) { bun: &bundle.Bundle{ Name: "example", Description: "description", - Schema: "draft-07", - Type: "infrastructure", + Type: "infrastructure", Steps: []bundle.Step{{ Path: "testdata/lint/module", Provisioner: "opentofu", @@ -186,8 +163,7 @@ func TestLintInputsMatchProvisioner(t *testing.T) { bun: &bundle.Bundle{ Name: "example", Description: "description", - Schema: "draft-07", - Type: "infrastructure", + Type: "infrastructure", Steps: []bundle.Step{{ Path: "testdata/lint/module", Provisioner: "opentofu", @@ -293,7 +269,6 @@ func TestLintMatchRequired(t *testing.T) { bun: &bundle.Bundle{ Name: "example", Description: "description", - Schema: "draft-07", Type: "infrastructure", Params: map[string]any{ "required": []any{"foo"}, @@ -314,7 +289,6 @@ func TestLintMatchRequired(t *testing.T) { bun: &bundle.Bundle{ Name: "example", Description: "description", - Schema: "draft-07", Type: "infrastructure", Params: map[string]any{ "required": []any{"bar"}, @@ -343,7 +317,6 @@ func TestLintMatchRequired(t *testing.T) { bun: &bundle.Bundle{ Name: "example", Description: "description", - Schema: "draft-07", Type: "infrastructure", Params: map[string]any{ "required": []any{"foo"}, @@ -370,7 +343,6 @@ func TestLintMatchRequired(t *testing.T) { bun: &bundle.Bundle{ Name: "example", Description: "description", - Schema: "draft-07", Type: "infrastructure", Params: map[string]any{ "required": []any{"foo"}, diff --git a/pkg/bundle/testdata/lint/schema/bundle.json b/pkg/bundle/testdata/lint/schema/bundle.json index 5934d4e9..057567c9 100644 --- a/pkg/bundle/testdata/lint/schema/bundle.json +++ b/pkg/bundle/testdata/lint/schema/bundle.json @@ -7,7 +7,6 @@ "connections", "artifacts", "ui", - "schema", "description", "type", "name" @@ -79,14 +78,6 @@ "minLength": 3, "maxLength": 53 }, - "schema": { - "title": "JSON Schema Schema", - "type": "string", - "description": "The JSON Schema used to define the bundle.", - "enum": [ - "draft-07" - ] - }, "description": { "title": "Description", "description": "A description of the bundle.", diff --git a/pkg/bundle/write_schemas.go b/pkg/bundle/write_schemas.go index a8b35f57..8b56408f 100644 --- a/pkg/bundle/write_schemas.go +++ b/pkg/bundle/write_schemas.go @@ -8,7 +8,7 @@ import ( ) const idURLPattern = "https://schemas.massdriver.cloud/schemas/bundles/%s/schema-%s.json" -const jsonSchemaURLPattern = "http://json-schema.org/%s/schema" +const jsonSchemaURL = "http://json-schema.org/draft-07/schema" type Schema struct { schema map[string]any @@ -74,18 +74,14 @@ func generateIDURL(mdName string, schemaType string) string { return fmt.Sprintf(idURLPattern, mdName, schemaType) } -func generateSchemaURL(schema string) string { - return fmt.Sprintf(jsonSchemaURLPattern, schema) -} - -// Metadata returns common metadata fields for each JSON Schema +// buildMetadata returns common metadata fields for each JSON Schema func buildMetadata(schemaType string, b Bundle) map[string]string { if schemaType == "ui" { return make(map[string]string) } return map[string]string{ - "$schema": generateSchemaURL(b.Schema), + "$schema": jsonSchemaURL, "$id": generateIDURL(b.Name, schemaType), "title": b.Name, "description": b.Description,