Class: ChefCLI::Policyfile::ChefServerCookbookSource

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-cli/policyfile/chef_server_cookbook_source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, chef_config: nil) {|_self| ... } ⇒ ChefServerCookbookSource

Returns a new instance of ChefServerCookbookSource.

Yields:

  • (_self)

Yield Parameters:



30
31
32
33
34
35
36
# File 'lib/chef-cli/policyfile/chef_server_cookbook_source.rb', line 30

def initialize(uri, chef_config: nil)
  @uri = SourceURI.parse(uri)
  @http_connections = {}
  @chef_config = chef_config
  @preferred_cookbooks = []
  yield self if block_given?
end

Instance Attribute Details

#chef_configObject (readonly)

Returns the value of attribute chef_config.



28
29
30
# File 'lib/chef-cli/policyfile/chef_server_cookbook_source.rb', line 28

def chef_config
  @chef_config
end

#preferred_cookbooksObject (readonly)

Returns the value of attribute preferred_cookbooks.



27
28
29
# File 'lib/chef-cli/policyfile/chef_server_cookbook_source.rb', line 27

def preferred_cookbooks
  @preferred_cookbooks
end

#uriObject (readonly)

Returns the value of attribute uri.



26
27
28
# File 'lib/chef-cli/policyfile/chef_server_cookbook_source.rb', line 26

def uri
  @uri
end

Instance Method Details

#==(other) ⇒ Object



42
43
44
# File 'lib/chef-cli/policyfile/chef_server_cookbook_source.rb', line 42

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

#default_source_argsObject



38
39
40
# File 'lib/chef-cli/policyfile/chef_server_cookbook_source.rb', line 38

def default_source_args
  [:chef_server, uri]
end

#descObject



78
79
80
# File 'lib/chef-cli/policyfile/chef_server_cookbook_source.rb', line 78

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

#null?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/chef-cli/policyfile/chef_server_cookbook_source.rb', line 74

def null?
  false
end

#preferred_for(*cookbook_names) ⇒ Object



46
47
48
# File 'lib/chef-cli/policyfile/chef_server_cookbook_source.rb', line 46

def preferred_for(*cookbook_names)
  preferred_cookbooks.concat(cookbook_names)
end

#preferred_source_for?(cookbook_name) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/chef-cli/policyfile/chef_server_cookbook_source.rb', line 50

def preferred_source_for?(cookbook_name)
  preferred_cookbooks.include?(cookbook_name)
end

#source_options_for(cookbook_name, cookbook_version) ⇒ Object



66
67
68
69
70
71
72
# File 'lib/chef-cli/policyfile/chef_server_cookbook_source.rb', line 66

def source_options_for(cookbook_name, cookbook_version)
  {
    chef_server: uri.to_s,
    version: cookbook_version,
    http_client: http_connection_for(uri.to_s),
  }
end

#universe_graphObject



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/chef-cli/policyfile/chef_server_cookbook_source.rb', line 54

def universe_graph
  @universe_graph ||= begin
    full_chef_server_graph.inject({}) do |normalized_graph, (cookbook_name, )|
      normalized_graph[cookbook_name] = .inject({}) do |deps_by_version, (version, )|
        deps_by_version[version] = ["dependencies"]
        deps_by_version
      end
      normalized_graph
    end
  end
end