Merge lp:~lazypower/charm-tools/chef-charm-template-rev2 into lp:charm-tools/1.4

Proposed by Charles Butler
Status: Merged
Merged at revision: 348
Proposed branch: lp:~lazypower/charm-tools/chef-charm-template-rev2
Merge into: lp:charm-tools/1.4
Diff against target: 1108 lines (+907/-0)
32 files modified
charmtools/templates/chef/__init__.py (+18/-0)
charmtools/templates/chef/files/README.ex (+44/-0)
charmtools/templates/chef/files/config.yaml (+14/-0)
charmtools/templates/chef/files/hooks/Gemfile (+4/-0)
charmtools/templates/chef/files/hooks/Gemfile.lock (+64/-0)
charmtools/templates/chef/files/hooks/bootstrap (+20/-0)
charmtools/templates/chef/files/hooks/config-changed (+4/-0)
charmtools/templates/chef/files/hooks/cookbooks/charm-name/metadata.rb (+8/-0)
charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/definitions/juju_port.rb (+11/-0)
charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/definitions/relation_set.rb (+10/-0)
charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/libraries/juju.rb (+28/-0)
charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/libraries/juju/juju_helpers.rb (+48/-0)
charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/libraries/juju/juju_helpers_dev.rb (+25/-0)
charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/metadata.rb (+7/-0)
charmtools/templates/chef/files/hooks/cookbooks/relation-name-relation/metadata.rb (+8/-0)
charmtools/templates/chef/files/hooks/install (+5/-0)
charmtools/templates/chef/files/hooks/relation-name-relation-broken (+4/-0)
charmtools/templates/chef/files/hooks/relation-name-relation-changed (+4/-0)
charmtools/templates/chef/files/hooks/relation-name-relation-departed (+4/-0)
charmtools/templates/chef/files/hooks/relation-name-relation-joined (+4/-0)
charmtools/templates/chef/files/hooks/start (+4/-0)
charmtools/templates/chef/files/hooks/stop (+4/-0)
charmtools/templates/chef/files/hooks/stub (+15/-0)
charmtools/templates/chef/files/hooks/upgrade-charm (+4/-0)
charmtools/templates/chef/files/icon.svg (+279/-0)
charmtools/templates/chef/files/metadata.yaml (+17/-0)
charmtools/templates/chef/files/tests/00-setup (+5/-0)
charmtools/templates/chef/files/tests/99-autogen (+50/-0)
charmtools/templates/chef/template.py (+76/-0)
setup.py (+1/-0)
tests_functional/create/test.sh (+4/-0)
tests_functional/create/test_chef_create.py (+114/-0)
To merge this branch: bzr merge lp:~lazypower/charm-tools/chef-charm-template-rev2
Reviewer Review Type Date Requested Status
Tim Van Steenburgh (community) Approve
Review via email: mp+242081@code.launchpad.net

Description of the change

Adds chef template, without symlinks - and a proper deployment.

This branch has a known deficiency - when you try to do something clever - such as:

charm create -t chef /tmp/foobar - it reads '/tmp/foobar' as the charm string and breaks in all kinds of interesting ways. Not sure if this is isolated to just the chef-template generator or others as well - but this is a known deficiency.

Generates a boilerplate chef-solo powered charm, and passes deploy tests after a base initialization. This is pre-req. work for the chef-charm-developer story - and should be treated as a guideline for future chef-charm based development.

To post a comment you must log in.
351. By Charles Butler

Adds amulet deployment tests to chef template

Revision history for this message
Tim Van Steenburgh (tvansteenburgh) wrote :

Awesome, +1 LGTM, thanks Chuck!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'charmtools/templates/chef'
2=== added file 'charmtools/templates/chef/__init__.py'
3--- charmtools/templates/chef/__init__.py 1970-01-01 00:00:00 +0000
4+++ charmtools/templates/chef/__init__.py 2014-11-18 19:19:34 +0000
5@@ -0,0 +1,18 @@
6+#!/usr/bin/python
7+#
8+# Copyright (C) 2014 Canonical Ltd.
9+#
10+# This program is free software: you can redistribute it and/or modify
11+# it under the terms of the GNU General Public License as published by
12+# the Free Software Foundation, either version 3 of the License, or
13+# (at your option) any later version.
14+#
15+# This program is distributed in the hope that it will be useful,
16+# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+# GNU General Public License for more details.
19+#
20+# You should have received a copy of the GNU General Public License
21+# along with this program. If not, see <http://www.gnu.org/licenses/>.
22+
23+from .template import ChefCharmTemplate # noqa
24
25=== added directory 'charmtools/templates/chef/files'
26=== added file 'charmtools/templates/chef/files/README.ex'
27--- charmtools/templates/chef/files/README.ex 1970-01-01 00:00:00 +0000
28+++ charmtools/templates/chef/files/README.ex 2014-11-18 19:19:34 +0000
29@@ -0,0 +1,44 @@
30+# Overview
31+
32+Describe the intended usage of this charm and anything unique about how this charm relates to others here.
33+
34+This README will be displayed in the Charm Store, it should be either Markdown or RST. Ideal READMEs include instructions on how to use the charm, expected usage, and charm features that your audience might be interested in. For an example of a well written README check out Hadoop: http://jujucharms.com/charms/precise/hadoop
35+
36+Use this as a Markdown reference if you need help with the formatting of this README: http://askubuntu.com/editing-help
37+
38+This charm provides [service](http://example.com). Add a description here of what the service itself actually does.
39+
40+Also remember to check the [icon guidelines](https://juju.ubuntu.com/docs/authors-charm-icon.html) so that your charm looks good in the Juju GUI.
41+
42+# Usage
43+
44+Step by step instructions on using the charm:
45+
46+ juju deploy servicename
47+
48+and so on. If you're providing a web service or something that the end user needs to go to, tell them here, especially if you're deploying a service that might listen to a non-default port.
49+
50+You can then browse to http://ip-address to configure the service.
51+
52+## Scale out Usage
53+
54+If the charm has any recommendations for running at scale, outline them in examples here. For example if you have a memcached relation that improves performance, mention it here.
55+
56+## Known Limitations and Issues
57+
58+This not only helps users but gives people a place to start if they want to help you add features to your charm.
59+
60+# Configuration
61+
62+The configuration options will be listed on the charm store, however If you're making assumptions or opinionated decisions in the charm (like setting a default administrator password), you should detail that here so the user knows how to change it immediately, etc.
63+
64+# Contact Information
65+
66+Though this will be listed in the charm store itself don't assume a user will know that, so include that information here:
67+
68+## Upstream Project Name
69+
70+- Upstream website
71+- Upstream bug tracker
72+- Upstream mailing list or contact information
73+- Feel free to add things if it's useful for users
74
75=== added file 'charmtools/templates/chef/files/config.yaml'
76--- charmtools/templates/chef/files/config.yaml 1970-01-01 00:00:00 +0000
77+++ charmtools/templates/chef/files/config.yaml 2014-11-18 19:19:34 +0000
78@@ -0,0 +1,14 @@
79+options:
80+ string-option:
81+ type: string
82+ default: "Default Value"
83+ description: "A short description of the configuration option"
84+ boolean-option:
85+ type: boolean
86+ default: False
87+ description: "A short description of the configuration option"
88+ int-option:
89+ type: int
90+ default: 9001
91+ description: "A short description of the configuration option"
92+
93
94=== added directory 'charmtools/templates/chef/files/hooks'
95=== added file 'charmtools/templates/chef/files/hooks/Gemfile'
96--- charmtools/templates/chef/files/hooks/Gemfile 1970-01-01 00:00:00 +0000
97+++ charmtools/templates/chef/files/hooks/Gemfile 2014-11-18 19:19:34 +0000
98@@ -0,0 +1,4 @@
99+source "https://rubygems.org"
100+
101+gem 'chef', '~> 11.6.0'
102+gem 'activesupport', '~> 4.0.0'
103\ No newline at end of file
104
105=== added file 'charmtools/templates/chef/files/hooks/Gemfile.lock'
106--- charmtools/templates/chef/files/hooks/Gemfile.lock 1970-01-01 00:00:00 +0000
107+++ charmtools/templates/chef/files/hooks/Gemfile.lock 2014-11-18 19:19:34 +0000
108@@ -0,0 +1,64 @@
109+GEM
110+ remote: https://rubygems.org/
111+ specs:
112+ activesupport (4.0.10)
113+ i18n (~> 0.6, >= 0.6.9)
114+ minitest (~> 4.2)
115+ multi_json (~> 1.3)
116+ thread_safe (~> 0.1)
117+ tzinfo (~> 0.3.37)
118+ chef (11.6.0)
119+ erubis
120+ highline (>= 1.6.9)
121+ json (>= 1.4.4, <= 1.7.7)
122+ mixlib-authentication (>= 1.3.0)
123+ mixlib-cli (~> 1.3.0)
124+ mixlib-config (>= 1.1.2)
125+ mixlib-log (>= 1.3.0)
126+ mixlib-shellout
127+ net-ssh (~> 2.6)
128+ net-ssh-multi (~> 1.1.0)
129+ ohai (>= 0.6.0)
130+ rest-client (>= 1.0.4, < 1.7.0)
131+ yajl-ruby (~> 1.1)
132+ erubis (2.7.0)
133+ highline (1.6.19)
134+ i18n (0.6.11)
135+ ipaddress (0.8.0)
136+ json (1.7.7)
137+ mime-types (1.23)
138+ minitest (4.7.5)
139+ mixlib-authentication (1.3.0)
140+ mixlib-log
141+ mixlib-cli (1.3.0)
142+ mixlib-config (1.1.2)
143+ mixlib-log (1.6.0)
144+ mixlib-shellout (1.2.0)
145+ multi_json (1.10.1)
146+ net-ssh (2.6.8)
147+ net-ssh-gateway (1.2.0)
148+ net-ssh (>= 2.6.5)
149+ net-ssh-multi (1.1)
150+ net-ssh (>= 2.1.4)
151+ net-ssh-gateway (>= 0.99.0)
152+ ohai (6.18.0)
153+ ipaddress
154+ mixlib-cli
155+ mixlib-config
156+ mixlib-log
157+ mixlib-shellout
158+ systemu
159+ yajl-ruby
160+ rest-client (1.6.7)
161+ mime-types (>= 1.16)
162+ systemu (2.5.2)
163+ thread_safe (0.3.4)
164+ tzinfo (0.3.41)
165+ yajl-ruby (1.1.0)
166+
167+PLATFORMS
168+ ruby
169+
170+DEPENDENCIES
171+ activesupport (~> 4.0.0)
172+ chef (~> 11.6.0)
173
174=== added file 'charmtools/templates/chef/files/hooks/bootstrap'
175--- charmtools/templates/chef/files/hooks/bootstrap 1970-01-01 00:00:00 +0000
176+++ charmtools/templates/chef/files/hooks/bootstrap 2014-11-18 19:19:34 +0000
177@@ -0,0 +1,20 @@
178+#!/bin/bash
179+set -e
180+
181+export HOOKS_DIR=$( cd "$( dirname "$0" )" && pwd)
182+
183+apt-get update
184+
185+sudo apt-get install -y ruby1.9.1 ruby1.9.1-dev \
186+ rubygems1.9.1 irb1.9.1 ri1.9.1 rdoc1.9.1 \
187+ build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev
188+
189+gem install bundler --no-rdoc --no-ri
190+
191+cd "$(dirname $0)" && bundle install
192+
193+mkdir -p /etc/chef
194+
195+cat > /etc/chef/solo.rb <<EOF
196+cookbook_path '$HOOKS_DIR/cookbooks'
197+EOF
198\ No newline at end of file
199
200=== added file 'charmtools/templates/chef/files/hooks/config-changed'
201--- charmtools/templates/chef/files/hooks/config-changed 1970-01-01 00:00:00 +0000
202+++ charmtools/templates/chef/files/hooks/config-changed 2014-11-18 19:19:34 +0000
203@@ -0,0 +1,4 @@
204+#!/bin/bash
205+set -e
206+
207+source $(dirname $0)/stub
208
209=== added directory 'charmtools/templates/chef/files/hooks/cookbooks'
210=== added directory 'charmtools/templates/chef/files/hooks/cookbooks/charm-name'
211=== added file 'charmtools/templates/chef/files/hooks/cookbooks/charm-name/metadata.rb'
212--- charmtools/templates/chef/files/hooks/cookbooks/charm-name/metadata.rb 1970-01-01 00:00:00 +0000
213+++ charmtools/templates/chef/files/hooks/cookbooks/charm-name/metadata.rb 2014-11-18 19:19:34 +0000
214@@ -0,0 +1,8 @@
215+maintainer "$metadata.maintainer"
216+maintainer_email "$metadata.maintainer"
217+license "GPL-3"
218+description "$metadata.summary"
219+
220+version "0.1"
221+name "$metadata.package"
222+depends "juju-helpers"
223
224=== added directory 'charmtools/templates/chef/files/hooks/cookbooks/charm-name/recipes'
225=== added file 'charmtools/templates/chef/files/hooks/cookbooks/charm-name/recipes/config-changed.rb'
226=== added file 'charmtools/templates/chef/files/hooks/cookbooks/charm-name/recipes/install.rb'
227=== added file 'charmtools/templates/chef/files/hooks/cookbooks/charm-name/recipes/start.rb'
228=== added file 'charmtools/templates/chef/files/hooks/cookbooks/charm-name/recipes/stop.rb'
229=== added file 'charmtools/templates/chef/files/hooks/cookbooks/charm-name/recipes/upgrade-charm.rb'
230=== added directory 'charmtools/templates/chef/files/hooks/cookbooks/juju-helpers'
231=== added directory 'charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/definitions'
232=== added file 'charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/definitions/juju_port.rb'
233--- charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/definitions/juju_port.rb 1970-01-01 00:00:00 +0000
234+++ charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/definitions/juju_port.rb 2014-11-18 19:19:34 +0000
235@@ -0,0 +1,11 @@
236+define :juju_port, action: :nothing do
237+ if params[:action] == :open
238+ execute "open-port #{params[:name]}" do
239+ action :run
240+ end
241+ elsif params[:action] == :close
242+ execute "close-port #{params[:name]}" do
243+ action :run
244+ end
245+ end
246+end
247\ No newline at end of file
248
249=== added file 'charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/definitions/relation_set.rb'
250--- charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/definitions/relation_set.rb 1970-01-01 00:00:00 +0000
251+++ charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/definitions/relation_set.rb 2014-11-18 19:19:34 +0000
252@@ -0,0 +1,10 @@
253+define :relation_set do
254+ args_string = params[:variables].map { |key, value| "#{key}=\"#{value}\"" }.join(' ')
255+
256+ command = "relation-set #{args_string}"
257+ command += " -r #{params[:relation_id]}" if params[:relation_id]
258+
259+ execute command do
260+ action :run
261+ end
262+end
263\ No newline at end of file
264
265=== added directory 'charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/libraries'
266=== added directory 'charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/libraries/juju'
267=== added file 'charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/libraries/juju.rb'
268--- charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/libraries/juju.rb 1970-01-01 00:00:00 +0000
269+++ charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/libraries/juju.rb 2014-11-18 19:19:34 +0000
270@@ -0,0 +1,28 @@
271+$: << File.expand_path('..', __FILE__)
272+
273+require 'active_support/all'
274+require 'juju/juju_helpers'
275+require 'juju/juju_helpers_dev'
276+
277+class Chef
278+ class Resource
279+ include JujuHelpers
280+ if ENV['JUJU_ENV'] == 'development'
281+ include JujuHelpersDev
282+ end
283+ end
284+
285+ class Recipe
286+ include JujuHelpers
287+ if ENV['JUJU_ENV'] == 'development'
288+ include JujuHelpersDev
289+ end
290+ end
291+
292+ class Provider
293+ include JujuHelpers
294+ if ENV['JUJU_ENV'] == 'development'
295+ include JujuHelpersDev
296+ end
297+ end
298+end
299\ No newline at end of file
300
301=== added file 'charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/libraries/juju/juju_helpers.rb'
302--- charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/libraries/juju/juju_helpers.rb 1970-01-01 00:00:00 +0000
303+++ charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/libraries/juju/juju_helpers.rb 2014-11-18 19:19:34 +0000
304@@ -0,0 +1,48 @@
305+module JujuHelpers
306+ HOOK_ENVIRONMENT = %w(juju_unit_name juju_relation juju_remote_unit)
307+ COMMANDS = ''
308+
309+ HOOK_ENVIRONMENT.each do |method|
310+ define_method method do
311+ ENV[method.upcase]
312+ end
313+ end
314+
315+ def relation_ids(relation_name = nil)
316+ commands = ['relation-ids --fromat=json']
317+ commands << relation_name if relation_name
318+ run(commands.join(' ')).try { |relations| JSON.load(relations) }
319+ end
320+
321+ def relation_list(relation_id = nil)
322+ commands = ['relation-list --format=json']
323+ commands << "-r #{relation_id}" if relation_id
324+ run(commands.join(' ')).try { |relations| JSON.load(relations) }
325+ end
326+
327+ def relation_get(unit_name = nil, relation_id = nil)
328+ commands = ['relation-get --format=json']
329+ commands << "-r #{relation_id}" if relation_id
330+ commands << '-'
331+ commands << unit_name if unit_name
332+ run(commands.join(' ')).try { |relation| JSON.load(relation) }
333+ end
334+
335+ def config_get
336+ run("config-get --format=json").try { |relation| JSON.load(relation) }
337+ end
338+
339+ def unit_get(key)
340+ run("unit-get #{key}")
341+ end
342+
343+ def juju_log(text)
344+ run("juju-log #{text}")
345+ end
346+
347+private
348+ def run(command)
349+ value = %x{ #{command} 2>&1 }.strip
350+ value.empty? ? nil : value
351+ end
352+end
353\ No newline at end of file
354
355=== added file 'charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/libraries/juju/juju_helpers_dev.rb'
356--- charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/libraries/juju/juju_helpers_dev.rb 1970-01-01 00:00:00 +0000
357+++ charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/libraries/juju/juju_helpers_dev.rb 2014-11-18 19:19:34 +0000
358@@ -0,0 +1,25 @@
359+module JujuHelpersDev
360+ def relation_ids(relation_name = nil)
361+ []
362+ end
363+
364+ def relation_list(relation_id = nil)
365+ {}
366+ end
367+
368+ def relation_get(unit_name = nil, relation_id = nil)
369+ {}
370+ end
371+
372+ def config_get
373+ {}
374+ end
375+
376+ def unit_get(key)
377+ nil
378+ end
379+
380+ def juju_log(text)
381+ puts text
382+ end
383+end
384\ No newline at end of file
385
386=== added file 'charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/metadata.rb'
387--- charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/metadata.rb 1970-01-01 00:00:00 +0000
388+++ charmtools/templates/chef/files/hooks/cookbooks/juju-helpers/metadata.rb 2014-11-18 19:19:34 +0000
389@@ -0,0 +1,7 @@
390+maintainer "Charles Butler"
391+maintainer_email "charles.butler@ubuntu.com"
392+license "GPL-3"
393+description "JuJu Helpers"
394+
395+version "0.2"
396+name "juju-helpers"
397
398=== added directory 'charmtools/templates/chef/files/hooks/cookbooks/relation-name-relation'
399=== added file 'charmtools/templates/chef/files/hooks/cookbooks/relation-name-relation/metadata.rb'
400--- charmtools/templates/chef/files/hooks/cookbooks/relation-name-relation/metadata.rb 1970-01-01 00:00:00 +0000
401+++ charmtools/templates/chef/files/hooks/cookbooks/relation-name-relation/metadata.rb 2014-11-18 19:19:34 +0000
402@@ -0,0 +1,8 @@
403+maintainer "$metadata.maintainer"
404+maintainer_email "$metadata.maintainer"
405+license "GPL-3"
406+description "$metadata.summary"
407+
408+version "0.1"
409+name "relation-name-relation"
410+depends "juju-helpers"
411
412=== added directory 'charmtools/templates/chef/files/hooks/cookbooks/relation-name-relation/recipes'
413=== added file 'charmtools/templates/chef/files/hooks/cookbooks/relation-name-relation/recipes/broken.rb'
414=== added file 'charmtools/templates/chef/files/hooks/cookbooks/relation-name-relation/recipes/changed.rb'
415=== added file 'charmtools/templates/chef/files/hooks/cookbooks/relation-name-relation/recipes/departed.rb'
416=== added file 'charmtools/templates/chef/files/hooks/cookbooks/relation-name-relation/recipes/joined.rb'
417=== added file 'charmtools/templates/chef/files/hooks/install'
418--- charmtools/templates/chef/files/hooks/install 1970-01-01 00:00:00 +0000
419+++ charmtools/templates/chef/files/hooks/install 2014-11-18 19:19:34 +0000
420@@ -0,0 +1,5 @@
421+#!/bin/bash
422+set -e
423+
424+source $(dirname $0)/bootstrap
425+source $(dirname $0)/stub
426\ No newline at end of file
427
428=== added file 'charmtools/templates/chef/files/hooks/relation-name-relation-broken'
429--- charmtools/templates/chef/files/hooks/relation-name-relation-broken 1970-01-01 00:00:00 +0000
430+++ charmtools/templates/chef/files/hooks/relation-name-relation-broken 2014-11-18 19:19:34 +0000
431@@ -0,0 +1,4 @@
432+#!/bin/bash
433+set -e
434+
435+source $(dirname $0)/stub
436
437=== added file 'charmtools/templates/chef/files/hooks/relation-name-relation-changed'
438--- charmtools/templates/chef/files/hooks/relation-name-relation-changed 1970-01-01 00:00:00 +0000
439+++ charmtools/templates/chef/files/hooks/relation-name-relation-changed 2014-11-18 19:19:34 +0000
440@@ -0,0 +1,4 @@
441+#!/bin/bash
442+set -e
443+
444+source $(dirname $0)/stub
445
446=== added file 'charmtools/templates/chef/files/hooks/relation-name-relation-departed'
447--- charmtools/templates/chef/files/hooks/relation-name-relation-departed 1970-01-01 00:00:00 +0000
448+++ charmtools/templates/chef/files/hooks/relation-name-relation-departed 2014-11-18 19:19:34 +0000
449@@ -0,0 +1,4 @@
450+#!/bin/bash
451+set -e
452+
453+source $(dirname $0)/stub
454
455=== added file 'charmtools/templates/chef/files/hooks/relation-name-relation-joined'
456--- charmtools/templates/chef/files/hooks/relation-name-relation-joined 1970-01-01 00:00:00 +0000
457+++ charmtools/templates/chef/files/hooks/relation-name-relation-joined 2014-11-18 19:19:34 +0000
458@@ -0,0 +1,4 @@
459+#!/bin/bash
460+set -e
461+
462+source $(dirname $0)/stub
463
464=== added file 'charmtools/templates/chef/files/hooks/start'
465--- charmtools/templates/chef/files/hooks/start 1970-01-01 00:00:00 +0000
466+++ charmtools/templates/chef/files/hooks/start 2014-11-18 19:19:34 +0000
467@@ -0,0 +1,4 @@
468+#!/bin/bash
469+set -e
470+
471+source $(dirname $0)/stub
472
473=== added file 'charmtools/templates/chef/files/hooks/stop'
474--- charmtools/templates/chef/files/hooks/stop 1970-01-01 00:00:00 +0000
475+++ charmtools/templates/chef/files/hooks/stop 2014-11-18 19:19:34 +0000
476@@ -0,0 +1,4 @@
477+#!/bin/bash
478+set -e
479+
480+source $(dirname $0)/stub
481
482=== added file 'charmtools/templates/chef/files/hooks/stub'
483--- charmtools/templates/chef/files/hooks/stub 1970-01-01 00:00:00 +0000
484+++ charmtools/templates/chef/files/hooks/stub 2014-11-18 19:19:34 +0000
485@@ -0,0 +1,15 @@
486+#!/bin/bash
487+set -e
488+
489+HOOK_NAME=\$(basename \$0)
490+CHARM_NAME=$metadata.package
491+
492+if [[ "\$HOOK_NAME" == *-relation-* ]]; then
493+ COOKBOOK_NAME="\${HOOK_NAME%-relation*}-relation"
494+ RECIPE_NAME=\${HOOK_NAME\#*relation-}
495+else
496+ COOKBOOK_NAME=\$CHARM_NAME
497+ RECIPE_NAME=\$HOOK_NAME
498+fi
499+
500+cd "\$(dirname \$0)" && bundle exec chef-solo -o "recipe[\$COOKBOOK_NAME::\$RECIPE_NAME]"
501
502=== added file 'charmtools/templates/chef/files/hooks/upgrade-charm'
503--- charmtools/templates/chef/files/hooks/upgrade-charm 1970-01-01 00:00:00 +0000
504+++ charmtools/templates/chef/files/hooks/upgrade-charm 2014-11-18 19:19:34 +0000
505@@ -0,0 +1,4 @@
506+#!/bin/bash
507+set -e
508+
509+source $(dirname $0)/stub
510
511=== added file 'charmtools/templates/chef/files/icon.svg'
512--- charmtools/templates/chef/files/icon.svg 1970-01-01 00:00:00 +0000
513+++ charmtools/templates/chef/files/icon.svg 2014-11-18 19:19:34 +0000
514@@ -0,0 +1,279 @@
515+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
516+<!-- Created with Inkscape (http://www.inkscape.org/) -->
517+
518+<svg
519+ xmlns:dc="http://purl.org/dc/elements/1.1/"
520+ xmlns:cc="http://creativecommons.org/ns#"
521+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
522+ xmlns:svg="http://www.w3.org/2000/svg"
523+ xmlns="http://www.w3.org/2000/svg"
524+ xmlns:xlink="http://www.w3.org/1999/xlink"
525+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
526+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
527+ width="96"
528+ height="96"
529+ id="svg6517"
530+ version="1.1"
531+ inkscape:version="0.48+devel r12274"
532+ sodipodi:docname="Juju_charm_icon_template.svg">
533+ <defs
534+ id="defs6519">
535+ <linearGradient
536+ inkscape:collect="always"
537+ xlink:href="#Background"
538+ id="linearGradient6461"
539+ gradientUnits="userSpaceOnUse"
540+ x1="0"
541+ y1="970.29498"
542+ x2="144"
543+ y2="970.29498"
544+ gradientTransform="matrix(0,-0.66666669,0.6660448,0,-866.25992,731.29077)" />
545+ <linearGradient
546+ id="Background">
547+ <stop
548+ id="stop4178"
549+ offset="0"
550+ style="stop-color:#b8b8b8;stop-opacity:1" />
551+ <stop
552+ id="stop4180"
553+ offset="1"
554+ style="stop-color:#c9c9c9;stop-opacity:1" />
555+ </linearGradient>
556+ <filter
557+ style="color-interpolation-filters:sRGB;"
558+ inkscape:label="Inner Shadow"
559+ id="filter1121">
560+ <feFlood
561+ flood-opacity="0.59999999999999998"
562+ flood-color="rgb(0,0,0)"
563+ result="flood"
564+ id="feFlood1123" />
565+ <feComposite
566+ in="flood"
567+ in2="SourceGraphic"
568+ operator="out"
569+ result="composite1"
570+ id="feComposite1125" />
571+ <feGaussianBlur
572+ in="composite1"
573+ stdDeviation="1"
574+ result="blur"
575+ id="feGaussianBlur1127" />
576+ <feOffset
577+ dx="0"
578+ dy="2"
579+ result="offset"
580+ id="feOffset1129" />
581+ <feComposite
582+ in="offset"
583+ in2="SourceGraphic"
584+ operator="atop"
585+ result="composite2"
586+ id="feComposite1131" />
587+ </filter>
588+ <filter
589+ style="color-interpolation-filters:sRGB;"
590+ inkscape:label="Drop Shadow"
591+ id="filter950">
592+ <feFlood
593+ flood-opacity="0.25"
594+ flood-color="rgb(0,0,0)"
595+ result="flood"
596+ id="feFlood952" />
597+ <feComposite
598+ in="flood"
599+ in2="SourceGraphic"
600+ operator="in"
601+ result="composite1"
602+ id="feComposite954" />
603+ <feGaussianBlur
604+ in="composite1"
605+ stdDeviation="1"
606+ result="blur"
607+ id="feGaussianBlur956" />
608+ <feOffset
609+ dx="0"
610+ dy="1"
611+ result="offset"
612+ id="feOffset958" />
613+ <feComposite
614+ in="SourceGraphic"
615+ in2="offset"
616+ operator="over"
617+ result="composite2"
618+ id="feComposite960" />
619+ </filter>
620+ <clipPath
621+ clipPathUnits="userSpaceOnUse"
622+ id="clipPath873">
623+ <g
624+ transform="matrix(0,-0.66666667,0.66604479,0,-258.25992,677.00001)"
625+ id="g875"
626+ inkscape:label="Layer 1"
627+ style="fill:#ff00ff;fill-opacity:1;stroke:none;display:inline">
628+ <path
629+ style="fill:#ff00ff;fill-opacity:1;stroke:none;display:inline"
630+ d="m 46.702703,898.22775 50.594594,0 C 138.16216,898.22775 144,904.06497 144,944.92583 l 0,50.73846 c 0,40.86071 -5.83784,46.69791 -46.702703,46.69791 l -50.594594,0 C 5.8378378,1042.3622 0,1036.525 0,995.66429 L 0,944.92583 C 0,904.06497 5.8378378,898.22775 46.702703,898.22775 Z"
631+ id="path877"
632+ inkscape:connector-curvature="0"
633+ sodipodi:nodetypes="sssssssss" />
634+ </g>
635+ </clipPath>
636+ <filter
637+ inkscape:collect="always"
638+ id="filter891"
639+ inkscape:label="Badge Shadow">
640+ <feGaussianBlur
641+ inkscape:collect="always"
642+ stdDeviation="0.71999962"
643+ id="feGaussianBlur893" />
644+ </filter>
645+ </defs>
646+ <sodipodi:namedview
647+ id="base"
648+ pagecolor="#ffffff"
649+ bordercolor="#666666"
650+ borderopacity="1.0"
651+ inkscape:pageopacity="0.0"
652+ inkscape:pageshadow="2"
653+ inkscape:zoom="4.0745362"
654+ inkscape:cx="18.514671"
655+ inkscape:cy="49.018169"
656+ inkscape:document-units="px"
657+ inkscape:current-layer="layer1"
658+ showgrid="true"
659+ fit-margin-top="0"
660+ fit-margin-left="0"
661+ fit-margin-right="0"
662+ fit-margin-bottom="0"
663+ inkscape:window-width="1920"
664+ inkscape:window-height="1029"
665+ inkscape:window-x="0"
666+ inkscape:window-y="24"
667+ inkscape:window-maximized="1"
668+ showborder="true"
669+ showguides="true"
670+ inkscape:guide-bbox="true"
671+ inkscape:showpageshadow="false">
672+ <inkscape:grid
673+ type="xygrid"
674+ id="grid821" />
675+ <sodipodi:guide
676+ orientation="1,0"
677+ position="16,48"
678+ id="guide823" />
679+ <sodipodi:guide
680+ orientation="0,1"
681+ position="64,80"
682+ id="guide825" />
683+ <sodipodi:guide
684+ orientation="1,0"
685+ position="80,40"
686+ id="guide827" />
687+ <sodipodi:guide
688+ orientation="0,1"
689+ position="64,16"
690+ id="guide829" />
691+ </sodipodi:namedview>
692+ <metadata
693+ id="metadata6522">
694+ <rdf:RDF>
695+ <cc:Work
696+ rdf:about="">
697+ <dc:format>image/svg+xml</dc:format>
698+ <dc:type
699+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
700+ <dc:title></dc:title>
701+ </cc:Work>
702+ </rdf:RDF>
703+ </metadata>
704+ <g
705+ inkscape:label="BACKGROUND"
706+ inkscape:groupmode="layer"
707+ id="layer1"
708+ transform="translate(268,-635.29076)"
709+ style="display:inline">
710+ <path
711+ style="fill:url(#linearGradient6461);fill-opacity:1;stroke:none;display:inline;filter:url(#filter1121)"
712+ d="m -268,700.15563 0,-33.72973 c 0,-27.24324 3.88785,-31.13513 31.10302,-31.13513 l 33.79408,0 c 27.21507,0 31.1029,3.89189 31.1029,31.13513 l 0,33.72973 c 0,27.24325 -3.88783,31.13514 -31.1029,31.13514 l -33.79408,0 C -264.11215,731.29077 -268,727.39888 -268,700.15563 Z"
713+ id="path6455"
714+ inkscape:connector-curvature="0"
715+ sodipodi:nodetypes="sssssssss" />
716+ </g>
717+ <g
718+ inkscape:groupmode="layer"
719+ id="layer3"
720+ inkscape:label="PLACE YOUR PICTOGRAM HERE"
721+ style="display:inline" />
722+ <g
723+ inkscape:groupmode="layer"
724+ id="layer2"
725+ inkscape:label="BADGE"
726+ style="display:none"
727+ sodipodi:insensitive="true">
728+ <g
729+ style="display:inline"
730+ transform="translate(-340.00001,-581)"
731+ id="g4394"
732+ clip-path="none">
733+ <g
734+ id="g855">
735+ <g
736+ inkscape:groupmode="maskhelper"
737+ id="g870"
738+ clip-path="url(#clipPath873)"
739+ style="opacity:0.6;filter:url(#filter891)">
740+ <path
741+ transform="matrix(1.4999992,0,0,1.4999992,-29.999795,-237.54282)"
742+ d="m 264,552.36218 a 12,12 0 1 1 -24,0 A 12,12 0 1 1 264,552.36218 Z"
743+ sodipodi:ry="12"
744+ sodipodi:rx="12"
745+ sodipodi:cy="552.36218"
746+ sodipodi:cx="252"
747+ id="path844"
748+ style="color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:4;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
749+ sodipodi:type="arc" />
750+ </g>
751+ <g
752+ id="g862">
753+ <path
754+ sodipodi:type="arc"
755+ style="color:#000000;fill:#f5f5f5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:4;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
756+ id="path4398"
757+ sodipodi:cx="252"
758+ sodipodi:cy="552.36218"
759+ sodipodi:rx="12"
760+ sodipodi:ry="12"
761+ d="m 264,552.36218 a 12,12 0 1 1 -24,0 A 12,12 0 1 1 264,552.36218 Z"
762+ transform="matrix(1.4999992,0,0,1.4999992,-29.999795,-238.54282)" />
763+ <path
764+ transform="matrix(1.25,0,0,1.25,33,-100.45273)"
765+ d="m 264,552.36218 a 12,12 0 1 1 -24,0 A 12,12 0 1 1 264,552.36218 Z"
766+ sodipodi:ry="12"
767+ sodipodi:rx="12"
768+ sodipodi:cy="552.36218"
769+ sodipodi:cx="252"
770+ id="path4400"
771+ style="color:#000000;fill:#dd4814;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:4;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
772+ sodipodi:type="arc" />
773+ <path
774+ sodipodi:type="star"
775+ style="color:#000000;fill:#f5f5f5;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
776+ id="path4459"
777+ sodipodi:sides="5"
778+ sodipodi:cx="666.19574"
779+ sodipodi:cy="589.50385"
780+ sodipodi:r1="7.2431178"
781+ sodipodi:r2="4.3458705"
782+ sodipodi:arg1="1.0471976"
783+ sodipodi:arg2="1.6755161"
784+ inkscape:flatsided="false"
785+ inkscape:rounded="0.1"
786+ inkscape:randomized="0"
787+ d="m 669.8173,595.77657 c -0.39132,0.22593 -3.62645,-1.90343 -4.07583,-1.95066 -0.44938,-0.0472 -4.05653,1.36297 -4.39232,1.06062 -0.3358,-0.30235 0.68963,-4.03715 0.59569,-4.47913 -0.0939,-0.44198 -2.5498,-3.43681 -2.36602,-3.8496 0.18379,-0.41279 4.05267,-0.59166 4.44398,-0.81759 0.39132,-0.22593 2.48067,-3.48704 2.93005,-3.4398 0.44938,0.0472 1.81505,3.67147 2.15084,3.97382 0.3358,0.30236 4.08294,1.2817 4.17689,1.72369 0.0939,0.44198 -2.9309,2.86076 -3.11469,3.27355 C 669.9821,591.68426 670.20862,595.55064 669.8173,595.77657 Z"
788+ transform="matrix(1.511423,-0.16366377,0.16366377,1.511423,-755.37346,-191.93651)" />
789+ </g>
790+ </g>
791+ </g>
792+ </g>
793+</svg>
794
795=== added file 'charmtools/templates/chef/files/metadata.yaml'
796--- charmtools/templates/chef/files/metadata.yaml 1970-01-01 00:00:00 +0000
797+++ charmtools/templates/chef/files/metadata.yaml 2014-11-18 19:19:34 +0000
798@@ -0,0 +1,17 @@
799+name: $metadata.package
800+summary: $metadata.summary
801+maintainer: $metadata.maintainer
802+description: |
803+ $metadata.description
804+tags:
805+ - misc
806+subordinate: false
807+provides:
808+ provides-relation:
809+ interface: interface-name
810+requires:
811+ requires-relation:
812+ interface: interface-name
813+peers:
814+ peer-relation:
815+ interface: interface-name
816
817=== added directory 'charmtools/templates/chef/files/tests'
818=== added file 'charmtools/templates/chef/files/tests/00-setup'
819--- charmtools/templates/chef/files/tests/00-setup 1970-01-01 00:00:00 +0000
820+++ charmtools/templates/chef/files/tests/00-setup 2014-11-18 19:19:34 +0000
821@@ -0,0 +1,5 @@
822+#!/bin/bash
823+
824+sudo add-apt-repository -y ppa:juju/stable
825+sudo apt-get update
826+sudo apt-get install -y amulet python-requests
827
828=== added file 'charmtools/templates/chef/files/tests/99-autogen'
829--- charmtools/templates/chef/files/tests/99-autogen 1970-01-01 00:00:00 +0000
830+++ charmtools/templates/chef/files/tests/99-autogen 2014-11-18 19:19:34 +0000
831@@ -0,0 +1,50 @@
832+#!/usr/bin/env python3
833+
834+import amulet
835+import requests
836+import unittest
837+
838+
839+class TestDeployment(unittest.TestCase):
840+ @classmethod
841+ def setUpClass(cls):
842+ cls.deployment = amulet.Deployment(series='trusty')
843+
844+ cls.deployment.add('$metadata.package')
845+ cls.deployment.expose('$metadata.package')
846+
847+ try:
848+ cls.deployment.setup(timeout=900)
849+ cls.deployment.sentry.wait()
850+ except amulet.helpers.TimeoutError:
851+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
852+ except:
853+ raise
854+
855+ def test_case(self):
856+ # Now you can use self.deployment.sentry.unit[UNIT] to address each of
857+ # the units and perform more in-depth steps. You can also reference
858+ # the first unit as self.unit.
859+ # There are three test statuses that can be triggered with
860+ # amulet.raise_status():
861+ # - amulet.PASS
862+ # - amulet.FAIL
863+ # - amulet.SKIP
864+ # Each unit has the following methods:
865+ # - .info - An array of the information of that unit from Juju
866+ # - .file(PATH) - Get the details of a file on that unit
867+ # - .file_contents(PATH) - Get plain text output of PATH file from that unit
868+ # - .directory(PATH) - Get details of directory
869+ # - .directory_contents(PATH) - List files and folders in PATH on that unit
870+ # - .relation(relation, service:rel) - Get relation data from return service
871+ # add tests here to confirm service is up and working properly
872+ # For example, to confirm that it has a functioning HTTP server:
873+ # page = requests.get('http://{}'.format(self.unit.info['public-address']))
874+ # page.raise_for_status()
875+ # More information on writing Amulet tests can be found at:
876+ # https://juju.ubuntu.com/docs/tools-amulet.html
877+ pass
878+
879+
880+if __name__ == '__main__':
881+ unittest.main()
882
883=== added file 'charmtools/templates/chef/template.py'
884--- charmtools/templates/chef/template.py 1970-01-01 00:00:00 +0000
885+++ charmtools/templates/chef/template.py 2014-11-18 19:19:34 +0000
886@@ -0,0 +1,76 @@
887+#!/usr/bin/python
888+#
889+# Copyright (C) 2014 Canonical Ltd.
890+#
891+# This program is free software: you can redistribute it and/or modify
892+# it under the terms of the GNU General Public License as published by
893+# the Free Software Foundation, either version 3 of the License, or
894+# (at your option) any later version.
895+#
896+# This program is distributed in the hope that it will be useful,
897+# but WITHOUT ANY WARRANTY; without even the implied warranty of
898+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
899+# GNU General Public License for more details.
900+#
901+# You should have received a copy of the GNU General Public License
902+# along with this program. If not, see <http://www.gnu.org/licenses/>.
903+
904+import logging
905+import os
906+import os.path as path
907+import time
908+import shutil
909+import tempfile
910+
911+from Cheetah.Template import Template
912+from stat import ST_MODE
913+
914+from charmtools.generators import (
915+ CharmTemplate,
916+)
917+
918+log = logging.getLogger(__name__)
919+
920+
921+class ChefCharmTemplate(CharmTemplate):
922+
923+ def create_charm(self, config, output_dir):
924+ cb_path = "hooks/cookbooks/{}".format(config['metadata']['package'])
925+
926+ to_parse = ['metadata.yaml', 'metadata.rb', 'stub', '99-autogen']
927+
928+ self._copy_files(output_dir, cb_path)
929+ for root, dirs, files in os.walk(output_dir):
930+ for outfile in files:
931+ if outfile in to_parse:
932+ self._template_file(config, path.join(root, outfile))
933+
934+
935+ def _copy_files(self, output_dir, cb_path):
936+ here = path.abspath(path.dirname(__file__))
937+ template_dir = path.join(here, 'files')
938+ if os.path.exists(output_dir):
939+ shutil.rmtree(output_dir)
940+ shutil.copytree(template_dir, output_dir)
941+ self._setup_cookbook(output_dir, cb_path)
942+
943+ def _setup_cookbook(self, output_dir, cb_path):
944+ outpath = "{}/hooks/cookbooks/charm-name".format(output_dir)
945+ cb_path = "{}/{}".format(output_dir, cb_path)
946+ shutil.move(outpath, cb_path)
947+
948+ def _template_file(self, config, outfile):
949+ if path.islink(outfile):
950+ return
951+
952+ mode = os.stat(outfile)[ST_MODE]
953+ t = Template(file=outfile, searchList=(config))
954+ o = tempfile.NamedTemporaryFile(
955+ dir=path.dirname(outfile), delete=False)
956+ os.chmod(o.name, mode)
957+ o.write(str(t))
958+ o.close()
959+ backupname = outfile + str(time.time())
960+ os.rename(outfile, backupname)
961+ os.rename(o.name, outfile)
962+ os.unlink(backupname)
963
964=== modified file 'setup.py'
965--- setup.py 2014-11-05 22:36:57 +0000
966+++ setup.py 2014-11-18 19:19:34 +0000
967@@ -61,6 +61,7 @@
968 'python = charmtools.templates.python_services'
969 ':PythonServicesCharmTemplate',
970 'ansible = charmtools.templates.ansible:AnsibleCharmTemplate',
971+ 'chef = charmtools.templates.chef:ChefCharmTemplate'
972 ]
973 },
974 )
975
976=== modified file 'tests_functional/create/test.sh'
977--- tests_functional/create/test.sh 2014-06-25 16:31:59 +0000
978+++ tests_functional/create/test.sh 2014-11-18 19:19:34 +0000
979@@ -55,6 +55,10 @@
980 echo ===== Testing ansible charm template =====
981 $PYTHON $TESTDIR/test_ansible_create.py
982
983+echo ===== Testing chef charm template =====
984+$PYTHON $TESTDIR/test_chef_create.py
985+
986+
987 echo ===== All tests passed! =====
988 echo PASS
989 set +e
990
991=== added file 'tests_functional/create/test_chef_create.py'
992--- tests_functional/create/test_chef_create.py 1970-01-01 00:00:00 +0000
993+++ tests_functional/create/test_chef_create.py 2014-11-18 19:19:34 +0000
994@@ -0,0 +1,114 @@
995+#!/usr/bin/python
996+
997+# Copyright (C) 2014 Canonical Ltd.
998+#
999+# This program is free software: you can redistribute it and/or modify
1000+# it under the terms of the GNU General Public License as published by
1001+# the Free Software Foundation, either version 3 of the License, or
1002+# (at your option) any later version.
1003+#
1004+# This program is distributed in the hope that it will be useful,
1005+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1006+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1007+# GNU General Public License for more details.
1008+#
1009+# You should have received a copy of the GNU General Public License
1010+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1011+
1012+import os
1013+import shutil
1014+import tempfile
1015+import unittest
1016+
1017+from mock import patch
1018+from os.path import join
1019+from unittest import TestCase
1020+
1021+import yaml
1022+
1023+from charmtools.create import (
1024+ main,
1025+)
1026+
1027+
1028+def flatten(path):
1029+ for root, dirs, files in os.walk(path):
1030+ for f in files:
1031+ yield join(root[len(path):], f).lstrip('/')
1032+
1033+
1034+class ChefCreateTest(TestCase):
1035+ maxDiff = None
1036+
1037+ def setUp(self):
1038+ self.tempdir = tempfile.mkdtemp()
1039+
1040+ def tearDown(self):
1041+ shutil.rmtree(self.tempdir)
1042+
1043+ def _expected_files(self):
1044+ static_files = [
1045+ 'hooks/config-changed',
1046+ 'hooks/install',
1047+ 'hooks/start',
1048+ 'hooks/stop',
1049+ 'hooks/stub',
1050+ 'hooks/Gemfile',
1051+ 'hooks/Gemfile.lock',
1052+ 'hooks/bootstrap',
1053+ 'hooks/upgrade-charm',
1054+ 'hooks/relation-name-relation-broken',
1055+ 'hooks/relation-name-relation-changed',
1056+ 'hooks/relation-name-relation-departed',
1057+ 'hooks/relation-name-relation-joined',
1058+ 'hooks/cookbooks/testcharm/metadata.rb',
1059+ 'hooks/cookbooks/testcharm/recipes/config-changed.rb',
1060+ 'hooks/cookbooks/testcharm/recipes/install.rb',
1061+ 'hooks/cookbooks/testcharm/recipes/start.rb',
1062+ 'hooks/cookbooks/testcharm/recipes/stop.rb',
1063+ 'hooks/cookbooks/testcharm/recipes/upgrade-charm.rb',
1064+ 'hooks/cookbooks/juju-helpers/definitions/juju_port.rb',
1065+ 'hooks/cookbooks/juju-helpers/definitions/relation_set.rb',
1066+ 'hooks/cookbooks/juju-helpers/libraries/juju.rb',
1067+ 'hooks/cookbooks/juju-helpers/libraries/juju/juju_helpers_dev.rb',
1068+ 'hooks/cookbooks/juju-helpers/libraries/juju/juju_helpers.rb',
1069+ 'hooks/cookbooks/juju-helpers/metadata.rb',
1070+ 'hooks/cookbooks/relation-name-relation/metadata.rb',
1071+ 'hooks/cookbooks/relation-name-relation/recipes/broken.rb',
1072+ 'hooks/cookbooks/relation-name-relation/recipes/changed.rb',
1073+ 'hooks/cookbooks/relation-name-relation/recipes/departed.rb',
1074+ 'hooks/cookbooks/relation-name-relation/recipes/joined.rb',
1075+ 'tests/00-setup',
1076+ 'tests/99-autogen',
1077+ 'icon.svg',
1078+ 'metadata.yaml',
1079+ 'README.ex',
1080+ 'config.yaml',
1081+ ]
1082+ return sorted(static_files)
1083+
1084+ @patch('charmtools.create.setup_parser')
1085+ def test_default(self, setup_parser):
1086+ """Test of `charm create -t chef testcharm`"""
1087+ class args(object):
1088+ charmname = 'testcharm'
1089+ charmhome = self.tempdir
1090+ template = 'chef'
1091+ accept_defaults = True
1092+ verbose = False
1093+
1094+ setup_parser.return_value.parse_args.return_value = args
1095+
1096+ main()
1097+
1098+ outputdir = join(self.tempdir, args.charmname)
1099+ actual_files = sorted(flatten(outputdir))
1100+ expected_files = self._expected_files()
1101+ metadata = yaml.load(open(join(outputdir, 'metadata.yaml'), 'r'))
1102+
1103+ self.assertEqual(expected_files, actual_files)
1104+ self.assertEqual(metadata['name'], args.charmname)
1105+
1106+
1107+if __name__ == '__main__':
1108+ unittest.main()

Subscribers

People subscribed via source and target branches

to all changes: