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

Render task parses an implicit yml file as explicit when there are multiple yaml resources #513

Closed
peiranliushop opened this issue Jul 12, 2019 · 1 comment · Fixed by #551
Assignees
Labels
🪲 bug Something isn't working

Comments

@peiranliushop
Copy link
Contributor

Bug report

Without --- at the beginning of a yaml file, KubernetesDeploy::RenderTask takes it as explicit yaml when it includes multiple yaml resources. The output yaml string is not properly delimited between yaml resources.

Expected behavior: [What you expected to happen]
File c.yml

---
c

File b.yml

a
---
b

should be rendered as a single yaml str

---
c
---
a
---
b

Actual behavior: [What actually happened]
Instead, it is rendered as

---
c
a
---
b

Version(s) affected: [run kubernetes-deploy --version]
All versions

Steps to Reproduce

require 'kubernetes-deploy'
require 'kubernetes-deploy/render_task'

logger = KubernetesDeploy::FormattedLogger.build(nil, nil, File.open(File::NULL, 'w'))
render = KubernetesDeploy::RenderTask.new(logger:logger, current_sha:'', template_dir:'.', bindings:{})
render.run!(result, ["c.yml","b.yml"])
YAML.load_stream(result.string)

output

["c\na", "b"]
@dturn
Copy link
Contributor

dturn commented Jul 12, 2019

irb(main):012:0> puts `cat /tmp/c.yml`
---
c
=> nil
irb(main):013:0> puts `cat /tmp/b.yml`
a
---
b

irb(main):018:0> result = STDOUT
=> #<IO:<STDOUT>>
irb(main):019:0> require 'kubernetes-deploy'
=> false
irb(main):020:0> require 'kubernetes-deploy/render_task'
=> false
irb(main):021:0> 
irb(main):022:0* logger = KubernetesDeploy::FormattedLogger.build(nil, nil, File.open(File::NULL, 'w'))
=> #<KubernetesDeploy::FormattedLogger:0x007ff59d8a1c28 @summary=#<KubernetesDeploy::DeferredSummaryLogging::DeferredSummary:0x007ff59d8a1bb0 @actions_taken=[], @paragraphs=[]>, @current_phase=0, @progname=nil, @level=1, @default_formatter=#<Logger::Formatter:0x007ff59d8a1b38 @datetime_format=nil>, @formatter=#<Proc:0x007ff59d8a1a20@/Users/danielturner/src/github.com/Shopify/kubernetes-deploy/lib/kubernetes-deploy/formatted_logger.rb:28>, @logdev=#<Logger::LogDevice:0x007ff59d8a1ae8 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<File:/dev/null>, @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x007ff59d8a1ac0>>>
irb(main):023:0> render = KubernetesDeploy::RenderTask.new(logger:logger, current_sha:'', template_dir:'/tmp', bindings:{})
=> #<KubernetesDeploy::RenderTask:0x007ff59d8bbf60 @logger=#<KubernetesDeploy::FormattedLogger:0x007ff59d8a1c28 @summary=#<KubernetesDeploy::DeferredSummaryLogging::DeferredSummary:0x007ff59d8a1bb0 @actions_taken=[], @paragraphs=[]>, @current_phase=0, @progname=nil, @level=1, @default_formatter=#<Logger::Formatter:0x007ff59d8a1b38 @datetime_format=nil>, @formatter=#<Proc:0x007ff59d8a1a20@/Users/danielturner/src/github.com/Shopify/kubernetes-deploy/lib/kubernetes-deploy/formatted_logger.rb:28>, @logdev=#<Logger::LogDevice:0x007ff59d8a1ae8 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<File:/dev/null>, @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x007ff59d8a1ac0>>>, @template_dir="/tmp", @renderer=#<KubernetesDeploy::Renderer:0x007ff59d8bbee8 @current_sha="", @template_dir="/tmp", @partials_dirs=["/tmp/partials", "/partials"], @logger=#<KubernetesDeploy::FormattedLogger:0x007ff59d8a1c28 @summary=#<KubernetesDeploy::DeferredSummaryLogging::DeferredSummary:0x007ff59d8a1bb0 @actions_taken=[], @paragraphs=[]>, @current_phase=0, @progname=nil, @level=1, @default_formatter=#<Logger::Formatter:0x007ff59d8a1b38 @datetime_format=nil>, @formatter=#<Proc:0x007ff59d8a1a20@/Users/danielturner/src/github.com/Shopify/kubernetes-deploy/lib/kubernetes-deploy/formatted_logger.rb:28>, @logdev=#<Logger::LogDevice:0x007ff59d8a1ae8 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<File:/dev/null>, @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x007ff59d8a1ac0>>>, @bindings={}, @id="-839ca6b9">>
irb(main):024:0> render.run!(result, ["c.yml","b.yml"])

---
c
a
---
b

irb(main):025:0> KubernetesDeploy::VERSION
=> "0.26.5"

@peiranliushop Can you confirm what version you're using? Also what is the type of result in your example?

Reading is hard. Yep that does it.

@dturn dturn added the 🪲 bug Something isn't working label Sep 6, 2019
@dturn dturn self-assigned this Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪲 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants