Skip to content

Commit

Permalink
Merge pull request #4 from MridulS/ssl
Browse files Browse the repository at this point in the history
explicit ssl config, and update configmap for boolean values
  • Loading branch information
bitnik authored Apr 14, 2021
2 parents 2fa9368 + 9f5bac3 commit c5a0f72
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion helm-chart/binder-launches/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: binder-launches
version: 0.1.1
version: 0.1.2
appVersion: "0.1.0"
# kubeVersion: A SemVer range of compatible Kubernetes versions (optional)
description: A Helm chart for Kubernetes
Expand Down
9 changes: 4 additions & 5 deletions helm-chart/binder-launches/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ metadata:
name: {{ .Release.Name }}-configmap
data:
# `|-` is for declaring a multi-line string
# To check boolean values explicity, we use
# (kindIs "invalid") to check if the value is nil.
config.js: |-
const config = {
{{- if .Values.baseUrl }}
baseUrl: {{ .Values.baseUrl | quote }},
{{- end }}
{{- if .Values.port }}
port: {{ .Values.port }},
{{- end }}
{{- if .Values.debug }}
{{- if not (kindIs "invalid" .Values.debug) }}
debug: {{ .Values.debug }},
{{- end }}
{{- if .Values.db.ssl }}
{{- if not (kindIs "invalid" .Values.db.ssl) }}
dbSSL: {{ .Values.db.ssl }},
{{- end }}
//db: "postgres://{{ template "binder-launches.dbURL" . }}"
Expand Down
38 changes: 25 additions & 13 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,31 @@ const app = express();
app.use(expressLogger);
const port = config.port;

const sequelize = new Sequelize(config.db,
{
// https://sequelize.org/master/class/lib/sequelize.js~Sequelize.html
dialect: 'postgres',
protocol: 'postgres',
dialectOptions: {
ssl: {
require: config.dbSSL,
rejectUnauthorized: false
}
},
logging: config.debug
});
let sequelize;
if (config.dbSSL){
sequelize = new Sequelize(config.db,
{
// https://sequelize.org/master/class/lib/sequelize.js~Sequelize.html
dialect: 'postgres',
protocol: 'postgres',
dialectOptions: {
ssl: {
require: true,
rejectUnauthorized: false
}
},
logging: config.debug
});
} else {
sequelize = new Sequelize(config.db,
{
// https://sequelize.org/master/class/lib/sequelize.js~Sequelize.html
dialect: 'postgres',
protocol: 'postgres',
logging: config.debug
});
}


// init Launch model
const Launch = _Launch(sequelize, DataTypes);
Expand Down

0 comments on commit c5a0f72

Please sign in to comment.