Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit 628f34e

Browse files
Added yamllint and shellchecked scripts (#22)
1 parent 4c3a87a commit 628f34e

11 files changed

+203
-152
lines changed

.bluemix/pipeline.yml

+57-56
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,60 @@
11
---
22
stages:
3-
- name: BUILD
4-
inputs:
5-
- type: git
6-
branch: master
7-
service: ${SAMPLE_REPO}
8-
triggers:
9-
- type: commit
10-
jobs:
11-
- name: Build
12-
type: builder
13-
artifact_dir: ''
14-
build_type: shell
15-
script: |-
16-
#!/bin/bash
17-
bash -n *.sh
18-
- name: DEPLOY
19-
inputs:
20-
- type: job
21-
stage: BUILD
22-
job: Build
23-
dir_name: null
24-
triggers:
25-
- type: stage
26-
properties:
27-
- name: BLUEMIX_USER
28-
type: text
29-
value: ${BLUEMIX_USER}
30-
- name: BLUEMIX_PASSWORD
31-
type: secure
32-
value: ${BLUEMIX_PASSWORD}
33-
- name: BLUEMIX_ACCOUNT
34-
type: secure
35-
value: ${BLUEMIX_ACCOUNT}
36-
- name: CLUSTER_NAME
37-
type: text
38-
value: ${CLUSTER_NAME}
39-
- name: API_KEY
40-
type: secure
41-
value: ${API_KEY}
42-
jobs:
43-
- name: Deploy
44-
type: deployer
45-
target:
46-
region_id: ${PROD_REGION_ID}
47-
organization: ${PROD_ORG_NAME}
48-
space: ${PROD_SPACE_NAME}
49-
application: Pipeline
50-
script: |
51-
#!/bin/bash
52-
. ./scripts/install_bx.sh
53-
./scripts/bx_login.sh
54-
./scripts/deploy.sh
3+
- name: BUILD
4+
inputs:
5+
- type: git
6+
branch: master
7+
service: ${SAMPLE_REPO}
8+
triggers:
9+
- type: commit
10+
jobs:
11+
- name: Build
12+
type: builder
13+
artifact_dir: ''
14+
build_type: shell
15+
script: |-
16+
#!/bin/bash
17+
bash -n *.sh
18+
- name: DEPLOY
19+
inputs:
20+
- type: job
21+
stage: BUILD
22+
job: Build
23+
dir_name: null
24+
triggers:
25+
- type: stage
26+
properties:
27+
- name: BLUEMIX_USER
28+
type: text
29+
value: ${BLUEMIX_USER}
30+
- name: BLUEMIX_PASSWORD
31+
type: secure
32+
value: ${BLUEMIX_PASSWORD}
33+
- name: BLUEMIX_ACCOUNT
34+
type: secure
35+
value: ${BLUEMIX_ACCOUNT}
36+
- name: CLUSTER_NAME
37+
type: text
38+
value: ${CLUSTER_NAME}
39+
- name: API_KEY
40+
type: secure
41+
value: ${API_KEY}
42+
jobs:
43+
- name: Deploy
44+
type: deployer
45+
target:
46+
region_id: ${PROD_REGION_ID}
47+
organization: ${PROD_ORG_NAME}
48+
space: ${PROD_SPACE_NAME}
49+
application: Pipeline
50+
script: |
51+
#!/bin/bash
52+
. ./scripts/deploy-to-bluemix/install_bx.sh
53+
./scripts/deploy-to-bluemix/bx_login.sh
54+
./scripts/deploy-to-bluemix/deploy.sh
5555
hooks:
56-
- enabled: true
57-
label: null
58-
ssl_enabled: false
59-
url: https://devops-api-integration.stage1.ng.bluemix.net/v1/messaging/webhook/publish
56+
- enabled: true
57+
label: null
58+
ssl_enabled: false
59+
url: >-
60+
https://devops-api-integration.stage1.ng.bluemix.net/v1/messaging/webhook/publish

.bluemix/toolchain.yml

+16-16
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ version: 0.1
55
image: data:image/svg+xml;base64,$file(toolchain.svg,base64)
66
icon: data:image/svg+xml;base64,$file(icon.svg,base64)
77
required:
8-
- deploy
9-
- sample-repo
8+
- deploy
9+
- sample-repo
1010

1111
# Github repos
1212
sample-repo:
@@ -24,23 +24,23 @@ sample-build:
2424
name: "{{name}}"
2525
ui-pipeline: true
2626
configuration:
27-
content: $file(pipeline.yml)
28-
env:
29-
SAMPLE_REPO: "sample-repo"
30-
CF_APP_NAME: "{{deploy.parameters.prod-app-name}}"
31-
PROD_SPACE_NAME: "{{deploy.parameters.prod-space}}"
32-
PROD_ORG_NAME: "{{deploy.parameters.prod-organization}}"
33-
PROD_REGION_ID: "{{deploy.parameters.prod-region}}"
34-
BLUEMIX_USER: "{{deploy.parameters.bluemix-user}}"
35-
BLUEMIX_PASSWORD: "{{deploy.parameters.bluemix-password}}"
36-
API_KEY: "{{deploy.parameters.bluemix-api-key}}"
37-
BLUEMIX_ACCOUNT: "{{deploy.parameters.bluemix-cluster-account}}"
38-
CLUSTER_NAME: "{{deploy.parameters.bluemix-cluster-name}}"
39-
execute: true
27+
content: $file(pipeline.yml)
28+
env:
29+
SAMPLE_REPO: "sample-repo"
30+
CF_APP_NAME: "{{deploy.parameters.prod-app-name}}"
31+
PROD_SPACE_NAME: "{{deploy.parameters.prod-space}}"
32+
PROD_ORG_NAME: "{{deploy.parameters.prod-organization}}"
33+
PROD_REGION_ID: "{{deploy.parameters.prod-region}}"
34+
BLUEMIX_USER: "{{deploy.parameters.bluemix-user}}"
35+
BLUEMIX_PASSWORD: "{{deploy.parameters.bluemix-password}}"
36+
API_KEY: "{{deploy.parameters.bluemix-api-key}}"
37+
BLUEMIX_ACCOUNT: "{{deploy.parameters.bluemix-cluster-account}}"
38+
CLUSTER_NAME: "{{deploy.parameters.bluemix-cluster-name}}"
39+
execute: true
4040
services: ["sample-repo"]
4141
hidden: [form, description]
4242

43-
#Deployment
43+
# Deployment
4444
deploy:
4545
schema:
4646
$ref: deploy.json

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
---
12
language: bash
23
sudo: required
34
script:
4-
- bash scripts/install.sh
5+
- bash scripts/install.sh
56
group: stable
67
dist: trusty
7-
sudo: required
88
os: linux

.yamllint.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
rules:
3+
braces:
4+
min-spaces-inside: 0
5+
max-spaces-inside: 0
6+
min-spaces-inside-empty: 0
7+
max-spaces-inside-empty: 0
8+
brackets:
9+
min-spaces-inside: 0
10+
max-spaces-inside: 0
11+
min-spaces-inside-empty: 0
12+
max-spaces-inside-empty: 0
13+
colons:
14+
max-spaces-before: 0
15+
max-spaces-after: 1
16+
commas:
17+
max-spaces-before: 0
18+
min-spaces-after: 1
19+
max-spaces-after: 1
20+
comments:
21+
require-starting-space: true
22+
min-spaces-from-content: 2
23+
comments-indentation: enable
24+
document-end: disable
25+
document-start:
26+
present: true
27+
empty-lines:
28+
max: 2
29+
max-start: 0
30+
max-end: 0
31+
hyphens:
32+
max-spaces-after: 1
33+
indentation:
34+
spaces: consistent
35+
indent-sequences: true
36+
check-multi-line-strings: false
37+
key-duplicates: enable
38+
line-length:
39+
max: 80
40+
allow-non-breakable-words: true
41+
allow-non-breakable-inline-mappings: true
42+
level: warning
43+
new-line-at-end-of-file: enable
44+
new-lines:
45+
type: unix
46+
trailing-spaces: enable
47+
truthy: enable

local-volumes.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
apiVersion: v1
23
kind: PersistentVolume
34
metadata:

mysql-deployment.yaml

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
apiVersion: v1
23
kind: Service
34
metadata:
@@ -41,21 +42,21 @@ spec:
4142
tier: mysql
4243
spec:
4344
containers:
44-
- image: mysql:5.6
45-
name: mysql
46-
env:
47-
- name: MYSQL_ROOT_PASSWORD
48-
valueFrom:
49-
secretKeyRef:
50-
name: mysql-pass
51-
key: password.txt
52-
ports:
53-
- containerPort: 3306
45+
- image: mysql:5.6
5446
name: mysql
55-
volumeMounts:
56-
- name: mysql-local-storage
57-
mountPath: /var/lib/mysql
47+
env:
48+
- name: MYSQL_ROOT_PASSWORD
49+
valueFrom:
50+
secretKeyRef:
51+
name: mysql-pass
52+
key: password.txt
53+
ports:
54+
- containerPort: 3306
55+
name: mysql
56+
volumeMounts:
57+
- name: mysql-local-storage
58+
mountPath: /var/lib/mysql
5859
volumes:
59-
- name: mysql-local-storage
60-
persistentVolumeClaim:
61-
claimName: mysql-lv-claim
60+
- name: mysql-local-storage
61+
persistentVolumeClaim:
62+
claimName: mysql-lv-claim

scripts/bx_login.sh

-37
This file was deleted.

scripts/deploy-to-bluemix/bx_login.sh

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/sh
2+
3+
if [ -z "$CF_ORG" ]; then
4+
CF_ORG="$BLUEMIX_ORG"
5+
fi
6+
if [ -z "$CF_SPACE" ]; then
7+
CF_SPACE="$BLUEMIX_SPACE"
8+
fi
9+
10+
11+
if ([ -z "$BLUEMIX_USER" ] || [ -z "$BLUEMIX_PASSWORD" ] || [ -z "$BLUEMIX_ACCOUNT" ]) && ([ -z "$API_KEY" ]); then
12+
echo "Define all required environment variables and rerun the stage."
13+
exit 1
14+
fi
15+
16+
echo "Deploy pods"
17+
18+
echo "bx login -a $CF_TARGET_URL"
19+
20+
if [ -z "$API_KEY" ]; then
21+
if ! bx login -a "$CF_TARGET_URL" -u "$BLUEMIX_USER" -p "$BLUEMIX_PASSWORD" -c "$BLUEMIX_ACCOUNT" -o "$CF_ORG" -s "$CF_SPACE"; then
22+
echo "Failed to authenticate to Bluemix"
23+
exit 1
24+
fi
25+
else
26+
if ! bx login -a "$CF_TARGET_URL" --apikey "$API_KEY" -o "$CF_ORG" -s "$CF_SPACE"; then
27+
echo "Failed to authenticate to Bluemix"
28+
exit 1
29+
fi
30+
fi
31+
32+
# Init container clusters
33+
echo "bx cs init"
34+
if ! bx cs init; then
35+
echo "Failed to initialize to Bluemix Container Service"
36+
exit 1
37+
fi

scripts/deploy.sh scripts/deploy-to-bluemix/deploy.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/bin/bash
22

33
echo "Create WordPress"
4-
IP_ADDR=$(bx cs workers $CLUSTER_NAME | grep Ready | awk '{ print $2 }')
5-
if [ -z $IP_ADDR ]; then
4+
IP_ADDR=$(bx cs workers "$CLUSTER_NAME" | grep Ready | awk '{ print $2 }')
5+
if [ -z "$IP_ADDR" ]; then
66
echo "$CLUSTER_NAME not created or workers not ready"
77
exit 1
88
fi
99

1010
echo -e "Configuring vars"
11-
exp=$(bx cs cluster-config $CLUSTER_NAME | grep export)
12-
if [ $? -ne 0 ]; then
11+
exp=$(bx cs cluster-config "$CLUSTER_NAME" | grep export)
12+
if ! bx cs cluster-config "$CLUSTER_NAME" | grep export; then
1313
echo "Cluster $CLUSTER_NAME not created or not ready."
1414
exit 1
1515
fi

scripts/install_bx.sh scripts/deploy-to-bluemix/install_bx.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ echo "Install the Bluemix container-service plugin"
1616
bx plugin install container-service -r Bluemix
1717

1818
echo "Install kubectl"
19-
wget --quiet --output-document=/tmp/Bluemix_CLI/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
19+
wget --quiet --output-document=/tmp/Bluemix_CLI/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/"$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)"/bin/linux/amd64/kubectl
2020
chmod +x /tmp/Bluemix_CLI/bin/kubectl
2121

2222
if [ -n "$DEBUG" ]; then

0 commit comments

Comments
 (0)