From 2523e807e6a1d8ea542abbf31a2fd58dbe268f34 Mon Sep 17 00:00:00 2001 From: Kevin Franklin Kim Date: Tue, 8 Oct 2024 10:12:15 +0200 Subject: [PATCH] fix: ref --- internal/config/unit.go | 11 ++++++++++- squadron.schema.json | 3 +-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/internal/config/unit.go b/internal/config/unit.go index f5ef0b3..00ea908 100644 --- a/internal/config/unit.go +++ b/internal/config/unit.go @@ -14,7 +14,7 @@ import ( ) type Unit struct { - Chart Chart `json:"chart,omitempty" yaml:"chart,omitempty" jsonschema:"anyof_type=string;Chart"` + Chart Chart `json:"chart,omitempty" yaml:"chart,omitempty" jsonschema:"anyof_type=string,anyof_ref=#/$defs/Chart"` Kustomize string `json:"kustomize,omitempty" yaml:"kustomize,omitempty"` Tags Tags `json:"tags,omitempty" yaml:"tags,omitempty"` Builds map[string]Build `json:"builds,omitempty" yaml:"builds,omitempty"` @@ -25,6 +25,15 @@ type Unit struct { // ~ Public methods // ------------------------------------------------------------------------------------------------ +// JSONSchemaProperty type workaround +func (Unit) JSONSchemaProperty(prop string) any { + var x any + if prop == "chart" { + return x + } + return nil +} + func (u *Unit) ValuesYAML(global, vars map[string]any) ([]byte, error) { values := u.Values if values == nil { diff --git a/squadron.schema.json b/squadron.schema.json index f209b49..4e5755a 100644 --- a/squadron.schema.json +++ b/squadron.schema.json @@ -180,13 +180,12 @@ "Unit": { "properties": { "chart": { - "$ref": "#/$defs/Chart", "anyOf": [ { "type": "string" }, { - "type": "Chart" + "$ref": "#/$defs/Chart" } ] },