Skip to content

Commit

Permalink
Switch to mount JS files in volume from ConfigMap.
Browse files Browse the repository at this point in the history
Externalize configurable parameters into Helm values.yaml so that
upgrades can occur without rebuilding the docker image.
  • Loading branch information
mbjones committed Mar 7, 2022
1 parent 094a290 commit d17afca
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 19 deletions.
1 change: 1 addition & 0 deletions app/purser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ <h1>Payment</h1>
</section>

<button id="checkout"><span>Checkout</span></button>
<script type="text/javascript" src="js/purser.js"></script>
<script type="text/javascript" src="js/payment.js"></script>
</div>
<iframe id="pay-frame"
Expand Down
2 changes: 1 addition & 1 deletion helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ version: 0.7.0
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v0.4.0"
appVersion: "v0.5.0"
20 changes: 2 additions & 18 deletions app/purser/js/payment.js → helm/config/payment.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@

// Service Unit Rate
// DataONE Plus year $575.04
// Hosted Repository year $12,999.96
// HA Storage TB/year $150.00
// Data Curation day $689.00
// Design / Development day $915.00
function prices() {
prices_ = {};
prices_.dataoneplus = 575.04;
prices_.hostedrepo = 12999.96
prices_.hastorage = 150.00
prices_.curation = 689.00
prices_.customdev = 915.00
return(prices_);
}

function change_listener() {
document.getElementById('total_price').innerText = calc_total();
}
Expand Down Expand Up @@ -99,7 +82,8 @@ function checkout() {
var prod_list = products_selected();
if (amount > 0) {
var orderid = create_order();
var pay_base_url = "https://cert.payconex.net/paymentpage/enhanced/?action=view&aid=220614974061&id=31721";
//var pay_base_url = "https://cert.payconex.net/paymentpage/enhanced/?action=view&aid=220614974061&id=31721";
var pay_base_url = config.purser.purser_url + "&aid=" + config.purser.client_key + "&id=" + config.purser.form_id;
var payment_url = pay_base_url + "&amount=" + amount + "&orderid=" + orderid + "&products=" + prod_list;
hide_products();
update_iframe(payment_url);
Expand Down
17 changes: 17 additions & 0 deletions helm/config/purser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var config = {
"purser": {
"purser_url": "{{ .Values.purser.purser_url }}",
"client_key": "{{ .Values.purser.client_key }}",
"form_id": "{{ .Values.purser.form_id }}"
}
}

function prices() {
prices_ = {};
prices_.dataoneplus = 575.04;
prices_.hostedrepo = 12999.96
prices_.hastorage = 150.00
prices_.curation = 689.00
prices_.customdev = 915.00
return(prices_);
}
9 changes: 9 additions & 0 deletions helm/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Load all files in the "config" directory into a ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-configfiles
labels:
{{- include "purser.labels" . | nindent 4 }}
data:
{{ (tpl (.Files.Glob "config/*").AsConfig . ) | indent 4 }}
12 changes: 12 additions & 0 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ spec:
- name: http
containerPort: 80
protocol: TCP
volumeMounts:
- mountPath: /usr/share/nginx/html/purser/js/purser.js
subPath: purser.js
name: {{ .Release.Name }}-config-volume
- mountPath: /usr/share/nginx/html/purser/js/payment.js
subPath: payment.js
name: {{ .Release.Name }}-config-volume
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
Expand All @@ -51,3 +58,8 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: {{ .Release.Name }}-config-volume
configMap:
name: {{ .Release.Name }}-configfiles
defaultMode: 0644
5 changes: 5 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

replicaCount: 1

purser:
purser_url: "https://cert.payconex.net/paymentpage/enhanced/?action=view&"
client_key: "220614974061"
form_id: "31721"

image:
repository: ghcr.io/dataoneorg/purser
pullPolicy: Always
Expand Down

0 comments on commit d17afca

Please sign in to comment.