From 1acaad4862b6a18054ab1d75477047aa11cbedd7 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Thu, 23 Nov 2023 16:33:42 +0530 Subject: [PATCH 1/6] added migration script for dependency --- scripts/sql/196_alter_resource.down.sql | 3 +++ scripts/sql/196_alter_resource.up.sql | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 scripts/sql/196_alter_resource.down.sql create mode 100644 scripts/sql/196_alter_resource.up.sql diff --git a/scripts/sql/196_alter_resource.down.sql b/scripts/sql/196_alter_resource.down.sql new file mode 100644 index 00000000000..438010ddbd7 --- /dev/null +++ b/scripts/sql/196_alter_resource.down.sql @@ -0,0 +1,3 @@ +delete +from devtron_resource +where kind = 'cd-pipeline'; \ No newline at end of file diff --git a/scripts/sql/196_alter_resource.up.sql b/scripts/sql/196_alter_resource.up.sql new file mode 100644 index 00000000000..f96c0778352 --- /dev/null +++ b/scripts/sql/196_alter_resource.up.sql @@ -0,0 +1,3 @@ +INSERT INTO devtron_resource(kind, display_name, icon, parent_kind_id, deleted, created_on, created_by, updated_on, + updated_by) +VALUES ('cd-pipeline', 'Cd Pipeline', '', 0, false, now(), 1, now(), 1); From 42311305eb24a93c1789656f9f6d210bc3473190 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Thu, 30 Nov 2023 04:00:29 +0530 Subject: [PATCH 2/6] added schema for cd pipeline --- scripts/sql/196_alter_resource.up.sql | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/scripts/sql/196_alter_resource.up.sql b/scripts/sql/196_alter_resource.up.sql index f96c0778352..77f79e6e34a 100644 --- a/scripts/sql/196_alter_resource.up.sql +++ b/scripts/sql/196_alter_resource.up.sql @@ -1,3 +1,35 @@ INSERT INTO devtron_resource(kind, display_name, icon, parent_kind_id, deleted, created_on, created_by, updated_on, updated_by) VALUES ('cd-pipeline', 'Cd Pipeline', '', 0, false, now(), 1, now(), 1); + + +INSERT INTO devtron_resource_schema(devtron_resource_id, version, schema, latest, created_on, created_by, updated_on, + updated_by) +VALUES ((select id from devtron_resource where kind = 'cd-pipeline'), 'v1', + '{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "CD Pipeline Schema", + "type": "object", + "properties": { + "version": { + "type": "string" + }, + "kind": { + "type": "string" + }, + "overview": { + "type": "object" + }, + "actions": { + "type": "object" + }, + "dependencies": { + "type": "array" + } + }, + "required": [ + "version", + "kind" + ] + }', + true, now(), 1, now(), 1); \ No newline at end of file From 05e90edddd9b1c7530f70f99bf015bb13494d27c Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Thu, 30 Nov 2023 04:05:56 +0530 Subject: [PATCH 3/6] updated existing schemas --- scripts/sql/196_alter_resource.up.sql | 788 +++++++++++++++++++++++++- 1 file changed, 786 insertions(+), 2 deletions(-) diff --git a/scripts/sql/196_alter_resource.up.sql b/scripts/sql/196_alter_resource.up.sql index 77f79e6e34a..6fa52bb7220 100644 --- a/scripts/sql/196_alter_resource.up.sql +++ b/scripts/sql/196_alter_resource.up.sql @@ -21,7 +21,7 @@ VALUES ((select id from devtron_resource where kind = 'cd-pipeline'), 'v1', "type": "object" }, "actions": { - "type": "object" + "type": "array" }, "dependencies": { "type": "array" @@ -32,4 +32,788 @@ VALUES ((select id from devtron_resource where kind = 'cd-pipeline'), 'v1', "kind" ] }', - true, now(), 1, now(), 1); \ No newline at end of file + true, now(), 1, now(), 1); + + + +update devtron_resource_schema +set schema='{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Cluster Schema", + "type": "object", + "properties": + { + "version": + { + "type": "string" + }, + "kind": + { + "type": "string" + }, + "overview": + { + "type": "object", + "properties": + { + "id": + { + "type": "number" + }, + "name": + { + "type": "string" + }, + "icon": + { + "type": "string", + "contentEncoding": "base64" + }, + "description": + { + "type": "string" + }, + "createdOn": + { + "type": "string" + }, + "createdBy": + { + "type": "object", + "refType": "#/references/users" + }, + "tags": + { + "additionalProperties": + { + "type": "string" + } + }, + "metadata": + { + "type": "object", + "properties": + { + "Contacts": + { + "type": "object", + "properties": + { + "Owner": + { + "type": "object", + "refType": "#/references/users" + }, + "On pager duty": + { + "type": "array", + "uniqueItems": true, + "items": + { + "type": "object", + "refType": "#/references/users" + } + }, + "Team": + { + "type": "string", + "enum": + [ + "Growth team", + "Support team", + "Platform team", + "Operations team" + ] + }, + "3rd party contacts": + { + "type": "array", + "uniqueItems": true, + "items": + { + "type": "string" + } + } + }, + "required": + [ + "Owner" + ] + }, + "Networking & Others": + { + "type": "object", + "properties": + { + "Cluster type": + { + "type": "string", + "enum": + [ + "Production", + "Non production" + ] + }, + "Exposed to": + { + "type": "string", + "enum": + [ + "Public", + "Private" + ] + }, + "VPC peered": + { + "type": "array", + "items": + { + "type": "string" + } + }, + "Documentation": + { + "type": "string", + "format": "uri" + } + } + }, + "Backup": + { + "type": "object", + "properties": + { + "Backup strategy": + { + "type": "string", + "enum": + [ + "Full backup", + "Incremental", + "Snapshot" + ] + }, + "Backup retention policy (days)": + { + "type": "integer" + } + } + } + }, + "required": + [ + "Contacts" + ] + } + }, + "required": + [ + "id", + "metadata" + ] + }, + "actions": + { + "type": "array" + }, + "dependencies": + { + "type": "array" + } + }, + "required": + [ + "version", + "kind", + "overview" + ] +}' +where devtron_resource_id = (select id from devtron_resource where kind = 'cluster') + and version = 'v1'; + +update devtron_resource_schema +set schema='{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Job Schema", + "type": "object", + "properties": + { + "version": + { + "type": "string" + }, + "kind": + { + "type": "string" + }, + "overview": + { + "type": "object", + "properties": + { + "id": + { + "type": "number" + }, + "name": + { + "type": "string" + }, + "icon": + { + "type": "string", + "contentEncoding": "base64" + }, + "description": + { + "type": "string" + }, + "createdOn": + { + "type": "string" + }, + "createdBy": + { + "type": "object", + "refType": "#/references/users" + }, + "tags": + { + "additionalProperties": + { + "type": "string" + } + }, + "metadata": + { + "type": "object", + "properties": + { + "Contacts": + { + "type": "object", + "properties": + { + "Owner": + { + "type": "object", + "refType": "#/references/users" + }, + "POCs": + { + "type": "array", + "uniqueItems": true, + "items": + { + "type": "object", + "refType": "#/references/users" + } + }, + "Team": + { + "type": "string", + "enum": + [ + "Growth team", + "Support team", + "Platform team", + "Operations team" + ] + }, + "Access manager": + { + "type": "array", + "uniqueItems": true, + "items": + { + "type": "object", + "refType": "#/references/users" + } + } + }, + "required": + [ + "Owner" + ] + }, + "About job": + { + "type": "object", + "properties": + { + "Type of job": + { + "type": "string", + "enum": + [ + "Deployment", + "Migration", + "Backup", + "Others" + ] + }, + "For environment": + { + "type": "string", + "enum": + [ + "Production", + "Dev", + "Staging", + "QA", + "UAT" + ] + }, + "Documentation": + { + "type": "string", + "format": "uri" + } + } + }, + "Operational schedule": + { + "type": "object", + "properties": + { + "Preferred run": + { + "type": "string" + }, + "Maintenance time": + { + "type": "string" + } + } + } + }, + "required": + [ + "Contacts" + ] + } + }, + "required": + [ + "id", + "metadata" + ] + }, + "actions": + { + "type": "array" + }, + "dependencies": + { + "type": "array" + } + }, + "required": + [ + "version", + "kind", + "overview" + ] +}' +where devtron_resource_id = (select id from devtron_resource where kind = 'job') + and version = 'v1'; + +update devtron_resource_schema +set schema='{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Devtron Application Schema", + "type": "object", + "properties": + { + "version": + { + "type": "string" + }, + "kind": + { + "type": "string" + }, + "overview": + { + "type": "object", + "properties": + { + "id": + { + "type": "number" + }, + "name": + { + "type": "string" + }, + "icon": + { + "type": "string", + "contentEncoding": "base64" + }, + "description": + { + "type": "string" + }, + "createdOn": + { + "type": "string" + }, + "createdBy": + { + "type": "object", + "refType": "#/references/users" + }, + "tags": + { + "additionalProperties": + { + "type": "string" + } + }, + "metadata": + { + "type": "object", + "properties": + { + "Owners & Pager Duty": + { + "type": "object", + "properties": + { + "Code owners": + { + "type": "array", + "uniqueItems": true, + "items": + { + "type": "object", + "refType": "#/references/users" + } + }, + "On pager duty": + { + "type": "object", + "refType": "#/references/users" + } + }, + "required": + [ + "Code owners" + ] + }, + "Service details": + { + "type": "object", + "properties": + { + "Framework": + { + "type": "array", + "uniqueItems": true, + "items": + { + "type": "string", + "enum": + [ + "Django", + "Ruby on Rails", + "Laravel", + "Angular", + "React", + "jQuery", + "ASP.NET Core", + "Bootstrap" + ] + } + }, + "Language": + { + "type": "array", + "uniqueItems": true, + "items": + { + "type": "string", + "enum": + [ + "Java", + "Python", + "PHP", + "Go", + "Ruby", + "Node" + ] + } + }, + "Communication method": + { + "type": "string", + "enum": + [ + "GraphQL", + "gRPC", + "Message Queue", + "NATS", + "REST API", + "WebSocket" + ] + }, + "Internet facing": + { + "type": "boolean" + } + } + }, + "Documentation": + { + "type": "object", + "properties": + { + "Service Documentation": + { + "type": "string", + "format": "uri" + }, + "API Contract": + { + "type": "string", + "format": "uri" + }, + "Runbook": + { + "type": "string", + "format": "uri" + } + } + } + }, + "required": + [ + "Owners & Pager Duty" + ] + } + }, + "required": + [ + "id", + "metadata" + ] + }, + "actions": + { + "type": "array" + }, + "dependencies": + { + "type": "array" + } + }, + "required": + [ + "version", + "kind", + "overview" + ] +}' +where devtron_resource_id = (select id from devtron_resource where kind = 'devtron-application') + and version = 'v1'; + +update devtron_resource_schema +set schema='{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Helm Application Schema", + "type": "object", + "properties": + { + "version": + { + "type": "string" + }, + "kind": + { + "type": "string" + }, + "overview": + { + "type": "object", + "properties": + { + "id": + { + "type": "number" + }, + "name": + { + "type": "string" + }, + "icon": + { + "type": "string", + "contentEncoding": "base64" + }, + "description": + { + "type": "string" + }, + "createdOn": + { + "type": "string" + }, + "createdBy": + { + "type": "object", + "refType": "#/references/users" + }, + "tags": + { + "additionalProperties": + { + "type": "string" + } + }, + "metadata": + { + "type": "object", + "properties": + { + "Owners & Pager Duty": + { + "type": "object", + "properties": + { + "Code owners": + { + "type": "array", + "uniqueItems": true, + "items": + { + "type": "object", + "refType": "#/references/users" + } + }, + "On pager duty": + { + "type": "object", + "refType": "#/references/users" + } + }, + "required": + [ + "Code owners" + ] + }, + "Service details": + { + "type": "object", + "properties": + { + "Framework": + { + "type": "array", + "uniqueItems": true, + "items": + { + "type": "string", + "enum": + [ + "Django", + "Ruby on Rails", + "Laravel", + "Angular", + "React", + "jQuery", + "ASP.NET Core", + "Bootstrap" + ] + } + }, + "Language": + { + "type": "array", + "uniqueItems": true, + "items": + { + "type": "string", + "enum": + [ + "Java", + "Python", + "PHP", + "Go", + "Ruby", + "Node" + ] + } + }, + "Communication method": + { + "type": "string", + "enum": + [ + "GraphQL", + "gRPC", + "Message Queue", + "NATS", + "REST API", + "WebSocket" + ] + }, + "Internet facing": + { + "type": "boolean" + } + } + }, + "Documentation": + { + "type": "object", + "properties": + { + "Service Documentation": + { + "type": "string", + "format": "uri" + }, + "API Contract": + { + "type": "string", + "format": "uri" + }, + "Runbook": + { + "type": "string", + "format": "uri" + } + } + } + }, + "required": + [ + "Owners & Pager Duty" + ] + } + }, + "required": + [ + "id", + "metadata" + ] + }, + "actions": + { + "type": "array" + }, + "dependencies": + { + "type": "array" + } + }, + "required": + [ + "version", + "kind", + "overview" + ] +}' +where devtron_resource_id = (select id from devtron_resource where kind = 'helm-application') + and version = 'v1'; \ No newline at end of file From 17a08da194adda678c752d27d5edccd2e259c449 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Thu, 30 Nov 2023 13:06:10 +0530 Subject: [PATCH 4/6] synced schema with v1 story --- scripts/sql/196_alter_resource.up.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/sql/196_alter_resource.up.sql b/scripts/sql/196_alter_resource.up.sql index 6fa52bb7220..3d1fa799b41 100644 --- a/scripts/sql/196_alter_resource.up.sql +++ b/scripts/sql/196_alter_resource.up.sql @@ -34,8 +34,6 @@ VALUES ((select id from devtron_resource where kind = 'cd-pipeline'), 'v1', }', true, now(), 1, now(), 1); - - update devtron_resource_schema set schema='{ "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -485,6 +483,7 @@ set schema='{ { "type": "array", "uniqueItems": true, + "minItems": 1, "items": { "type": "object", @@ -685,6 +684,7 @@ set schema='{ { "type": "array", "uniqueItems": true, + "minItems": 1, "items": { "type": "object", From 26a867678b9a8eea010b96124efeed9f7bbd098d Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 5 Dec 2023 09:50:09 +0530 Subject: [PATCH 5/6] updated sql script no --- .../{196_alter_resource.down.sql => 198_alter_resource.down.sql} | 0 .../sql/{196_alter_resource.up.sql => 198_alter_resource.up.sql} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename scripts/sql/{196_alter_resource.down.sql => 198_alter_resource.down.sql} (100%) rename scripts/sql/{196_alter_resource.up.sql => 198_alter_resource.up.sql} (100%) diff --git a/scripts/sql/196_alter_resource.down.sql b/scripts/sql/198_alter_resource.down.sql similarity index 100% rename from scripts/sql/196_alter_resource.down.sql rename to scripts/sql/198_alter_resource.down.sql diff --git a/scripts/sql/196_alter_resource.up.sql b/scripts/sql/198_alter_resource.up.sql similarity index 100% rename from scripts/sql/196_alter_resource.up.sql rename to scripts/sql/198_alter_resource.up.sql From 8ca0a70adbaab561968773e1b24a4f275050ebac Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Fri, 8 Dec 2023 01:05:01 +0530 Subject: [PATCH 6/6] updated sql script no. --- .../{198_alter_resource.down.sql => 201_alter_resource.down.sql} | 0 .../sql/{198_alter_resource.up.sql => 201_alter_resource.up.sql} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename scripts/sql/{198_alter_resource.down.sql => 201_alter_resource.down.sql} (100%) rename scripts/sql/{198_alter_resource.up.sql => 201_alter_resource.up.sql} (100%) diff --git a/scripts/sql/198_alter_resource.down.sql b/scripts/sql/201_alter_resource.down.sql similarity index 100% rename from scripts/sql/198_alter_resource.down.sql rename to scripts/sql/201_alter_resource.down.sql diff --git a/scripts/sql/198_alter_resource.up.sql b/scripts/sql/201_alter_resource.up.sql similarity index 100% rename from scripts/sql/198_alter_resource.up.sql rename to scripts/sql/201_alter_resource.up.sql