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

Allow objects to bypass Service's global config #34

Merged
merged 5 commits into from Apr 7, 2014

Conversation

tokengeek
Copy link
Member

Up to now you had to accept that if ~/.fog exists on a system that
it's values were likely to be merged into any service by the reference
to Fog.credentials.

One solution was to load your own credentials and pass the settings
through to services. However the cleaning of the Hash still merged the
settings with the global and created a new Hash.

This also encouraged each service to do it's own authentication
internally by passing in values like username and password then
requesting a token that was isolated to that service.

That made it unsuitable for passing one configuration object that is
shared between multiple services where both may want to change something
such as the latest, valid authentication token.

This change allows any object that responds to config_service? with
true to bypass the global merging, parsing, coercion etc. and be
passed directly to a service.

That allows services to dispense with primitive obsession and use tested
objects to configure their services.

Resolves fog/fog#1390

Up to now you had to accept that if `~/.fog` exists on a system that
it's values were likely to be merged into any service by the reference
to `Fog.credentials`.

One solution was to load your own credentials and pass the settings
through to services. However the cleaning of the Hash still merged the
settings with the global and created a new Hash.

This also encouraged each service to do it's own authentication
internally by passing in values like `username` and `password` then
requesting a token that was isolated to that service.

That made it unsuitable for passing one configuration object that is
shared between multiple services where both may want to change something
such as the latest, valid authentication token.

This change allows any object that responds to `config_service?` with
`true` to bypass the global merging, parsing, coercion etc. and be
passed directly to a service.

That allows services to dispense with primitive obsession and use tested
objects to configure their services.

Resolves fog/fog#1390
@tokengeek
Copy link
Member Author

@geemus This is the backwards compatible implementation of the discussion on fog/fog#1390

You can use everything as normal and it should work fine.

However if you pass an object the responds true to #config_service? then it gets passed through untouched to the services. Given the double complexity it's very much opt-in.

I have a Fog::Brightbox::Config object I'm finalising that is now working within our compute service and I believe completely avoids Fog.credentials.

If I pass in a blank config with FOG_RC the only failure I can trigger is the case where you are falling back on the default behaviour and Fog.credentials is getting called.

Subtle parsing difference > 1.8.7
@tokengeek
Copy link
Member Author

Errors were due to declaring a lambda in line phasing Ruby 1.8.7

The examples were for the top level Service builder but the lower level
Provider based version. The higher level one does not accept config yet
(and the object needs to declare which Provider it can work with).
More than just an example.
tokengeek added a commit that referenced this pull request Apr 7, 2014
Allow objects to bypass Service's global config
@tokengeek tokengeek merged commit 2528270 into master Apr 7, 2014
@tokengeek tokengeek deleted the gh1390_allow_external_credentials branch April 7, 2014 20:20
@geemus
Copy link
Member

geemus commented Apr 8, 2014

Thanks!

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.

Fog.credentials is a global we should phase out of provider code
2 participants