Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update kubectl flag: --prune-allowlist -> --prune-allowlist #935

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/krane/kubectl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Kubectl
DEFAULT_TIMEOUT = 15
MAX_RETRY_DELAY = 16
SERVER_DRY_RUN_MIN_VERSION = "1.13"
PRUNE_ALLOWLIST_MIN_VERSION = "1.26"

class ResourceNotFoundError < StandardError; end

Expand Down Expand Up @@ -112,6 +113,14 @@ def dry_run_flag
"--dry-run=server"
end

def prune_allowlist_flag
if client_version >= Gem::Version.new(PRUNE_ALLOWLIST_MIN_VERSION)
return "--prune-allowlist"
else
return "--prune-whitelist"
end
end

private

def build_command_from_options(args, use_namespace, use_context, output)
Expand Down
2 changes: 1 addition & 1 deletion lib/krane/resource_deployer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def apply_all(resources, prune, dry_run: false)
else
command.push("--all")
end
@prune_whitelist.each { |type| command.push("--prune-whitelist=#{type}") }
@prune_whitelist.each { |type| command.push("#{kubectl.prune_allowlist_flag}=#{type}") }
end

command.push(kubectl.dry_run_flag) if dry_run
Expand Down
4 changes: 2 additions & 2 deletions test/unit/krane/resource_deployer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def test_deploy_prune_builds_whitelist
whitelist_kind = "fake_kind"
resource = build_mock_resource
Krane::Kubectl.any_instance.expects(:run).with do |*args|
args.include?("--prune-whitelist=#{whitelist_kind}")
args.include?("--prune-allowlist=#{whitelist_kind}")
end.returns(["", "", stub(success?: true)])
resource_deployer(kubectl_times: 0, prune_whitelist: [whitelist_kind]).deploy!([resource], false, true)
end
Expand All @@ -16,7 +16,7 @@ def test_deploy_no_prune_doesnt_prune
whitelist_kind = "fake_kind"
resource = build_mock_resource
Krane::Kubectl.any_instance.expects(:run).with do |*args|
!args.include?("--prune-whitelist=#{whitelist_kind}")
!args.include?("--prune-allowlist=#{whitelist_kind}")
end.returns(["", "", stub(success?: true)])
resource_deployer(kubectl_times: 0, prune_whitelist: [whitelist_kind]).deploy!([resource], false, false)
end
Expand Down
Loading