Fix rake gdk.example.yml truncating file on error
What does this Merge Request do and why?
This MR fixes an issue where gdk.example.yml
was left truncated (rake gdk.example.yml
failed. We now rescue when an error occurs, so gdk.example.yml
is not truncated and also improve the error reporting to the user:
Before
$ rake gdk.example.yml
rake aborted!
TypeError: Value '' for registry.self_signed is not a valid bool
/Users/ash/src/gitlab/gitlab-development-kit/lib/gdk/config_type/base.rb:40:in `validate!'
/Users/ash/src/gitlab/gitlab-development-kit/lib/gdk/config_type/base.rb:18:in `initialize'
/Users/ash/src/gitlab/gitlab-development-kit/lib/gdk/config_type/builder.rb:20:in `new'
/Users/ash/src/gitlab/gitlab-development-kit/lib/gdk/config_type/builder.rb:20:in `build'
/Users/ash/src/gitlab/gitlab-development-kit/lib/gdk/config_settings.rb:107:in `block in dump!'
/Users/ash/src/gitlab/gitlab-development-kit/lib/gdk/config_settings.rb:101:in `each'
/Users/ash/src/gitlab/gitlab-development-kit/lib/gdk/config_settings.rb:101:in `each_with_object'
/Users/ash/src/gitlab/gitlab-development-kit/lib/gdk/config_settings.rb:101:in `dump!'
/Users/ash/src/gitlab/gitlab-development-kit/lib/gdk/config_settings.rb:110:in `block in dump!'
/Users/ash/src/gitlab/gitlab-development-kit/lib/gdk/config_settings.rb:101:in `each'
/Users/ash/src/gitlab/gitlab-development-kit/lib/gdk/config_settings.rb:101:in `each_with_object'
/Users/ash/src/gitlab/gitlab-development-kit/lib/gdk/config_settings.rb:101:in `dump!'
/Users/ash/src/gitlab/gitlab-development-kit/lib/tasks/config.rake:20:in `block (2 levels) in <top (required)>'
/Users/ash/src/gitlab/gitlab-development-kit/lib/tasks/config.rake:19:in `open'
/Users/ash/src/gitlab/gitlab-development-kit/lib/tasks/config.rake:19:in `block in <top (required)>'
Tasks: TOP => gdk.example.yml
(See full trace by running task with --trace)
After
$ rake gdk.example.yml
❌️ ERROR: Value '' for registry.self_signed is not a valid bool
Merge Request checklist
-
This change is backward compatible. If not, please include steps to communicate to our users. -
Tests added for new functionality. If not, please raise Issue to follow-up. -
Documentation added/updated, if needed. -
gdk doctor
test added, if needed. -
Add the ~highlight
label if this MR should be included in theCHANGELOG.md
.