~bloodearnest/charm-helpers/ppa-tools

« back to all changes in this revision

Viewing changes to tools/charm_helpers_sync/README

  • Committer: Michael Nelson
  • Date: 2013-07-09 10:07:34 UTC
  • mfrom: (36.1.3 ensure_etc_salt_exists)
  • Revision ID: michael.nelson@canonical.com-20130709100734-wg0mb1zo9h5etlcn
Merged ensure_etc_salt_exists into namespace-relation-data.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Script for synchronizing charm-helpers into a charm branch.
 
2
 
 
3
This script is intended to be used by charm authors during the development
 
4
of their charm.  It allows authors to pull in bits of a charm-helpers source
 
5
tree and embed directly into their charm, to be deployed with the rest of
 
6
their hooks and charm payload.  This script is not intended to be called
 
7
by the hooks themselves, but instead by the charm author while they are
 
8
hacking on a charm offline.  Consider it a method of compiling specific
 
9
revision of a charm-helpers branch into a given charm source tree.
 
10
 
 
11
Some goals and benefits to using a sync tool to manage this process:
 
12
 
 
13
    - Reduces the burden of manually copying in upstream charm helpers code
 
14
      into a charm and helps ensure we can easily keep a specific charm's
 
15
      helper code up to date.
 
16
 
 
17
    - Allows authors to hack on their own working branch of charm-helpers,
 
18
      easily sync into their WIP charm.  Any changes they've made to charm
 
19
      helpers can be upstreamed via a merge of their charm-helpers branch
 
20
      into lp:charm-helpers, ideally at the same time they are upstreaming
 
21
      the charm itself into the charm store.  Separating charm helper
 
22
      development from charm development can help reduce cases where charms
 
23
      are shipping locally modified helpers.
 
24
 
 
25
    - Avoids the need to ship the *entire* lp:charm-helpers source tree with
 
26
      a charm.  Authors can selectively pick and choose what subset of helpers
 
27
      to include to satisfy the goals of their charm.
 
28
 
 
29
Loosely based on OpenStack's oslo-incubator:
 
30
 
 
31
    https://github.com/openstack/oslo-incubator.git
 
32
 
 
33
Allows specifying a list of dependencies to sync in from a charm-helpers
 
34
branch.  Ideally, each charm should describe its requirements in a yaml
 
35
config included in the charm, eg charm-helpers.yaml (NOTE: Example module
 
36
layout as of 05/30/2013):
 
37
 
 
38
    $ cd my-charm
 
39
    $ cat >charm-helpers.yaml <<END
 
40
    destination: hooks/helpers
 
41
    branch: lp:charm-helpers
 
42
    include:
 
43
        - core
 
44
        - contrib.openstack
 
45
        - contrib.hahelpers:
 
46
            - ceph_utils
 
47
    END
 
48
 
 
49
includes may be defined as entire module sub-directories, or as invidual
 
50
.py files with in a module sub-directory.
 
51
 
 
52
Charm author can then sync in and update helpers as needed.  The following
 
53
import all of charmhelpers.core + charmhelpers.contrib.openstack, and only
 
54
ceph_utils.py from charmhelpers.contrib.hahelpers:
 
55
 
 
56
    $ charm-helper-sync -c charm-helpers.yaml
 
57
    $ find hooks/helpers/
 
58
    hooks/helpers/
 
59
    hooks/helpers/contrib
 
60
    hooks/helpers/contrib/openstack
 
61
    hooks/helpers/contrib/openstack/openstack_utils.py
 
62
    hooks/helpers/contrib/openstack/__init__.py
 
63
    hooks/helpers/contrib/hahelpers
 
64
    hooks/helpers/contrib/hahelpers/ceph_utils.py
 
65
    hooks/helpers/contrib/hahelpers/__init__.py
 
66
    hooks/helpers/contrib/__init__.py
 
67
    hooks/helpers/core
 
68
    hooks/helpers/core/hookenv.py
 
69
    hooks/helpers/core/host.py
 
70
    hooks/helpers/core/__init__.py
 
71
    hooks/helpers/__init__.py
 
72
 
 
73
 
 
74
Script will create missing __init__.py's to ensure each subdirectory is
 
75
importable, assuming the script is run from the charm's top-level directory.
 
76
 
 
77
You may also override configured destination directory and source bzr
 
78
branch:
 
79
 
 
80
    $ charm-helper-sync -b ~/src/bzr/charm-helpers-dev \
 
81
            -d hooks/helpers-test \
 
82
            -c charm-helpers.yaml
 
83
 
 
84
Or not use a config file at all:
 
85
    $ charm-helper-sync -b lp:~gandelman-a/charm-helpers/fixes \
 
86
            -d hooks/helpers core contrib.openstack contrib.hahelpers
 
87
 
 
88
Script will create missing __init__.py's to ensure each subdirectory is
 
89
importable, assuming the script is run from the charm's top-level directory.