Skip to content

Commit

Permalink
hacky fix for render task, add test for partial naming collision
Browse files Browse the repository at this point in the history
  • Loading branch information
timothysmith0609 committed Jul 24, 2019
1 parent d214b8d commit 92a6523
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/kubernetes-deploy/render_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def run!(stream, only_filenames = [])
@logger.phase_heading("Initializing render task")

filenames = if only_filenames.empty?
TemplateDiscovery.new(@template_dir).templates
TemplateDiscovery.new([@template_dir]).templates[@template_dir]
else
only_filenames
end
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/test-partials2/deployment.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
apiVersion: extensions/v1beta1
kind: Deployment
<<: <%= partial 'pod' %> # Use same partial name as `test-partials` dir to ensure no naming collision
15 changes: 15 additions & 0 deletions test/fixtures/test-partials2/partials/pod.yaml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
metadata:
name: web-from-partial
spec:
replicas: 1
template:
metadata:
labels:
name: web-from-partial
app: test-partials
spec:
containers:
- name: partial-pod
image: busybox
imagePullPolicy: IfNotPresent
command: ["sleep", "8000"]
14 changes: 9 additions & 5 deletions test/integration/kubernetes_deploy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -803,11 +803,15 @@ def test_deploy_successful_with_partial_availability
end

def test_deploy_successful_with_multiple_template_dirs
deploy_dir(fixture_path("hello-cloud"), fixture_path("cronjobs"))
assert_logs_match_all([
%r{Service/web\s+Doesn't require any endpoint},
%r{Deployment/web\s+0 replicas},
])
result = deploy_dir(fixture_path("test-partials"), fixture_path("cronjobs"),
bindings: { 'supports_partials' => 'yep' })
assert_deploy_success(result)
end

def test_deploy_successful_with_multiple_template_dirs_multiple_partials
result = deploy_dir(fixture_path("test-partials"), fixture_path("test-partials2"),
bindings: { 'supports_partials' => 'yep' })
assert_deploy_success(false)
end

def test_deploy_aborts_immediately_if_metadata_name_missing
Expand Down

0 comments on commit 92a6523

Please sign in to comment.