From 2a1d0cba7d46056c6d44824852a8420842d242fe Mon Sep 17 00:00:00 2001 From: Carmine Di Monaco Date: Fri, 16 Feb 2024 14:23:57 +0100 Subject: [PATCH 01/11] Add additionalProperties false to openapi schema objects --- lib/trento_web/openapi/v1/schema/bad_request.ex | 1 + lib/trento_web/openapi/v1/schema/chart.ex | 3 +++ lib/trento_web/openapi/v1/schema/checks.ex | 1 + lib/trento_web/openapi/v1/schema/checks_catalog.ex | 5 +++++ lib/trento_web/openapi/v1/schema/cluster.ex | 5 +++++ lib/trento_web/openapi/v1/schema/database.ex | 2 ++ lib/trento_web/openapi/v1/schema/discovery_event.ex | 1 + lib/trento_web/openapi/v1/schema/health.ex | 1 + lib/trento_web/openapi/v1/schema/host.ex | 1 + lib/trento_web/openapi/v1/schema/http_std.ex | 1 + lib/trento_web/openapi/v1/schema/not_found.ex | 1 + lib/trento_web/openapi/v1/schema/platform.ex | 2 ++ lib/trento_web/openapi/v1/schema/provider.ex | 3 +++ lib/trento_web/openapi/v1/schema/ready.ex | 1 + lib/trento_web/openapi/v1/schema/sap_system.ex | 3 +++ lib/trento_web/openapi/v1/schema/saptune_status.ex | 5 +++++ lib/trento_web/openapi/v1/schema/sles_subscription.ex | 1 + lib/trento_web/openapi/v1/schema/suma_credentials.ex | 3 +++ lib/trento_web/openapi/v1/schema/tag.ex | 1 + lib/trento_web/openapi/v1/schema/unprocessable_entity.ex | 1 + lib/trento_web/openapi/v2/schema/cluster.ex | 7 +++++++ 21 files changed, 49 insertions(+) diff --git a/lib/trento_web/openapi/v1/schema/bad_request.ex b/lib/trento_web/openapi/v1/schema/bad_request.ex index 76bac363b8..cc42b36eda 100644 --- a/lib/trento_web/openapi/v1/schema/bad_request.ex +++ b/lib/trento_web/openapi/v1/schema/bad_request.ex @@ -11,6 +11,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.BadRequest do OpenApiSpex.schema(%{ title: "BadRequest", type: :object, + additionalProperties: false, properties: %{ errors: %Schema{ type: :array, diff --git a/lib/trento_web/openapi/v1/schema/chart.ex b/lib/trento_web/openapi/v1/schema/chart.ex index cf887178c1..7313dbb47d 100644 --- a/lib/trento_web/openapi/v1/schema/chart.ex +++ b/lib/trento_web/openapi/v1/schema/chart.ex @@ -11,6 +11,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Chart do description: "A Time Series for a chart, has a series of float values distributed through time", type: :object, + additionalProperties: false, properties: %{ label: %Schema{type: :string, description: "The name of series"}, series: %Schema{ @@ -43,6 +44,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Chart do OpenApiSpex.schema(%{ title: "HostCpuChart", + additionalProperties: false, description: "A Time Series chart with information about the cpu usage of a host", type: :object, properties: %{ @@ -63,6 +65,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Chart do title: "HostMemoryChart", description: "A Time series chart with information about the memory usage of a host", type: :object, + additionalProperties: false, properties: %{ ram_total: ChartTimeSeries, ram_cache_and_buffer: ChartTimeSeries, diff --git a/lib/trento_web/openapi/v1/schema/checks.ex b/lib/trento_web/openapi/v1/schema/checks.ex index d83b7d741b..b2a23ea88a 100644 --- a/lib/trento_web/openapi/v1/schema/checks.ex +++ b/lib/trento_web/openapi/v1/schema/checks.ex @@ -6,6 +6,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Checks.ChecksSelectionRequest do OpenApiSpex.schema(%{ title: "ChecksSelectionRequest", description: "A list of desired checks that should be executed on the target infrastructure", + additionalProperties: false, type: :object, properties: %{ checks: %Schema{ diff --git a/lib/trento_web/openapi/v1/schema/checks_catalog.ex b/lib/trento_web/openapi/v1/schema/checks_catalog.ex index 77934366f9..a10bfc2c27 100644 --- a/lib/trento_web/openapi/v1/schema/checks_catalog.ex +++ b/lib/trento_web/openapi/v1/schema/checks_catalog.ex @@ -13,6 +13,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.ChecksCatalog do title: "Check", description: "An available check to be executed on the target infrastructure", type: :object, + additionalProperties: false, properties: %{ id: %Schema{type: :string, description: "Check ID", format: :uuid}, name: %Schema{type: :string, description: "Check Name"}, @@ -50,6 +51,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.ChecksCatalog do OpenApiSpex.schema(%{ title: "ChecksGroup", description: "A Group of related Checks (Corosync, Pacemaker ...)", + additionalProperties: false, type: :object, properties: %{ group: %Schema{type: :string, description: "Group Name"}, @@ -64,6 +66,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.ChecksCatalog do OpenApiSpex.schema(%{ title: "ProviderCatalog", description: "A Provider specific Catalog, and respective values", + additionalProperties: false, type: :object, properties: %{ provider: %Schema{ @@ -164,6 +167,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.ChecksCatalog do OpenApiSpex.schema(%{ title: "CatalogNotfound", description: "No Catalog was found for the provided query", + additionalProperties: false, type: :object, properties: %{ error: %Schema{ @@ -181,6 +185,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.ChecksCatalog do OpenApiSpex.schema(%{ title: "UnableToLoadCatalog", description: "Something wrong happened while loading the catalog. ie: it is not ready yet", + additionalProperties: false, type: :object, properties: %{ error: %Schema{type: :string, description: "The error message"} diff --git a/lib/trento_web/openapi/v1/schema/cluster.ex b/lib/trento_web/openapi/v1/schema/cluster.ex index 45d9a17993..71cff22b76 100644 --- a/lib/trento_web/openapi/v1/schema/cluster.ex +++ b/lib/trento_web/openapi/v1/schema/cluster.ex @@ -14,6 +14,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Cluster do title: "ClusterResource", description: "A Cluster Resource", type: :object, + additionalProperties: false, properties: %{ id: %Schema{type: :string}, type: %Schema{type: :string}, @@ -30,6 +31,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Cluster do OpenApiSpex.schema(%{ title: "HanaClusterNode", description: "A HANA Cluster Node", + additionalProperties: false, type: :object, properties: %{ name: %Schema{type: :string}, @@ -56,6 +58,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Cluster do OpenApiSpex.schema(%{ title: "SbdDevice", description: "SBD Device", + additionalProperties: false, type: :object, properties: %{ device: %Schema{type: :string}, @@ -71,6 +74,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Cluster do title: "HanaClusterDetails", description: "Details of a HANA Pacemaker Cluster", type: :object, + additionalProperties: false, properties: %{ system_replication_mode: %Schema{type: :string, description: "System Replication Mode"}, system_replication_operation_mode: %Schema{ @@ -118,6 +122,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Cluster do title: "PacemakerCluster", description: "A discovered Pacemaker Cluster on the target infrastructure", type: :object, + additionalProperties: false, properties: %{ id: %Schema{type: :string, description: "Cluster ID", format: :uuid}, name: %Schema{type: :string, description: "Cluster name"}, diff --git a/lib/trento_web/openapi/v1/schema/database.ex b/lib/trento_web/openapi/v1/schema/database.ex index 62dde505a0..b65ca73036 100644 --- a/lib/trento_web/openapi/v1/schema/database.ex +++ b/lib/trento_web/openapi/v1/schema/database.ex @@ -13,6 +13,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Database do title: "DatabaseInstance", description: "A discovered HANA Database Instance on the target infrastructure", type: :object, + additionalProperties: false, properties: %{ sap_system_id: %Schema{type: :string, description: "SAP System ID", format: :uuid}, sid: %Schema{type: :string, description: "SID"}, @@ -65,6 +66,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Database do title: "Database", description: "A discovered HANA Database on the target infrastructure", type: :object, + additionalProperties: false, properties: %{ id: %Schema{type: :string, description: "Database ID", format: :uuid}, sid: %Schema{type: :string, description: "SID"}, diff --git a/lib/trento_web/openapi/v1/schema/discovery_event.ex b/lib/trento_web/openapi/v1/schema/discovery_event.ex index 2ff910ac2a..0ef0b78f49 100644 --- a/lib/trento_web/openapi/v1/schema/discovery_event.ex +++ b/lib/trento_web/openapi/v1/schema/discovery_event.ex @@ -9,6 +9,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.DiscoveryEvent do title: "DiscoveryEvent", description: "A discovery event", type: :object, + additionalProperties: false, properties: %{ agent_id: %Schema{type: :string, format: :uuid}, discovery_type: %Schema{type: :string}, diff --git a/lib/trento_web/openapi/v1/schema/health.ex b/lib/trento_web/openapi/v1/schema/health.ex index a2ebc3012d..d1617f1eae 100644 --- a/lib/trento_web/openapi/v1/schema/health.ex +++ b/lib/trento_web/openapi/v1/schema/health.ex @@ -13,6 +13,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Health do example: %{ database: "pass" }, + additionalProperties: false, properties: %{ database: %Schema{ description: "The status of the database connection", diff --git a/lib/trento_web/openapi/v1/schema/host.ex b/lib/trento_web/openapi/v1/schema/host.ex index 095202928a..d3f56b1e01 100644 --- a/lib/trento_web/openapi/v1/schema/host.ex +++ b/lib/trento_web/openapi/v1/schema/host.ex @@ -33,6 +33,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Host do title: "Host", description: "A discovered host on the target infrastructure", type: :object, + additionalProperties: false, properties: %{ id: %Schema{type: :string, description: "Host ID", format: :uuid}, hostname: %Schema{type: :string, description: "Host name"}, diff --git a/lib/trento_web/openapi/v1/schema/http_std.ex b/lib/trento_web/openapi/v1/schema/http_std.ex index 241c69cb10..fb47b534ee 100644 --- a/lib/trento_web/openapi/v1/schema/http_std.ex +++ b/lib/trento_web/openapi/v1/schema/http_std.ex @@ -16,6 +16,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.HttpStd do "labelname" => "mylabel" } }, + additionalProperties: false, properties: %{ labels: %Schema{ type: :object, diff --git a/lib/trento_web/openapi/v1/schema/not_found.ex b/lib/trento_web/openapi/v1/schema/not_found.ex index 536b2d4e3d..4e6c07f04a 100644 --- a/lib/trento_web/openapi/v1/schema/not_found.ex +++ b/lib/trento_web/openapi/v1/schema/not_found.ex @@ -10,6 +10,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.NotFound do OpenApiSpex.schema(%{ title: "NotFound", type: :object, + additionalProperties: false, properties: %{ errors: %Schema{ type: :array, diff --git a/lib/trento_web/openapi/v1/schema/platform.ex b/lib/trento_web/openapi/v1/schema/platform.ex index d4afe8c1e2..157760e5e4 100644 --- a/lib/trento_web/openapi/v1/schema/platform.ex +++ b/lib/trento_web/openapi/v1/schema/platform.ex @@ -11,6 +11,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Platform do title: "PlatformSettings", description: "Settings values for the current installation", type: :object, + additionalProperties: false, properties: %{ eula_accepted: %Schema{ type: :boolean, @@ -31,6 +32,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Platform do title: "GeneralInformation", description: "General information about the current installation", type: :object, + additionalProperties: false, properties: %{ flavor: %Schema{ type: :string, diff --git a/lib/trento_web/openapi/v1/schema/provider.ex b/lib/trento_web/openapi/v1/schema/provider.ex index 0cbcbc343a..d282b96414 100644 --- a/lib/trento_web/openapi/v1/schema/provider.ex +++ b/lib/trento_web/openapi/v1/schema/provider.ex @@ -35,6 +35,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Provider do title: "AzureProviderData", description: "Azure detected metadata", type: :object, + additionalProperties: false, properties: %{ resource_group: %Schema{type: :string}, location: %Schema{type: :string}, @@ -54,6 +55,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Provider do title: "AwsProviderData", description: "AWS detected metadata", type: :object, + additionalProperties: false, properties: %{ account_id: %Schema{type: :string}, ami_id: %Schema{type: :string}, @@ -74,6 +76,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Provider do title: "GcpProviderData", description: "GCP detected metadata", type: :object, + additionalProperties: false, properties: %{ disk_number: %Schema{type: :integer}, image: %Schema{type: :string}, diff --git a/lib/trento_web/openapi/v1/schema/ready.ex b/lib/trento_web/openapi/v1/schema/ready.ex index b8e64f08de..68fe848e02 100644 --- a/lib/trento_web/openapi/v1/schema/ready.ex +++ b/lib/trento_web/openapi/v1/schema/ready.ex @@ -13,6 +13,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Ready do example: %{ ready: true }, + additionalProperties: false, properties: %{ ready: %Schema{ description: "Trento Web platform ready", diff --git a/lib/trento_web/openapi/v1/schema/sap_system.ex b/lib/trento_web/openapi/v1/schema/sap_system.ex index f829c80748..e8d9e82939 100644 --- a/lib/trento_web/openapi/v1/schema/sap_system.ex +++ b/lib/trento_web/openapi/v1/schema/sap_system.ex @@ -15,6 +15,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.SAPSystem do title: "ApplicationInstance", description: "A discovered Application Instance on the target infrastructure", type: :object, + additionalProperties: false, properties: %{ sap_system_id: %Schema{type: :string, description: "SAP System ID", format: :uuid}, sid: %Schema{type: :string, description: "SID"}, @@ -49,6 +50,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.SAPSystem do title: "SAPSystem", description: "A discovered SAP System on the target infrastructure", type: :object, + additionalProperties: false, properties: %{ id: %Schema{type: :string, description: "SAP System ID", format: :uuid}, sid: %Schema{type: :string, description: "SID"}, @@ -90,6 +92,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.SAPSystem do title: "SAPSystemHealthOverview", description: "An overview of the health of a discovered SAP System and its components", type: :object, + additionalProperties: false, properties: %{ id: %Schema{type: :string, description: "SAP System ID", format: :uuid}, sid: %Schema{type: :string, description: "SID"}, diff --git a/lib/trento_web/openapi/v1/schema/saptune_status.ex b/lib/trento_web/openapi/v1/schema/saptune_status.ex index 43547ce93f..98319a4d9c 100644 --- a/lib/trento_web/openapi/v1/schema/saptune_status.ex +++ b/lib/trento_web/openapi/v1/schema/saptune_status.ex @@ -12,6 +12,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.SaptuneStatus do title: "Saptune service", description: "Saptune service", type: :object, + additionalProperties: false, properties: %{ name: %Schema{ type: :string, @@ -36,6 +37,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.SaptuneStatus do title: "Saptune note", description: "Saptune note", type: :object, + additionalProperties: false, properties: %{ id: %Schema{ type: :string, @@ -56,6 +58,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.SaptuneStatus do title: "Saptune solution", description: "Saptune solution", type: :object, + additionalProperties: false, properties: %{ id: %Schema{ type: :boolean, @@ -81,6 +84,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.SaptuneStatus do title: "Saptune staging", description: "Saptune staging data", type: :object, + additionalProperties: false, properties: %{ enabled: %Schema{ type: :boolean, @@ -105,6 +109,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.SaptuneStatus do description: "Saptune status output on the host", type: :object, nullable: true, + additionalProperties: false, properties: %{ package_version: %Schema{type: :string, description: "Saptune package version"}, configured_version: %Schema{type: :string, description: "Saptune configure version"}, diff --git a/lib/trento_web/openapi/v1/schema/sles_subscription.ex b/lib/trento_web/openapi/v1/schema/sles_subscription.ex index a096ce013c..a9dcfdccef 100644 --- a/lib/trento_web/openapi/v1/schema/sles_subscription.ex +++ b/lib/trento_web/openapi/v1/schema/sles_subscription.ex @@ -8,6 +8,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.SlesSubscription do title: "SlesSubscription", description: "A discovered SLES Subscription on a host", type: :object, + additionalProperties: false, properties: %{ host_id: %Schema{type: :string, format: :uuid}, identifier: %Schema{type: :string}, diff --git a/lib/trento_web/openapi/v1/schema/suma_credentials.ex b/lib/trento_web/openapi/v1/schema/suma_credentials.ex index 42b2d71e72..5125518625 100644 --- a/lib/trento_web/openapi/v1/schema/suma_credentials.ex +++ b/lib/trento_web/openapi/v1/schema/suma_credentials.ex @@ -11,6 +11,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.SUMACredentials do title: "SaveSUMACredentialsRequest", description: "Request body for saving SUMA credentials", type: :object, + additionalProperties: false, properties: %{ url: %Schema{ type: :string @@ -39,6 +40,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.SUMACredentials do "Request body for updating SUMA credentials.\nOnly provide fields to be updated", type: :object, minProperties: 1, + additionalProperties: false, properties: %{ url: %Schema{ type: :string @@ -66,6 +68,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.SUMACredentials do title: "SUMACredentials", description: "User settings for SUSE Manager", type: :object, + additionalProperties: false, properties: %{ url: %Schema{ type: :string, diff --git a/lib/trento_web/openapi/v1/schema/tag.ex b/lib/trento_web/openapi/v1/schema/tag.ex index 6f9a63375c..7a628423aa 100644 --- a/lib/trento_web/openapi/v1/schema/tag.ex +++ b/lib/trento_web/openapi/v1/schema/tag.ex @@ -13,6 +13,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Tags do title: "Tag", description: "A tag attached to a resource", type: :object, + additionalProperties: false, properties: %{ id: %Schema{type: :integer}, resource_id: %Schema{type: :string, format: :uuid}, diff --git a/lib/trento_web/openapi/v1/schema/unprocessable_entity.ex b/lib/trento_web/openapi/v1/schema/unprocessable_entity.ex index e9cd04121d..f1b36365d0 100644 --- a/lib/trento_web/openapi/v1/schema/unprocessable_entity.ex +++ b/lib/trento_web/openapi/v1/schema/unprocessable_entity.ex @@ -9,6 +9,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.UnprocessableEntity do OpenApiSpex.schema(%{ type: :object, + additionalProperties: false, properties: %{ errors: %Schema{ type: :array, diff --git a/lib/trento_web/openapi/v2/schema/cluster.ex b/lib/trento_web/openapi/v2/schema/cluster.ex index c0ae90d137..daad96e98f 100644 --- a/lib/trento_web/openapi/v2/schema/cluster.ex +++ b/lib/trento_web/openapi/v2/schema/cluster.ex @@ -16,6 +16,7 @@ defmodule TrentoWeb.OpenApi.V2.Schema.Cluster do title: "HanaClusterNode", description: "A HANA Cluster Node", type: :object, + additionalProperties: false, properties: %{ name: %Schema{type: :string}, site: %Schema{type: :string}, @@ -44,6 +45,7 @@ defmodule TrentoWeb.OpenApi.V2.Schema.Cluster do title: "HanaClusterSite", description: "A HANA Cluster Site", type: :object, + additionalProperties: false, properties: %{ name: %Schema{type: :string, description: "Site name"}, state: %Schema{type: :string, description: "Site state"}, @@ -59,6 +61,7 @@ defmodule TrentoWeb.OpenApi.V2.Schema.Cluster do title: "HanaClusterDetails", description: "Details of a HANA Pacemaker Cluster", type: :object, + additionalProperties: false, properties: %{ system_replication_mode: %Schema{type: :string, description: "System Replication Mode"}, system_replication_operation_mode: %Schema{ @@ -102,6 +105,7 @@ defmodule TrentoWeb.OpenApi.V2.Schema.Cluster do title: "AscsErsClusterNode", description: "ASCS/ERS Cluster Node", type: :object, + additionalProperties: false, properties: %{ attributes: %Schema{ type: :object, @@ -143,6 +147,7 @@ defmodule TrentoWeb.OpenApi.V2.Schema.Cluster do title: "AscsErsClusterSAPSystem", description: "SAP system managed by a ASCS/ERS cluster", type: :object, + additionalProperties: false, properties: %{ distributed: %Schema{ type: :boolean, @@ -169,6 +174,7 @@ defmodule TrentoWeb.OpenApi.V2.Schema.Cluster do title: "AscsErsClusterDetails", description: "Details of a ASCS/ERS Pacemaker Cluster", type: :object, + additionalProperties: false, properties: %{ fencing_type: %Schema{ type: :string, @@ -219,6 +225,7 @@ defmodule TrentoWeb.OpenApi.V2.Schema.Cluster do title: "PacemakerCluster", description: "A discovered Pacemaker Cluster on the target infrastructure", type: :object, + additionalProperties: false, properties: %{ id: %Schema{type: :string, description: "Cluster ID", format: :uuid}, name: %Schema{type: :string, description: "Cluster name"}, From b386aa9187f37ae9980f7eec932d8bd831019df3 Mon Sep 17 00:00:00 2001 From: Carmine Di Monaco Date: Wed, 21 Feb 2024 10:06:45 +0100 Subject: [PATCH 02/11] Cluster v1/v2 controller tests and view refactored for openapi compatibility --- lib/trento_web/views/v1/cluster_view.ex | 1 + lib/trento_web/views/v2/cluster_view.ex | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/trento_web/views/v1/cluster_view.ex b/lib/trento_web/views/v1/cluster_view.ex index 5aeb0b3f40..eff378822d 100644 --- a/lib/trento_web/views/v1/cluster_view.ex +++ b/lib/trento_web/views/v1/cluster_view.ex @@ -8,6 +8,7 @@ defmodule TrentoWeb.V1.ClusterView do def render("cluster.json", %{cluster: cluster}) do cluster |> Map.from_struct() + |> Map.delete(:deregistered_at) |> Map.delete(:__meta__) |> adapt_v1() end diff --git a/lib/trento_web/views/v2/cluster_view.ex b/lib/trento_web/views/v2/cluster_view.ex index 1a9904bbf7..79a8ad1cfa 100644 --- a/lib/trento_web/views/v2/cluster_view.ex +++ b/lib/trento_web/views/v2/cluster_view.ex @@ -6,11 +6,26 @@ defmodule TrentoWeb.V2.ClusterView do end def render("cluster.json", %{cluster: cluster}) do + cluster_details = render("cluster_details.json", %{details: cluster.details}) + cluster |> Map.from_struct() + |> Map.put(:details, cluster_details) + |> Map.delete(:deregistered_at) |> Map.delete(:__meta__) end + def render("cluster_details.json", %{details: %{"sap_systems" => sap_systems} = details}) do + sap_systems = + Enum.map(sap_systems, &Map.take(&1, [:distributed, :filesystem_resource_based, :nodes])) + + Map.put(details, :sap_systems, sap_systems) + end + + def render("cluster_details.json", %{details: details}) do + details + end + def render("cluster_registered.json", %{cluster: cluster}) do Map.delete(render("cluster.json", %{cluster: cluster}), :tags) end From 8869575a61fbc24515b15cb50c557a426e9662d2 Mon Sep 17 00:00:00 2001 From: Carmine Di Monaco Date: Wed, 21 Feb 2024 10:10:22 +0100 Subject: [PATCH 03/11] HealthOverview controller refactored for openapi compatibility --- lib/trento_web/views/v1/health_overview_view.ex | 2 -- test/trento_web/views/v1/health_overview_view_test.exs | 2 -- 2 files changed, 4 deletions(-) diff --git a/lib/trento_web/views/v1/health_overview_view.ex b/lib/trento_web/views/v1/health_overview_view.ex index 68d7e5931e..978153dc21 100644 --- a/lib/trento_web/views/v1/health_overview_view.ex +++ b/lib/trento_web/views/v1/health_overview_view.ex @@ -28,8 +28,6 @@ defmodule TrentoWeb.V1.HealthOverviewView do sid: sid, sapsystem_health: sapsystem_health, database_health: database_health, - # deprecated field - clusters_health: database_cluster_health, application_cluster_health: application_cluster_health, database_cluster_health: database_cluster_health, hosts_health: hosts_health, diff --git a/test/trento_web/views/v1/health_overview_view_test.exs b/test/trento_web/views/v1/health_overview_view_test.exs index 9e5b5135d1..93a082a7d6 100644 --- a/test/trento_web/views/v1/health_overview_view_test.exs +++ b/test/trento_web/views/v1/health_overview_view_test.exs @@ -39,7 +39,6 @@ defmodule TrentoWeb.V1.HealthOverviewViewTest do assert [ %{ cluster_id: db_cluster_id, - clusters_health: Health.warning(), application_cluster_id: app_cluster_id, database_cluster_id: db_cluster_id, application_cluster_health: Health.critical(), @@ -93,7 +92,6 @@ defmodule TrentoWeb.V1.HealthOverviewViewTest do assert [ %{ cluster_id: nil, - clusters_health: Health.unknown(), application_cluster_id: nil, database_cluster_id: nil, application_cluster_health: Health.unknown(), From 9532571d183148d1cd746418b9edcb67c9fa367a Mon Sep 17 00:00:00 2001 From: Carmine Di Monaco Date: Wed, 21 Feb 2024 11:38:45 +0100 Subject: [PATCH 04/11] Host views aligned with openapi spex --- lib/trento_web/views/v1/host_view.ex | 34 ++++++++++++++++++--- test/trento_web/views/v1/host_view_test.exs | 11 +++++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/lib/trento_web/views/v1/host_view.ex b/lib/trento_web/views/v1/host_view.ex index c46acf0475..c98f6fc79d 100644 --- a/lib/trento_web/views/v1/host_view.ex +++ b/lib/trento_web/views/v1/host_view.ex @@ -5,14 +5,40 @@ defmodule TrentoWeb.V1.HostView do render_many(hosts, __MODULE__, "host.json") end - def render("host.json", %{host: host}) do + def render("host.json", %{host: %{sles_subscriptions: sles_subscriptions} = host}) do + sles_subscriptions = + render_many(sles_subscriptions, __MODULE__, "sles_subscription.json", + as: :sles_subscription + ) + + host + |> Map.from_struct() + |> Map.put(:sles_subscriptions, sles_subscriptions) + |> Map.delete(:fully_qualified_domain_name) + |> Map.delete(:health) + |> Map.delete(:selected_checks) + |> Map.delete(:inserted_at) + |> Map.delete(:__meta__) + end + + def render("sles_subscription.json", %{sles_subscription: sles_subscription}) do + sles_subscription + |> Map.from_struct() + |> Map.delete(:__meta__) + |> Map.delete(:inserted_at) + |> Map.delete(:updated_at) + end + + def render("sles_subscription.json", _), do: nil + + def render("broadcast_host.json", %{host: host}) do host |> Map.from_struct() |> Map.delete(:__meta__) end def render("host_details_updated.json", %{host: host}) do - render("host.json", %{host: host}) + render("broadcast_host.json", %{host: host}) |> Map.delete(:sles_subscriptions) |> Map.delete(:tags) |> Map.delete(:cluster_id) @@ -22,13 +48,13 @@ defmodule TrentoWeb.V1.HostView do end def render("host_registered.json", %{host: host}) do - render("host.json", %{host: host}) + render("broadcast_host.json", %{host: host}) |> Map.delete(:sles_subscriptions) |> Map.delete(:tags) end def render("host_restored.json", %{host: host}) do - render("host.json", %{host: host}) + render("broadcast_host.json", %{host: host}) end def render("heartbeat_result.json", %{host: %{id: id, hostname: hostname}}) do diff --git a/test/trento_web/views/v1/host_view_test.exs b/test/trento_web/views/v1/host_view_test.exs index 04e9d7e61f..92ec042639 100644 --- a/test/trento_web/views/v1/host_view_test.exs +++ b/test/trento_web/views/v1/host_view_test.exs @@ -17,6 +17,17 @@ defmodule TrentoWeb.V1.HostViewTest do render(HostView, "host_health_changed.json", %{host: host}) end + test "should render single host information" do + host = build(:host, sles_subscriptions: build_list(1, :sles_subscription)) + + rendered_host = render(HostView, "host.json", %{host: host}) + + refute Access.get(rendered_host, "fully_qualified_domain_name") + refute Access.get(rendered_host, "health") + refute Access.get(rendered_host, "selected_checks") + refute Access.get(rendered_host, "inserted_at") + end + test "should render host details relevant information" do host = build(:host) From f0206af3a13ee79eb233c7bdfda79636a060c23e Mon Sep 17 00:00:00 2001 From: Carmine Di Monaco Date: Wed, 21 Feb 2024 13:03:26 +0100 Subject: [PATCH 05/11] Sap system view adapted to sap system controller openapi --- lib/trento_web/views/v1/sap_system_view.ex | 73 +++++++++++++++++++++- 1 file changed, 70 insertions(+), 3 deletions(-) diff --git a/lib/trento_web/views/v1/sap_system_view.ex b/lib/trento_web/views/v1/sap_system_view.ex index eb9c4796a6..5c34c2856e 100644 --- a/lib/trento_web/views/v1/sap_system_view.ex +++ b/lib/trento_web/views/v1/sap_system_view.ex @@ -17,11 +17,38 @@ defmodule TrentoWeb.V1.SapSystemView do database |> Map.from_struct() |> Map.delete(:__meta__) + |> Map.delete(:deregistered_at) |> Map.put(:database_instances, rendered_database_instances) |> add_system_replication_status_to_secondary_instance end def render("database_instance.json", %{instance: instance}) do + instance + |> Map.from_struct() + |> Map.delete(:__meta__) + |> Map.delete(:absent_at) + |> Map.delete(:host) + end + + def render("broadcast_database.json", %{ + database: + %{ + database_instances: database_instances + } = database + }) do + rendered_database_instances = + render_many(database_instances, __MODULE__, "broadcast_database_instance.json", + as: :instance + ) + + database + |> Map.from_struct() + |> Map.delete(:__meta__) + |> Map.put(:database_instances, rendered_database_instances) + |> add_system_replication_status_to_secondary_instance + end + + def render("broadcast_database_instance.json", %{instance: instance}) do instance |> Map.from_struct() |> Map.delete(:__meta__) @@ -32,7 +59,7 @@ defmodule TrentoWeb.V1.SapSystemView do instance: instance, database_instances: database_instances }) do - "database_instance.json" + "broadcast_database_instance.json" |> render(%{instance: instance}) |> add_system_replication_status(database_instances) end @@ -46,7 +73,7 @@ defmodule TrentoWeb.V1.SapSystemView do end def render("database_restored.json", %{database: database}) do - render("database.json", database: database) + render("broadcast_database.json", database: database) end def render("database_health_changed.json", %{health: health}), do: health @@ -86,6 +113,14 @@ defmodule TrentoWeb.V1.SapSystemView do end def render("application_instance.json", %{instance: instance}) do + instance + |> Map.from_struct() + |> Map.delete(:__meta__) + |> Map.delete(:absent_at) + |> Map.delete(:host) + end + + def render("broadcast_application_instance.json", %{instance: instance}) do instance |> Map.from_struct() |> Map.delete(:__meta__) @@ -114,6 +149,38 @@ defmodule TrentoWeb.V1.SapSystemView do rendered_database_instances = render_many(database_instances, __MODULE__, "database_instance.json", as: :instance) + sap_system + |> Map.from_struct() + |> Map.delete(:__meta__) + |> Map.delete(:deregistered_at) + |> Map.put( + :database_instances, + rendered_database_instances + ) + |> Map.put( + :application_instances, + rendered_application_instances + ) + |> add_system_replication_status_to_secondary_instance + end + + def render("broadcast_sap_system.json", %{ + sap_system: + %{ + application_instances: application_instances, + database_instances: database_instances + } = sap_system + }) do + rendered_application_instances = + render_many(application_instances, __MODULE__, "broadcast_application_instance.json", + as: :instance + ) + + rendered_database_instances = + render_many(database_instances, __MODULE__, "broadcast_database_instance.json", + as: :instance + ) + sap_system |> Map.from_struct() |> Map.delete(:__meta__) @@ -138,7 +205,7 @@ defmodule TrentoWeb.V1.SapSystemView do end def render("sap_system_restored.json", %{sap_system: sap_system}) do - render("sap_system.json", sap_system: sap_system) + render("broadcast_sap_system.json", sap_system: sap_system) end def render("sap_system_updated.json", %{id: id, ensa_version: ensa_version}), From 9b2c150713116f43e3057d8b04a8728a92572219 Mon Sep 17 00:00:00 2001 From: Carmine Di Monaco Date: Wed, 21 Feb 2024 13:59:35 +0100 Subject: [PATCH 06/11] Fixed Host schema v1 --- lib/trento_web/openapi/v1/schema/host.ex | 9 ++++++++- lib/trento_web/views/v1/host_view.ex | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/trento_web/openapi/v1/schema/host.ex b/lib/trento_web/openapi/v1/schema/host.ex index d3f56b1e01..59cad74e8e 100644 --- a/lib/trento_web/openapi/v1/schema/host.ex +++ b/lib/trento_web/openapi/v1/schema/host.ex @@ -4,7 +4,13 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Host do require OpenApiSpex alias OpenApiSpex.Schema - alias TrentoWeb.OpenApi.V1.Schema.{Provider, SaptuneStatus, SlesSubscription, Tags} + alias TrentoWeb.OpenApi.V1.Schema.{ + Provider, + SaptuneStatus, + SlesSubscription, + Tags, + ResourceHealth + } defmodule IPv4 do @moduledoc false @@ -52,6 +58,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Host do type: :string, description: "Version of the agent installed on the host" }, + health: ResourceHealth, cluster_id: %Schema{ type: :string, description: "Identifier of the cluster this host is part of", diff --git a/lib/trento_web/views/v1/host_view.ex b/lib/trento_web/views/v1/host_view.ex index c98f6fc79d..94ae7fd617 100644 --- a/lib/trento_web/views/v1/host_view.ex +++ b/lib/trento_web/views/v1/host_view.ex @@ -15,7 +15,6 @@ defmodule TrentoWeb.V1.HostView do |> Map.from_struct() |> Map.put(:sles_subscriptions, sles_subscriptions) |> Map.delete(:fully_qualified_domain_name) - |> Map.delete(:health) |> Map.delete(:selected_checks) |> Map.delete(:inserted_at) |> Map.delete(:__meta__) From 46cfc67fe5c3753df82fb1fdb4f279c3edb45850 Mon Sep 17 00:00:00 2001 From: Carmine Di Monaco Date: Wed, 21 Feb 2024 14:34:17 +0100 Subject: [PATCH 07/11] mix credo fix --- lib/trento_web/openapi/v1/schema/host.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/trento_web/openapi/v1/schema/host.ex b/lib/trento_web/openapi/v1/schema/host.ex index 59cad74e8e..fb856b896a 100644 --- a/lib/trento_web/openapi/v1/schema/host.ex +++ b/lib/trento_web/openapi/v1/schema/host.ex @@ -6,10 +6,10 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Host do alias TrentoWeb.OpenApi.V1.Schema.{ Provider, + ResourceHealth, SaptuneStatus, SlesSubscription, - Tags, - ResourceHealth + Tags } defmodule IPv4 do From 3cfdb3fa235a869462c1672df1422c6080d5bad3 Mon Sep 17 00:00:00 2001 From: Carmine Di Monaco Date: Thu, 22 Feb 2024 10:39:35 +0100 Subject: [PATCH 08/11] Revert "HealthOverview controller refactored for openapi compatibility" This reverts commit 8869575a61fbc24515b15cb50c557a426e9662d2. --- lib/trento_web/views/v1/health_overview_view.ex | 2 ++ test/trento_web/views/v1/health_overview_view_test.exs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/trento_web/views/v1/health_overview_view.ex b/lib/trento_web/views/v1/health_overview_view.ex index 978153dc21..68d7e5931e 100644 --- a/lib/trento_web/views/v1/health_overview_view.ex +++ b/lib/trento_web/views/v1/health_overview_view.ex @@ -28,6 +28,8 @@ defmodule TrentoWeb.V1.HealthOverviewView do sid: sid, sapsystem_health: sapsystem_health, database_health: database_health, + # deprecated field + clusters_health: database_cluster_health, application_cluster_health: application_cluster_health, database_cluster_health: database_cluster_health, hosts_health: hosts_health, diff --git a/test/trento_web/views/v1/health_overview_view_test.exs b/test/trento_web/views/v1/health_overview_view_test.exs index 93a082a7d6..9e5b5135d1 100644 --- a/test/trento_web/views/v1/health_overview_view_test.exs +++ b/test/trento_web/views/v1/health_overview_view_test.exs @@ -39,6 +39,7 @@ defmodule TrentoWeb.V1.HealthOverviewViewTest do assert [ %{ cluster_id: db_cluster_id, + clusters_health: Health.warning(), application_cluster_id: app_cluster_id, database_cluster_id: db_cluster_id, application_cluster_health: Health.critical(), @@ -92,6 +93,7 @@ defmodule TrentoWeb.V1.HealthOverviewViewTest do assert [ %{ cluster_id: nil, + clusters_health: Health.unknown(), application_cluster_id: nil, database_cluster_id: nil, application_cluster_health: Health.unknown(), From c30a5e970879aee3c297de3c3d14fe2635dc62da Mon Sep 17 00:00:00 2001 From: Carmine Di Monaco Date: Thu, 22 Feb 2024 10:44:11 +0100 Subject: [PATCH 09/11] Addressing review feedbacks --- lib/trento_web/openapi/v1/schema/database.ex | 6 ++ lib/trento_web/openapi/v1/schema/host.ex | 6 ++ .../openapi/v1/schema/sap_system.ex | 8 ++- lib/trento_web/openapi/v2/schema/cluster.ex | 2 + lib/trento_web/views/v1/host_view.ex | 1 - lib/trento_web/views/v1/sap_system_view.ex | 71 +------------------ lib/trento_web/views/v2/cluster_view.ex | 14 ---- test/trento_web/views/v1/host_view_test.exs | 6 +- 8 files changed, 26 insertions(+), 88 deletions(-) diff --git a/lib/trento_web/openapi/v1/schema/database.ex b/lib/trento_web/openapi/v1/schema/database.ex index b65ca73036..38543e76ed 100644 --- a/lib/trento_web/openapi/v1/schema/database.ex +++ b/lib/trento_web/openapi/v1/schema/database.ex @@ -24,6 +24,12 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Database do description: "Instance Hostname", nullable: true }, + absent_at: %Schema{ + type: :string, + description: "Absent instance timestamp", + format: :datetime, + nullable: true + }, features: %Schema{type: :string, description: "Instance Features"}, http_port: %Schema{type: :integer, description: "Instance HTTP Port", nullable: true}, https_port: %Schema{type: :integer, description: "Instance HTTPS Port", nullable: true}, diff --git a/lib/trento_web/openapi/v1/schema/host.ex b/lib/trento_web/openapi/v1/schema/host.ex index fb856b896a..a010cd3f4d 100644 --- a/lib/trento_web/openapi/v1/schema/host.ex +++ b/lib/trento_web/openapi/v1/schema/host.ex @@ -78,6 +78,12 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Host do type: :array, items: SlesSubscription }, + selected_checks: %Schema{ + title: "SelectedChecks", + description: "A list of check ids selected for an execution on this host", + type: :array, + items: %Schema{type: :string} + }, saptune_status: SaptuneStatus, deregistered_at: %Schema{ title: "DeregisteredAt", diff --git a/lib/trento_web/openapi/v1/schema/sap_system.ex b/lib/trento_web/openapi/v1/schema/sap_system.ex index e8d9e82939..23c734727e 100644 --- a/lib/trento_web/openapi/v1/schema/sap_system.ex +++ b/lib/trento_web/openapi/v1/schema/sap_system.ex @@ -25,6 +25,12 @@ defmodule TrentoWeb.OpenApi.V1.Schema.SAPSystem do description: "Instance Hostname", nullable: true }, + absent_at: %Schema{ + type: :string, + description: "Absent instance timestamp", + format: :datetime, + nullable: true + }, features: %Schema{type: :string, description: "Instance Features"}, http_port: %Schema{type: :integer, description: "Instance HTTP Port", nullable: true}, https_port: %Schema{type: :integer, description: "Instance HTTPS Port", nullable: true}, @@ -116,7 +122,7 @@ defmodule TrentoWeb.OpenApi.V1.Schema.SAPSystem do sapsystem_health: ResourceHealth, database_health: ResourceHealth, hosts_health: ResourceHealth, - clusters_heatlh: %Schema{ + clusters_health: %Schema{ allOf: [ ResourceHealth, %Schema{deprecated: true} diff --git a/lib/trento_web/openapi/v2/schema/cluster.ex b/lib/trento_web/openapi/v2/schema/cluster.ex index daad96e98f..2e6162602f 100644 --- a/lib/trento_web/openapi/v2/schema/cluster.ex +++ b/lib/trento_web/openapi/v2/schema/cluster.ex @@ -148,7 +148,9 @@ defmodule TrentoWeb.OpenApi.V2.Schema.Cluster do description: "SAP system managed by a ASCS/ERS cluster", type: :object, additionalProperties: false, + required: [:sid], properties: %{ + sid: %Schema{type: :string, description: "SID"}, distributed: %Schema{ type: :boolean, description: "ASCS and ERS instances are distributed and running in different nodes" diff --git a/lib/trento_web/views/v1/host_view.ex b/lib/trento_web/views/v1/host_view.ex index 94ae7fd617..143e52f1d9 100644 --- a/lib/trento_web/views/v1/host_view.ex +++ b/lib/trento_web/views/v1/host_view.ex @@ -15,7 +15,6 @@ defmodule TrentoWeb.V1.HostView do |> Map.from_struct() |> Map.put(:sles_subscriptions, sles_subscriptions) |> Map.delete(:fully_qualified_domain_name) - |> Map.delete(:selected_checks) |> Map.delete(:inserted_at) |> Map.delete(:__meta__) end diff --git a/lib/trento_web/views/v1/sap_system_view.ex b/lib/trento_web/views/v1/sap_system_view.ex index 5c34c2856e..529b2afd24 100644 --- a/lib/trento_web/views/v1/sap_system_view.ex +++ b/lib/trento_web/views/v1/sap_system_view.ex @@ -23,32 +23,6 @@ defmodule TrentoWeb.V1.SapSystemView do end def render("database_instance.json", %{instance: instance}) do - instance - |> Map.from_struct() - |> Map.delete(:__meta__) - |> Map.delete(:absent_at) - |> Map.delete(:host) - end - - def render("broadcast_database.json", %{ - database: - %{ - database_instances: database_instances - } = database - }) do - rendered_database_instances = - render_many(database_instances, __MODULE__, "broadcast_database_instance.json", - as: :instance - ) - - database - |> Map.from_struct() - |> Map.delete(:__meta__) - |> Map.put(:database_instances, rendered_database_instances) - |> add_system_replication_status_to_secondary_instance - end - - def render("broadcast_database_instance.json", %{instance: instance}) do instance |> Map.from_struct() |> Map.delete(:__meta__) @@ -59,7 +33,7 @@ defmodule TrentoWeb.V1.SapSystemView do instance: instance, database_instances: database_instances }) do - "broadcast_database_instance.json" + "database_instance.json" |> render(%{instance: instance}) |> add_system_replication_status(database_instances) end @@ -73,7 +47,7 @@ defmodule TrentoWeb.V1.SapSystemView do end def render("database_restored.json", %{database: database}) do - render("broadcast_database.json", database: database) + render("database.json", database: database) end def render("database_health_changed.json", %{health: health}), do: health @@ -113,14 +87,6 @@ defmodule TrentoWeb.V1.SapSystemView do end def render("application_instance.json", %{instance: instance}) do - instance - |> Map.from_struct() - |> Map.delete(:__meta__) - |> Map.delete(:absent_at) - |> Map.delete(:host) - end - - def render("broadcast_application_instance.json", %{instance: instance}) do instance |> Map.from_struct() |> Map.delete(:__meta__) @@ -164,37 +130,6 @@ defmodule TrentoWeb.V1.SapSystemView do |> add_system_replication_status_to_secondary_instance end - def render("broadcast_sap_system.json", %{ - sap_system: - %{ - application_instances: application_instances, - database_instances: database_instances - } = sap_system - }) do - rendered_application_instances = - render_many(application_instances, __MODULE__, "broadcast_application_instance.json", - as: :instance - ) - - rendered_database_instances = - render_many(database_instances, __MODULE__, "broadcast_database_instance.json", - as: :instance - ) - - sap_system - |> Map.from_struct() - |> Map.delete(:__meta__) - |> Map.put( - :database_instances, - rendered_database_instances - ) - |> Map.put( - :application_instances, - rendered_application_instances - ) - |> add_system_replication_status_to_secondary_instance - end - def render("sap_system_registered.json", %{sap_system: sap_system}) do sap_system |> Map.from_struct() @@ -205,7 +140,7 @@ defmodule TrentoWeb.V1.SapSystemView do end def render("sap_system_restored.json", %{sap_system: sap_system}) do - render("broadcast_sap_system.json", sap_system: sap_system) + render("sap_system.json", sap_system: sap_system) end def render("sap_system_updated.json", %{id: id, ensa_version: ensa_version}), diff --git a/lib/trento_web/views/v2/cluster_view.ex b/lib/trento_web/views/v2/cluster_view.ex index 79a8ad1cfa..d4eb39fc09 100644 --- a/lib/trento_web/views/v2/cluster_view.ex +++ b/lib/trento_web/views/v2/cluster_view.ex @@ -6,26 +6,12 @@ defmodule TrentoWeb.V2.ClusterView do end def render("cluster.json", %{cluster: cluster}) do - cluster_details = render("cluster_details.json", %{details: cluster.details}) - cluster |> Map.from_struct() - |> Map.put(:details, cluster_details) |> Map.delete(:deregistered_at) |> Map.delete(:__meta__) end - def render("cluster_details.json", %{details: %{"sap_systems" => sap_systems} = details}) do - sap_systems = - Enum.map(sap_systems, &Map.take(&1, [:distributed, :filesystem_resource_based, :nodes])) - - Map.put(details, :sap_systems, sap_systems) - end - - def render("cluster_details.json", %{details: details}) do - details - end - def render("cluster_registered.json", %{cluster: cluster}) do Map.delete(render("cluster.json", %{cluster: cluster}), :tags) end diff --git a/test/trento_web/views/v1/host_view_test.exs b/test/trento_web/views/v1/host_view_test.exs index 92ec042639..84f34357e4 100644 --- a/test/trento_web/views/v1/host_view_test.exs +++ b/test/trento_web/views/v1/host_view_test.exs @@ -22,10 +22,8 @@ defmodule TrentoWeb.V1.HostViewTest do rendered_host = render(HostView, "host.json", %{host: host}) - refute Access.get(rendered_host, "fully_qualified_domain_name") - refute Access.get(rendered_host, "health") - refute Access.get(rendered_host, "selected_checks") - refute Access.get(rendered_host, "inserted_at") + refute Access.get(rendered_host, :fully_qualified_domain_name) + refute Access.get(rendered_host, :inserted_at) end test "should render host details relevant information" do From 2df1abd3f43a31b77767e6195adaca3d497e9368 Mon Sep 17 00:00:00 2001 From: Carmine Di Monaco Date: Thu, 22 Feb 2024 11:03:43 +0100 Subject: [PATCH 10/11] Temporary fix incompatible api check --- .github/workflows/ci.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index be445c7409..158d8e55bb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -533,7 +533,6 @@ jobs: docker run -v "$(pwd)/specs:/specs" --rm openapitools/openapi-diff:2.0.1 \ /specs/main-spec.json \ /specs/current-spec.json \ - --fail-on-incompatible \ --markdown /specs/changes.md \ --text /specs/changes.txt \ --html /specs/changes.html @@ -835,4 +834,4 @@ jobs: run: | pushd $OSC_CHECKOUT_DIR osc ar - osc commit -m "GitHub Actions automated update to reference ${{ github.sha }}" \ No newline at end of file + osc commit -m "GitHub Actions automated update to reference ${{ github.sha }}" From 4368429fed6fbcbe01e1e21bbde42a0cc85e4112 Mon Sep 17 00:00:00 2001 From: Carmine Di Monaco Date: Thu, 22 Feb 2024 11:27:00 +0100 Subject: [PATCH 11/11] Revert "Temporary fix incompatible api check" This reverts commit 2df1abd3f43a31b77767e6195adaca3d497e9368. --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 158d8e55bb..be445c7409 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -533,6 +533,7 @@ jobs: docker run -v "$(pwd)/specs:/specs" --rm openapitools/openapi-diff:2.0.1 \ /specs/main-spec.json \ /specs/current-spec.json \ + --fail-on-incompatible \ --markdown /specs/changes.md \ --text /specs/changes.txt \ --html /specs/changes.html @@ -834,4 +835,4 @@ jobs: run: | pushd $OSC_CHECKOUT_DIR osc ar - osc commit -m "GitHub Actions automated update to reference ${{ github.sha }}" + osc commit -m "GitHub Actions automated update to reference ${{ github.sha }}" \ No newline at end of file