Skip to content

Commit 095c2c1

Browse files
authored
Merge pull request #294 from QuanMPhm/ops_1514/automate
Updated Dockerfile and manifests for invoice cronjob
2 parents 78bd0d9 + 7312460 commit 095c2c1

9 files changed

Lines changed: 90 additions & 28 deletions

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ COPY requirements.txt .
88
RUN pip install -r requirements.txt
99

1010
COPY tools/ tools/
11-
COPY process_report/process_report.py process_report/
12-
COPY process_report/institute_list.yaml process_report/
11+
COPY process_report process_report
1312

14-
CMD ["tools/clone_nonbillables_and_process_invoice.sh"]
13+
CMD ["tools/setup_and_process.sh"]

k8s/base/invoice-daily-check.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
apiVersion: batch/v1
2+
kind: CronJob
3+
metadata:
4+
name: invoice-daily-check
5+
spec:
6+
schedule: "0 7 * * *"
7+
jobTemplate:
8+
spec:
9+
template:
10+
spec:
11+
containers:
12+
- name: invoice-daily-check
13+
image: ghcr.io/cci-moc/process-csv-report:latest
14+
env:
15+
- name: GH_NONBILLABLE_DEPLOYKEY
16+
valueFrom:
17+
secretKeyRef:
18+
name: gh-nonbillables
19+
key: ssh-privatekey
20+
- name: S3_KEY_ID
21+
valueFrom:
22+
secretKeyRef:
23+
name: nerc-invoices-s3-bucket
24+
key: s3-key-id
25+
- name: S3_APP_KEY
26+
valueFrom:
27+
secretKeyRef:
28+
name: nerc-invoices-s3-bucket
29+
key: s3-app-key
30+
- name: KEYCLOAK_CLIENT_ID
31+
valueFrom:
32+
secretKeyRef:
33+
name: coldfront-api
34+
key: keycloak-client-id
35+
- name: KEYCLOAK_CLIENT_SECRET
36+
valueFrom:
37+
secretKeyRef:
38+
name: coldfront-api
39+
key: keycloak-client-secret
40+
- name: UPLOAD_TO_S3
41+
value: "False"
42+
restartPolicy: OnFailure

k8s/base/invoice-processing.yaml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,29 @@ spec:
1414
env:
1515
- name: GH_NONBILLABLE_DEPLOYKEY
1616
valueFrom:
17-
secretKeyRef:
18-
name: gh-nonbillables
19-
key: ssh-deploykey
17+
secretKeyRef:
18+
name: gh-nonbillables
19+
key: ssh-privatekey
2020
- name: S3_KEY_ID
2121
valueFrom:
22-
secretKeyRef:
23-
name: nerc-invoices-s3-bucket
24-
key: s3-key-id
22+
secretKeyRef:
23+
name: nerc-invoices-s3-bucket
24+
key: s3-key-id
2525
- name: S3_APP_KEY
2626
valueFrom:
27-
secretKeyRef:
28-
name: nerc-invoices-s3-bucket
29-
key: s3-app-key
27+
secretKeyRef:
28+
name: nerc-invoices-s3-bucket
29+
key: s3-app-key
30+
- name: KEYCLOAK_CLIENT_ID
31+
valueFrom:
32+
secretKeyRef:
33+
name: coldfront-api
34+
key: keycloak-client-id
35+
- name: KEYCLOAK_CLIENT_SECRET
36+
valueFrom:
37+
secretKeyRef:
38+
name: coldfront-api
39+
key: keycloak-client-secret
40+
- name: UPLOAD_TO_S3
41+
value: "True"
3042
restartPolicy: OnFailure

k8s/base/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
resources:
22
- invoice-processing.yaml
3+
- invoice-daily-check.yaml

k8s/overlay/kustomization.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
resources:
22
- ../base
3-
- secret-b2-old-pi.yaml
3+
- secret-nerc-invoices-s3-bucket.yaml
44
- secret-gh-nonbillables.yaml
5+
- secret-coldfront-api.yaml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: coldfront-api
5+
type: Opaque
6+
data:
7+
keycloak-client-id: test
8+
keycloak-client-secret: test
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ metadata:
44
name: gh-nonbillables
55
type: kubernetes.io/ssh-auth
66
data:
7-
ssh-deploykey: test
7+
ssh-privatekey: test
File renamed without changes.
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,16 @@ if [ ! -d ./non-billable-projects ]; then
2727
git clone git@github-nonbillable:CCI-MOC/non-billable-projects.git ./non-billable-projects
2828
fi
2929

30-
INVOICE_MONTH=$(date --date="$(date +%Y-%m-01) -1 month" +%Y-%m)
31-
python -m process_report.process_report \
32-
--fetch-from-s3 \
33-
--upload-to-s3 \
34-
--invoice-month $INVOICE_MONTH \
35-
--pi-file ./non-billable-projects/pi.txt \
36-
--projects-file ./non-billable-projects/projects.txt \
37-
--timed-projects-file ./non-billable-projects/timed_projects.txt \
38-
--nonbillable-file "NERC (Nonbillable)" \
39-
--output-file "NERC" \
40-
--output-folder "PI Invoices" \
41-
--BU-invoice-file "NERC BU" \
42-
--Lenovo-file "Lenovo" \
43-
--BU-subsidy-amount 100
30+
31+
export S3_ENDPOINT=${S3_ENDPOINT:-'https://s3.us-east-005.backblazeb2.com'}
32+
export S3_BUCKET_NAME=${S3_BUCKET_NAME:-'nerc-invoicing'}
33+
34+
export CHROME_BIN_PATH='/usr/bin/chromium'
35+
36+
export NONBILLABLE_PIS_FILEPATH='./non-billable-projects/pi.yaml'
37+
export NONBILLABLE_PROJECTS_FILEPATH='./non-billable-projects/projects.yaml'
38+
export PREPAY_PROJECTS_FILEPATH='./non-billable-projects/prepaid_projects.yaml'
39+
export PREPAY_CREDITS_FILEPATH='./non-billable-projects/prepaid_credits.yaml'
40+
export PREPAY_CONTACTS_FILEPATH='./non-billable-projects/prepaid_contacts.yaml'
41+
42+
python -m process_report.process_report

0 commit comments

Comments
 (0)