Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add legacy boolean to clusters #1350

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/core/lib/core/schema/cluster.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ defmodule Core.Schema.Cluster do
field :domain, :string
field :pinged_at, :utc_datetime_usec
field :service_count, :integer
field :legacy, :boolean

belongs_to :owner, User
belongs_to :account, Account
Expand Down Expand Up @@ -85,7 +86,7 @@ defmodule Core.Schema.Cluster do
from(c in query, order_by: ^order)
end

@valid ~w(owner_id account_id provider name domain console_url source git_url pinged_at service_count)a
@valid ~w(owner_id legacy account_id provider name domain console_url source git_url pinged_at service_count)a

def changeset(model, attrs \\ %{}) do
model
Expand Down
3 changes: 2 additions & 1 deletion apps/core/lib/core/schema/upgrade_queue.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ defmodule Core.Schema.UpgradeQueue do
field :name, :string
field :domain, :string
field :git, :string
field :legacy, :boolean
field :provider, Core.Schema.Recipe.Provider
field :pinged_at, :utc_datetime_usec

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

@valid ~w(acked user_id name domain git provider cluster_id)a
@valid ~w(acked legacy user_id name domain git provider cluster_id)a

def changeset(model, attrs \\ %{}) do
model
Expand Down
1 change: 1 addition & 0 deletions apps/core/lib/core/services/clusters.ex
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ defmodule Core.Services.Clusters do
upsert_cluster(%{
console_url: d,
domain: infer_domain(d),
legacy: q.legacy,
git_url: g,
pinged_at: pinged,
}, p, n, user)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defmodule Core.Repo.Migrations.AddLegacyFlagClusters do
use Ecto.Migration

def change do
alter table(:clusters) do
add :legacy, :boolean, default: true
end

alter table(:upgrade_queues) do
add :legacy, :boolean, default: true
end
end
end
8 changes: 7 additions & 1 deletion apps/core/test/services/clusters_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ defmodule Core.Services.ClustersTest do

describe "#create_from_queue/1" do
test "it can create a new cluster from an upgrade queue" do
queue = insert(:upgrade_queue, domain: "console.plural.sh", git: "[email protected]/pluralsh/repo", provider: :aws)
queue = insert(:upgrade_queue,
domain: "console.plural.sh",
git: "[email protected]/pluralsh/repo",
provider: :aws,
legacy: true
)

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

assert cluster.name == queue.name
assert cluster.legacy
assert cluster.provider == queue.provider
assert cluster.owner_id == queue.user_id
assert cluster.account_id == queue.user.account_id
Expand Down
2 changes: 2 additions & 0 deletions apps/graphql/lib/graphql/schema/cluster.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ defmodule GraphQl.Schema.Cluster do
input_object :cluster_attributes do
field :name, non_null(:string), description: "The name of the cluster."
field :provider, non_null(:provider), description: "The cluster's cloud provider."
field :legacy, :boolean, description: "whether this is a legacy oss cluster"
field :source, :source, description: "The source of the cluster."
field :git_url, :string, description: "The git repository URL for the cluster."
field :console_url, :string, description: "The URL of the console running on the cluster."
Expand All @@ -21,6 +22,7 @@ defmodule GraphQl.Schema.Cluster do
field :id, non_null(:id), description: "The ID of the cluster."
field :name, non_null(:string), description: "The name of the cluster."
field :provider, non_null(:provider), description: "The cluster's cloud provider."
field :legacy, :boolean, description: "whether this is a legacy OSS cluster"
field :source, :source, description: "The source of the cluster."
field :git_url, :string, description: "The git repository URL for the cluster."
field :console_url, :string, description: "The URL of the console running on the cluster."
Expand Down
3 changes: 2 additions & 1 deletion apps/graphql/lib/graphql/schema/upgrade.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ defmodule GraphQl.Schema.Upgrade do

input_object :upgrade_queue_attributes do
field :name, non_null(:string)
field :legacy, :boolean
field :domain, :string
field :git, :string
field :provider, :provider
Expand Down Expand Up @@ -129,8 +130,8 @@ defmodule GraphQl.Schema.Upgrade do
object :upgrade_mutations do
field :create_queue, :upgrade_queue do
middleware Authenticated

arg :attributes, non_null(:upgrade_queue_attributes)

resolve &Upgrade.create_upgrade_queue/2
end

Expand Down
7 changes: 7 additions & 0 deletions schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,9 @@ type Cluster {
"The cluster's cloud provider."
provider: Provider!

"whether this is a legacy OSS cluster"
legacy: Boolean

"The source of the cluster."
source: Source

Expand Down Expand Up @@ -2837,6 +2840,9 @@ input ClusterAttributes {
"The cluster's cloud provider."
provider: Provider!

"whether this is a legacy oss cluster"
legacy: Boolean

"The source of the cluster."
source: Source

Expand Down Expand Up @@ -3675,6 +3681,7 @@ input StackAttributes {

input UpgradeQueueAttributes {
name: String!
legacy: Boolean
domain: String
git: String
provider: Provider
Expand Down
5 changes: 5 additions & 0 deletions www/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ export type Cluster = {
/** The ID of the cluster. */
id: Scalars['ID']['output'];
insertedAt?: Maybe<Scalars['DateTime']['output']>;
/** whether this is a legacy OSS cluster */
legacy?: Maybe<Scalars['Boolean']['output']>;
/** whether any installation in the cluster has been locked */
locked?: Maybe<Scalars['Boolean']['output']>;
/** The name of the cluster. */
Expand Down Expand Up @@ -464,6 +466,8 @@ export type ClusterAttributes = {
domain?: InputMaybe<Scalars['String']['input']>;
/** The git repository URL for the cluster. */
gitUrl?: InputMaybe<Scalars['String']['input']>;
/** whether this is a legacy oss cluster */
legacy?: InputMaybe<Scalars['Boolean']['input']>;
/** The name of the cluster. */
name: Scalars['String']['input'];
/** The cluster's cloud provider. */
Expand Down Expand Up @@ -4926,6 +4930,7 @@ export type UpgradeQueueUpgradesArgs = {
export type UpgradeQueueAttributes = {
domain?: InputMaybe<Scalars['String']['input']>;
git?: InputMaybe<Scalars['String']['input']>;
legacy?: InputMaybe<Scalars['Boolean']['input']>;
name: Scalars['String']['input'];
provider?: InputMaybe<Provider>;
};
Expand Down
Loading