Sha256: 32b7152e3f1d05fed3d82da130fb1f2a74a862bf4086d0068a17306fd2f08850

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true
module Krane
  class DeployTaskConfigValidator < TaskConfigValidator
    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

    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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kubernetes-deploy-1.0.0.pre.2 lib/krane/deploy_task_config_validator.rb
kubernetes-deploy-1.0.0.pre.1 lib/krane/deploy_task_config_validator.rb
kubernetes-deploy-0.31.1 lib/krane/deploy_task_config_validator.rb
kubernetes-deploy-0.31.0 lib/krane/deploy_task_config_validator.rb