Merge ~hopem/stsstack-bundles:cleanup-k8-channel-commit into stsstack-bundles:master

Proposed by Edward Hope-Morley
Status: Merged
Approved by: Edward Hope-Morley
Approved revision: adf5a83c41bd3ad1592fbc1b5e12fd4f911ce9f9
Merged at revision: adf5a83c41bd3ad1592fbc1b5e12fd4f911ce9f9
Proposed branch: ~hopem/stsstack-bundles:cleanup-k8-channel-commit
Merge into: stsstack-bundles:master
Diff against target: 298 lines (+44/-52)
8 files modified
ceph/generate-bundle.sh (+4/-3)
common/generate-bundle-base.sh (+11/-35)
common/helpers.sh (+3/-1)
kubernetes/generate-bundle.sh (+13/-4)
kubernetes/kubernetes.yaml.template (+1/-1)
landscape/generate-bundle.sh (+4/-2)
openstack/generate-bundle.sh (+4/-3)
swift/generate-bundle.sh (+4/-3)
Reviewer Review Type Date Requested Status
Rodrigo Barbieri (community) Approve
Felipe Reyes Pending
Review via email: mp+369026@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Rodrigo Barbieri (rodrigo-barbieri2010) wrote :

LGTM now, thanks Ed!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/ceph/generate-bundle.sh b/ceph/generate-bundle.sh
2index 72298d0..6f8ef1a 100755
3--- a/ceph/generate-bundle.sh
4+++ b/ceph/generate-bundle.sh
5@@ -1,10 +1,10 @@
6 #!/bin/bash -eu
7-CACHED_STDIN=( $@ )
8 # imports
9 LIB_COMMON=`dirname $0`/common
10 . $LIB_COMMON/helpers.sh
11
12-# vars
13+# This list provides a way to set "internal opts" i.e. the ones accepted by
14+# the top-level generate-bundle.sh. The need to modify these should be rare.
15 opts=(
16 --internal-template ceph.yaml.template
17 --internal-generator-path $0
18@@ -23,7 +23,8 @@ declare -A app_versions=( [firefly]=icehouse
19 EOF
20 cat $LIB_COMMON/openstack_release_info.sh >> $f_rel_info
21
22-# defaults
23+# Bundle template parameters. These should correspond to variables set at the top
24+# of yaml bundle and overlay templates.
25 parameters[__NUM_CEPH_MON_UNITS__]=1
26 parameters[__NUM_VAULT_UNITS__]=1 # there are > 1 vault* overlay so need to use a global with default
27 parameters[__SSL_CA__]=
28diff --git a/common/generate-bundle-base.sh b/common/generate-bundle-base.sh
29index cd09f55..4975e3e 100644
30--- a/common/generate-bundle-base.sh
31+++ b/common/generate-bundle-base.sh
32@@ -1,26 +1,16 @@
33 #!/bin/bash -eu
34 #
35-# Author: edward.hope-morley@canonical.com
36-#
37-# Description: Use this tool to generate a Juju (2.x) native-format bundle e.g.
38-#
39-# Xenial + Queens UCA: ./generate-bundle.sh --series xenial --release queens
40-#
41-# Bionic (Queens) Proposed: ./generate-bundle.sh --series bionic --pocket proposed
42-#
43-# Bionic + Stein UCA: ./generate-bundle.sh --release stein
44-#
45+# PLEASE AVOID PUTTING BUNDLE-SPECIFIC CODE IN HERE. INSTEAD USE THE INDIVIDUAL
46+# BUNDLE GENERATORS.
47 #
48 series_provided=false
49 pocket=
50 template=
51 path=
52-k8s_channel="latest/stable"
53 charm_channel=
54 params_path=
55 bundle_name=
56 replay=false
57-is_k8s=false
58 run_command=false
59 list_bundles=false
60 create_model=false
61@@ -35,6 +25,10 @@ release=`get_release`
62 while (($# > 0))
63 do
64 case "$1" in
65+ --charm-channel)
66+ charm_channel=$2
67+ shift
68+ ;;
69 --create-model)
70 # creates a model using the value provided by --name
71 create_model=true
72@@ -53,11 +47,6 @@ do
73 pocket=$2
74 shift
75 ;;
76- --k8s-channel)
77- # which Kubernetes channel to set on deployment
78- k8s_channel=$2
79- shift
80- ;;
81 --name|-n)
82 # give bundle set a name and store under named dir
83 bundle_name=$2
84@@ -67,10 +56,6 @@ do
85 # replay the last recorded command if exists
86 replay=true
87 ;;
88- --K8S)
89- # marks this as a K8S deployment to use --channel=edge by default
90- is_k8s=true
91- ;;
92 --list)
93 list_bundles=true
94 ;;
95@@ -115,10 +100,6 @@ do
96 shift
97 done
98
99-if ! $use_stable_charms && $is_k8s; then
100- charm_channel="edge"
101-fi
102-
103 if $create_model; then
104 if [ -z "$bundle_name" ]; then
105 echo "ERROR: no --name provided so cannot create Juju model"
106@@ -253,13 +234,9 @@ os_origin=$source
107
108 render () {
109 # generic replacements
110-tmp_path=$1
111-fixed_channel=$(echo "$k8s_channel" | sed 's/\//\\\//g')
112-fixed_channel=$(echo "$fixed_channel" | sed 's/\./\\\./g')
113-sed -i -e "s/__SERIES__/$series/g" \
114- -e "s/__OS_ORIGIN__/$os_origin/g" \
115- -e "s/__SOURCE__/$source/g" \
116- -e "s/__CHANNEL__/$fixed_channel/g" $tmp_path
117+sed -i -e "s,__SERIES__,$series,g" \
118+ -e "s,__OS_ORIGIN__,$os_origin,g" \
119+ -e "s,__SOURCE__,$source,g" $1
120
121 # service-specific replacements
122 if [ -n "$params_path" ]; then
123@@ -272,7 +249,7 @@ fi
124 }
125
126 dtmp=`mktemp -d`
127-fout=$dtmp/`basename $template| sed 's/.template//'`
128+fout=$dtmp/`basename $template| sed 's,.template,,'`
129 cp $template $fout
130 render $fout
131
132@@ -310,10 +287,9 @@ else
133 fi
134
135 channel_param=
136-
137 if [ -n "$charm_channel" ]; then
138 channel_param="--channel=$charm_channel"
139 fi
140
141-echo -e "juju deploy ${result} ${_overlays[@]:-} $channel_param \n " > ${bundles_dir}/command
142+echo -e "juju deploy ${result} ${_overlays[@]:-\b} ${channel_param}\n " > ${bundles_dir}/command
143 finish
144diff --git a/common/helpers.sh b/common/helpers.sh
145index 5d0712f..177b55a 100644
146--- a/common/helpers.sh
147+++ b/common/helpers.sh
148@@ -10,6 +10,8 @@ cat << EOF
149 USAGE: `basename $0` INTERNAL_OPTS OPTIONS [OVERLAYS]
150
151 OPTIONS:
152+ --charm-channel
153+ Charm channel to deploy from (if supported).
154 --create-model
155 Create Juju model using --name. Switches to model if it already
156 exists. If this is not provided then the current Juju model is used.
157@@ -137,7 +139,7 @@ generate()
158 ftmp=`mktemp`
159 echo -n "sed -i " > $ftmp
160 for p in ${!parameters[@]}; do
161- echo -n "-e 's/$p/${parameters[$p]}/g' " >> $ftmp
162+ echo -n "-e 's,$p,${parameters[$p]},g' " >> $ftmp
163 done
164 opts+=( "--internal-bundle-params $ftmp" )
165 fi
166diff --git a/kubernetes/generate-bundle.sh b/kubernetes/generate-bundle.sh
167index 32c9883..9f43fe1 100755
168--- a/kubernetes/generate-bundle.sh
169+++ b/kubernetes/generate-bundle.sh
170@@ -3,11 +3,11 @@
171 LIB_COMMON=`dirname $0`/common
172 . $LIB_COMMON/helpers.sh
173
174-# vars
175+# This list provides a way to set "internal opts" i.e. the ones accepted by
176+# the top-level generate-bundle.sh. The need to modify these should be rare.
177 opts=(
178 --internal-template kubernetes.yaml.template
179 --internal-generator-path $0
180---K8S
181 )
182 f_rel_info=`mktemp`
183
184@@ -21,14 +21,23 @@ declare -A nonlts=( [cosmic]=cdk
185 [disco]=cdk )
186 EOF
187
188-# defaults
189-# defaults
190+# Bundle template parameters. These should correspond to variables set at the top
191+# of yaml bundle and overlay templates.
192 parameters[__NUM_CEPH_MON_UNITS__]=1
193+parameters[__K8S_CHANNEL__]="latest/stable"
194+if ! `has_opt '--use-stable-charms' ${CACHED_STDIN[@]:-""}`; then
195+ opts+=( "--charm-channel edge" )
196+fi
197
198 trap_help ${CACHED_STDIN[@]:-""}
199 while (($# > 0))
200 do
201 case "$1" in
202+ --k8s-channel)
203+ # which Kubernetes channel to set on deployment
204+ parameters[__K8S_CHANNEL__]="$2"
205+ shift
206+ ;;
207 --ceph)
208 overlays+=( "ceph.yaml" )
209 overlays+=( "k8s-ceph.yaml" )
210diff --git a/kubernetes/kubernetes.yaml.template b/kubernetes/kubernetes.yaml.template
211index 7ef5d56..005e35f 100644
212--- a/kubernetes/kubernetes.yaml.template
213+++ b/kubernetes/kubernetes.yaml.template
214@@ -1,5 +1,5 @@
215
216-k8s_channel: &k8s_channel __CHANNEL__
217+k8s_channel: &k8s_channel __K8S_CHANNEL__
218
219 description: A highly-available, production-grade Kubernetes cluster.
220 series: bionic
221diff --git a/landscape/generate-bundle.sh b/landscape/generate-bundle.sh
222index cad65f0..3a0b1eb 100755
223--- a/landscape/generate-bundle.sh
224+++ b/landscape/generate-bundle.sh
225@@ -3,7 +3,8 @@
226 LIB_COMMON=`dirname $0`/common
227 . $LIB_COMMON/helpers.sh
228
229-# vars
230+# This list provides a way to set "internal opts" i.e. the ones accepted by
231+# the top-level generate-bundle.sh. The need to modify these should be rare.
232 opts=(
233 --internal-template landscape.yaml.template
234 --internal-generator-path $0
235@@ -21,7 +22,8 @@ declare -A nonlts=( [cosmic]=landscape
236 [disco]=landscape )
237 EOF
238
239-# defaults
240+# Bundle template parameters. These should correspond to variables set at the top
241+# of yaml bundle and overlay templates.
242 parameters[__LANDSCAPE_VERSION__]="19.01"
243
244 trap_help ${CACHED_STDIN[@]:-""}
245diff --git a/openstack/generate-bundle.sh b/openstack/generate-bundle.sh
246index 3c35dba..d67fb84 100755
247--- a/openstack/generate-bundle.sh
248+++ b/openstack/generate-bundle.sh
249@@ -1,10 +1,10 @@
250 #!/bin/bash -eu
251-CACHED_STDIN=( $@ )
252 # imports
253 LIB_COMMON=`dirname $0`/common
254 . $LIB_COMMON/helpers.sh
255
256-# vars
257+# This list provides a way to set "internal opts" i.e. the ones accepted by
258+# the top-level generate-bundle.sh. The need to modify these should be rare.
259 opts=(
260 --internal-template openstack.yaml.template
261 --internal-generator-path $0
262@@ -20,7 +20,8 @@ cat << 'EOF' > $f_rel_info
263 EOF
264 cat $LIB_COMMON/openstack_release_info.sh >> $f_rel_info
265
266-# defaults
267+# Bundle template parameters. These should correspond to variables set at the top
268+# of yaml bundle and overlay templates.
269 parameters[__NUM_COMPUTE_UNITS__]=1
270 parameters[__NUM_CEPH_MON_UNITS__]=1
271 parameters[__NUM_NEUTRON_GATEWAY_UNITS__]=1
272diff --git a/swift/generate-bundle.sh b/swift/generate-bundle.sh
273index 9f386ce..763d75e 100755
274--- a/swift/generate-bundle.sh
275+++ b/swift/generate-bundle.sh
276@@ -1,10 +1,10 @@
277 #!/bin/bash -eu
278-CACHED_STDIN=( $@ )
279 # imports
280 LIB_COMMON=`dirname $0`/common
281 . $LIB_COMMON/helpers.sh
282
283-# vars
284+# This list provides a way to set "internal opts" i.e. the ones accepted by
285+# the top-level generate-bundle.sh. The need to modify these should be rare.
286 opts=(
287 --internal-template swift.yaml.template
288 --internal-generator-path $0
289@@ -19,7 +19,8 @@ cat << 'EOF' > $f_rel_info
290 EOF
291 cat $LIB_COMMON/openstack_release_info.sh >> $f_rel_info
292
293-# defaults
294+# Bundle template parameters. These should correspond to variables set at the top
295+# of yaml bundle and overlay templates.
296 parameters[__NUM_VAULT_UNITS__]=1 # there are > 1 vault* overlay so need to use a global with default
297 parameters[__SSL_CA__]=
298 parameters[__SSL_CERT__]=

Subscribers

People subscribed via source and target branches