Files
ubicloud/model/kubernetes/kubernetes_nodepool.rb
Jeremy Evans 718370f4c9 Convert ResourceMethods to a plugin
Allow plugin to take an etc_type keyword argument for using the
TYPE_ETC ubid type, and remove the separate definitions in every
model that uses the TYPE_ETC ubid type.

This was the cleanest way to DRY things up.  You cannot extend
the models with a module to do this before including ResourceMethods,
because then ResourceMethods::ClassMethods will override it, and
you cannot extend the models with a module to do this after
including ResourceMethods, because the inclusion will not work
correctly due to the eager definition of @ubid_format.

Best reviewed without whitespace differences.
2025-06-04 04:55:45 +09:00

31 lines
1.3 KiB
Ruby

# frozen_string_literal: true
require_relative "../../model"
class KubernetesNodepool < Sequel::Model
one_to_one :strand, key: :id
many_to_one :cluster, key: :kubernetes_cluster_id, class: :KubernetesCluster
many_to_many :vms, order: :created_at
plugin ResourceMethods
include SemaphoreMethods
semaphore :destroy, :start_bootstrapping, :upgrade
end
# Table: kubernetes_nodepool
# Columns:
# id | uuid | PRIMARY KEY
# name | text | NOT NULL
# node_count | integer | NOT NULL
# created_at | timestamp with time zone | NOT NULL DEFAULT CURRENT_TIMESTAMP
# kubernetes_cluster_id | uuid | NOT NULL
# target_node_size | text | NOT NULL
# target_node_storage_size_gib | bigint |
# Indexes:
# kubernetes_nodepool_pkey | PRIMARY KEY btree (id)
# Foreign key constraints:
# kubernetes_nodepool_kubernetes_cluster_id_fkey | (kubernetes_cluster_id) REFERENCES kubernetes_cluster(id)
# Referenced By:
# kubernetes_nodepools_vms | kubernetes_nodepools_vms_kubernetes_nodepool_id_fkey | (kubernetes_nodepool_id) REFERENCES kubernetes_nodepool(id)