knife-github 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/knife-github.gemspec +4 -3
- data/lib/chef/knife/github_repo_create.rb +92 -44
- data/lib/knife-github/version.rb +1 -1
- metadata +19 -14
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NDViMjMxNGQzYTkxODBmMzM2MTI2ZjVkYmFkNmRmNjMyNjEzZjE2MA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NDk3NTRkOTc1MjYxMzZiZDhlNWJmZThlM2ZlNDNiZDg2MzcxZDBkMw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
N2ZkMTM5OGIxNTRiNDkyMGY2YWMyY2E4NjYxYmU3ZGMyN2FkZWI5YThhYmE3
|
10
|
+
MGE4YjhiODIzYTg4ZWE4OTM0NGIzOGY1MGI0NWQ0MjY1MzkwZWM4N2NmMjFk
|
11
|
+
YWIzY2Y3ODY2ZjhhNDNlMjQzMzRmYjc3Mzg4ZGU3ZGRiODEwMzI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ODllMmI5OTRhNDlhYTNkM2MwNmQ5ODIwNmJjZGZiYjE5MThmY2EwMmRkMDIy
|
14
|
+
NzJjNDVkNDk3MGM5YjIzYjZmN2I3ZTdiMjQ4N2JmNjIwMTdhMjliZTllZjFm
|
15
|
+
Y2EwZDNkMDJhMzk4NTQ2MWI4YjdjMGRiMTcyNjMwY2JkOWVkOTY=
|
data/knife-github.gemspec
CHANGED
@@ -18,7 +18,8 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
s.license = 'Apache 2.0'
|
21
|
-
s.add_dependency
|
22
|
-
s.add_dependency
|
23
|
-
s.add_dependency
|
21
|
+
s.add_dependency 'mixlib-versioning', '>= 1.0.0'
|
22
|
+
s.add_dependency 'highline', '>= 1.6.19'
|
23
|
+
s.add_dependency 'rb-readline', '~> 0.5.1'
|
24
|
+
s.add_dependency 'chef', '>= 10.0.0'
|
24
25
|
end
|
@@ -41,6 +41,7 @@ module KnifeGithubRepoCreate
|
|
41
41
|
require 'chef/knife/github_base'
|
42
42
|
include Chef::Knife::GithubBase
|
43
43
|
require 'chef/mixin/shell_out'
|
44
|
+
require 'readline'
|
44
45
|
end
|
45
46
|
|
46
47
|
banner "knife github repo create <name> <description> (options)"
|
@@ -69,7 +70,6 @@ module KnifeGithubRepoCreate
|
|
69
70
|
# Get the name_args from the command line
|
70
71
|
name = name_args.first
|
71
72
|
name_args.shift
|
72
|
-
desc = name_args.join(" ")
|
73
73
|
|
74
74
|
# Get the organization name from config
|
75
75
|
org = locate_config_value('github_organizations').first
|
@@ -79,10 +79,8 @@ module KnifeGithubRepoCreate
|
|
79
79
|
exit 1
|
80
80
|
end
|
81
81
|
|
82
|
-
|
83
|
-
|
84
|
-
exit 1
|
85
|
-
end
|
82
|
+
desc = get_repo_description
|
83
|
+
type = get_repo_type
|
86
84
|
|
87
85
|
if config[:github_user_repo]
|
88
86
|
url = @github_url + "/api/" + @github_api_version + "/user/repos"
|
@@ -102,8 +100,7 @@ module KnifeGithubRepoCreate
|
|
102
100
|
body = get_body_json(name, desc)
|
103
101
|
|
104
102
|
# Creating the local repository or using existing one.
|
105
|
-
cookbook_dir = ""
|
106
|
-
cookbook_dir = get_cookbook_path(name)
|
103
|
+
cookbook_dir = get_cookbook_path(name) || ""
|
107
104
|
|
108
105
|
if File.exists?(cookbook_dir)
|
109
106
|
Chef::Log.debug("Using local repository from #{cookbook_dir}")
|
@@ -119,16 +116,13 @@ module KnifeGithubRepoCreate
|
|
119
116
|
|
120
117
|
puts "Finished creating #{name} and uploading #{cookbook_dir}"
|
121
118
|
else
|
122
|
-
Chef::Log.debug("Creating the
|
123
|
-
create_cookbook(name, @github_tmp)
|
119
|
+
Chef::Log.debug("Creating the repository based on #{type} template")
|
120
|
+
create_cookbook(name, type, @github_tmp)
|
124
121
|
|
125
122
|
cookbook_dir = File.join(@github_tmp, name)
|
126
123
|
|
127
|
-
#
|
128
|
-
|
129
|
-
|
130
|
-
# Updateing metadata.rb if needed.
|
131
|
-
update_metadata(cookbook_dir)
|
124
|
+
# Updateing template information if needed.
|
125
|
+
update_template_files(name, cookbook_dir, desc)
|
132
126
|
|
133
127
|
# Creating the github repository
|
134
128
|
Chef::Log.debug("Creating the github repository")
|
@@ -144,7 +138,56 @@ module KnifeGithubRepoCreate
|
|
144
138
|
puts "Finished creating and uploading #{name}"
|
145
139
|
end
|
146
140
|
end
|
141
|
+
|
147
142
|
|
143
|
+
# User selection on repo description
|
144
|
+
# @return [string]
|
145
|
+
def get_repo_description
|
146
|
+
question = "\nPlease enter a description for the repository: "
|
147
|
+
|
148
|
+
desc = input question
|
149
|
+
if desc.nil? || desc.empty?
|
150
|
+
Chef::Log.error("Please enter a repository description")
|
151
|
+
get_repo_description
|
152
|
+
end
|
153
|
+
desc
|
154
|
+
end
|
155
|
+
|
156
|
+
# User selection on repo type
|
157
|
+
# @return [string]
|
158
|
+
def get_repo_type
|
159
|
+
question = "\nPlease select the repository type that you want to create.\n"
|
160
|
+
question += " 1 - Empty\n"
|
161
|
+
question += " 2 - Cookbook Application\n"
|
162
|
+
question += " 3 - Cookbook Wrapper\n"
|
163
|
+
question += " 4 - Cookbook Role\n"
|
164
|
+
question += "Type: "
|
165
|
+
|
166
|
+
type = input question
|
167
|
+
case type
|
168
|
+
when '1'
|
169
|
+
return 'empty'
|
170
|
+
when '2'
|
171
|
+
return "application"
|
172
|
+
when '3'
|
173
|
+
return "wrapper"
|
174
|
+
when '4'
|
175
|
+
return "role"
|
176
|
+
else
|
177
|
+
Chef::Log.error("Please select 1-4 to continue.")
|
178
|
+
get_repo_type
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# Read the commandline input and return the input
|
183
|
+
# @param prompt [String] info to prompt to user
|
184
|
+
|
185
|
+
$stdout.sync = false
|
186
|
+
def input(prompt="", newline=true)
|
187
|
+
prompt += "\n" if newline
|
188
|
+
Readline.readline(prompt).squeeze(" ").strip
|
189
|
+
end
|
190
|
+
|
148
191
|
# Set the username in README.md
|
149
192
|
# @param cookbook_path [String] cookbook path
|
150
193
|
# github_ssh_url [String] github ssh url from repo
|
@@ -161,33 +204,29 @@ module KnifeGithubRepoCreate
|
|
161
204
|
shell_out!("git push -u origin master", :cwd => cookbook_path)
|
162
205
|
end
|
163
206
|
|
164
|
-
#
|
207
|
+
# Update all template files with the right information
|
165
208
|
# @param name [String] cookbook path
|
166
|
-
def
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
line.gsub!(/YOUR_COMPANY_NAME/,username) if username
|
187
|
-
line.gsub!(/YOUR_EMAIL/,email) if email
|
188
|
-
contents = contents << line
|
209
|
+
def update_template_files(name, cookbook_path, description)
|
210
|
+
files = Dir.glob("#{cookbook_path}/**/*").select{ |e| File.file? e }
|
211
|
+
user = get_username || "Your Name"
|
212
|
+
email = get_useremail || "Your Email"
|
213
|
+
company = "Schuberg Philis"
|
214
|
+
year = Time.now.year
|
215
|
+
date = Time.now
|
216
|
+
files.each do |file|
|
217
|
+
contents = ""
|
218
|
+
File.foreach(file) do |line|
|
219
|
+
line.gsub!(/DESCRIPTION/, description)
|
220
|
+
line.gsub!(/COOKBOOK/, name)
|
221
|
+
line.gsub!(/COMPANY/, company)
|
222
|
+
line.gsub!(/NAME/, user)
|
223
|
+
line.gsub!(/EMAIL/, email)
|
224
|
+
line.gsub!(/YEAR/, year.to_s)
|
225
|
+
line.gsub!(/DATE/, date.to_s)
|
226
|
+
contents += line
|
227
|
+
end
|
228
|
+
File.open(file, 'w') {|f| f.write(contents) }
|
189
229
|
end
|
190
|
-
File.open(metadata, 'w') {|f| f.write(contents) }
|
191
230
|
return nil
|
192
231
|
end
|
193
232
|
|
@@ -213,12 +252,21 @@ module KnifeGithubRepoCreate
|
|
213
252
|
|
214
253
|
# Create the cookbook template for upload
|
215
254
|
# @param name [String] cookbook name
|
255
|
+
# type [String] type of cookbook
|
216
256
|
# tmp [String] temp location
|
217
|
-
def create_cookbook(name, tmp)
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
257
|
+
def create_cookbook(name, type, tmp)
|
258
|
+
target = File.join(tmp, name)
|
259
|
+
template_org = locate_config_value("github_template_org")
|
260
|
+
if template_org.nil? || template_org.empty?
|
261
|
+
Chef::Log.fatal("Cannot find github_template_org within your configuration")
|
262
|
+
else
|
263
|
+
|
264
|
+
github_url = @github_url.gsub('http://', 'git://') if @github_url =~ /^http:\/\/.*$/
|
265
|
+
github_url = @github_url.gsub('https://', 'git://') if @github_url =~ /^https:\/\/.*$/
|
266
|
+
|
267
|
+
template_path = File.join(github_url, template_org, "chef_template_#{type}.git")
|
268
|
+
shell_out!("git clone #{template_path} #{target}") # , :cwd => cookbook_path)
|
269
|
+
end
|
222
270
|
end
|
223
271
|
|
224
272
|
# Create the json body with repo config for POST information
|
data/lib/knife-github/version.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sander Botman
|
@@ -10,12 +9,11 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2014-03
|
12
|
+
date: 2014-11-03 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: mixlib-versioning
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
18
|
- - ! '>='
|
21
19
|
- !ruby/object:Gem::Version
|
@@ -23,7 +21,6 @@ dependencies:
|
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
25
|
- - ! '>='
|
29
26
|
- !ruby/object:Gem::Version
|
@@ -31,7 +28,6 @@ dependencies:
|
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: highline
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
32
|
- - ! '>='
|
37
33
|
- !ruby/object:Gem::Version
|
@@ -39,15 +35,27 @@ dependencies:
|
|
39
35
|
type: :runtime
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
39
|
- - ! '>='
|
45
40
|
- !ruby/object:Gem::Version
|
46
41
|
version: 1.6.19
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rb-readline
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.5.1
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.5.1
|
47
56
|
- !ruby/object:Gem::Dependency
|
48
57
|
name: chef
|
49
58
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
59
|
requirements:
|
52
60
|
- - ! '>='
|
53
61
|
- !ruby/object:Gem::Version
|
@@ -55,7 +63,6 @@ dependencies:
|
|
55
63
|
type: :runtime
|
56
64
|
prerelease: false
|
57
65
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
66
|
requirements:
|
60
67
|
- - ! '>='
|
61
68
|
- !ruby/object:Gem::Version
|
@@ -123,27 +130,25 @@ files:
|
|
123
130
|
homepage: https://github.com/schubergphilis/knife-github
|
124
131
|
licenses:
|
125
132
|
- Apache 2.0
|
133
|
+
metadata: {}
|
126
134
|
post_install_message:
|
127
135
|
rdoc_options: []
|
128
136
|
require_paths:
|
129
137
|
- lib
|
130
138
|
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
-
none: false
|
132
139
|
requirements:
|
133
140
|
- - ! '>='
|
134
141
|
- !ruby/object:Gem::Version
|
135
142
|
version: '0'
|
136
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
144
|
requirements:
|
139
145
|
- - ! '>='
|
140
146
|
- !ruby/object:Gem::Version
|
141
147
|
version: '0'
|
142
148
|
requirements: []
|
143
149
|
rubyforge_project:
|
144
|
-
rubygems_version: 1.
|
150
|
+
rubygems_version: 2.1.11
|
145
151
|
signing_key:
|
146
|
-
specification_version:
|
152
|
+
specification_version: 4
|
147
153
|
summary: Github interaction support for chef's knife cli tool
|
148
154
|
test_files: []
|
149
|
-
has_rdoc: false
|