Skip to content
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
1 change: 0 additions & 1 deletion pkg/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
32 changes: 2 additions & 30 deletions pkg/bundle/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}},
Expand All @@ -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 {
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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"},
Expand All @@ -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"},
Expand Down Expand Up @@ -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"},
Expand All @@ -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"},
Expand Down
9 changes: 0 additions & 9 deletions pkg/bundle/testdata/lint/schema/bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"connections",
"artifacts",
"ui",
"schema",
"description",
"type",
"name"
Expand Down Expand Up @@ -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.",
Expand Down
10 changes: 3 additions & 7 deletions pkg/bundle/write_schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Loading