From 33eb3984aa19fe23a93ee06badce9978c9cfab75 Mon Sep 17 00:00:00 2001 From: Varik Matevosyan Date: Sun, 5 May 2024 12:13:08 -0700 Subject: [PATCH] add labels to lantern resource in api as well --- routes/api/project/lantern.rb | 1 + serializers/api/lantern.rb | 1 + spec/routes/api/project/lantern_spec.rb | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/routes/api/project/lantern.rb b/routes/api/project/lantern.rb index 451e81f60..cdeeed08c 100644 --- a/routes/api/project/lantern.rb +++ b/routes/api/project/lantern.rb @@ -43,6 +43,7 @@ class CloverApi project_id: @project.id, location: r.params["location"], name: r.params["name"], + label: r.params["label"], org_id: r.params["org_id"].to_i, target_vm_size: parsed_size.vm_size, target_storage_size_gib: r.params["storage_size_gib"] || parsed_size.storage_size_gib, diff --git a/serializers/api/lantern.rb b/serializers/api/lantern.rb index c3afa9501..60cd8d24b 100644 --- a/serializers/api/lantern.rb +++ b/serializers/api/lantern.rb @@ -8,6 +8,7 @@ def self.base(pg) parent_id: pg.parent_id, path: pg.path, name: pg.name, + label: pg.label, state: pg.display_state, instance_type: pg.representative_server&.instance_type, location: pg.location, diff --git a/spec/routes/api/project/lantern_spec.rb b/spec/routes/api/project/lantern_spec.rb index b06b1b604..a40b9c71f 100644 --- a/spec/routes/api/project/lantern_spec.rb +++ b/spec/routes/api/project/lantern_spec.rb @@ -59,12 +59,13 @@ describe "create" do it "creates new lantern database" do - post "/api/project/#{project.ubid}/lantern", {size: "n1-standard-2", name: "instance-2", org_id: 0, location: "us-central1", storage_size_gib: 100, lantern_version: "0.2.2", extras_version: "0.1.4", minor_version: "1", domain: "test.db.lantern.dev", app_env: "test", repl_password: "test-repl-pass", enable_telemetry: true, postgres_password: "test-pg-pass"} + post "/api/project/#{project.ubid}/lantern", {size: "n1-standard-2", name: "instance-2", label: "test-label", org_id: 0, location: "us-central1", storage_size_gib: 100, lantern_version: "0.2.2", extras_version: "0.1.4", minor_version: "1", domain: "test.db.lantern.dev", app_env: "test", repl_password: "test-repl-pass", enable_telemetry: true, postgres_password: "test-pg-pass"} body = JSON.parse(last_response.body) expect(last_response.status).to eq(200) expect(body["name"]).to eq("instance-2") + expect(body["label"]).to eq("test-label") expect(body["state"]).to eq("creating") expect(body["instance_type"]).to eq("writer") expect(body["location"]).to eq("us-central1")