From bfd40a79c3d9eedab3e098066eb55ffba465affd Mon Sep 17 00:00:00 2001 From: Colton Gerke Date: Tue, 3 Dec 2024 15:23:21 -0600 Subject: [PATCH] Remove the `default_to_predeployed` function from previous iterations on this PR Also add CRDs and CRs to their previous functionality, not using the `default_to_predeployed` functionality --- lib/krane/kubernetes_resource.rb | 10 +--------- lib/krane/kubernetes_resource/custom_resource.rb | 9 +++++---- .../kubernetes_resource/custom_resource_definition.rb | 9 +++------ 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/lib/krane/kubernetes_resource.rb b/lib/krane/kubernetes_resource.rb index d71b4b6ac..eea0dfdca 100644 --- a/lib/krane/kubernetes_resource.rb +++ b/lib/krane/kubernetes_resource.rb @@ -395,15 +395,7 @@ def use_generated_name(instance_data) def predeployed? predeployed = krane_annotation_value("predeployed") - if PREDEPLOYED_RESOURCE_TYPES.include?(type) - true - else - default_to_predeployed? ? (predeployed != "false") : (predeployed == "true") - end - end - - def default_to_predeployed? - false + PREDEPLOYED_RESOURCE_TYPES.include?(type) || predeployed == "true" end class Event diff --git a/lib/krane/kubernetes_resource/custom_resource.rb b/lib/krane/kubernetes_resource/custom_resource.rb index 66417f4b8..e5372aadb 100644 --- a/lib/krane/kubernetes_resource/custom_resource.rb +++ b/lib/krane/kubernetes_resource/custom_resource.rb @@ -62,6 +62,11 @@ def type kind end + def predeployed? + predeployed = krane_annotation_value("predeployed") + predeployed.nil? || predeployed == "true" + end + def validate_definition(*, **) super @@ -74,10 +79,6 @@ def validate_definition(*, **) "Validation failed with: #{e}" end - def default_to_predeployed? - true - end - private def kind diff --git a/lib/krane/kubernetes_resource/custom_resource_definition.rb b/lib/krane/kubernetes_resource/custom_resource_definition.rb index f3d9d4a1c..f07d84a27 100644 --- a/lib/krane/kubernetes_resource/custom_resource_definition.rb +++ b/lib/krane/kubernetes_resource/custom_resource_definition.rb @@ -57,8 +57,9 @@ def prunable? prunable == "true" end - def default_to_predeployed? - true + def predeployed? + predeployed = krane_annotation_value("predeployed") + predeployed.nil? || predeployed == "true" end def rollout_conditions @@ -89,10 +90,6 @@ def validate_rollout_conditions @rollout_conditions_validated = true end - def default_to_predeployed? - true - end - private def names_accepted_condition