diff --git a/lib/krane/kubernetes_resource.rb b/lib/krane/kubernetes_resource.rb index 361c396b2..225384dc1 100644 --- a/lib/krane/kubernetes_resource.rb +++ b/lib/krane/kubernetes_resource.rb @@ -381,9 +381,20 @@ def use_generated_name(instance_data) @file = create_definition_tempfile end + PREDEPLOYED_RESOURCE_TYPES = [ + "ResourceQuota", + "NetworkPolicy", + "ConfigMap", + "PersistentVolumeClaim", + "ServiceAccount", + "Role", + "RoleBinding", + "Secret" + ] + def predeployed? predeployed = krane_annotation_value("predeployed") - if type == "Role" || type == "RoleBinding" + if PREDEPLOYED_RESOURCE_TYPES.include?(type) true else default_to_predeployed? ? (predeployed != "false") : (predeployed == "true") diff --git a/lib/krane/kubernetes_resource/config_map.rb b/lib/krane/kubernetes_resource/config_map.rb index 80f0f4782..364656922 100644 --- a/lib/krane/kubernetes_resource/config_map.rb +++ b/lib/krane/kubernetes_resource/config_map.rb @@ -3,10 +3,6 @@ module Krane class ConfigMap < KubernetesResource TIMEOUT = 30.seconds - def predeployed? - true - end - def deploy_succeeded? exists? end diff --git a/lib/krane/kubernetes_resource/custom_resource_definition.rb b/lib/krane/kubernetes_resource/custom_resource_definition.rb index 4dad6264d..f3d9d4a1c 100644 --- a/lib/krane/kubernetes_resource/custom_resource_definition.rb +++ b/lib/krane/kubernetes_resource/custom_resource_definition.rb @@ -57,9 +57,8 @@ def prunable? prunable == "true" end - def predeployed? - predeployed = krane_annotation_value("predeployed") - predeployed.nil? || predeployed == "true" + def default_to_predeployed? + true end def rollout_conditions diff --git a/lib/krane/kubernetes_resource/network_policy.rb b/lib/krane/kubernetes_resource/network_policy.rb index 89f8d54a6..8cbf622fa 100644 --- a/lib/krane/kubernetes_resource/network_policy.rb +++ b/lib/krane/kubernetes_resource/network_policy.rb @@ -3,10 +3,6 @@ module Krane class NetworkPolicy < KubernetesResource TIMEOUT = 30.seconds - def predeployed? - true - end - def status exists? ? "Created" : "Not Found" end diff --git a/lib/krane/kubernetes_resource/persistent_volume_claim.rb b/lib/krane/kubernetes_resource/persistent_volume_claim.rb index 59f0bdd9d..6a2824e15 100644 --- a/lib/krane/kubernetes_resource/persistent_volume_claim.rb +++ b/lib/krane/kubernetes_resource/persistent_volume_claim.rb @@ -3,10 +3,6 @@ module Krane class PersistentVolumeClaim < KubernetesResource TIMEOUT = 5.minutes - def predeployed? - true - end - def sync(cache) super @storage_classes = cache.get_all("StorageClass").map { |sc| StorageClass.new(sc) } diff --git a/lib/krane/kubernetes_resource/resource_quota.rb b/lib/krane/kubernetes_resource/resource_quota.rb index 8df17b3c6..8a1032666 100644 --- a/lib/krane/kubernetes_resource/resource_quota.rb +++ b/lib/krane/kubernetes_resource/resource_quota.rb @@ -3,10 +3,6 @@ module Krane class ResourceQuota < KubernetesResource TIMEOUT = 30.seconds - def predeployed? - true - end - def status exists? ? "In effect" : "Not Found" end diff --git a/lib/krane/kubernetes_resource/role.rb b/lib/krane/kubernetes_resource/role.rb index a30945d2b..58588739a 100644 --- a/lib/krane/kubernetes_resource/role.rb +++ b/lib/krane/kubernetes_resource/role.rb @@ -3,10 +3,6 @@ module Krane class Role < KubernetesResource TIMEOUT = 30.seconds - def predeployed? - true - end - def status exists? ? "Created" : "Not Found" end diff --git a/lib/krane/kubernetes_resource/role_binding.rb b/lib/krane/kubernetes_resource/role_binding.rb index 63c586c85..2ff4874ae 100644 --- a/lib/krane/kubernetes_resource/role_binding.rb +++ b/lib/krane/kubernetes_resource/role_binding.rb @@ -3,10 +3,6 @@ module Krane class RoleBinding < KubernetesResource TIMEOUT = 30.seconds - def predeployed? - true - end - def status exists? ? "Created" : "Not Found" end diff --git a/lib/krane/kubernetes_resource/secret.rb b/lib/krane/kubernetes_resource/secret.rb index d47474dcf..d484b0d90 100644 --- a/lib/krane/kubernetes_resource/secret.rb +++ b/lib/krane/kubernetes_resource/secret.rb @@ -5,10 +5,6 @@ class Secret < KubernetesResource SENSITIVE_TEMPLATE_CONTENT = true SERVER_DRY_RUNNABLE = true - def predeployed? - true - end - def status exists? ? "Available" : "Not Found" end diff --git a/lib/krane/kubernetes_resource/service_account.rb b/lib/krane/kubernetes_resource/service_account.rb index cde109eba..4ef4cbcff 100644 --- a/lib/krane/kubernetes_resource/service_account.rb +++ b/lib/krane/kubernetes_resource/service_account.rb @@ -3,10 +3,6 @@ module Krane class ServiceAccount < KubernetesResource TIMEOUT = 30.seconds - def predeployed? - true - end - def status exists? ? "Created" : "Not Found" end