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

Default droplet options #61

Merged
merged 34 commits into from
Sep 4, 2013
Merged

Default droplet options #61

merged 34 commits into from
Sep 4, 2013

Conversation

petems
Copy link
Owner

@petems petems commented Aug 29, 2013

Fixes #56

Currently the tests around creating a default droplet are failing, possibly because the changes to what's seen as a default value for a new droplet.

@pearkes @blom mind having a look?

@pearkes
Copy link
Collaborator

pearkes commented Sep 1, 2013

Hey @petems! Sorry for the delay on this.

I got your specs over the hump in 823745e, but they are still failing. This is because the output text hasn't been changed.

I think in this case, we should omit the messages about defaults. I think that's expected and we don't need to reminds people.

Other than that, we also need to add the defaults into the configuration file, likely just what we had in the cli.rb default arguments.

Make sense? Nice work!

@pearkes
Copy link
Collaborator

pearkes commented Sep 1, 2013

Also – totally nitpicky but try to be descriptive in all of your commit messages – helps a lot when reviewing!

@petems
Copy link
Owner Author

petems commented Sep 1, 2013

Cool beans 👍

Yeah, sorry about that, I've got a bad habit of just saying "spiking" in commit messages when I'm stuck in a rut, I'll see if I can do a rebase of this later with better commit messages.

Thanks for the help 😸

@petems
Copy link
Owner Author

petems commented Sep 2, 2013

Ok, ended up making a lot of changes, and added some tests around the creation of the ~/.tugboat file, as I accidentally deleted one of the defaults (556b7b0), and I didn't notice until I looked at the diff, so I added tests for that case. Also, did a bit of rebasing and made the commit messages a bit more descriptive 👍

@@ -3,3 +3,6 @@ rvm:
- 1.8.7
- 1.9.3
- 2.0.0
matrix:
allow_failures:
- rvm: 1.8.7
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any way to get around this? If not, I'm ok with removing it.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's to do with the way rspec handles should_include, it's not an actual test failure. But since 1.8.7 is EOL I went the easy route heh.

I think if I switch the order up on the text I might be able to fix this, so I'll give it a shot 👍

@pearkes
Copy link
Collaborator

pearkes commented Sep 3, 2013

A couple more thoughts inline.

Also, right now, this will crash if the user doesn't have their defaults configured (if they just update the gem and don't re-run authorize). It'd be good to make it backwards compatible by letting the configuration default inside of the `configuration.rb, so if it doesn't get the config it falls back to the constants.

/Users/pearkes/code/pearkes/tugboat/lib/tugboat/config.rb:51:in `default_region': undefined method `[]' for nil:NilClass (NoMethodError)
    from /Users/pearkes/code/pearkes/tugboat/lib/tugboat/middleware/create_droplet.rb:10:in `call'
    from /Users/pearkes/code/pearkes/tugboat/lib/tugboat/middleware/inject_client.rb:33:in `call'
    from /Users/pearkes/code/pearkes/tugboat/lib/tugboat/middleware/check_configuration.rb:13:in `call'
    from /Users/pearkes/code/pearkes/tugboat/lib/tugboat/middleware/inject_configuration.rb:10:in `call'
    from /Users/pearkes/.rvm/gems/ruby-2.0.0-p247/gems/middleware-0.1.0/lib/middleware/runner.rb:31:in `call'
    from /Users/pearkes/.rvm/gems/ruby-2.0.0-p247/gems/middleware-0.1.0/lib/middleware/builder.rb:102:in `call'
    from /Users/pearkes/code/pearkes/tugboat/lib/tugboat/cli.rb:115:in `create'
    from /Users/pearkes/.rvm/gems/ruby-2.0.0-p247/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
    from /Users/pearkes/.rvm/gems/ruby-2.0.0-p247/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
    from /Users/pearkes/.rvm/gems/ruby-2.0.0-p247/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
    from /Users/pearkes/.rvm/gems/ruby-2.0.0-p247/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
    from bin/tugboat:10:in `<main>'

@pearkes
Copy link
Collaborator

pearkes commented Sep 3, 2013

Oh! And last but not least, can we do default ssh_key_ids as well? Should be pretty straight forward.

Stops nil class errors if you don't have defaults in ~/.tugboat file
Having difficulty with tests, but almost got it...
Not sure how to stub the config class to use backwards compatible
~/.tugboat file..
Tests now all green, will also grandfather config files from 0.0.8 >
@petems
Copy link
Owner Author

petems commented Sep 4, 2013

Whew, that was a long hack...

Ok, now uses ssh_key_ids, is backwards compatible with ~/.tugboat config files without defaults set, and I've added tests for that edge case (not super sure if it's the right way of doing it?)

@pearkes any thoughts? Still need to look into the 1.8.7 fix, I don't think it should be too hard to fix but didn't have time

def ssh_port
@data['ssh']['ssh_port']
end

def default_region
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like there's a better way of doing this, rather than a ternary operator for each one, any suggestions welcome 👍

@@ -4,7 +4,7 @@
include_context "spec"

before do
Kernel.stub!(:exec)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pearkes
Copy link
Collaborator

pearkes commented Sep 4, 2013

Yay! I added a little note about this in eca3fb5, otherwise looks awesome to me. Merging!

pearkes added a commit that referenced this pull request Sep 4, 2013
@pearkes pearkes merged commit d9c52d1 into master Sep 4, 2013
@pearkes pearkes deleted the pm_default_region_option branch September 4, 2013 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to set default region
2 participants