This repository was archived by the owner on Dec 2, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +26
-7
lines changed Expand file tree Collapse file tree 3 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,13 @@ def self.default_protocol
1313 'https'
1414 end
1515
16+ def self . validate ( v )
17+ unless %w( git ssh https ) . member? v . to_s
18+ raise Puppet ::Error , \
19+ "Protocol can only be git, https, or ssh for now!"
20+ end
21+ end
22+
1623 def query
1724 h = { :name => @resource [ :name ] , :provider => :git }
1825
@@ -70,7 +77,14 @@ def destroy
7077
7178 def expand_source ( source )
7279 if source =~ /\A [^@\/ \s ]+\/ [^\/ \s ]+\z /
73- "#{ @resource [ :protocol ] } ://github.com/#{ source } "
80+ case @resource [ :protocol ]
81+ when "git" , "https"
82+ "#{ @resource [ :protocol ] } ://github.com/#{ source } "
83+ when "ssh"
84+ "git@github.com:#{ source } .git"
85+ else
86+ raise "failtown"
87+ end
7488 else
7589 source
7690 end
Original file line number Diff line number Diff line change @@ -60,13 +60,17 @@ def insync?(is)
6060 provider . class . default_protocol
6161 end
6262 end
63+
64+ validate do |v |
65+ provider . class . validate v
66+ end
6367 end
6468
6569 newparam :user do
6670 desc "User to run this operation as."
6771
6872 defaultto do
69- Facter [ :boxen_user ] . value
73+ Facter . value ( :boxen_user ) || Facter . value ( :id ) || "root"
7074 end
7175 end
7276
Original file line number Diff line number Diff line change 44 let ( :default_opts ) do
55 {
66 :source => 'boxen/boxen' ,
7- :path => '/tmp/boxen'
7+ :path => '/tmp/boxen' ,
88 }
99 end
1010
8282 end
8383
8484 it "should default to boxen_user if it exists" do
85- Facter [ :boxen_user ] . stubs ( :value ) . returns ( nil )
86- factory . call ( default_opts ) [ :user ] . should == nil
85+ Facter . stubs ( :value ) . with ( :boxen_user ) . returns ( nil )
86+ Facter . stubs ( :value ) . with ( :id ) . returns ( nil )
87+ factory . call ( default_opts ) [ :user ] . should == "root"
8788
88- Facter [ :boxen_user ] . stubs ( :value ) . returns ( 'testuser' )
89+ Facter . stubs ( :value ) . with ( :boxen_user ) . returns ( 'testuser' )
8990 factory . call ( default_opts ) [ :user ] . should == 'testuser'
9091 end
9192
9293 it "should override boxen_user if both exist" do
93- Facter [ :boxen_user ] . stubs ( :value ) . returns ( 'testuser' )
94+ Facter . stubs ( :value ) . with ( :boxen_user ) . returns ( 'testuser' )
9495
9596 opts = default_opts . merge ( :user => "otheruser" )
9697 factory . call ( opts ) [ :user ] . should == 'otheruser'
You can’t perform that action at this time.
0 commit comments