-
Notifications
You must be signed in to change notification settings - Fork 113
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
Add chef_version and ohai_version to database tables #1201
Comments
@lamont-granquist Can you add some examples of the various forms these versions may come in via cookbook metadata? I recall something about strings or arrays of strings. |
PR that added them to chef/chef: chef/chef#4081 |
Here's an example of the sub-JSON: |
@lamont-granquist: what am I looking for? I see that a cookbook itself can have multiple chef versions and multiple ohai versions, but I believe a cookbook VERSION can only have one chef version and one ohai version. Is there something that needs to change? |
OH wait a minute. It looks like people can specify that a cookbook works with multiple versions of Chef in their metadata.rb. Therefore, I believe the chef_version and ohai_version attributes should be on the Cookbook object, rather than the CookbookVersion object and should allow arrays of strings. Any objections to this? |
i think i ninja answered you? also note that they key will be "ohai_versions" and "chef_versions" in the plural. |
Right. So it looks like the changes that need to be made are:
Is this correct? |
I'm not sure what Cookbook and CookbookVersion mean to you? Each version of a cookbook will have different chef_versions and ohai_versions. |
So for a 'foo' cookbook: foo 0.0.0 may not have anything specified |
Got it! |
My read is they should stay on CookbookVersion. A new version of a cookbook could make use of an ohai or chef feature that requires different ohai/chef versions than a previous cookbook release. |
Understood. |
Or... what Lamont said. |
It should look something like how you handle the 'depends' field most likely? only its going to contain an array-of-arrays... |
Does it really need to be an array of arrays? (I know that's what is done on the Chef Server, but hear me out). Or would this be acceptable: Cookbook Name: MyCookbook Cookbook Versions: MyCookbookVersion1 * chef_versions = ['12.4.1','12.3.1'] * ohai_versions = ['8.0.0'],['8.1.0'] MyCookbookVersion2 * chef_versions = ['12.5.1','12.4.1'] * ohai_versions = ['8.0.1'],['8.1.2'] So I would add these columns to CookbookVersion - chef_versions and ohai_versions. Is there a need for the array of arrays that I am not seeing? |
Its not a version really its a version constraint. Simple version constraints rendered as strings may be "~> 12.0" or "= 1.2.3", but a more complicated constraint is ">= 12.4.3", "<= 13.0.0". So you could have something gnarly like: "chef_versions": [
[ ">= 11.14.5", "< 12.0.0" ],
[ ">= 12.4.2", "< 13.0.0" ]
] The way to read that is that the inner array elements are joined by "&&" while the outer array is joined by "||" operators. So that constraint would be appropriate if there was some bug that was fixed in chef or some new feature introduced in 11.14.5 and 12.4.2 which the cookbook depended upon, and it was expected that it worked for any future version of 11.x or 12.x, but couldn't be guaranteed to work on some future 13.x The |
Can the same thing not be accomplished with:
Like, "hey, dependency resolver, solve for all." |
If you join those with '&&' that has no solution. If you join those with '||' then everything passes. |
I see your point and it looks like we do indeed need an array of arrays or some other data structure. Will return to this in the morning :) |
A-ha. Paired upper and lower bounds, pick one. I see. |
The only real alternative is something like: "chef_versions": [
">= 11.14.5, < 12.0.0",
">= 12.4.2, < 13.0.0"
] But you're just joining and splitting on ',' all the time if you go down that route--there might conceivably be a parser bug in there somewhere as well, although I think it would require something perverse like allowing version numbers with commas in them... |
It is possible to store the array of arrays data structure as given in the metadata. We could use a JSON column in the database. As @nellshamrell says, in the morning. Fresh light of day and all. |
Yep, that sounds like a good approach. I don't particularly like the idea of rendering them back and forwards as strings because at some point we may wind up with mutually incompatible JSON formats running around the API... |
This is the task to extract the chef_version and ohai_version out of the uploaded cookbook metadata and to get them into a table.
Displaying the data in the UI comes later (and I actually don't super care about it as a priority)
Getting the chef_version and ohai_version into /universe also comes later (this is what I want to implement on top of this issue).
The text was updated successfully, but these errors were encountered: