-
Notifications
You must be signed in to change notification settings - Fork 87
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
#85: Feature/use environment without preserve #86
#85: Feature/use environment without preserve #86
Conversation
Will try to write an integration test and test against my existing repository. (The puppet version was causing some troubles, I'll try and figure out how to make that work). Integration tests don't work locally because I presume |
@@ -330,7 +334,7 @@ def install_ssl_client_password(logger, password) | |||
end | |||
|
|||
def environment | |||
@options[:preserve_environments] ? @options.fetch(:environment, 'production') : 'production' | |||
@options.fetch(:environment, 'production') |
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.
Maybe there should be a protection here to block environment
and create-symlinks
being used together, as the debug output on 89 states.
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.
I looked into this and you're actually very close here. There is a method in https://github.com/github/octocatalog-diff/blob/master/lib/octocatalog-diff/catalog/computed.rb#L82-L84 that needs to be updated to match this change. Also some spec tests need to be updated for the new behavior.
Have a look at https://gist.github.com/kpaulisse/7bda51e395aab49585aa9933d78fe724 for what I had to do to get the tests passing. Hopefully this is a push in the right direction - I'm 👍 to the change in general.
@@ -142,10 +145,11 @@ | |||
end | |||
|
|||
context 'without logger' do | |||
it 'should install default symlink' do | |||
it 'should install directory symlink' do |
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 should still say default. Oops.
@@ -80,7 +80,7 @@ def compilation_dir | |||
|
|||
# Environment used to compile catalog | |||
def environment | |||
@opts[:preserve_environments] ? @opts.fetch(:environment, 'production') : 'production' | |||
@options.fetch(:environment, 'production') |
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.
Oops, opts.
Will look at those failed tests over the next few days. Haven't checked them yet. But managed to get environment working fully on my own repo so that's good progress. |
Hey @homelinen I looked at the test results and this one looks like it might just be a broken test:
Basically 2 means "successful, with diffs" and 0 means "successful, no diffs". It looks like you actually changed the original test from 0 to 2 (and I vaguely remember this being in my patch when I first tried your code on my machine but I didn't look into it too deeply at the time). I just re-ran that on my machine and got the same failure as travis is seeing, so if you revert just that one change the test will hopefully pass as it did before. |
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.
I'm glad to hear this is mostly working for you. I pointed out the test that needs fixing, and made one suggestion about the logger.
Once you have verified code that works for you and let me know you're done, I'll run the updated code within GitHub for a day or so to make sure everything looks good (we end up running this up to 10k times per day in various CI) and then merge. Thanks!
'--hiera-path-strip', '/var/lib/puppet', '--no-parallel' | ||
] | ||
) | ||
end | ||
|
||
it 'should exit without error' do | ||
expect(@result.exitcode).to eq(0), OctocatalogDiff::Integration.format_exception(@result) | ||
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result) |
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 one should be reverted as per my earlier comment - change the 2 back to a 0 here.
context 'with --environment' do | ||
context 'with logger' do | ||
it 'should install a symlink to the given environment' do | ||
logger = double('Logger') |
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.
The pattern elsewhere in the tests is to actually construct a real logger using:
logger, logger_str = OctocatalogDiff::Spec.setup_logger
You can then also test logger_str.string
to be matching text if you want to verify log messages.
I realize that line 127 didn't use this pattern - must have been one I missed when I went through and tried to update all of them long, long ago... Would you mind doing it the new way? 😸
20bfdeb
to
ba0e21c
Compare
@homelinen the code looks fine now. Are you done with the development here? If so I'll test this internally within GitHub for a couple days, and then merge it. Please advise. |
@kpaulisse Yeah, I'm done with the development, I'm happy for internal testing to go ahead. I realise one thing missing is a doc change to the Advanced Environments page. Would you want that in this PR or separate? Happy to work it out either, sorry I forgot about it before. |
Feel free to do a separate PR for doc updates. I don't bump version numbers for that. We are testing this version within GitHub today and if all goes well I'll merge it tomorrow. Thanks again! |
…erve Bump version and changelog for #86
Overview
This pull request changes the behaviour of the
--environment
flag when used on its own.Solve the problem described in #85. Allows the
--environment
flag to be used without the--preserve-environments
flag.Tries to maintain the current functionality by ignoring this parameter when used with
--create-symlinks
.Doesn't modify the existing behaviour of
--preserve-environments
Checklist
rake
in your checkout directory, or review the CI job triggered whenever you push to a pull request.rake coverage:spec
or ignoring untestable sections of code with# :nocov
comments. If you need help getting to 100% coverage please ask; however, don't just submit code with no tests..gem
file into the vendor/cache directory.