Skip to content

Commit 8b26d12

Browse files
Add legacy boolean to clusters (#1350)
1 parent bc76f23 commit 8b26d12

File tree

9 files changed

+41
-4
lines changed

9 files changed

+41
-4
lines changed

apps/core/lib/core/schema/cluster.ex

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ defmodule Core.Schema.Cluster do
2020
field :domain, :string
2121
field :pinged_at, :utc_datetime_usec
2222
field :service_count, :integer
23+
field :legacy, :boolean
2324

2425
belongs_to :owner, User
2526
belongs_to :account, Account
@@ -85,7 +86,7 @@ defmodule Core.Schema.Cluster do
8586
from(c in query, order_by: ^order)
8687
end
8788

88-
@valid ~w(owner_id account_id provider name domain console_url source git_url pinged_at service_count)a
89+
@valid ~w(owner_id legacy account_id provider name domain console_url source git_url pinged_at service_count)a
8990

9091
def changeset(model, attrs \\ %{}) do
9192
model

apps/core/lib/core/schema/upgrade_queue.ex

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ defmodule Core.Schema.UpgradeQueue do
99
field :name, :string
1010
field :domain, :string
1111
field :git, :string
12+
field :legacy, :boolean
1213
field :provider, Core.Schema.Recipe.Provider
1314
field :pinged_at, :utc_datetime_usec
1415

@@ -35,7 +36,7 @@ defmodule Core.Schema.UpgradeQueue do
3536
from(q in query, where: is_nil(q.cluster_id))
3637
end
3738

38-
@valid ~w(acked user_id name domain git provider cluster_id)a
39+
@valid ~w(acked legacy user_id name domain git provider cluster_id)a
3940

4041
def changeset(model, attrs \\ %{}) do
4142
model

apps/core/lib/core/services/clusters.ex

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ defmodule Core.Services.Clusters do
158158
upsert_cluster(%{
159159
console_url: d,
160160
domain: infer_domain(d),
161+
legacy: q.legacy,
161162
git_url: g,
162163
pinged_at: pinged,
163164
}, p, n, user)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
defmodule Core.Repo.Migrations.AddLegacyFlagClusters do
2+
use Ecto.Migration
3+
4+
def change do
5+
alter table(:clusters) do
6+
add :legacy, :boolean, default: true
7+
end
8+
9+
alter table(:upgrade_queues) do
10+
add :legacy, :boolean, default: true
11+
end
12+
end
13+
end

apps/core/test/services/clusters_test.exs

+7-1
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,17 @@ defmodule Core.Services.ClustersTest do
3131

3232
describe "#create_from_queue/1" do
3333
test "it can create a new cluster from an upgrade queue" do
34-
queue = insert(:upgrade_queue, domain: "console.plural.sh", git: "[email protected]/pluralsh/repo", provider: :aws)
34+
queue = insert(:upgrade_queue,
35+
domain: "console.plural.sh",
36+
git: "[email protected]/pluralsh/repo",
37+
provider: :aws,
38+
legacy: true
39+
)
3540

3641
{:ok, cluster} = Clusters.create_from_queue(queue)
3742

3843
assert cluster.name == queue.name
44+
assert cluster.legacy
3945
assert cluster.provider == queue.provider
4046
assert cluster.owner_id == queue.user_id
4147
assert cluster.account_id == queue.user.account_id

apps/graphql/lib/graphql/schema/cluster.ex

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ defmodule GraphQl.Schema.Cluster do
1010
input_object :cluster_attributes do
1111
field :name, non_null(:string), description: "The name of the cluster."
1212
field :provider, non_null(:provider), description: "The cluster's cloud provider."
13+
field :legacy, :boolean, description: "whether this is a legacy oss cluster"
1314
field :source, :source, description: "The source of the cluster."
1415
field :git_url, :string, description: "The git repository URL for the cluster."
1516
field :console_url, :string, description: "The URL of the console running on the cluster."
@@ -21,6 +22,7 @@ defmodule GraphQl.Schema.Cluster do
2122
field :id, non_null(:id), description: "The ID of the cluster."
2223
field :name, non_null(:string), description: "The name of the cluster."
2324
field :provider, non_null(:provider), description: "The cluster's cloud provider."
25+
field :legacy, :boolean, description: "whether this is a legacy OSS cluster"
2426
field :source, :source, description: "The source of the cluster."
2527
field :git_url, :string, description: "The git repository URL for the cluster."
2628
field :console_url, :string, description: "The URL of the console running on the cluster."

apps/graphql/lib/graphql/schema/upgrade.ex

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ defmodule GraphQl.Schema.Upgrade do
3434

3535
input_object :upgrade_queue_attributes do
3636
field :name, non_null(:string)
37+
field :legacy, :boolean
3738
field :domain, :string
3839
field :git, :string
3940
field :provider, :provider
@@ -129,8 +130,8 @@ defmodule GraphQl.Schema.Upgrade do
129130
object :upgrade_mutations do
130131
field :create_queue, :upgrade_queue do
131132
middleware Authenticated
132-
133133
arg :attributes, non_null(:upgrade_queue_attributes)
134+
134135
resolve &Upgrade.create_upgrade_queue/2
135136
end
136137

schema/schema.graphql

+7
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,9 @@ type Cluster {
16261626
"The cluster's cloud provider."
16271627
provider: Provider!
16281628

1629+
"whether this is a legacy OSS cluster"
1630+
legacy: Boolean
1631+
16291632
"The source of the cluster."
16301633
source: Source
16311634

@@ -2837,6 +2840,9 @@ input ClusterAttributes {
28372840
"The cluster's cloud provider."
28382841
provider: Provider!
28392842

2843+
"whether this is a legacy oss cluster"
2844+
legacy: Boolean
2845+
28402846
"The source of the cluster."
28412847
source: Source
28422848

@@ -3675,6 +3681,7 @@ input StackAttributes {
36753681

36763682
input UpgradeQueueAttributes {
36773683
name: String!
3684+
legacy: Boolean
36783685
domain: String
36793686
git: String
36803687
provider: Provider

www/src/generated/graphql.ts

+5
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ export type Cluster = {
425425
/** The ID of the cluster. */
426426
id: Scalars['ID']['output'];
427427
insertedAt?: Maybe<Scalars['DateTime']['output']>;
428+
/** whether this is a legacy OSS cluster */
429+
legacy?: Maybe<Scalars['Boolean']['output']>;
428430
/** whether any installation in the cluster has been locked */
429431
locked?: Maybe<Scalars['Boolean']['output']>;
430432
/** The name of the cluster. */
@@ -464,6 +466,8 @@ export type ClusterAttributes = {
464466
domain?: InputMaybe<Scalars['String']['input']>;
465467
/** The git repository URL for the cluster. */
466468
gitUrl?: InputMaybe<Scalars['String']['input']>;
469+
/** whether this is a legacy oss cluster */
470+
legacy?: InputMaybe<Scalars['Boolean']['input']>;
467471
/** The name of the cluster. */
468472
name: Scalars['String']['input'];
469473
/** The cluster's cloud provider. */
@@ -4926,6 +4930,7 @@ export type UpgradeQueueUpgradesArgs = {
49264930
export type UpgradeQueueAttributes = {
49274931
domain?: InputMaybe<Scalars['String']['input']>;
49284932
git?: InputMaybe<Scalars['String']['input']>;
4933+
legacy?: InputMaybe<Scalars['Boolean']['input']>;
49294934
name: Scalars['String']['input'];
49304935
provider?: InputMaybe<Provider>;
49314936
};

0 commit comments

Comments
 (0)