From 6445e1795ea58c0bd4153ff48f72b5d864578524 Mon Sep 17 00:00:00 2001 From: Antonis Kalipetis Date: Fri, 14 Jun 2024 13:18:08 +0300 Subject: [PATCH] Extend relationships to support the new formats --- platformifier/platformifier_test.go | 3 - validator/schema/platformsh.application.json | 66 ++++++++++++++++++-- validator/schema/upsun.json | 55 ++++++++++++++-- 3 files changed, 110 insertions(+), 14 deletions(-) diff --git a/platformifier/platformifier_test.go b/platformifier/platformifier_test.go index 0b196ef..eac9244 100644 --- a/platformifier/platformifier_test.go +++ b/platformifier/platformifier_test.go @@ -3,7 +3,6 @@ package platformifier import ( "context" "errors" - "fmt" "io/fs" "os" "reflect" @@ -574,8 +573,6 @@ func TestPlatformifier_Upsunify(t *testing.T) { if err := validator.ValidateConfig(dir, "upsun"); (err != nil) != tt.wantErr { t.Errorf("Platformifier.Platformify() validation error = %v, wantErr %v", err, tt.wantErr) } - out, _ := os.ReadFile(dir + "/.upsun/config.yaml") - fmt.Println(string(out)) }) } } diff --git a/validator/schema/platformsh.application.json b/validator/schema/platformsh.application.json index d2de89c..9ed28b4 100644 --- a/validator/schema/platformsh.application.json +++ b/validator/schema/platformsh.application.json @@ -45,7 +45,25 @@ "relationships": { "type": "object", "additionalProperties": { - "type": "string" + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + }, + { + "type": "object", + "properties": { + "service": { + "type": "string" + }, + "endpoint": { + "type": "string" + } + } + } + ] }, "title": "The relationships of the application to defined services.", "default": {} @@ -373,9 +391,28 @@ "relationships": { "type": "object", "additionalProperties": { - "type": "string" + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + }, + { + "type": "object", + "properties": { + "service": { + "type": "string" + }, + "endpoint": { + "type": "string" + } + } + } + ] }, - "title": "The relationships of the application to defined services." + "title": "The relationships of the application to defined services.", + "default": {} }, "access": { "type": "object", @@ -762,9 +799,28 @@ "relationships": { "type": "object", "additionalProperties": { - "type": "string" + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + }, + { + "type": "object", + "properties": { + "service": { + "type": "string" + }, + "endpoint": { + "type": "string" + } + } + } + ] }, - "title": "The relationships of the application to defined services." + "title": "The relationships of the application to defined services.", + "default": {} }, "access": { "type": "object", diff --git a/validator/schema/upsun.json b/validator/schema/upsun.json index 29dafae..53d3925 100644 --- a/validator/schema/upsun.json +++ b/validator/schema/upsun.json @@ -48,6 +48,9 @@ { "type": "string" }, + { + "type": "null" + }, { "type": "object", "properties": { @@ -57,8 +60,7 @@ "endpoint": { "type": "string" } - }, - "nullable": true + } } ] }, @@ -384,9 +386,28 @@ "relationships": { "type": "object", "additionalProperties": { - "type": "string" + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + }, + { + "type": "object", + "properties": { + "service": { + "type": "string" + }, + "endpoint": { + "type": "string" + } + } + } + ] }, - "title": "The relationships of the application to defined services." + "title": "The relationships of the application to defined services.", + "default": {} }, "access": { "type": "object", @@ -769,9 +790,28 @@ "relationships": { "type": "object", "additionalProperties": { - "type": "string" + "oneOf": [ + { + "type": "null" + }, + { + "type": "string" + }, + { + "type": "object", + "properties": { + "service": { + "type": "string" + }, + "endpoint": { + "type": "string" + } + } + } + ] }, - "title": "The relationships of the application to defined services." + "title": "The relationships of the application to defined services.", + "default": {} }, "access": { "type": "object", @@ -1278,6 +1318,9 @@ { "type": "string" }, + { + "type": "null" + }, { "type": "object", "properties": {