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
Rackspace storage metadata #1251
Rackspace storage metadata #1251
Conversation
Added rackspace/models/storage/file_tests. Added tests for Fog::Storage::Rackspace::File#metadata Added Fog::Rackspace::Storage::File#metadata
@pastorius - seems good I think. Shindo is new to everybody (I made the mistake of writing a test framework, oops). @bradgignac @brianhartsock - thoughts? |
…and #origin Support Access-Control-Allow-Origin and Origin headers, borrowed testing ideas from pull request fog#1251
…and #origin Support Access-Control-Allow-Origin and Origin headers, borrowed testing ideas from pull request fog#1251
@@ -43,6 +44,16 @@ def destroy | |||
true | |||
end | |||
|
|||
remove_method :metadata | |||
def metadata | |||
attributes.reject {|key, value| !metadata_attribute?(key)} |
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.
Using this means you couldn't add metadata by doing file.metadata['key'] = 'value'. Also, you are exposing users to the X-Object-Meta- portion of the meta-data which kind of stinks. It would be nice to abstract that complexity away entirely since it is definitely vendor specific.
Would probably be better if metadata was stored as an instance variable and loaded from attributes upon first access.
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.
Totally agree. I was just trying not to take too much liberty in diverging from the AWS implementation.
@pastorius thanks a bunch for your work! I have a few comments. Let me know if you have any questions on them. Happy to help. |
@geemus I checked out the AWS version of meta-data and this pull request is pretty comparable. I have some recommended improvements but I'm not for sure it is a good idea to diverge from the AWS implementation too much. Let me know your thoughts. |
@geemus @brianhartsock I've made a few notes. I guess now I'm just waiting to get confirmation that you're comfortable with diverging from the AWS implementation in this way. |
@brianhartsock - thanks for being conscientious about diversion. I think we should do the sane/safe thing (and update AWS if need be). I think AWS was done as simplest that would work, so it may be due for review. We should do the right thing here and see about matching in AWS in a backwards compatible way (if possible). Once you guys settle on something perhaps open a ticket describing the changes that need to occur in AWS so somebody can find them and tackle it? Thanks! |
@geemus It seems like there are at least a couple cases here. If I call f = directory.files.get(my_key)
f.metadata #should be loaded if file was previously saved with metadata And if I call f = directory.files.new({
:key => 'resume.html',
:body => 'improvements'
})
f.metadata[:foo] = 'bar'
f.save Do you agree? If so, is there some way to tell if the file already exists in storage from within the File class itself? Or do I call |
@pastorius makes sense. I'd check to see if last-modified is defined probably. If it is you can pretty reasonably assume the file exists (as end users really shouldn't be setting this themselves). etag fits in that category of attributes as well. Make sense? |
@geemus Sure does. I'll let you know if I have any other questions. Thanks. On Nov 15, 2012, at 8:37 AM, Wesley Beary notifications@github.com wrote:
|
…metadata for new file. can unset metadata for existing file. refactored rackspace/models/storage/file_tests.rb Storage::Rackspace::File renamed some metadata key mapping methods. added more key mapping tests. reorganized tests
Updated to support metadata using the indexer syntax and encapsulated the Not sure how smart the conversion between hash key and HTTP header needs to be. I'd prefer to use TSTTCPW. Right now it converts symbols or strings with underscores and/or dashes, and supports compound key names. That's way more than I need though. Let me know what you think. |
@brianhartsock Cool. One thing that still smells to me is all the logic related to converting metadata to and from HTTP headers buried in I'm open to any feedback, and happy to offer help and opinions where you all think it makes sense. |
@pastorius - looks good. It does seem messy, but I'm reticent to try and figure out a good abstraction from a single example. Probably would be good to get the AWS side updated also and then figure out how to do that in a more common fashion (or at least that is my initial inclination). Hopefully that can prevent making mistakes based on simple oversight due to only having the single example. Anyway, I think this is good enough for our purposes currently. @brianhartsock - feel free to merge it when you are ready. |
@geemus Yup, makes sense. Thanks! |
Rackspace storage metadata
Thanks! |
I needed support for object level metadata on Rackspace Cloud Storage. I assume you're open to this based on AWS::File#metadata?
I added some tests as well, but only for what I changed. Let me know if there's anything else I can do to get this patch in. Shindo was definitely new to me. Not sure if I'm using it correctly.