chef-workstation icon indicating copy to clipboard operation
chef-workstation copied to clipboard

Migrate knife supermarket to chef supermarket

Open tas50 opened this issue 4 years ago • 2 comments

We should move the Ruby based knife supermarket commands to the chef CLI. The goal here is to mostly replicate existing behavior with some important differences.

Current knife commands

knife supermarket download COOKBOOK [VERSION] (options)
knife supermarket install COOKBOOK [VERSION] (options)
knife supermarket list (options)
knife supermarket search QUERY (options)
knife supermarket share COOKBOOK [CATEGORY] (options)
knife supermarket show COOKBOOK [VERSION] (options)
knife supermarket unshare COOKBOOK

New Commands

chef supermarket download ARTIFACT_TYPE ARTIFACT_NAME [VERSION] (options)
chef supermarket install ARTIFACT_TYPE ARTIFACT_NAME [VERSION] (options)
chef supermarket list ARTIFACT_TYPE (options)
chef supermarket search ARTIFACT_TYPE QUERY (options)
chef supermarket share ARTIFACT_TYPE ARTIFACT_NAME (options)
chef supermarket show ARTIFACT_TYPE ARTIFACT_NAME [VERSION] (options)
chef supermarket unshare ARTIFACT_TYPE ARTIFACT_NAME

Artifact Type

The main difference in the implementation as we move knife supermarket commands to chef supermarket is the concept of an artifact type. knife supermarket assumes that the user is searching, sharing, or downloading a cookbook. chef supermarket will allow either cookbooks or profiles. This requires us to have a positional parameter for the artifact type. For example:

knife supermarket download foo becomes chef supermarket download cookbook foo

More Intelligent Share

Right now knife supermarket share command requires the user to define their cookbook path in the knife.rb config file and this relies on a monolithic chef-repo setup with a dedicated cookbooks directory. We don't want to require the cookbooks path anymore. The command needs to be more intelligent about sharing in general.

When the user runs knife cookbook share without a cookbook name we should assume they want to share the cookbook in the current directory. If there's a metadata.rb file then share the current cookbook.

When the user runs knife cookbook share foo check the following locations:

  • Is there a metadata.rb file in the current directory?
  • Is there a directory named foo in the current working directory?
  • Is there a cookbooks/foo path in the current working directory?

Technical Questions:

  • Should we write a chef supermarket Go module that can be used by our customers and by the Automate team in the future?

tas50 avatar Sep 28 '21 18:09 tas50

Hello @tas50 , here are few questions from team :

  • Go or Ruby implementation ? - if eventually need to move to Go then we can use this right away
  • As part of this ticket does knife supermarket implementation needs to be enhanced as well ? Could do this, but why if we are eventually deprecating ?
  • Profiles in context of chef supermarket ?
  • Do we assume chef-cli implements the functionality vs chef taking care of it ?

kasif-adnan avatar Oct 29 '21 13:10 kasif-adnan

Thanks for sharing the notes, @kasif-adnan! ...the team will figure out answers to most Q's. the only input we need from product management is on the second Q i.e. "As part of this ticket does knife supermarket implementation needs to be enhanced as well ? Could do this, but why if we are eventually deprecating ?"

vkarve-chef avatar Nov 02 '21 06:11 vkarve-chef