diff options
Diffstat (limited to 'lib/chef_server')
-rw-r--r-- | lib/chef_server/controllers/application.rb | 18 | ||||
-rw-r--r-- | lib/chef_server/controllers/cookbook_templates.rb | 66 | ||||
-rw-r--r-- | lib/chef_server/controllers/cookbooks.rb | 18 | ||||
-rw-r--r-- | lib/chef_server/controllers/exceptions.rb | 18 | ||||
-rw-r--r-- | lib/chef_server/controllers/nodes.rb | 18 | ||||
-rw-r--r-- | lib/chef_server/controllers/openid_consumer.rb | 18 | ||||
-rw-r--r-- | lib/chef_server/controllers/openid_register.rb | 19 | ||||
-rw-r--r-- | lib/chef_server/controllers/openid_server.rb | 18 | ||||
-rw-r--r-- | lib/chef_server/controllers/search.rb | 18 | ||||
-rw-r--r-- | lib/chef_server/controllers/search_entries.rb | 18 | ||||
-rw-r--r-- | lib/chef_server/helpers/global_helpers.rb | 18 | ||||
-rw-r--r-- | lib/chef_server/helpers/nodes_helper.rb | 18 | ||||
-rw-r--r-- | lib/chef_server/helpers/openid_server_helpers.rb | 18 | ||||
-rw-r--r-- | lib/chef_server/init.rb | 22 | ||||
-rw-r--r-- | lib/chef_server/views/cookbook_templates/index.html.haml | 8 | ||||
-rw-r--r-- | lib/chef_server/views/cookbooks/show.html.haml | 8 |
16 files changed, 308 insertions, 13 deletions
diff --git a/lib/chef_server/controllers/application.rb b/lib/chef_server/controllers/application.rb index 4a0d247306..a288b87dba 100644 --- a/lib/chef_server/controllers/application.rb +++ b/lib/chef_server/controllers/application.rb @@ -1,3 +1,21 @@ +# +# Author:: Adam Jacob (<adam@hjksolutions.com>) +# Copyright:: Copyright (c) 2008 HJK Solutions, LLC +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + class Application < Merb::Controller def fix_up_node_id diff --git a/lib/chef_server/controllers/cookbook_templates.rb b/lib/chef_server/controllers/cookbook_templates.rb index 56338ac3f5..4cb5e4622c 100644 --- a/lib/chef_server/controllers/cookbook_templates.rb +++ b/lib/chef_server/controllers/cookbook_templates.rb @@ -1,29 +1,77 @@ +# +# Author:: Adam Jacob (<adam@hjksolutions.com>) +# Copyright:: Copyright (c) 2008 HJK Solutions, LLC +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + class CookbookTemplates < Application provides :html, :json - def load_cookbook(with_content=false) + def load_cookbook_templates() @cl = Chef::CookbookLoader.new @cookbook = @cl[params[:cookbook_id]] raise NotFound unless @cookbook + @templates = Hash.new @cookbook.template_files.each do |tf| - @templates[File.basename(tf)] = { - :file => tf, + full = File.expand_path(tf) + name = File.basename(full) + tf =~ /^.+#{params[:cookbook_id]}[\\|\/]templates[\\|\/](.+?)[\\|\/]#{name}/ + singlecopy = $1 + @templates[full] = { + :name => name, + :singlecopy => singlecopy, + :file => full, } - @templates[File.basename(tf)][:contents] = File.read(tf) if with_content end + @templates end def index - load_cookbook(false) - display @templates + if params[:id] + show + else + load_cookbook_templates() + display @templates + end end def show - load_cookbook(true) - @template = @templates[params[:id]] - display @template + load_cookbook_templates() + preferences = [ + File.join("host-#{params[:fqdn]}", "#{params[:id]}"), + File.join("#{params[:platform]}-#{params[:version]}", "#{params[:id]}"), + File.join("#{params[:platform]}", "#{params[:id]}"), + File.join("default", "#{params[:id]}") + ] + to_send = nil + @templates.each_key do |file| + Chef::Log.debug("Looking at #{file}") + preferences.each do |pref| + Chef::Log.debug("Compared to #{pref}") + if file =~ /#{pref}/ + Chef::Log.debug("Matched #{pref} for #{file}!") + to_send = file + break + end + end + break if to_send + end + raise NotFound, "Cannot find a suitable template!" unless to_send + send_file(to_send) end end diff --git a/lib/chef_server/controllers/cookbooks.rb b/lib/chef_server/controllers/cookbooks.rb index d18b3506a2..3e68d1f4bc 100644 --- a/lib/chef_server/controllers/cookbooks.rb +++ b/lib/chef_server/controllers/cookbooks.rb @@ -1,3 +1,21 @@ +# +# Author:: Adam Jacob (<adam@hjksolutions.com>) +# Copyright:: Copyright (c) 2008 HJK Solutions, LLC +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + class Cookbooks < Application provides :html, :json diff --git a/lib/chef_server/controllers/exceptions.rb b/lib/chef_server/controllers/exceptions.rb index 7f72e57ad2..d8f7307637 100644 --- a/lib/chef_server/controllers/exceptions.rb +++ b/lib/chef_server/controllers/exceptions.rb @@ -1,3 +1,21 @@ +# +# Author:: Adam Jacob (<adam@hjksolutions.com>) +# Copyright:: Copyright (c) 2008 HJK Solutions, LLC +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + class Exceptions < Application provides :html, :json diff --git a/lib/chef_server/controllers/nodes.rb b/lib/chef_server/controllers/nodes.rb index aa7273c47d..a1ba1131ac 100644 --- a/lib/chef_server/controllers/nodes.rb +++ b/lib/chef_server/controllers/nodes.rb @@ -1,3 +1,21 @@ +# +# Author:: Adam Jacob (<adam@hjksolutions.com>) +# Copyright:: Copyright (c) 2008 HJK Solutions, LLC +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + class Nodes < Application provides :html, :json diff --git a/lib/chef_server/controllers/openid_consumer.rb b/lib/chef_server/controllers/openid_consumer.rb index 39e8173f24..4e3980ce3d 100644 --- a/lib/chef_server/controllers/openid_consumer.rb +++ b/lib/chef_server/controllers/openid_consumer.rb @@ -1,3 +1,21 @@ +# +# Author:: Adam Jacob (<adam@hjksolutions.com>) +# Copyright:: Copyright (c) 2008 HJK Solutions, LLC +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + require 'pathname' require "openid" diff --git a/lib/chef_server/controllers/openid_register.rb b/lib/chef_server/controllers/openid_register.rb index a6c30c95c5..34851bc517 100644 --- a/lib/chef_server/controllers/openid_register.rb +++ b/lib/chef_server/controllers/openid_register.rb @@ -1,5 +1,20 @@ -# Controller for handling the login, logout process for "users" of our -# little server. Users have no password. This is just an example. +# +# Author:: Adam Jacob (<adam@hjksolutions.com>) +# Copyright:: Copyright (c) 2008 HJK Solutions, LLC +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# require 'openid' diff --git a/lib/chef_server/controllers/openid_server.rb b/lib/chef_server/controllers/openid_server.rb index 7c89e33d99..4cdaf67adb 100644 --- a/lib/chef_server/controllers/openid_server.rb +++ b/lib/chef_server/controllers/openid_server.rb @@ -1,3 +1,21 @@ +# +# Author:: Adam Jacob (<adam@hjksolutions.com>) +# Copyright:: Copyright (c) 2008 HJK Solutions, LLC +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + require 'pathname' # load the openid library, first trying rubygems diff --git a/lib/chef_server/controllers/search.rb b/lib/chef_server/controllers/search.rb index 17c0d553a4..0abbf352b8 100644 --- a/lib/chef_server/controllers/search.rb +++ b/lib/chef_server/controllers/search.rb @@ -1,3 +1,21 @@ +# +# Author:: Adam Jacob (<adam@hjksolutions.com>) +# Copyright:: Copyright (c) 2008 HJK Solutions, LLC +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + class Search < Application provides :html, :json diff --git a/lib/chef_server/controllers/search_entries.rb b/lib/chef_server/controllers/search_entries.rb index ab79b57b3c..c93add3dc5 100644 --- a/lib/chef_server/controllers/search_entries.rb +++ b/lib/chef_server/controllers/search_entries.rb @@ -1,3 +1,21 @@ +# +# Author:: Adam Jacob (<adam@hjksolutions.com>) +# Copyright:: Copyright (c) 2008 HJK Solutions, LLC +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + class SearchEntries < Application provides :html, :json diff --git a/lib/chef_server/helpers/global_helpers.rb b/lib/chef_server/helpers/global_helpers.rb index 1ef7ac9331..f3b15129a8 100644 --- a/lib/chef_server/helpers/global_helpers.rb +++ b/lib/chef_server/helpers/global_helpers.rb @@ -1,3 +1,21 @@ +# +# Author:: Adam Jacob (<adam@hjksolutions.com>) +# Copyright:: Copyright (c) 2008 HJK Solutions, LLC +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + module Merb module GlobalHelpers # helpers defined here available to all views. diff --git a/lib/chef_server/helpers/nodes_helper.rb b/lib/chef_server/helpers/nodes_helper.rb index 5e6c25c453..44a190a7c6 100644 --- a/lib/chef_server/helpers/nodes_helper.rb +++ b/lib/chef_server/helpers/nodes_helper.rb @@ -1,3 +1,21 @@ +# +# Author:: Adam Jacob (<adam@hjksolutions.com>) +# Copyright:: Copyright (c) 2008 HJK Solutions, LLC +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + module Merb module NodesHelper def recipe_list(node) diff --git a/lib/chef_server/helpers/openid_server_helpers.rb b/lib/chef_server/helpers/openid_server_helpers.rb index 73be9cab27..dc56d2742f 100644 --- a/lib/chef_server/helpers/openid_server_helpers.rb +++ b/lib/chef_server/helpers/openid_server_helpers.rb @@ -1,3 +1,21 @@ +# +# Author:: Adam Jacob (<adam@hjksolutions.com>) +# Copyright:: Copyright (c) 2008 HJK Solutions, LLC +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + module Merb module OpenidServerHelper diff --git a/lib/chef_server/init.rb b/lib/chef_server/init.rb index cf1d17e224..886a378cb7 100644 --- a/lib/chef_server/init.rb +++ b/lib/chef_server/init.rb @@ -1,3 +1,21 @@ +# +# Author:: Adam Jacob (<adam@hjksolutions.com>) +# Copyright:: Copyright (c) 2008 HJK Solutions, LLC +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + Merb.root = File.join(File.dirname(__FILE__)) # @@ -141,10 +159,12 @@ Merb::Router.prepare do |r| end r.match("/cookbooks/_attribute_files").to(:controller => "cookbooks", :action => "attribute_files") +# r.match("/cookbooks/:cookbook_id/templates").to(:controller => "cookbook_templates", :action => "index") + r.resources :cookbooks do |cookbooks| cookbooks.resources :templates, :controller => "cookbook_templates" end - + #r.resources :openid do |res| # res.resources :register, :controller => "openid_register" # res.resources :server, :controller => "openid_server" diff --git a/lib/chef_server/views/cookbook_templates/index.html.haml b/lib/chef_server/views/cookbook_templates/index.html.haml new file mode 100644 index 0000000000..307aefd812 --- /dev/null +++ b/lib/chef_server/views/cookbook_templates/index.html.haml @@ -0,0 +1,8 @@ +%h1 Cookbook Templates +- @templates.each do |template, data| + .index + %table + %tr + %td + %a{ :href => url(:cookbook_template, { :cookbook_id => params[:cookbook_id], :id => data[:link_name], :version => data[:version] }) } + = "#{data[:version]} - #{data[:name]}" diff --git a/lib/chef_server/views/cookbooks/show.html.haml b/lib/chef_server/views/cookbooks/show.html.haml index 58175c298c..d97964f436 100644 --- a/lib/chef_server/views/cookbooks/show.html.haml +++ b/lib/chef_server/views/cookbooks/show.html.haml @@ -1,6 +1,7 @@ %h1= "Cookbook #{h @cookbook.name}" .cookbook - if @cookbook.attribute_files.length > 0 + %h2 Attribute Files - @cookbook.attribute_files.each do |af| = partial(:attribute_file, :name => File.basename(af), :contents => File.read(af)) @@ -15,4 +16,9 @@ %h2 Recipe Files %h3= File.basename(rf) = Uv.parse(File.read(rf), "xhtml", "ruby", true, "twilight") -
\ No newline at end of file + +- if @cookbook.template_files.length > 0 + - @cookbook.template_files.each do |tf| + %h2 Template Files + %h3= File.basename(tf) + = Uv.parse(File.read(tf), "xhtml", "html_rails", true, "twilight") |