class Krane::CustomResourceDefinition
Constants
- GLOBAL
- ROLLOUT_CONDITIONS_ANNOTATION
- ROLLOUT_CONDITIONS_ANNOTATION_SUFFIX
- TIMEOUT
- TIMEOUT_FOR_INSTANCE_ANNOTATION
Public Instance Methods
deploy_failed?()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 14 def deploy_failed? names_accepted_status == "False" end
deploy_succeeded?()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 10 def deploy_succeeded? names_accepted_status == "True" end
group_version_kind()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 39 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 45 def kind @definition.dig("spec", "names", "kind") end
predeployed?()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 54 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 49 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 59 def rollout_conditions return @rollout_conditions if defined?(@rollout_conditions) @rollout_conditions = if krane_annotation_value(ROLLOUT_CONDITIONS_ANNOTATION_SUFFIX) RolloutConditions.from_annotation(krane_annotation_value(ROLLOUT_CONDITIONS_ANNOTATION_SUFFIX)) 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 29 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 22 def timeout_for_instance timeout = krane_annotation_value("instance-timeout") 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 18 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 69 def validate_definition(*) super validate_rollout_conditions rescue RolloutConditionsError => e @validation_errors << "Annotation #{krane_annotation_key(ROLLOUT_CONDITIONS_ANNOTATION_SUFFIX)} "\ "on #{name} is invalid: #{e}" end
validate_rollout_conditions()
click to toggle source
# File lib/krane/kubernetes_resource/custom_resource_definition.rb, line 78 def validate_rollout_conditions if krane_annotation_value(ROLLOUT_CONDITIONS_ANNOTATION_SUFFIX) && @rollout_conditions_validated.nil? conditions = RolloutConditions.from_annotation(krane_annotation_value(ROLLOUT_CONDITIONS_ANNOTATION_SUFFIX)) 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 89 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 94 def names_accepted_status names_accepted_condition["status"] end