Skip to content

Commit 4d1b345

Browse files
Fix frontend domain inference
The frontend seems to be expecting the domain pattern to be different than it currently is, expose the inferred domain via gql and fix fe code accordingly
1 parent bd85d21 commit 4d1b345

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

apps/core/lib/core/services/cloud.ex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ defmodule Core.Services.Cloud do
9191
|> notify(:create, user)
9292
end
9393

94-
def domain(%ConsoleInstance{name: name, domain_version: :v2}), do: "https://#{name}.console.#{domain()}/oauth/callback"
95-
def domain(%ConsoleInstance{name: name}), do: "https://console.#{name}.#{domain()}/oauth/callback"
94+
def fqdn(%ConsoleInstance{name: name, domain_version: :v2}), do: "#{name}.console.#{domain()}"
95+
def fqdn(%ConsoleInstance{name: name}), do: "console.#{name}.#{domain()}"
96+
97+
def domain(%ConsoleInstance{} = inst), do: "https://#{fqdn(inst)}/oauth/callback"
9698

9799
@doc """
98100
Updates base attributes of a console instance
@@ -203,7 +205,7 @@ defmodule Core.Services.Cloud do
203205
end
204206

205207
def add_configuration(attrs, name, token, %OIDCProvider{} = oidc, %User{} = user) do
206-
Map.merge(attrs, %{subdomain: "#{name}.#{domain()}", url: "console.#{name}.#{domain()}"})
208+
Map.merge(attrs, %{subdomain: "#{name}.#{domain()}", url: "#{name}.console.#{domain()}"})
207209
|> Map.put(:configuration, %{
208210
aes_key: aes_key(),
209211
encryption_key: encryption_key(),

apps/graphql/lib/graphql/resolvers/cloud.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ defmodule GraphQl.Resolvers.Cloud do
1515
ok(Clusters.get_cluster_by_url("https://#{url}") || Clusters.get_cluster_by_url(url))
1616
end
1717

18+
def resolve_domain(%ConsoleInstance{} = inst, _, _), do: {:ok, Cloud.fqdn(inst)}
19+
1820
def list_instances(args, %{context: %{current_user: user}}) do
1921
ConsoleInstance.for_account(user.account_id)
2022
|> ConsoleInstance.ordered()

apps/graphql/lib/graphql/schema/cloud.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ defmodule GraphQl.Schema.Cloud do
5252
field :network, :console_instance_network, description: "the network configuration for this instance"
5353
field :oidc, :console_instance_oidc, description: "custom oidc configuration for this instance"
5454

55+
field :domain, :string, description: "the domain of this instance", resolve: &Cloud.resolve_domain/3
56+
5557
field :status, non_null(:console_instance_status),
5658
description: "the provisioning status of this instance, liveness is fetched through the console field"
5759

schema/schema.graphql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,9 @@ type ConsoleInstance {
665665
"custom oidc configuration for this instance"
666666
oidc: ConsoleInstanceOidc
667667

668+
"the domain of this instance"
669+
domain: String
670+
668671
"the provisioning status of this instance, liveness is fetched through the console field"
669672
status: ConsoleInstanceStatus!
670673

www/src/generated/graphql.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,8 @@ export type ConsoleInstance = {
581581
console?: Maybe<Cluster>;
582582
/** the time this instance was deleted on */
583583
deletedAt?: Maybe<Scalars['DateTime']['output']>;
584+
/** the domain of this instance */
585+
domain?: Maybe<Scalars['String']['output']>;
584586
id: Scalars['ID']['output'];
585587
insertedAt?: Maybe<Scalars['DateTime']['output']>;
586588
/** the name of this instance (globally unique) */

0 commit comments

Comments
 (0)