Skip to content

Commit 88c5d95

Browse files
committed
TODO:
- document usage in reference dataset - add minimal tests WIP-tasks(cf_push): support variable substitution for cf apps a file ending with `vars.yml` in application template dir is detected as file with `variables` to be injected into application manifest. fix #188
1 parent a8c5bab commit 88c5d95

File tree

3 files changed

+36
-18
lines changed

3 files changed

+36
-18
lines changed

concourse/tasks/cf_push.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ params:
1919
SECRETS_DIR:
2020
CUSTOM_SCRIPT_DIR:
2121
CF_MANIFEST:
22+
VARS_FILES_SUFFIX: vars.yml

scripts/cf/push.sh

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ validate(){
2929
fi
3030
}
3131

32-
validate
32+
#validate
3333

3434
CURRENT_DIR=$(pwd)
3535
OUTPUT_DIR=${OUTPUT_DIR:-${CURRENT_DIR}/generated-files}
@@ -38,16 +38,25 @@ ADDITIONAL_RESSOURCE=${ADDITIONAL_RESSOURCE:-additional-resource}
3838

3939
CF_MANIFEST=${CF_MANIFEST:-manifest.yml}
4040

41+
API_OPTIONS="--skip-ssl-validation"
42+
43+
echo "copying file from $ADDITIONAL_RESSOURCE to $OUTPUT_DIR"
44+
cp -r $ADDITIONAL_RESSOURCE/. $OUTPUT_DIR/
4145

46+
VARS_FILES=""
47+
ls ${OUTPUT_DIR}/*
48+
for a_vars_file in $(ls ${OUTPUT_DIR}/*${VARS_FILES_SUFFIX}); do
49+
VARS_FILES="${VARS_FILES} --vars-file ${a_vars_file}"
50+
done
51+
52+
echo "Vars files detected: <${VARS_FILES}>"
4253

43-
API_OPTIONS="--skip-ssl-validation"
4454

4555
#TODO add an option to manage ssl validation
56+
cf --version
4657
cf api "$CF_API_URL" $API_OPTIONS
4758
cf auth "$CF_USERNAME" "$CF_PASSWORD"
4859

49-
echo "copying file from $ADDITIONAL_RESSOURCE to $OUTPUT_DIR"
50-
cp -r $ADDITIONAL_RESSOURCE/. $OUTPUT_DIR/
5160

5261
if [ -n "$CUSTOM_SCRIPT_DIR" -a -f "$CUSTOM_SCRIPT_DIR/pre-cf-push.sh" ]
5362
then
@@ -58,10 +67,19 @@ else
5867
echo "ignoring pre CF push. No $CUSTOM_SCRIPT_DIR/pre-cf-push.sh detected"
5968
fi
6069

70+
VARS_FILES=""
71+
72+
for a_vars_file in $(ls ./${OUTPUT_DIR}/*${VARS_FILES_SUFFIX}); do
73+
VARS_FILES="${VARS_FILES} --vars-file ${a_vars_file}"
74+
done
75+
76+
echo "Vars files detected: <${VARS_FILES}>"
77+
78+
6179
cf target -o "$CF_ORG" -s "$CF_SPACE"
6280

6381
set +e
64-
cf push -f ${CF_MANIFEST} |tee /tmp/cf-push.log
82+
cf push -f ${CF_MANIFEST} ${VARS_FILES}|tee /tmp/cf-push.log
6583
ret_code=$?
6684
if [ $ret_code -ne 0 ]
6785
then

spec/tasks/cf_push/task_spec.rb

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# encoding: utf-8
2-
# require 'spec_helper.rb'
31
require 'yaml'
42
require 'tmpdir'
3+
require_relative '../task_spec_helper'
54

65
describe 'cf push task' do
76

@@ -15,23 +14,23 @@
1514
before(:context) do
1615
generated_files = Dir.mktmpdir
1716

18-
# @output = execute('-c concourse/tasks/cf_push.yml ' \
19-
# '-i scripts-resource=. ' \
20-
# '-i templates-resource=spec/tasks/cf_push/template-resource ' \
21-
# '-i credentials-resource=spec/tasks/cf_push/credentials-resource ' \
22-
# '-i additional-resource=spec/tasks/cf_push/additional-resource ' \
23-
# "-o generated-files=#{generated_files} ",
24-
# 'CUSTOM_SCRIPT_DIR' =>'',
25-
# 'SECRETS_DIR' => '' )
17+
@output = execute('-c concourse/tasks/cf_push.yml ' \
18+
'-i scripts-resource=. ' \
19+
'-i templates-resource=spec/tasks/cf_push/template-resource ' \
20+
'-i credentials-resource=spec/tasks/cf_push/credentials-resource ' \
21+
'-i additional-resource=spec/tasks/cf_push/additional-resource ' \
22+
"-o generated-files=#{generated_files} ",
23+
'CUSTOM_SCRIPT_DIR' =>'',
24+
'SECRETS_DIR' => '' )
2625
end
2726

2827
after(:context) do
2928
FileUtils.rm_rf generated_files
3029
end
3130

32-
it 'displays an ignore message'
33-
# expect(@output).to include('ignoring pre CF push. No /pre-cf-push.sh detected')
34-
31+
it 'displays an ignore message' do
32+
expect(@output).to include('ignoring pre CF push. No /pre-cf-push.sh detected')
33+
end
3534
end
3635

3736
context 'when a custom pre-push script script is detected' do

0 commit comments

Comments
 (0)