Class: ChefDK::Policyfile::DeliverySupermarketSource

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/chef-dk/policyfile/delivery_supermarket_source.rb

Overview

Fetches cookbooks from a supermarket, similar to CommunityCookbookSource (which it delegates to), except that only the latest versions of any cookbook can be used.

This is intended to be used in an environment where the team wants to make only the newest version of a given cookbook available in order to force developers to integrate continuously at the component artifact (cookbook) level. To achieve this goal, two constraints must be imposed:

  • Cookbook changes pass through a Ci pipeline and are ultimately uploaded to a private supermarket (or equivalent, i.e. mini-mart) after final approval (which can be automated or not)

  • Version numbers for cookbooks that pass through the Ci pipeline always increase over time (so that largest version number == newest)

In the future, alternative approaches may be persued to achieve the goal of continuously integrating at the cookbook level without imposing those constraints.

Instance Method Summary collapse

Constructor Details

#initialize(uri) {|_self| ... } ⇒ DeliverySupermarketSource

Returns a new instance of DeliverySupermarketSource.

Yields:

  • (_self)

Yield Parameters:



57
58
59
60
# File 'lib/chef-dk/policyfile/delivery_supermarket_source.rb', line 57

def initialize(uri)
  @community_source = CommunityCookbookSource.new(uri)
  yield self if block_given?
end

Instance Method Details

#==(other) ⇒ Object



62
63
64
# File 'lib/chef-dk/policyfile/delivery_supermarket_source.rb', line 62

def ==(other)
  other.is_a?(self.class) && other.uri == uri
end

#default_source_argsObject



66
67
68
# File 'lib/chef-dk/policyfile/delivery_supermarket_source.rb', line 66

def default_source_args
  [:delivery_supermarket, uri]
end

#descObject



83
84
85
# File 'lib/chef-dk/policyfile/delivery_supermarket_source.rb', line 83

def desc
  "delivery_supermarket(#{uri})"
end

#universe_graphObject



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/chef-dk/policyfile/delivery_supermarket_source.rb', line 70

def universe_graph
  @universe_graph ||= begin
    @community_source.universe_graph.inject({}) do |truncated, (cookbook_name, version_and_deps_list)|
      sorted_versions = version_and_deps_list.keys.sort_by do |version_string|
        Semverse::Version.new(version_string)
      end
      greatest_version = sorted_versions.last
      truncated[cookbook_name] = { greatest_version => version_and_deps_list[greatest_version] }
      truncated
    end
  end
end