class Krane::CustomResourceDefinition
Constants
- GLOBAL
- ROLLOUT_CONDITIONS_ANNOTATION
- TIMEOUT
- TIMEOUT_FOR_INSTANCE_ANNOTATION
Public Instance Methods
deploy_failed?()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 13 def deploy_failed? names_accepted_status == "False" end
deploy_succeeded?()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 9 def deploy_succeeded? names_accepted_status == "True" end
group()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 48 def group @definition.dig("spec", "group") end
group_version_kind()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 38 def group_version_kind group = @definition.dig("spec", "group") version = @definition.dig("spec", "version") "#{group}/#{version}/#{kind}" end
kind()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 44 def kind @definition.dig("spec", "names", "kind") end
predeployed?()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 57 def predeployed? predeployed = krane_annotation_value("predeployed") predeployed.nil? || predeployed == "true" end
prunable?()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 52 def prunable? prunable = krane_annotation_value("prunable") prunable == "true" end
rollout_conditions()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 62 def rollout_conditions return @rollout_conditions if defined?(@rollout_conditions) @rollout_conditions = if krane_annotation_value(ROLLOUT_CONDITIONS_ANNOTATION) RolloutConditions.from_annotation(krane_annotation_value(ROLLOUT_CONDITIONS_ANNOTATION)) end rescue RolloutConditionsError @rollout_conditions = nil end
status()
click to toggle source
Calls superclass method
Krane::KubernetesResource#status
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 28 def status if !exists? super elsif deploy_succeeded? "Names accepted" else "#{names_accepted_condition['reason']} (#{names_accepted_condition['message']})" end end
timeout_for_instance()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 21 def timeout_for_instance timeout = krane_annotation_value(TIMEOUT_FOR_INSTANCE_ANNOTATION) DurationParser.new(timeout).parse!.to_i rescue DurationParser::ParsingError nil end
timeout_message()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 17 def timeout_message "The names this CRD is attempting to register were neither accepted nor rejected in time" end
validate_definition(*, **)
click to toggle source
Calls superclass method
Krane::KubernetesResource#validate_definition
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 72 def validate_definition(*, **) super validate_rollout_conditions rescue RolloutConditionsError => e @validation_errors << "Annotation #{Annotation.for(ROLLOUT_CONDITIONS_ANNOTATION)} " \ "on #{name} is invalid: #{e}" end
validate_rollout_conditions()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 81 def validate_rollout_conditions if krane_annotation_value(ROLLOUT_CONDITIONS_ANNOTATION) && @rollout_conditions_validated.nil? conditions = RolloutConditions.from_annotation(krane_annotation_value(ROLLOUT_CONDITIONS_ANNOTATION)) conditions.validate! end @rollout_conditions_validated = true end
Private Instance Methods
names_accepted_condition()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 92 def names_accepted_condition conditions = @instance_data.dig("status", "conditions") || [] conditions.detect { |c| c["type"] == "NamesAccepted" } || {} end
names_accepted_status()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 97 def names_accepted_status names_accepted_condition["status"] end