Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
df6354b8
Commit
df6354b8
authored
Jan 03, 2019
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRY up some functions in Auto-DevOps script
- DRY up setting deploy name - DRY up application_secret_name
parent
1d41e587
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
16 deletions
+27
-16
lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml
lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml
+27
-16
No files found.
lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml
View file @
df6354b8
...
@@ -607,6 +607,9 @@ rollout 100%:
...
@@ -607,6 +607,9 @@ rollout 100%:
# A: dmFsdWUxCg==
# A: dmFsdWUxCg==
# B: bXVsdGkgd29yZCB2YWx1ZQo=
# B: bXVsdGkgd29yZCB2YWx1ZQo=
function create_application_secret() {
function create_application_secret() {
track="${1-stable}"
export APPLICATION_SECRET_NAME=$(application_secret_name "$track")
bash -c '
bash -c '
function k8s_prefixed_variables() {
function k8s_prefixed_variables() {
env | sed -n "s/^K8S_SECRET_\(.*\)$/\1/p"
env | sed -n "s/^K8S_SECRET_\(.*\)$/\1/p"
...
@@ -619,10 +622,28 @@ rollout 100%:
...
@@ -619,10 +622,28 @@ rollout 100%:
'
'
}
}
function deploy_name() {
name="$CI_ENVIRONMENT_SLUG"
track="${1-stable}"
if [[ "$track" != "stable" ]]; then
name="$name-$track"
fi
echo $name
}
function application_secret_name() {
track="${1-stable}"
name=$(deploy_name "$track")
echo "${name}-secret"
}
function deploy() {
function deploy() {
track="${1-stable}"
track="${1-stable}"
percentage="${2:-100}"
percentage="${2:-100}"
name=
"$CI_ENVIRONMENT_SLUG"
name=
$(deploy_name "$track")
replicas="1"
replicas="1"
service_enabled="true"
service_enabled="true"
...
@@ -631,7 +652,6 @@ rollout 100%:
...
@@ -631,7 +652,6 @@ rollout 100%:
# if track is different than stable,
# if track is different than stable,
# re-use all attached resources
# re-use all attached resources
if [[ "$track" != "stable" ]]; then
if [[ "$track" != "stable" ]]; then
name="$name-$track"
service_enabled="false"
service_enabled="false"
postgres_enabled="false"
postgres_enabled="false"
fi
fi
...
@@ -644,8 +664,7 @@ rollout 100%:
...
@@ -644,8 +664,7 @@ rollout 100%:
secret_name=''
secret_name=''
fi
fi
export APPLICATION_SECRET_NAME="${name}-secret"
create_application_secret "$track"
create_application_secret
if [[ -n "$DB_INITIALIZE" && -z "$(helm ls -q "^$name$")" ]]; then
if [[ -n "$DB_INITIALIZE" && -z "$(helm ls -q "^$name$")" ]]; then
echo "Deploying first release with database initialization..."
echo "Deploying first release with database initialization..."
...
@@ -712,11 +731,7 @@ rollout 100%:
...
@@ -712,11 +731,7 @@ rollout 100%:
function scale() {
function scale() {
track="${1-stable}"
track="${1-stable}"
percentage="${2-100}"
percentage="${2-100}"
name="$CI_ENVIRONMENT_SLUG"
name=$(deploy_name "$track")
if [[ "$track" != "stable" ]]; then
name="$name-$track"
fi
replicas=$(get_replicas "$track" "$percentage")
replicas=$(get_replicas "$track" "$percentage")
...
@@ -910,18 +925,14 @@ rollout 100%:
...
@@ -910,18 +925,14 @@ rollout 100%:
function delete() {
function delete() {
track="${1-stable}"
track="${1-stable}"
name="$CI_ENVIRONMENT_SLUG"
name=$(deploy_name "$track")
if [[ "$track" != "stable" ]]; then
name="$name-$track"
fi
if [[ -n "$(helm ls -q "^$name$")" ]]; then
if [[ -n "$(helm ls -q "^$name$")" ]]; then
helm delete --purge "$name"
helm delete --purge "$name"
fi
fi
application_secret_name="${name}-secret"
secret_name=$(application_secret_name "$track")
kubectl delete secret --ignore-not-found -n "$KUBE_NAMESPACE" "$
application_
secret_name"
kubectl delete secret --ignore-not-found -n "$KUBE_NAMESPACE" "$secret_name"
}
}
before_script
:
before_script
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment