uffizzi_core 2.2.22 → 2.2.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a8b7a41bf7500c5bd99fcfade94c9f256eecb8a3531c4afb048902be526fc60
4
- data.tar.gz: 1a5c2e46220213fc439161c1b65d1535f9673b3885ca3b4559f049b0b7e19c86
3
+ metadata.gz: 2d8112c651358e76a331ea2e85d1562ecd15724adaf89eeebc10146958ef9550
4
+ data.tar.gz: fbc115075ccb252fbc6446b51fccd93c8571d3b106a83376b173b63c7de25fd7
5
5
  SHA512:
6
- metadata.gz: 24b7a0c6c99809788c6606c1b21561ce0a7f14d639ebd321d66de8e7949285f61561b41cd3f060fe885b3c4ca943d0c1b2a7d0c626f33244071836cb27d7beb7
7
- data.tar.gz: 86ec582667bd5dd7b02e2f348f6f14aa781ce5a18f4c5c0f907656af6fcf54041db4a26c14256c82a78b0e85b158082de688f6a23bb860f61280ffdc66a311c7
6
+ metadata.gz: 55f7fb96c94e8dfca56310456bc3202764d1e16173fe57e96c027609748ae10bd758af06c355682c2c8ef2634b10402ce899778efb7467a99f16bd5aa4745a7f
7
+ data.tar.gz: 8d323b2dff07e8d9d03918e5642cd10093a9e2decc0f2cbf3a9e017b2ad99e8165bd447ea210a28a0497153b955244ebd68ce0d9d8db20424ed9cb05cfbf3273
@@ -11,13 +11,18 @@ class UffizziCore::Api::Cli::V1::Projects::ClustersController < UffizziCore::Api
11
11
  clusters = resource_project.clusters.enabled
12
12
  return respond_with clusters if request_by_admin? || valid_request_from_ci_workflow?
13
13
 
14
- respond_with clusters.deployed_by_user(current_user)
14
+ respond_with clusters.deployed_by_user(current_user), each_serializer: UffizziCore::Api::Cli::V1::Projects::ShortClusterSerializer
15
15
  end
16
16
 
17
17
  def create
18
+ version = cluster_params[:k8s_version]
19
+ kubernetes_distribution = find_kubernetes_distribution(version)
20
+ return render_distribution_version_error(version) if kubernetes_distribution.blank?
21
+
18
22
  cluster_form = UffizziCore::Api::Cli::V1::Cluster::CreateForm.new(cluster_params)
19
23
  cluster_form.project = resource_project
20
24
  cluster_form.deployed_by = current_user
25
+ cluster_form.kubernetes_distribution = kubernetes_distribution
21
26
  return respond_with cluster_form unless cluster_form.save
22
27
 
23
28
  UffizziCore::ClusterService.start_deploy(cluster_form)
@@ -57,4 +62,16 @@ class UffizziCore::Api::Cli::V1::Projects::ClustersController < UffizziCore::Api
57
62
  def cluster_params
58
63
  params.require(:cluster)
59
64
  end
65
+
66
+ def find_kubernetes_distribution(version)
67
+ return UffizziCore::KubernetesDistribution.default if version.blank?
68
+
69
+ UffizziCore::KubernetesDistribution.find_by(version: version)
70
+ end
71
+
72
+ def render_distribution_version_error(version)
73
+ available_versions = UffizziCore::KubernetesDistribution.pluck(:version).join(', ')
74
+ message = I18n.t('kubernetes_distribution.not_available', version: version, available_versions: available_versions)
75
+ render json: { errors: { kubernetes_distribution: [message] } }, status: :unprocessable_entity
76
+ end
60
77
  end
@@ -20,6 +20,7 @@ module UffizziCore::Concerns::Models::Cluster
20
20
  enumerize :creation_source, in: UffizziCore.cluster_creation_sources, scope: true, predicates: true
21
21
  attribute :creation_source, :string, default: :manual
22
22
  validates :creation_source, presence: true
23
+ belongs_to :kubernetes_distribution, optional: true
23
24
 
24
25
  aasm(:state) do
25
26
  state :deploying_namespace, initial: true
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UffizziCore::Concerns::Models::KubernetesDistribution
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ self.table_name = UffizziCore.table_names[:kubernetes_distributions]
8
+
9
+ has_many :clusters
10
+
11
+ def self.default
12
+ find_by(default: true)
13
+ end
14
+ end
15
+ end
@@ -3,6 +3,7 @@
3
3
  module UffizziCore::Concerns::Models::Project
4
4
  extend ActiveSupport::Concern
5
5
 
6
+ # rubocop:disable Metrics/BlockLength
6
7
  included do
7
8
  include AASM
8
9
  include UffizziCore::StateMachineConcern
@@ -43,10 +44,15 @@ module UffizziCore::Concerns::Models::Project
43
44
 
44
45
  def after_disable
45
46
  disable_deployments
47
+ disable_clusters
46
48
  end
47
49
 
48
50
  def active_deployments
49
- deployments.active
51
+ deployments.enabled
52
+ end
53
+
54
+ def active_clusters
55
+ clusters.enabled
50
56
  end
51
57
 
52
58
  def disable_deployments
@@ -56,8 +62,13 @@ module UffizziCore::Concerns::Models::Project
56
62
  end
57
63
  end
58
64
 
65
+ def disable_clusters
66
+ active_clusters.each(&:disable!)
67
+ end
68
+
59
69
  def compose_file
60
70
  compose_files.main.first
61
71
  end
62
72
  end
73
+ # rubocop:enable Metrics/BlockLength
63
74
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UffizziCore::KubernetesDistribution < UffizziCore::ApplicationRecord
4
+ include UffizziCore::Concerns::Models::KubernetesDistribution
5
+ end
@@ -3,5 +3,9 @@
3
3
  class UffizziCore::Api::Cli::V1::Projects::ClusterSerializer < UffizziCore::BaseSerializer
4
4
  type :cluster
5
5
 
6
- attributes :id, :name, :state, :kubeconfig, :created_at, :host
6
+ attributes :id, :name, :state, :kubeconfig, :created_at, :host, :k8s_version
7
+
8
+ def k8s_version
9
+ object.kubernetes_distribution&.version || UffizziCore::KubernetesDistribution.default.version
10
+ end
7
11
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UffizziCore::Api::Cli::V1::Projects::ShortClusterSerializer < UffizziCore::BaseSerializer
4
+ type :cluster
5
+
6
+ attributes :id, :name
7
+ end
@@ -4,11 +4,25 @@ class UffizziCore::Controller::CreateCluster::ClusterSerializer < UffizziCore::B
4
4
  include UffizziCore::DependencyInjectionConcern
5
5
  include_module_if_exists('UffizziCore::Controller::CreateCluster::ClusterSerializerModule')
6
6
 
7
- attributes :name, :manifest, :base_ingress_host
7
+ attributes :name, :manifest, :base_ingress_host, :distro, :image
8
8
 
9
9
  def base_ingress_host
10
10
  managed_dns_zone = controller_settings_service.vcluster(object).managed_dns_zone
11
11
 
12
12
  [object.namespace, managed_dns_zone].join('.')
13
13
  end
14
+
15
+ def image
16
+ kubernetes_distribution.image
17
+ end
18
+
19
+ def distro
20
+ kubernetes_distribution.distro
21
+ end
22
+
23
+ private
24
+
25
+ def kubernetes_distribution
26
+ @kubernetes_distribution ||= object.kubernetes_distribution
27
+ end
14
28
  end
@@ -70,7 +70,7 @@ class UffizziCore::ComposeFile::Parsers::ServicesParserService
70
70
  def check_and_parse_build_option(value, compose_payload)
71
71
  build_parser_module = find_build_parser_module
72
72
 
73
- raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.not_implemented', option: :build) unless build_parser_module
73
+ raise UffizziCore::ComposeFile::ParseError, I18n.t('compose.build_not_implemented') unless build_parser_module
74
74
 
75
75
  build_parser_module.parse(value, compose_payload)
76
76
  end
@@ -74,6 +74,7 @@ en:
74
74
  required_start_commands: "When 'test' is a list the first item must be one of: '%{available_commands}'"
75
75
  volumes_should_be_array: Volumes '%{volumes}' should be an arra
76
76
  healthcheck_missing_required_option: "One of these options is required: %{required_options}"
77
+ build_not_implemented: "The 'build' directive is not supported by the uffizzi command-line tool. Use 'image' instead, or configure Uffizzi CI if you want Uffizzi Cloud to build your application from source. See https://docs.uffizzi.com/references/compose-spec/"
77
78
 
78
79
  secrets:
79
80
  duplicates_exists: Secret with key %{secrets} already exist.
@@ -87,6 +88,9 @@ en:
87
88
  unsupported_login_type: This type of login is not supported
88
89
  unauthorized: Unauthorized
89
90
 
91
+ kubernetes_distribution:
92
+ not_available: "The k8s version %{version} is not supported. Available version are: %{available_versions}."
93
+
90
94
  enumerize:
91
95
  credential:
92
96
  type:
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateUffizziCoreKubernetesDistributions < ActiveRecord::Migration[6.1]
4
+ def change
5
+ create_table :uffizzi_core_kubernetes_distributions do |t|
6
+ t.string :version
7
+ t.string :distro
8
+ t.string :image
9
+ t.boolean :default, default: false
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddKubernetesDistributionIdToUffizziCoreClusters < ActiveRecord::Migration[6.1]
4
+ def change
5
+ add_column(:uffizzi_core_clusters, :kubernetes_distribution_id, :integer, foreign_key: true)
6
+ end
7
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UffizziCore
4
- VERSION = '2.2.22'
4
+ VERSION = '2.2.24'
5
5
  end
data/lib/uffizzi_core.rb CHANGED
@@ -66,6 +66,7 @@ module UffizziCore
66
66
  host_volume_files: :uffizzi_core_host_volume_files,
67
67
  container_host_volume_files: :uffizzi_core_container_host_volume_files,
68
68
  deployment_events: :uffizzi_core_deployment_events,
69
+ kubernetes_distributions: :uffizzi_core_kubernetes_distributions,
69
70
  }
70
71
  mattr_accessor :user_creation_sources, default: [:system, :online_registration, :google, :sso]
71
72
  mattr_accessor :user_project_roles, default: [:admin, :developer, :viewer]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uffizzi_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.22
4
+ version: 2.2.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Thurman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-09-07 00:00:00.000000000 Z
12
+ date: 2023-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aasm
@@ -865,6 +865,7 @@ files:
865
865
  - app/lib/uffizzi_core/concerns/models/deployment_event.rb
866
866
  - app/lib/uffizzi_core/concerns/models/event.rb
867
867
  - app/lib/uffizzi_core/concerns/models/host_volume_file.rb
868
+ - app/lib/uffizzi_core/concerns/models/kubernetes_distribution.rb
868
869
  - app/lib/uffizzi_core/concerns/models/membership.rb
869
870
  - app/lib/uffizzi_core/concerns/models/payment.rb
870
871
  - app/lib/uffizzi_core/concerns/models/price.rb
@@ -909,6 +910,7 @@ files:
909
910
  - app/models/uffizzi_core/deployment_event.rb
910
911
  - app/models/uffizzi_core/event.rb
911
912
  - app/models/uffizzi_core/host_volume_file.rb
913
+ - app/models/uffizzi_core/kubernetes_distribution.rb
912
914
  - app/models/uffizzi_core/membership.rb
913
915
  - app/models/uffizzi_core/payment.rb
914
916
  - app/models/uffizzi_core/price.rb
@@ -982,6 +984,7 @@ files:
982
984
  - app/serializers/uffizzi_core/api/cli/v1/projects/deployments_serializer.rb
983
985
  - app/serializers/uffizzi_core/api/cli/v1/projects/deployments_serializer/user_serializer.rb
984
986
  - app/serializers/uffizzi_core/api/cli/v1/projects/secret_serializer.rb
987
+ - app/serializers/uffizzi_core/api/cli/v1/projects/short_cluster_serializer.rb
985
988
  - app/serializers/uffizzi_core/api/cli/v1/short_project_serializer.rb
986
989
  - app/serializers/uffizzi_core/api/cli/v1/user_serializer.rb
987
990
  - app/serializers/uffizzi_core/api/cli/v1/user_serializer/account_serializer.rb
@@ -1088,6 +1091,8 @@ files:
1088
1091
  - db/migrate/20230711101901_add_host_to_clusters.rb
1089
1092
  - db/migrate/20230810140316_add_source_to_uffizzi_core_clusters.rb
1090
1093
  - db/migrate/20230824150022_update_name_constraint_to_projects.rb
1094
+ - db/migrate/20231009162719_create_uffizzi_core_kubernetes_distributions.rb
1095
+ - db/migrate/20231009182412_add_kubernetes_distribution_id_to_uffizzi_core_clusters.rb
1091
1096
  - db/seeds.rb
1092
1097
  - lib/tasks/uffizzi_core_tasks.rake
1093
1098
  - lib/uffizzi_core.rb