From 1000695832b669ea42dc34c85a77c95dada5f8a6 Mon Sep 17 00:00:00 2001 From: michaeljguarino Date: Thu, 16 Jan 2025 10:28:33 -0500 Subject: [PATCH] Release ai-proxy v1.2.0 (#1755) --- assets/src/generated/graphql.ts | 3 ++- charts/ai-proxy/Chart.yaml | 22 ++----------------- lib/console/deployments/clusters.ex | 3 ++- lib/console/deployments/init.ex | 2 +- lib/console/graphql/deployments/cluster.ex | 3 ++- .../graphql/resolvers/deployments/cluster.ex | 6 ++++- schema/schema.graphql | 2 +- test/console/deployments/init_test.exs | 2 +- .../deployments/cluster_queries_test.exs | 13 +++++++++++ 9 files changed, 29 insertions(+), 27 deletions(-) diff --git a/assets/src/generated/graphql.ts b/assets/src/generated/graphql.ts index a92ab15c16..e86a2b7e1b 100644 --- a/assets/src/generated/graphql.ts +++ b/assets/src/generated/graphql.ts @@ -6819,7 +6819,8 @@ export type RootQueryTypeClusterProvidersArgs = { export type RootQueryTypeClusterRegistrationArgs = { - id: Scalars['ID']['input']; + id?: InputMaybe; + machineId?: InputMaybe; }; diff --git a/charts/ai-proxy/Chart.yaml b/charts/ai-proxy/Chart.yaml index 8e4b831771..d4b4b5b27c 100644 --- a/charts/ai-proxy/Chart.yaml +++ b/charts/ai-proxy/Chart.yaml @@ -1,24 +1,6 @@ apiVersion: v2 name: ai-proxy description: A Helm chart for ai-proxy - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -# Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.2.0 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. Versions are not expected to -# follow Semantic Versioning. They should reflect the version the application is using. -# It is recommended to use it with quotes. -appVersion: "v1.1.0" +version: 0.2.1 +appVersion: "v1.2.0" diff --git a/lib/console/deployments/clusters.ex b/lib/console/deployments/clusters.ex index f0d9fbfee2..ddbb78ce15 100644 --- a/lib/console/deployments/clusters.ex +++ b/lib/console/deployments/clusters.ex @@ -74,7 +74,8 @@ defmodule Console.Deployments.Clusters do def get_cluster_usage!(id), do: Repo.get!(ClusterUsage, id) |> Repo.preload([:cluster]) - def get_cluster_registration(id), do: Repo.get!(ClusterRegistration, id) + def get_cluster_registration!(id), do: Repo.get!(ClusterRegistration, id) + def get_registration_by_machine_id!(id), do: Repo.get_by!(ClusterRegistration, machine_id: id) def get_runtime_service(id) do Console.Repo.get(RuntimeService, id) diff --git a/lib/console/deployments/init.ex b/lib/console/deployments/init.ex index 8670f2d0f6..cd779b4988 100644 --- a/lib/console/deployments/init.ex +++ b/lib/console/deployments/init.ex @@ -90,7 +90,7 @@ defmodule Console.Deployments.Init do Map.put(attrs, :ai, %{ provider: :openai, enabled: true, - openai: %{base_url: "http://ai-proxy.ai-proxy:8000/openai"} + openai: %{base_url: "http://ai-proxy.ai-proxy:8000/openai/v1"} }) _ -> attrs end diff --git a/lib/console/graphql/deployments/cluster.ex b/lib/console/graphql/deployments/cluster.ex index d1bea76b08..7c238645fa 100644 --- a/lib/console/graphql/deployments/cluster.ex +++ b/lib/console/graphql/deployments/cluster.ex @@ -1093,7 +1093,8 @@ defmodule Console.GraphQl.Deployments.Cluster do field :cluster_registration, :cluster_registration do middleware Authenticated - arg :id, non_null(:id) + arg :id, :id + arg :machine_id, :string resolve &Deployments.resolve_cluster_registration/2 end diff --git a/lib/console/graphql/resolvers/deployments/cluster.ex b/lib/console/graphql/resolvers/deployments/cluster.ex index c5fd36546a..9362ab3690 100644 --- a/lib/console/graphql/resolvers/deployments/cluster.ex +++ b/lib/console/graphql/resolvers/deployments/cluster.ex @@ -47,8 +47,12 @@ defmodule Console.GraphQl.Resolvers.Deployments.Cluster do |> allow(user, :read) end + def resolve_cluster_registration(%{machine_id: id}, %{context: %{current_user: user}}) do + Clusters.get_registration_by_machine_id!(id) + |> allow(user, :read) + end def resolve_cluster_registration(%{id: id}, %{context: %{current_user: user}}) do - Clusters.get_cluster_registration(id) + Clusters.get_cluster_registration!(id) |> allow(user, :read) end diff --git a/schema/schema.graphql b/schema/schema.graphql index a6ee84e06f..76f8bf8318 100644 --- a/schema/schema.graphql +++ b/schema/schema.graphql @@ -211,7 +211,7 @@ type RootQueryType { clusterUsage(id: ID!): ClusterUsage - clusterRegistration(id: ID!): ClusterRegistration + clusterRegistration(id: ID, machineId: String): ClusterRegistration clusterRegistrations(after: String, first: Int, before: String, last: Int): ClusterRegistrationConnection diff --git a/test/console/deployments/init_test.exs b/test/console/deployments/init_test.exs index a7feb1a0bb..104ee3de13 100644 --- a/test/console/deployments/init_test.exs +++ b/test/console/deployments/init_test.exs @@ -87,7 +87,7 @@ defmodule Console.Deployments.InitTest do assert res.settings.ai.enabled assert res.settings.ai.provider == :openai - assert res.settings.ai.openai.base_url == "http://ai-proxy.ai-proxy:8000/openai" + assert res.settings.ai.openai.base_url == "http://ai-proxy.ai-proxy:8000/openai/v1" end end end diff --git a/test/console/graphql/queries/deployments/cluster_queries_test.exs b/test/console/graphql/queries/deployments/cluster_queries_test.exs index 0adac5ef47..dbc895aae0 100644 --- a/test/console/graphql/queries/deployments/cluster_queries_test.exs +++ b/test/console/graphql/queries/deployments/cluster_queries_test.exs @@ -758,6 +758,19 @@ defmodule Console.GraphQl.Deployments.ClusterQueriesTest do assert found["id"] == reg.id end + + test "bootstrap token creators can read by machine id" do + user = bootstrap_user() + reg = insert(:cluster_registration, creator: user) + + {:ok, %{data: %{"clusterRegistration" => found}}} = run_query(""" + query Reg($machineId: String!) { + clusterRegistration(machineId: $machineId) { id } + } + """, %{"machineId" => reg.machine_id}, %{current_user: user}) + + assert found["id"] == reg.id + end end describe "clusterRegistrations" do