-
Notifications
You must be signed in to change notification settings - Fork 115
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
kubectl --kubeconfig cannot merge multiple files #468
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# frozen_string_literal: true | ||
module KubernetesDeploy | ||
VERSION = "0.26.2" | ||
VERSION = "0.26.3" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,36 +5,57 @@ | |
class KubeClientBuilderTest < KubernetesDeploy::TestCase | ||
def test_config_validation_default_config_file | ||
builder = KubernetesDeploy::KubeclientBuilder.new(kubeconfig: nil) | ||
assert(builder.validate_config_files, []) | ||
assert_equal(builder.validate_config_files, []) | ||
end | ||
|
||
def test_config_validation_missing_file | ||
config_file = File.join(__dir__, '../fixtures/kube-config/unknown_config.yml') | ||
config_file = File.join(__dir__, '../../fixtures/kube-config/unknown_config.yml') | ||
builder = KubernetesDeploy::KubeclientBuilder.new(kubeconfig: config_file) | ||
assert(builder.validate_config_files, "Kube config not found at #{config_file}") | ||
errors = builder.validate_config_files | ||
assert_equal(1, errors.length) | ||
assert_equal(errors.first, "Kube config not found at #{config_file}") | ||
end | ||
|
||
def test_multiple_configuration_files | ||
def test_build_runs_config_validation | ||
config_file = File.join(__dir__, '../../fixtures/kube-config/unknown_config.yml') | ||
kubeclient_builder = KubernetesDeploy::KubeclientBuilder.new(kubeconfig: config_file) | ||
|
||
expected_err = /Kube config not found at .*unknown_config.yml/ | ||
assert_raises_message(KubernetesDeploy::TaskConfigurationError, expected_err) do | ||
kubeclient_builder.build_v1_kubeclient('test-context') | ||
end | ||
end | ||
|
||
def test_no_config_files_specified | ||
builder = KubernetesDeploy::KubeclientBuilder.new(kubeconfig: " : ") | ||
assert(builder.validate_config_files, "Kube config file name(s) not set in $KUBECONFIG") | ||
errors = builder.validate_config_files | ||
assert_equal(1, errors.length) | ||
assert_equal(errors.first, "Kube config file name(s) not set in $KUBECONFIG") | ||
|
||
builder = KubernetesDeploy::KubeclientBuilder.new(kubeconfig: "") | ||
errors = builder.validate_config_files | ||
assert_equal(1, errors.length) | ||
assert_equal(errors.first, "Kube config file name(s) not set in $KUBECONFIG") | ||
end | ||
|
||
def test_multiple_valid_configuration_files | ||
default_config = "#{Dir.home}/.kube/config" | ||
extra_config = File.join(__dir__, '../fixtures/kube-config/dummy_config.yml') | ||
extra_config = File.join(__dir__, '../../fixtures/kube-config/dummy_config.yml') | ||
builder = KubernetesDeploy::KubeclientBuilder.new(kubeconfig: "#{default_config}:#{extra_config}") | ||
assert(builder.validate_config_files, []) | ||
assert_empty(builder.validate_config_files) | ||
end | ||
|
||
def test_build_client_from_multiple_config_files | ||
Kubeclient::Client.any_instance.stubs(:discover) | ||
# Set KUBECONFIG to include multiple config files | ||
default_config = "#{Dir.home}/.kube/config" | ||
dummy_config = File.join(__dir__, '../../fixtures/kube-config/dummy_config.yml') | ||
kubeconfig = "#{ENV['KUBECONFIG']}:#{dummy_config}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This wasn't providing great multi-config coverage in our CI, which doesn't set the env var. |
||
kubeclient_builder = KubernetesDeploy::KubeclientBuilder.new(kubeconfig: kubeconfig) | ||
|
||
kubeclient_builder = KubernetesDeploy::KubeclientBuilder.new(kubeconfig: "#{default_config}:#{dummy_config}") | ||
# Build kubeclient for an unknown context fails | ||
context_name = "unknown_context" | ||
assert_raises_message(KubernetesDeploy::KubeclientBuilder::ContextMissingError, | ||
"`#{context_name}` context must be configured in your KUBECONFIG file(s) " \ | ||
"(#{kubeconfig}).") do | ||
"(#{default_config}, #{dummy_config})") do | ||
kubeclient_builder.build_v1_kubeclient(context_name) | ||
end | ||
# Build kubeclient for a context present in the dummy config succeeds | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the revert (see https://github.com/Shopify/kubernetes-deploy/pull/428/files#diff-f5478b2ac59d4babc30470442f3a8656)