Skip to content

Commit

Permalink
Fixing #107: Lazily load all the things.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Cowie committed May 16, 2014
1 parent b83867d commit 2e71076
Show file tree
Hide file tree
Showing 25 changed files with 127 additions and 74 deletions.
8 changes: 6 additions & 2 deletions lib/chef/knife/spork-bump.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
require 'chef/knife'
require 'knife-spork/runner'

module KnifeSpork
class SporkBump < Chef::Knife
include KnifeSpork::Runner

deps do
require 'knife-spork/runner'
end

TYPE_INDEX = { :major => 0, :minor => 1, :patch => 2, :manual => 3 }.freeze

Expand All @@ -30,6 +32,7 @@ class SporkBump < Chef::Knife
banner 'knife spork bump COOKBOOK [major|minor|patch|manual]'

def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)
config[:cookbook_path] ||= Chef::Config[:cookbook_path]

Expand All @@ -51,6 +54,7 @@ def run
end

private

def bump
old_version = @cookbook.version

Expand Down
7 changes: 5 additions & 2 deletions lib/chef/knife/spork-check.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
require 'chef/knife'
require 'knife-spork/runner'

module KnifeSpork
class SporkCheck < Chef::Knife
include KnifeSpork::Runner

deps do
require 'knife-spork/runner'
end

banner 'knife spork check COOKBOOK (options)'

Expand Down Expand Up @@ -37,6 +39,7 @@ class SporkCheck < Chef::Knife
end

def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

if name_args.empty?
Expand Down
6 changes: 3 additions & 3 deletions lib/chef/knife/spork-databag-create.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
require 'chef/knife'
require 'knife-spork/runner'
require 'json'

module KnifeSpork
class SporkDataBagCreate < Chef::Knife
include KnifeSpork::Runner

deps do
require 'knife-spork/runner'
require 'json'
require 'chef/knife/data_bag_create'
end

Expand All @@ -22,6 +21,7 @@ class SporkDataBagCreate < Chef::Knife
:description => "A file containing the secret key to use to encrypt data bag item values"

def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

if @name_args.nil?
Expand Down
6 changes: 3 additions & 3 deletions lib/chef/knife/spork-databag-delete.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
require 'chef/knife'
require 'knife-spork/runner'
require 'json'

module KnifeSpork
class SporkDataBagDelete < Chef::Knife
include KnifeSpork::Runner

deps do
require 'knife-spork/runner'
require 'json'
require 'chef/knife/data_bag_delete'
end

banner 'knife data bag delete BAG [ITEM] (options)'


def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

if @name_args.length == 2
Expand Down
6 changes: 3 additions & 3 deletions lib/chef/knife/spork-databag-edit.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
require 'chef/knife'
require 'knife-spork/runner'
require 'json'

module KnifeSpork
class SporkDataBagEdit < Chef::Knife
include KnifeSpork::Runner

deps do
require 'knife-spork/runner'
require 'json'
require 'chef/knife/data_bag_edit'
end

Expand All @@ -22,6 +21,7 @@ class SporkDataBagEdit < Chef::Knife
:description => "A file containing the secret key to use to encrypt data bag item values"

def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

if @name_args.length != 2
Expand Down
6 changes: 3 additions & 3 deletions lib/chef/knife/spork-databag-fromfile.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
require 'chef/knife'
require 'knife-spork/runner'
require 'json'

module KnifeSpork
class SporkDataBagFromFile < Chef::Knife
include KnifeSpork::Runner

deps do
require 'knife-spork/runner'
require 'json'
require 'chef/knife/data_bag_from_file'
end

Expand All @@ -27,6 +26,7 @@ class SporkDataBagFromFile < Chef::Knife
:description => "Upload all data bags"

def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

@object_name = @name_args.first
Expand Down
7 changes: 5 additions & 2 deletions lib/chef/knife/spork-environment-create.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
require 'chef/knife'
require 'knife-spork/runner'

module KnifeSpork
class SporkEnvironmentCreate < Chef::Knife
include KnifeSpork::Runner

deps do
require 'knife-spork/runner'
end

banner 'knife spork environment create ENVIRONMENT (options)'

Expand All @@ -13,6 +15,7 @@ class SporkEnvironmentCreate < Chef::Knife
:description => "The environment description"

def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

if @name_args.empty?
Expand Down
10 changes: 6 additions & 4 deletions lib/chef/knife/spork-environment-delete.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
require 'chef/knife'
require 'knife-spork/runner'

module KnifeSpork
class SporkEnvironmentDelete < Chef::Knife
include KnifeSpork::Runner

deps do
require 'chef/knife'
require 'knife-spork/runner'
end

banner 'knife spork environment delete ENVIRONMENT (options)'

def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

if @name_args.empty?
Expand Down
7 changes: 5 additions & 2 deletions lib/chef/knife/spork-environment-edit.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
require 'chef/knife'
require 'knife-spork/runner'

module KnifeSpork
class SporkEnvironmentEdit < Chef::Knife
include KnifeSpork::Runner

deps do
require 'knife-spork/runner'
end

banner 'knife spork environment edit ENVIRONMENT (options)'

def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

if @name_args.empty?
Expand Down
6 changes: 3 additions & 3 deletions lib/chef/knife/spork-environment-fromfile.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
require 'chef/knife'
require 'knife-spork/runner'
require 'json'

module KnifeSpork
class SporkEnvironmentFromFile < Chef::Knife
include KnifeSpork::Runner

deps do
require 'knife-spork/runner'
require 'json'
require 'chef/knife/environment_from_file'
end

banner 'knife spork environment from file FILENAME (options)'

def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

if @name_args.empty?
Expand Down
7 changes: 5 additions & 2 deletions lib/chef/knife/spork-info.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
require 'chef/knife'
require 'knife-spork/runner'

module KnifeSpork
class SporkInfo < Chef::Knife
include KnifeSpork::Runner

deps do
require 'knife-spork/runner'
end

banner 'knife spork info'

def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

run_plugins(:before_info)
Expand Down
7 changes: 5 additions & 2 deletions lib/chef/knife/spork-node-create.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
require 'chef/knife'
require 'knife-spork/runner'

module KnifeSpork
class SporkNodeCreate < Chef::Knife
include KnifeSpork::Runner

deps do
require 'knife-spork/runner'
end

banner 'knife spork node create NODE (options)'


def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

if @name_args.empty?
Expand Down
7 changes: 5 additions & 2 deletions lib/chef/knife/spork-node-delete.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
require 'chef/knife'
require 'knife-spork/runner'

module KnifeSpork
class SporkNodeDelete < Chef::Knife
include KnifeSpork::Runner

deps do
require 'knife-spork/runner'
end

banner 'knife spork node delete NODE (options)'


def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

if @name_args.empty?
Expand Down
9 changes: 6 additions & 3 deletions lib/chef/knife/spork-node-edit.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
require 'chef/knife'
require 'chef/knife/core/node_editor'
require 'knife-spork/runner'

module KnifeSpork
class SporkNodeEdit < Chef::Knife
include KnifeSpork::Runner

deps do
require 'chef/knife/core/node_editor'
require 'knife-spork/runner'
end

banner 'knife spork node edit NODE (options)'

Expand All @@ -15,6 +17,7 @@ class SporkNodeEdit < Chef::Knife
:description => "Display all attributes when editing"

def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

if @name_args.empty?
Expand Down
7 changes: 5 additions & 2 deletions lib/chef/knife/spork-node-fromfile.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
require 'chef/knife'
require 'knife-spork/runner'

module KnifeSpork
class SporkNodeFromFile < Chef::Knife
include KnifeSpork::Runner

deps do
require 'knife-spork/runner'
end

banner 'knife spork node from file FILE (options)'


def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

if @name_args.empty?
Expand Down
7 changes: 5 additions & 2 deletions lib/chef/knife/spork-node-runlistadd.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
require 'chef/knife'
require 'knife-spork/runner'

module KnifeSpork
class SporkNodeRunListAdd < Chef::Knife
include KnifeSpork::Runner

deps do
require 'knife-spork/runner'
end

banner 'knife spork node run_list add [NODE] [ENTRY[,ENTRY]] (options)'

Expand All @@ -14,6 +16,7 @@ class SporkNodeRunListAdd < Chef::Knife
:description => "Place the ENTRY in the run list after ITEM"

def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

if @name_args.empty?
Expand Down
8 changes: 5 additions & 3 deletions lib/chef/knife/spork-node-runlistremove.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
require 'chef/knife'
require 'knife-spork/runner'

module KnifeSpork
class SporkNodeRunListRemove < Chef::Knife
include KnifeSpork::Runner

banner 'knife spork node run_list add [NODE] [ENTRY[,ENTRY]] (options)'
deps do
require 'knife-spork/runner'
end

banner 'knife spork node run_list add [NODE] [ENTRY[,ENTRY]] (options)'

def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

if @name_args.empty?
Expand Down
8 changes: 5 additions & 3 deletions lib/chef/knife/spork-node-runlistset.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
require 'chef/knife'
require 'knife-spork/runner'

module KnifeSpork
class SporkNodeRunListSet < Chef::Knife
include KnifeSpork::Runner

banner 'knife spork node run_list set NODE ENTRIES (options)'
deps do
require 'knife-spork/runner'
end

banner 'knife spork node run_list set NODE ENTRIES (options)'

def run
self.class.send(:include, KnifeSpork::Runner)
self.config = Chef::Config.merge!(config)

if @name_args.size < 2
Expand Down
Loading

0 comments on commit 2e71076

Please sign in to comment.