go-chef/chef

Support Cookbook Uploads

Opened this issue · 4 comments

As a user, I would like to be able to upload cookbooks using the go-chef/chef library.

Ruby Chef Cookbook Uploader: https://github.com/chef/chef/blob/main/lib/chef/cookbook_uploader.rb

General Process:

  • Parse local cookbook, generating checksums for all cookbook files.
  • Create a sandbox with the generated checksums to determine which files will need to be uploaded.
    • Use chef.Sandbox Post
  • Upload each cookbook file into the sandbox that has needs_upload set to true in the chef.Sandbox Post JSON response by performing a PUT to the provided sandbox item url.
  • Commit the sandbox.
    • Use chef.Sandbox Put
  • Upload the cookbook version manifest.

I am currently taking a look at implementing this and submitting a PR.

Cool. Just to note I've never been able to get the sandbox api client to work at all.

Cool. Just to note I've never been able to get the sandbox api client to work at all.

I haven't had any trouble with it so far, but it may be due to different Chef Server versions (I've been working with Chef Server 15). Were you seeing issues against Chef Server, CINC Server, or Goiardi?

I usually test against the current chef server. The test suite for this project has a cookbook that spins up a chef server I run the integration tests against and where I do development. Good to hear you have it working.