Git Product home page Git Product logo

cookbook-omnifetch's Introduction

CookbookOmnifetch

Gem Version Build status

Umbrella Project: Chef Workstation

CookbookOmnifetch provides library code for fetching Chef cookbooks from an artifact server (usually https://supermarket.chef.io), git/github, a local path, or a chef-server to a local cache for developement.

Installation

Add this line to your application's Gemfile:

gem 'cookbook-omnifetch'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cookbook-omnifetch

Usage

Inject Dependencies and Configure

Cookbook Omnifetch is designed to work with utilities from both the Berkshelf and Chef Software ecosystems, so you have to configure it before you can use it. In ChefDK, we do this:

# Configure CookbookOmnifetch's dependency injection settings to use our classes and config.
CookbookOmnifetch.configure do |c|
  c.cache_path = File.expand_path('~/.chefdk/cache')
  c.storage_path = Pathname.new(File.expand_path('~/.chefdk/cache/cookbooks'))
  c.shell_out_class = ChefDK::ShellOut
  c.cached_cookbook_class = ChefDK::CookbookMetadata
end

Fetching Cookbooks

To download a cookbook:

fetcher = CookbookOmnifetch.init(dependency, source_options)
fetcher.install

To specify the cookbook you want, you give CookbookOmnifetch a dependency object that responds to #name and #version_constraint, e.g.:

require 'semverse'

Dependency = Struct.new(:name, :version_constraint)

my_dep = Dependency.new("apache2", Semverse::Constraint.new("~> 1.0"))

The source options for the cookbook are given as a Hash; the keys and values vary based on the kind of storage location. As with Bundler's gem options, one key specifies the type of upstream service for the cookbook while other keys specify other options specific to that type. For example:

CookbookOmnifetch.init(dependency, artifact_server: "https://supermarket.chef.io/api/v1/cookbooks/apache2/versions/3.0.1/download")
CookbookOmnifetch.init(dependency, git: "[email protected]:svanzoest/apache2-cookbook.git", tag: "v3.0.1")
CookbookOmnifetch.init(dependency, github: "svanzoest/apache2-cookbook", tag: "v3.0.1")
CookbookOmnifetch.init(dependency, path: "~/chef-cookbooks/apache2")

Contributing

For information on contributing to this project, see https://github.com/chef/chef/blob/master/CONTRIBUTING.md

After that:

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -asm 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Thanks

This code was initially extracted from Berkshelf. Thanks to the Berkshelf core teams and contributors.

cookbook-omnifetch's People

Contributors

chef-ci avatar chef-expeditor[bot] avatar danielsdeleo avatar dependabot-preview[bot] avatar karmix avatar lamont-granquist avatar marcparadise avatar mattray avatar skeshari12 avatar tas50 avatar tduffield avatar thommay avatar tyler-ball avatar vkarve-chef avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.