Skip to content

Commit 8726618

Browse files
authored
Merge pull request #25 from mmohamed/feat/api
Feat API
2 parents 8cb1211 + 394a39d commit 8726618

36 files changed

+3599
-50
lines changed

.env.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ USE_FSBACKUP=1
88
DEBUG=1
99
READ_ONLY_USER=0
1010
AUDIT_LOG=1
11+
API_PORT=3002
12+
API_SUB_PATH=/api
1113
METRICS=true
1214
METRICS_PORT=3001
1315
METRICS_PATH=metrics

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ All notable changes to this project will be documented in this file.
3434
### Changed
3535

3636
- Upgrade dependencies: @kubernetes/client-node from 0.19.0 to 0.20.0
37+
38+
## [1.2.0] - 2024-01-10
39+
40+
### Added
41+
42+
- Full Rest API support V1 (swagger doc)

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This is a very simplified Velero dashboard for backup, restore and schedule mana
2222
- Delete a schedule
2323
- Pause / Unpause a schedule
2424
- Get backup and restore result information (logs included)
25+
- Full Rest API support (docs /v1/docs)
2526

2627
### 2. App features
2728

@@ -43,7 +44,7 @@ LDAP_SEARCH_BASE="OU=users,DC=mtr,DC=com"
4344
LDAP_SEARCH_FILTER=sAMAccountName
4445
```
4546

46-
- Multi-tenant & User access namspaced scope : With LDAP configuration, you can define a scope control based on an assotioation of a LDAP groups and a list of namespace, for example, if a user X is member of LDAP group group-it, he can manage backup, restore and schedule with include-namespace associated to the group-it (all namespace mut be accessible by the user to see these resources)
47+
- Multi-tenant & User access namespaced scope : With LDAP configuration, you can define a scope control based on an assotioation of a LDAP groups and a list of namespace, for example, if a user X is member of LDAP group group-it, he can manage backup, restore and schedule with include-namespace associated to the group-it (all namespace mut be accessible by the user to see these resources)
4748

4849
```ini
4950
NAMESPACE_FILTERING='[{"group": "group-it", "namespaces": ["ns1","ns2","ns3"]}]' # json list
@@ -86,11 +87,13 @@ MULTI_CLUSTER_CONFIG_DIR=/absolut/path/config/dir #default false
8687

8788
_Important : If metrics is enabled, a cluster label will contain the context name of the metric._
8889

89-
- Web app options : to define Web app listening port , a secret key for session encryption, a subpath (baypass absolute UI URL), a secured cookie restriction (work only with SSL on backned enabled, key and cert files required) and the admin credentials
90+
- Web app options : to define Web app listening port , api server listening port and subpath, a secret key for session encryption, a subpath (baypass absolute UI URL), a secured cookie restriction (work only with SSL on backned enabled, key and cert files required) and the admin credentials
9091

9192
```ini
9293
SECRET_KEY=random-secret-key #default default-secret-mut-be-changed
9394
APP_PORT=8080 #default 3000
95+
API_PORT=8082 #default 3002
96+
API_SUB_PATH=/api #default /
9497
SECURE_HOST=true # default false
9598
SECURE_HOST_CERT_FILE_PATH=/absolut/path/to/cert/file # default false
9699
SECURE_HOST_KEY_FILE_PATH=/absolut/path/to/key/file # default false

app.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
const server = require('./src/main');
22
const tools = require('./src/tools');
3+
const api = require('./src/api');
34

45
server.app.listen(tools.port(), () => {
56
console.log(new Date(), ': Application started...');
67
});
78

9+
api.listen(tools.apiPort(), () => {
10+
console.log(new Date(), ': API server started...');
11+
});
12+
813
if (tools.metrics()) {
914
server.metrics.listen(tools.metricsPort(), () => {
1015
console.log(new Date(), ': Metrics server started...');

app.test.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,24 @@ express.mockReturnValue({
1212
},
1313
get: function () {},
1414
post: function () {},
15-
delete: function () {}
15+
delete: function () {},
16+
put: function () {}
17+
});
18+
19+
express.Router.mockReturnValue({
20+
get: function () {},
21+
post: function () {},
22+
delete: function () {},
23+
put: function () {},
24+
use: function () {}
1625
});
1726

1827
process.env.METRICS = true;
1928
const server = require('./app.js');
2029

2130
describe('Check lanching servers', () => {
22-
it('should app/metrics server in running mode', async () => {
23-
expect(ports.length).toEqual(2);
24-
expect(ports).toEqual([3000, 3001]);
31+
it('should app/metrics/api servers in running mode', async () => {
32+
expect(ports.length).toEqual(3);
33+
expect(ports).toEqual([3000, 3002, 3001]);
2534
});
2635
});

kubernetes/my-velero.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ spec:
6666
protocol: TCP
6767
- containerPort: 3001
6868
protocol: TCP
69+
- containerPort: 3002
70+
protocol: TCP
6971
resources:
7072
limits:
7173
cpu: 1000m
@@ -95,11 +97,13 @@ spec:
9597
# - name: SECURE_HOST_CERT_FILE_PATH
9698
# value: "/usr/src/tls/tls.crt"
9799
# - name: SECURE_HOST_KEY_FILE_PATH
98-
# value: "/usr/src/tls/tls.key"
100+
# value: "/usr/src/tls/tls.key"
99101
- name: DEBUG
100102
value: '1'
101103
- name: METRICS
102104
value: '1'
105+
- name: API_SUB_PATH
106+
value: '/api'
103107
- name: LDAP_HOST
104108
value: ldaps://my-velero-ldap-svc.velero.svc.cluster.local:636
105109
- name: LDAP_SKIP_SSL
@@ -115,7 +119,7 @@ spec:
115119
- name: LDAP_SEARCH_FILTER
116120
value: sAMAccountName
117121
- name: NAMESPACE_FILTERING
118-
value: '[{"group": "IT", "namespaces": ["ovpn","ovpn-dev","ovpn-prd"]}]'
122+
value: '[{"group": "IT", "namespaces": ["qrcode","qrcode-dev","qrcode-prd"]}]'
119123

120124
---
121125
apiVersion: v1
@@ -128,6 +132,9 @@ spec:
128132
- name: http
129133
port: 80
130134
targetPort: 3000
135+
- name: api
136+
port: 81
137+
targetPort: 3002
131138
selector:
132139
app: myvelero
133140

@@ -152,6 +159,10 @@ spec:
152159
serviceName: my-velero-svc
153160
servicePort: http
154161
path: /
162+
- backend:
163+
serviceName: my-velero-svc
164+
servicePort: api
165+
path: /api
155166
tls:
156167
- hosts:
157168
- myvelero.medinvention.dev

0 commit comments

Comments
 (0)