class Krane::DeployTaskConfigValidator

Public Class Methods

new(protected_namespaces, allow_protected_ns, prune, *arguments) click to toggle source
Calls superclass method
# File lib/krane/deploy_task_config_validator.rb, line 4
def initialize(protected_namespaces, allow_protected_ns, prune, *arguments)
  super(*arguments)
  @protected_namespaces = protected_namespaces
  @allow_protected_ns = allow_protected_ns
  @prune = prune
  @validations += %i(validate_protected_namespaces)
end

Private Instance Methods

validate_protected_namespaces() click to toggle source
# File lib/krane/deploy_task_config_validator.rb, line 14
def validate_protected_namespaces
  if @protected_namespaces.include?(namespace)
    if @allow_protected_ns && @prune
      @errors << "Refusing to deploy to protected namespace '#{namespace}' with pruning enabled"
    elsif @allow_protected_ns
      logger.warn("You're deploying to protected namespace #{namespace}, which cannot be pruned.")
      logger.warn("Existing resources can only be removed manually with kubectl. " \
        "Removing templates from the set deployed will have no effect.")
      logger.warn("***Please do not deploy to #{namespace} unless you really know what you are doing.***")
    else
      @errors << "Refusing to deploy to protected namespace '#{namespace}'"
    end
  end
end