Class: Pangea::Kubernetes::Types::NodePoolConfig

Inherits:
Resources::BaseAttributes
  • Object
show all
Defined in:
lib/pangea/kubernetes/types.rb

Overview

Node pool configuration — cloud-agnostic

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(attributes) ⇒ Object



76
77
78
79
80
81
82
# File 'lib/pangea/kubernetes/types.rb', line 76

def self.new(attributes)
  attrs = attributes.is_a?(::Hash) ? attributes : {}
  if attrs[:max_size] && attrs[:min_size] && attrs[:max_size] < attrs[:min_size]
    raise Dry::Struct::Error, "max_size (#{attrs[:max_size]}) must be >= min_size (#{attrs[:min_size]})"
  end
  super(attrs)
end

Instance Method Details

#effective_desired_sizeObject



84
85
86
# File 'lib/pangea/kubernetes/types.rb', line 84

def effective_desired_size
  desired_size || min_size
end

#to_hObject



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/pangea/kubernetes/types.rb', line 88

def to_h
  hash = {
    name: name,
    instance_types: instance_types,
    min_size: min_size,
    max_size: max_size,
    disk_size_gb: disk_size_gb
  }
  hash[:desired_size] = desired_size if desired_size
  hash[:labels] = labels if labels.any?
  hash[:taints] = taints if taints.any?
  hash[:max_pods] = max_pods if max_pods
  hash[:ssh_keys] = ssh_keys if ssh_keys.any?
  hash
end