whisk 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +21 -5
- data/lib/whisk/cli.rb +24 -35
- data/lib/whisk/exceptions.rb +18 -0
- data/lib/whisk/mixin/shellout.rb +13 -0
- data/lib/whisk/provider/bowl.rb +73 -0
- data/lib/whisk/provider/ingredient.rb +77 -0
- data/lib/whisk/{flavours.rb → provider.rb} +9 -5
- data/lib/whisk/resource/bowl.rb +49 -0
- data/lib/whisk/resource/ingredient.rb +45 -0
- data/lib/whisk/{ingredient.rb → resource.rb} +23 -15
- data/lib/whisk/runner.rb +56 -0
- data/lib/whisk/version.rb +1 -1
- data/lib/whisk/whiskfile.rb +1 -1
- data/lib/whisk.rb +1 -1
- metadata +9 -6
- data/lib/whisk/bowl.rb +0 -94
- data/lib/whisk/flavour/git.rb +0 -75
data/README.md
CHANGED
@@ -31,6 +31,20 @@ Whiskfile.
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
bowl "development" do
|
35
|
+
path cb_path % name
|
36
|
+
|
37
|
+
ingredient "ntp" do
|
38
|
+
source github % "ntp"
|
39
|
+
ref 'develop'
|
40
|
+
end
|
41
|
+
|
42
|
+
ingredient "ssh" do
|
43
|
+
source github % "ssh"
|
44
|
+
ref 'develop'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
34
48
|
# Commands #
|
35
49
|
|
36
50
|
## whisk prepare ##
|
@@ -45,17 +59,19 @@ checkout a specified ref.
|
|
45
59
|
Cloning into 'ntp'...
|
46
60
|
Checking out ref '1.1.2' for ingredient ntp
|
47
61
|
|
48
|
-
You can also use specify
|
49
|
-
cookbooks
|
62
|
+
You can also use specify a filter to run whisk subcommands on a subset of
|
63
|
+
cookbooks by specifying the bowl and ingredient separated by a forward slash.
|
64
|
+
Wildcards or optional matches can be specified by using ruby syntax.
|
50
65
|
|
66
|
+
# Given the Whiskfile as described earlier in the documentation
|
51
67
|
# prepare the 'development' bowl
|
52
|
-
$ whisk prepare dev
|
68
|
+
$ whisk prepare 'dev.*'
|
53
69
|
|
54
70
|
# prepare the ntp cookbook in all configured bowls'
|
55
|
-
$ whisk prepare '
|
71
|
+
$ whisk prepare '.*/ntp'
|
56
72
|
|
57
73
|
# prepare a list of cookbooks
|
58
|
-
$ whisk prepare 'dev
|
74
|
+
$ whisk prepare 'dev/(ssh|ntp)'
|
59
75
|
|
60
76
|
## whisk status ##
|
61
77
|
|
data/lib/whisk/cli.rb
CHANGED
@@ -18,20 +18,7 @@
|
|
18
18
|
|
19
19
|
require 'thor'
|
20
20
|
require 'whisk'
|
21
|
-
require 'whisk/
|
22
|
-
|
23
|
-
def filter_bowls(bowls, bowl=nil, ingredient=nil)
|
24
|
-
if bowl
|
25
|
-
bowls.delete_if {|k,v| !k.to_s.match(/^#{bowl}$/)}
|
26
|
-
if ingredient
|
27
|
-
bowls.each do |name, b|
|
28
|
-
bowls[name].ingredients.delete_if {|k,v| !k.to_s.match(/^#{ingredient}$/)}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
return bowls
|
34
|
-
end
|
21
|
+
require 'whisk/runner'
|
35
22
|
|
36
23
|
class Whisk
|
37
24
|
class CLI < Thor
|
@@ -53,14 +40,10 @@ class Whisk
|
|
53
40
|
desc: "Path to a Whiskfile to operate off of.",
|
54
41
|
aliases: "-w",
|
55
42
|
banner: "PATH"
|
56
|
-
desc "
|
57
|
-
def
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
bowls.each do |name, bowl|
|
62
|
-
bowl.prepare
|
63
|
-
end
|
43
|
+
desc "diff", "run git diff in your bowls"
|
44
|
+
def diff(filter=nil)
|
45
|
+
runner = Whisk::Runner.new(options[:whiskfile], filter)
|
46
|
+
runner.run('diff')
|
64
47
|
end
|
65
48
|
|
66
49
|
method_option :whiskfile,
|
@@ -70,12 +53,9 @@ class Whisk
|
|
70
53
|
aliases: "-w",
|
71
54
|
banner: "PATH"
|
72
55
|
desc "prepare", "prepare a bowl by cloning any missing repositories"
|
73
|
-
def
|
74
|
-
|
75
|
-
|
76
|
-
bowls.each do |name, bowl|
|
77
|
-
bowl.status
|
78
|
-
end
|
56
|
+
def prepare(filter=nil)
|
57
|
+
runner = Whisk::Runner.new(options[:whiskfile], filter)
|
58
|
+
runner.run('prepare')
|
79
59
|
end
|
80
60
|
|
81
61
|
method_option :whiskfile,
|
@@ -84,13 +64,22 @@ class Whisk
|
|
84
64
|
desc: "Path to a Whiskfile to operate off of.",
|
85
65
|
aliases: "-w",
|
86
66
|
banner: "PATH"
|
87
|
-
desc "
|
88
|
-
def
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
67
|
+
desc "status", "run git status in your bowls"
|
68
|
+
def status(filter=nil)
|
69
|
+
runner = Whisk::Runner.new(options[:whiskfile], filter)
|
70
|
+
runner.run('status')
|
71
|
+
end
|
72
|
+
|
73
|
+
method_option :whiskfile,
|
74
|
+
type: :string,
|
75
|
+
default: File.join(Dir.pwd, Whisk::DEFAULT_FILENAME),
|
76
|
+
desc: "Path to a Whiskfile to operate off of.",
|
77
|
+
aliases: "-w",
|
78
|
+
banner: "PATH"
|
79
|
+
desc "update", "run git remote update in your bowls"
|
80
|
+
def update(filter=nil)
|
81
|
+
runner = Whisk::Runner.new(options[:whiskfile], filter)
|
82
|
+
runner.run('update')
|
94
83
|
end
|
95
84
|
end
|
96
85
|
end
|
data/lib/whisk/exceptions.rb
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Mathieu Sauve-Frankel <msf@kisoku.net>
|
3
|
+
# Copyright:: Copyright (c) 2012 Mathieu Sauve-Frankel
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
1
19
|
class Chef
|
2
20
|
class Exceptions
|
3
21
|
class ValidationFailed < ArgumentError; end
|
data/lib/whisk/mixin/shellout.rb
CHANGED
@@ -32,11 +32,24 @@ class Whisk
|
|
32
32
|
cmd
|
33
33
|
end
|
34
34
|
|
35
|
+
def shell_out!(*command_args)
|
36
|
+
cmd = shell_out(*command_args)
|
37
|
+
cmd.error!
|
38
|
+
cmd
|
39
|
+
end
|
40
|
+
|
35
41
|
def run_command(*command_args)
|
36
42
|
cmd = Mixlib::ShellOut.new(*command_args)
|
37
43
|
cmd.run_command
|
38
44
|
cmd
|
39
45
|
end
|
46
|
+
|
47
|
+
def run_command!(*command_args)
|
48
|
+
cmd = run_command(*command_args)
|
49
|
+
cmd.error!
|
50
|
+
cmd
|
51
|
+
end
|
52
|
+
|
40
53
|
end
|
41
54
|
end
|
42
55
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Mathieu Sauve-Frankel <msf@kisoku.net>
|
3
|
+
# Copyright:: Copyright (c) 2012 Mathieu Sauve-Frankel
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'whisk'
|
20
|
+
require 'whisk/provider'
|
21
|
+
|
22
|
+
class Whisk
|
23
|
+
class Provider
|
24
|
+
class Bowl < Provider
|
25
|
+
|
26
|
+
def exist?
|
27
|
+
::Dir.exist? resource.path
|
28
|
+
end
|
29
|
+
|
30
|
+
def ingredients_run(action)
|
31
|
+
resource.ingredients.each do |name, ingredient|
|
32
|
+
ingredient.run_action(action)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def create
|
37
|
+
unless self.exist?
|
38
|
+
Whisk.ui.info "Creating bowl '#{resource.name}' with path #{resource.path}"
|
39
|
+
::FileUtils.mkdir_p resource.path
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def action_diff
|
44
|
+
if self.exist?
|
45
|
+
::Dir.chdir resource.path
|
46
|
+
ingredients_run("diff")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def action_prepare
|
51
|
+
self.create unless self.exist?
|
52
|
+
::Dir.chdir resource.path
|
53
|
+
Whisk.ui.info "Preparing bowl '#{resource.name}' with path #{resource.path}"
|
54
|
+
ingredients_run("prepare")
|
55
|
+
end
|
56
|
+
|
57
|
+
def action_status
|
58
|
+
if self.exist?
|
59
|
+
::Dir.chdir resource.path
|
60
|
+
Whisk.ui.info "Status for bowl '#{resource.name}' with path #{resource.path}"
|
61
|
+
ingredients_run("status")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def action_update
|
66
|
+
if self.exist?
|
67
|
+
::Dir.chdir resource.path
|
68
|
+
ingredients_run("update")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Mathieu Sauve-Frankel <msf@kisoku.net>
|
3
|
+
# Copyright:: Copyright (c) 2012 Mathieu Sauve-Frankel
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'whisk/mixin/shellout'
|
20
|
+
|
21
|
+
class Whisk
|
22
|
+
class Provider
|
23
|
+
class Ingredient < Provider
|
24
|
+
|
25
|
+
include Whisk::Mixin::ShellOut
|
26
|
+
|
27
|
+
def clone
|
28
|
+
if ::File.exists? File.join(Dir.pwd, resource.name, ".git", "config")
|
29
|
+
Whisk.ui.info "Ingredient '#{resource.name}' already prepared"
|
30
|
+
else
|
31
|
+
Whisk.ui.info "Cloning ingredient '#{resource.name}', " + "from url #{resource.source}"
|
32
|
+
shell_out!("git clone #{resource.source} #{resource.name}")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def current_ref
|
37
|
+
cref = run_command!("git rev-parse --abbrev-ref HEAD", :cwd => resource.name).stdout.chomp
|
38
|
+
if cref == 'HEAD'
|
39
|
+
return run_command!("git describe", :cwd => resource.name).stdout.chomp
|
40
|
+
else
|
41
|
+
return cref
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def checkout
|
46
|
+
if resource.ref
|
47
|
+
if self.current_ref == resource.ref
|
48
|
+
Whisk.ui.info "Ingredient '#{resource.name}' already at ref '#{resource.ref}'"
|
49
|
+
else
|
50
|
+
Whisk.ui.info "Checking out ref '#{resource.ref}' for ingredient '#{resource.name}'"
|
51
|
+
shell_out!("git checkout #{resource.ref}", :cwd => resource.name)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def action_diff
|
57
|
+
Whisk.ui.info "Diff for ingredient '#{resource.name}'"
|
58
|
+
shell_out!("git diff", :cwd => resource.name)
|
59
|
+
end
|
60
|
+
|
61
|
+
def action_prepare
|
62
|
+
self.clone
|
63
|
+
self.checkout
|
64
|
+
end
|
65
|
+
|
66
|
+
def action_status
|
67
|
+
Whisk.ui.info "Status for ingredient '#{resource.name}'"
|
68
|
+
shell_out!("git status", :cwd => resource.name)
|
69
|
+
end
|
70
|
+
|
71
|
+
def action_update
|
72
|
+
Whisk.ui.info "Updating ingredient '#{resource.name}'"
|
73
|
+
shell_out!("git remote update", :cwd => resource.name)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -15,11 +15,15 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
|
-
|
19
|
-
|
18
|
+
# This organization of this class and classes under whisk/provider
|
19
|
+
# are directly inspired by Opscode Chef's Chef::Provider
|
20
20
|
|
21
21
|
class Whisk
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
class Provider
|
23
|
+
attr_reader :resource
|
24
|
+
|
25
|
+
def initialize(resource)
|
26
|
+
@resource = resource
|
27
|
+
end
|
28
|
+
end
|
25
29
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Mathieu Sauve-Frankel <msf@kisoku.net>
|
3
|
+
# Copyright:: Copyright (c) 2012 Mathieu Sauve-Frankel
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
require 'fileutils'
|
19
|
+
require 'whisk/resource'
|
20
|
+
require 'whisk/resource/ingredient'
|
21
|
+
require 'whisk/provider/bowl'
|
22
|
+
|
23
|
+
class Whisk
|
24
|
+
class Resource
|
25
|
+
class Bowl < Resource
|
26
|
+
|
27
|
+
attr_reader :ingredients
|
28
|
+
|
29
|
+
def initialize(name, &block)
|
30
|
+
@provider = Whisk::Provider::Bowl
|
31
|
+
@ingredients = {}
|
32
|
+
|
33
|
+
super(name, &block)
|
34
|
+
end
|
35
|
+
|
36
|
+
def ingredient(iname, &block)
|
37
|
+
if ingredients.has_key? iname
|
38
|
+
raise ArgumentError "Ingredient '#{iname}' has already added to bowl '#{name}'"
|
39
|
+
else
|
40
|
+
ingredients[iname] = Whisk::Resource::Ingredient.new(iname, &block)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def path(arg=nil)
|
45
|
+
set_or_return(:path, arg, :default => File.join(Dir.getwd, name))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Mathieu Sauve-Frankel <msf@kisoku.net>
|
3
|
+
# Copyright:: Copyright (c) 2012 Mathieu Sauve-Frankel
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
require 'whisk/exceptions'
|
19
|
+
require 'whisk/resource'
|
20
|
+
require 'whisk/provider/ingredient'
|
21
|
+
|
22
|
+
class Whisk
|
23
|
+
class Resource
|
24
|
+
class Ingredient < Resource
|
25
|
+
|
26
|
+
include Chef::Mixin::ParamsValidate
|
27
|
+
|
28
|
+
def initialize(name, &block)
|
29
|
+
@provider = Whisk::Provider::Ingredient
|
30
|
+
@ref = nil
|
31
|
+
@source = nil
|
32
|
+
|
33
|
+
super(name, &block)
|
34
|
+
end
|
35
|
+
|
36
|
+
def source(arg=nil)
|
37
|
+
set_or_return(:source, arg, :required => true)
|
38
|
+
end
|
39
|
+
|
40
|
+
def ref(arg=nil)
|
41
|
+
set_or_return(:ref, arg, :kind_of => String)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -14,39 +14,47 @@
|
|
14
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
|
+
#
|
18
|
+
# This organization of this class and classes under whisk/resource
|
19
|
+
# are heavily inspired by Opscode Chef's Chef::Resource
|
20
|
+
# which was authored by Adam Jacob
|
17
21
|
|
18
22
|
require 'chef/mixin/params_validate'
|
19
23
|
require 'whisk/exceptions'
|
20
|
-
require 'whisk/flavours'
|
21
24
|
|
22
25
|
class Whisk
|
23
|
-
class
|
26
|
+
class Resource
|
24
27
|
|
25
28
|
include Chef::Mixin::ParamsValidate
|
26
29
|
|
27
30
|
attr_reader :name
|
31
|
+
attr_accessor :provider
|
28
32
|
|
29
33
|
def initialize(name, &block)
|
30
34
|
@name = name
|
31
|
-
@flavour = 'git'
|
32
|
-
@ref = nil
|
33
|
-
@source = nil
|
34
35
|
|
35
36
|
instance_eval(&block) if block_given?
|
36
|
-
|
37
|
-
self.class.send(:include, Whisk::FLAVOURS[@flavour])
|
38
|
-
end
|
39
|
-
|
40
|
-
def source(arg=nil)
|
41
|
-
set_or_return(:source, arg, :required => true)
|
42
37
|
end
|
43
38
|
|
44
|
-
def
|
45
|
-
|
39
|
+
def provider(arg=nil)
|
40
|
+
klass = if arg.kind_of?(String) || arg.kind_of?(Symbol)
|
41
|
+
raise ArgumentError "must provider provider by klass"
|
42
|
+
# lookup_provider_constant(arg)
|
43
|
+
else
|
44
|
+
arg
|
45
|
+
end
|
46
|
+
set_or_return(
|
47
|
+
:provider,
|
48
|
+
klass,
|
49
|
+
:kind_of => [ Class ]
|
50
|
+
)
|
46
51
|
end
|
47
52
|
|
48
|
-
def
|
49
|
-
|
53
|
+
def run_action(action)
|
54
|
+
if self.provider
|
55
|
+
provider = self.provider.new(self)
|
56
|
+
provider.send("action_#{action}")
|
57
|
+
end
|
50
58
|
end
|
51
59
|
end
|
52
60
|
end
|
data/lib/whisk/runner.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Mathieu Sauve-Frankel <msf@kisoku.net>
|
3
|
+
# Copyright:: Copyright (c) 2012 Mathieu Sauve-Frankel
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'whisk'
|
20
|
+
require 'whisk/whiskfile'
|
21
|
+
|
22
|
+
class Whisk
|
23
|
+
class Runner
|
24
|
+
|
25
|
+
attr_accessor :bowls
|
26
|
+
|
27
|
+
def initialize(whiskfile=Whisk::DEFAULT_FILENAME, filter=nil)
|
28
|
+
@bowls = Whisk::WhiskFile.from_file(whiskfile).bowls
|
29
|
+
|
30
|
+
if filter
|
31
|
+
bowl, ingredient = filter.split('/')
|
32
|
+
if bowl
|
33
|
+
bowls.delete_if {|k,v| !k.to_s.match(/^#{bowl}$/)}
|
34
|
+
if ingredient
|
35
|
+
bowls.each do |name, b|
|
36
|
+
bowls[name].ingredients.delete_if {|k,v| !k.to_s.match(/^#{ingredient}$/)}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def run(action)
|
44
|
+
@bowls.each do |name, bowl|
|
45
|
+
begin
|
46
|
+
bowl.run_action(action)
|
47
|
+
rescue Exception => e
|
48
|
+
Whisk.ui.error "Caught exception while running action #{action} on bowl #{bowl.name}"
|
49
|
+
Whisk.ui.output e.message
|
50
|
+
Whisk.ui.output e.backtrace
|
51
|
+
exit 1
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/whisk/version.rb
CHANGED
data/lib/whisk/whiskfile.rb
CHANGED
data/lib/whisk.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whisk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|
@@ -103,13 +103,16 @@ files:
|
|
103
103
|
- lib/whisk.rb
|
104
104
|
- lib/whisk/mixin/shellout.rb
|
105
105
|
- lib/whisk/cli.rb
|
106
|
-
- lib/whisk/
|
106
|
+
- lib/whisk/resource/ingredient.rb
|
107
|
+
- lib/whisk/resource/bowl.rb
|
107
108
|
- lib/whisk/whiskfile.rb
|
109
|
+
- lib/whisk/resource.rb
|
108
110
|
- lib/whisk/exceptions.rb
|
109
|
-
- lib/whisk/
|
111
|
+
- lib/whisk/provider.rb
|
112
|
+
- lib/whisk/runner.rb
|
110
113
|
- lib/whisk/version.rb
|
111
|
-
- lib/whisk/
|
112
|
-
- lib/whisk/
|
114
|
+
- lib/whisk/provider/ingredient.rb
|
115
|
+
- lib/whisk/provider/bowl.rb
|
113
116
|
- bin/whisk
|
114
117
|
homepage: http://github.com/kisoku/whisk
|
115
118
|
licenses: []
|
data/lib/whisk/bowl.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Mathieu Sauve-Frankel <msf@kisoku.net>
|
3
|
-
# Copyright:: Copyright (c) 2012 Mathieu Sauve-Frankel
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
require 'fileutils'
|
19
|
-
require 'chef/mixin/params_validate'
|
20
|
-
require 'whisk/exceptions'
|
21
|
-
require 'whisk/ingredient'
|
22
|
-
|
23
|
-
class Whisk
|
24
|
-
class Bowl
|
25
|
-
|
26
|
-
include Chef::Mixin::ParamsValidate
|
27
|
-
|
28
|
-
attr_reader :name, :ingredients
|
29
|
-
|
30
|
-
def initialize(name, path=nil, &block)
|
31
|
-
@name = name
|
32
|
-
@path = File.join(Dir.getwd, name)
|
33
|
-
@ingredients = {}
|
34
|
-
|
35
|
-
instance_eval(&block) if block_given?
|
36
|
-
end
|
37
|
-
|
38
|
-
def ingredient(iname, &block)
|
39
|
-
if ingredients.has_key? iname
|
40
|
-
raise ArgumentError "Ingredient '#{iname}' has already added to bowl '#{name}'"
|
41
|
-
else
|
42
|
-
ingredients[iname] = Whisk::Ingredient.new(iname, &block)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def create!
|
47
|
-
unless Dir.exists? path
|
48
|
-
begin
|
49
|
-
Whisk.ui.info "Creating bowl '#{name}' with path #{path}"
|
50
|
-
::FileUtils.mkdir_p path
|
51
|
-
rescue Exception => e
|
52
|
-
puts "#{e.backtrace} #{e.message}"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def prepare
|
58
|
-
self.create!
|
59
|
-
::Dir.chdir path
|
60
|
-
|
61
|
-
Whisk.ui.info "Preparing bowl '#{name}' with path #{path}"
|
62
|
-
|
63
|
-
ingredients.each do |name, ingredient|
|
64
|
-
begin
|
65
|
-
ingredient.prepare
|
66
|
-
rescue Exception => e
|
67
|
-
Whisk.ui.error "Failed fetching ingredient '#{name}'"
|
68
|
-
raise
|
69
|
-
exit 1
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def status
|
75
|
-
::Dir.chdir path
|
76
|
-
ingredients.each do |name, ingredient|
|
77
|
-
Whisk.ui.info "Status for ingredient '#{self.name}/#{name}'"
|
78
|
-
ingredient.status
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def update
|
83
|
-
::Dir.chdir path
|
84
|
-
ingredients.each do |name, ingredient|
|
85
|
-
Whisk.ui.info "Updating ingredient '#{self.name}/#{name}'"
|
86
|
-
ingredient.update
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def path(arg=nil)
|
91
|
-
set_or_return(:path, arg, :default => File.join(Dir.getwd, name))
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
data/lib/whisk/flavour/git.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Mathieu Sauve-Frankel <msf@kisoku.net>
|
3
|
-
# Copyright:: Copyright (c) 2012 Mathieu Sauve-Frankel
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
require 'whisk/mixin/shellout'
|
19
|
-
require 'whisk/ingredient'
|
20
|
-
|
21
|
-
class Whisk
|
22
|
-
module Flavour
|
23
|
-
module Git
|
24
|
-
|
25
|
-
include Whisk::Mixin::ShellOut
|
26
|
-
|
27
|
-
def clone
|
28
|
-
if ::File.exists? File.join(Dir.pwd, name, ".git", "config")
|
29
|
-
Whisk.ui.info "Ingredient '#{self.name}' already prepared"
|
30
|
-
else
|
31
|
-
Whisk.ui.info "Cloning ingredient '#{self.name}', " + "from url #{self.source}"
|
32
|
-
shell_out("git clone #{self.source} #{self.name}")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def current_ref
|
37
|
-
cref = run_command("git rev-parse --abbrev-ref HEAD", :cwd => self.name).stdout.chomp
|
38
|
-
if cref == 'HEAD'
|
39
|
-
return run_command("git describe", :cwd => self.name).stdout.chomp
|
40
|
-
else
|
41
|
-
return cref
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def checkout
|
46
|
-
if self.ref
|
47
|
-
if self.current_ref == self.ref
|
48
|
-
Whisk.ui.info "Ingredient '#{self.name}' already at ref '#{self.ref}'"
|
49
|
-
else
|
50
|
-
Whisk.ui.info "Checking out ref '#{self.ref}' for ingredient '#{self.name}'"
|
51
|
-
shell_out("git checkout #{self.ref}", :cwd => self.name)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def prepare
|
57
|
-
begin
|
58
|
-
self.clone
|
59
|
-
self.checkout
|
60
|
-
rescue Exception => e
|
61
|
-
Whisk.ui.error "#{e.message} #{e.backtrace}"
|
62
|
-
raise
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def status
|
67
|
-
shell_out("git status", :cwd => self.name)
|
68
|
-
end
|
69
|
-
|
70
|
-
def update
|
71
|
-
shell_out("git remote update", :cwd => self.name)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|