mirror of
https://github.com/OliveTin/OliveTin
synced 2025-12-11 16:45:42 +00:00
Compare commits
468 Commits
2023.03.24
...
2025.6.6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ffdd93ddf | ||
|
|
18c5599704 | ||
|
|
224d7f40ed | ||
|
|
1357eae9b8 | ||
|
|
b2e7509959 | ||
|
|
cebab32514 | ||
|
|
7110399d41 | ||
|
|
74f0930dcc | ||
|
|
c20eea29cd | ||
|
|
8c073bf45f | ||
|
|
fcfa007cec | ||
|
|
b83b7a4c42 | ||
|
|
0a7f3f3226 | ||
|
|
633e513697 | ||
|
|
eb2721c023 | ||
|
|
765c698a9b | ||
|
|
c19428f6b6 | ||
|
|
f02982b451 | ||
|
|
6ffb0cedbc | ||
|
|
775b3d3ca6 | ||
|
|
6ad001619d | ||
|
|
db28e8915b | ||
|
|
bb4969c9ac | ||
|
|
aef70c0e1b | ||
|
|
27c287c2de | ||
|
|
ec1f974f67 | ||
|
|
4ccfd0f993 | ||
|
|
c5eaa35fb0 | ||
|
|
24ba4fb574 | ||
|
|
b742bd89c4 | ||
|
|
2fcc0a63a0 | ||
|
|
ba29325c15 | ||
|
|
88f639d29f | ||
|
|
fa44e958d8 | ||
|
|
182548e0dc | ||
|
|
c3097e40db | ||
|
|
2b66414a93 | ||
|
|
7da8a5bc38 | ||
|
|
2bc45e9a09 | ||
|
|
fd3c6087f0 | ||
|
|
c0b8dd71db | ||
|
|
1164e5fae2 | ||
|
|
902d4ed819 | ||
|
|
2320a56dd9 | ||
|
|
2981fc4c1f | ||
|
|
8865331da2 | ||
|
|
709d6ac2ad | ||
|
|
8d4e335dda | ||
|
|
44a9de080c | ||
|
|
9bb17badad | ||
|
|
ff31abe66c | ||
|
|
b4c886d5d3 | ||
|
|
e0bc1d86f6 | ||
|
|
270f20ec75 | ||
|
|
486253b253 | ||
|
|
6b9c6c8b9c | ||
|
|
1275934ac1 | ||
|
|
bbc6095e36 | ||
|
|
7906f2d363 | ||
|
|
d45bd887c2 | ||
|
|
7788f58aac | ||
|
|
f3bc82311d | ||
|
|
cae5d296ca | ||
|
|
5cd5bd2a25 | ||
|
|
6550223ee4 | ||
|
|
39368d511a | ||
|
|
0a4bcc6423 | ||
|
|
56ab1cec8f | ||
|
|
12f87ca6e1 | ||
|
|
2fc7c23416 | ||
|
|
2cf538bab1 | ||
|
|
906b6c5783 | ||
|
|
6d43ebef44 | ||
|
|
c04203e671 | ||
|
|
bf93707787 | ||
|
|
f0d70f0c15 | ||
|
|
17d9e29f19 | ||
|
|
be7168d9c5 | ||
|
|
d36b23832c | ||
|
|
b6429e9bc7 | ||
|
|
7ddc112b2c | ||
|
|
10a473ca1c | ||
|
|
c7207d1ee6 | ||
|
|
c585762ba8 | ||
|
|
476838d59a | ||
|
|
f0b1cefb72 | ||
|
|
b4a555e3da | ||
|
|
79a4119351 | ||
|
|
851d0dac84 | ||
|
|
655a7f205d | ||
|
|
13e48dded2 | ||
|
|
344df3739d | ||
|
|
0d981773b3 | ||
|
|
8d4ddd36cd | ||
|
|
209234c09f | ||
|
|
9bcb2d80dc | ||
|
|
de504f5f80 | ||
|
|
8fe91101db | ||
|
|
8717997b0e | ||
|
|
1bfb7c4b28 | ||
|
|
964dc7b48a | ||
|
|
ceb0a78180 | ||
|
|
9117163316 | ||
|
|
d3ad811ac5 | ||
|
|
ee26fe6b50 | ||
|
|
2950b59514 | ||
|
|
be5ddda020 | ||
|
|
16b07283b0 | ||
|
|
d7814ff6df | ||
|
|
be9b2a7c78 | ||
|
|
80e5b5b0c1 | ||
|
|
0283b51eca | ||
|
|
1af2e92132 | ||
|
|
71ad5d2e3a | ||
|
|
32b5fee108 | ||
|
|
de81ec00fd | ||
|
|
7cc07158ab | ||
|
|
3b8976fd51 | ||
|
|
fb7e650267 | ||
|
|
6a7187fb5b | ||
|
|
b31cdf15a2 | ||
|
|
6e0e0e8133 | ||
|
|
706441799f | ||
|
|
0b66bc7bbd | ||
|
|
86e876a9c9 | ||
|
|
8b33061bbb | ||
|
|
411f1bff1c | ||
|
|
eee4c4e404 | ||
|
|
a187c8c8a0 | ||
|
|
35dca50863 | ||
|
|
00856f15a7 | ||
|
|
d1c67a9dd8 | ||
|
|
6c289506c2 | ||
|
|
5d82ae7680 | ||
|
|
9737886839 | ||
|
|
1d9502d800 | ||
|
|
c0a18f82a5 | ||
|
|
9723a38ca1 | ||
|
|
8258a758d2 | ||
|
|
044613ae9a | ||
|
|
76c9171356 | ||
|
|
f8c330aae3 | ||
|
|
d4bd7dd586 | ||
|
|
fa20f6a63a | ||
|
|
b9ce695616 | ||
|
|
3f1dbf1130 | ||
|
|
6413e51cf5 | ||
|
|
defcf6d26e | ||
|
|
2671983c43 | ||
|
|
dc9653307b | ||
|
|
eb91eb33d5 | ||
|
|
ddb803d9b5 | ||
|
|
c9095b4d67 | ||
|
|
40158eda71 | ||
|
|
bbbbfceeb3 | ||
|
|
9ca1940834 | ||
|
|
37160a91f3 | ||
|
|
274d036f74 | ||
|
|
1fe0e49adb | ||
|
|
7a7a07d9ad | ||
|
|
5b5fca0837 | ||
|
|
fab0264d9b | ||
|
|
8d839ee6ce | ||
|
|
90efbf3159 | ||
|
|
17dd1b4158 | ||
|
|
e5f6d8ff50 | ||
|
|
e183910b88 | ||
|
|
8cd5b9fb46 | ||
|
|
6958445f83 | ||
|
|
ef91294d5e | ||
|
|
a36f286f8a | ||
|
|
d9e921950f | ||
|
|
ffcd19e748 | ||
|
|
d0eb132b95 | ||
|
|
1cf971c092 | ||
|
|
49f745be68 | ||
|
|
b50824a705 | ||
|
|
69d1cc75a7 | ||
|
|
a54ea505c9 | ||
|
|
a1563b72ae | ||
|
|
31d7168aac | ||
|
|
09016e1d5f | ||
|
|
652882350c | ||
|
|
20c4423799 | ||
|
|
bb90a5da92 | ||
|
|
3ca3a2dd3c | ||
|
|
510c48e1af | ||
|
|
3ac809c234 | ||
|
|
9dd33bc3f9 | ||
|
|
897cc0e034 | ||
|
|
482ef0e5e8 | ||
|
|
e0678fc0a9 | ||
|
|
9cb5574b99 | ||
|
|
c18b91f684 | ||
|
|
6622a6ded4 | ||
|
|
fb6aaa52c7 | ||
|
|
a1adc2a85d | ||
|
|
3d9cb621dd | ||
|
|
943b4c75aa | ||
|
|
fb972fae55 | ||
|
|
eb4f28dfda | ||
|
|
e36fedf4b2 | ||
|
|
362a97c59e | ||
|
|
c82beb61a9 | ||
|
|
00a8a0bf69 | ||
|
|
ffc17dd73b | ||
|
|
238abc95ad | ||
|
|
ac0f3ab6f8 | ||
|
|
4bac315568 | ||
|
|
daa48b5a73 | ||
|
|
c70cc864ee | ||
|
|
dc7ff40da6 | ||
|
|
046ffaecf4 | ||
|
|
3904f8563d | ||
|
|
18423a9888 | ||
|
|
8fbbd9b32c | ||
|
|
7e34efd453 | ||
|
|
9d33e62d34 | ||
|
|
6b2bc0adc0 | ||
|
|
80083fedab | ||
|
|
1ab35fdb36 | ||
|
|
f43ece4263 | ||
|
|
ea1ce82ded | ||
|
|
c24adaafcb | ||
|
|
c42875b107 | ||
|
|
447ad36d4d | ||
|
|
71dc467b31 | ||
|
|
8625e1fc0a | ||
|
|
638e5b7fe1 | ||
|
|
f467c69e8f | ||
|
|
8fd98874e2 | ||
|
|
dc6f6c2896 | ||
|
|
a783fc8cd4 | ||
|
|
6a16a7c6c2 | ||
|
|
ceb215a6dc | ||
|
|
d6cb634824 | ||
|
|
500419307b | ||
|
|
12cf0013e2 | ||
|
|
318d4fe0d0 | ||
|
|
a3aee3603f | ||
|
|
7c6f36c600 | ||
|
|
dde8a9cbb6 | ||
|
|
dfca712cb1 | ||
|
|
5057ba2e1c | ||
|
|
8f1dfffa49 | ||
|
|
6991724258 | ||
|
|
09e1de06ce | ||
|
|
5a644b0856 | ||
|
|
86b2187236 | ||
|
|
fafacfeafb | ||
|
|
362019738d | ||
|
|
1a0ba6c6b1 | ||
|
|
4c2cc5da1c | ||
|
|
30e2aa141b | ||
|
|
3768a57eaa | ||
|
|
db5de9be97 | ||
|
|
f60ab6ce85 | ||
|
|
43c48aef17 | ||
|
|
8341b1d6d0 | ||
|
|
dd11961a11 | ||
|
|
3de819a0e9 | ||
|
|
0b546eaeb5 | ||
|
|
558e1819bf | ||
|
|
9d6afa2fe7 | ||
|
|
5f3a967515 | ||
|
|
179f1be19a | ||
|
|
f13a5c070a | ||
|
|
9476d052b6 | ||
|
|
1d446ace04 | ||
|
|
3a8d8706a6 | ||
|
|
910418925a | ||
|
|
1b539df2aa | ||
|
|
f5794e57ee | ||
|
|
7dd1d0a7fc | ||
|
|
ce670cf58c | ||
|
|
c4d1a2a105 | ||
|
|
709223bd46 | ||
|
|
19b4340e18 | ||
|
|
a5a1c64dcb | ||
|
|
2b7bdffe41 | ||
|
|
a2df96354e | ||
|
|
8b49eeff98 | ||
|
|
a8c4db197d | ||
|
|
1319f314ff | ||
|
|
781abaaf40 | ||
|
|
744debc00a | ||
|
|
77321c1bcd | ||
|
|
c97fd60c25 | ||
|
|
2fb40ff443 | ||
|
|
a992ef84f5 | ||
|
|
8fce4c79b6 | ||
|
|
7e4aa9ebbe | ||
|
|
522e5bb129 | ||
|
|
1a97836dc3 | ||
|
|
e1bc9276bc | ||
|
|
555b6929e4 | ||
|
|
ee4d61e476 | ||
|
|
f15235d120 | ||
|
|
471d5726f6 | ||
|
|
e344530fc0 | ||
|
|
29fe38eff4 | ||
|
|
25e643371e | ||
|
|
32cb8dd873 | ||
|
|
12cc61fba5 | ||
|
|
fe40731df3 | ||
|
|
7464ca5543 | ||
|
|
ce83521429 | ||
|
|
27ab530ba6 | ||
|
|
843121f5fd | ||
|
|
d26c469107 | ||
|
|
97453260eb | ||
|
|
06b85c5769 | ||
|
|
5bb21031ac | ||
|
|
256d6139b7 | ||
|
|
aa342047ed | ||
|
|
ea663f8286 | ||
|
|
e953dfb017 | ||
|
|
54170f3da6 | ||
|
|
77ec2fea63 | ||
|
|
83beab4c92 | ||
|
|
29b6d12454 | ||
|
|
866a38f286 | ||
|
|
0ec2e7069b | ||
|
|
f3934b1906 | ||
|
|
fb2bb63d15 | ||
|
|
58cc04298f | ||
|
|
42535feadf | ||
|
|
baa690ffc2 | ||
|
|
d13f0a7acf | ||
|
|
b747199528 | ||
|
|
6a1af44aa0 | ||
|
|
6da050e3b9 | ||
|
|
b8f23ce80c | ||
|
|
865bef532a | ||
|
|
6fb158190d | ||
|
|
0e3f9c8ceb | ||
|
|
4dba6fd0f9 | ||
|
|
fbbf168e88 | ||
|
|
2cd739c3b4 | ||
|
|
a8e770726a | ||
|
|
0c5a99cc03 | ||
|
|
2dee246593 | ||
|
|
381bf59fbd | ||
|
|
fddf83f27d | ||
|
|
3d3e19e26a | ||
|
|
c082a5438a | ||
|
|
5adab1091f | ||
|
|
290a2ec91b | ||
|
|
9ebeabac51 | ||
|
|
b5e2c8d6b8 | ||
|
|
a482b6a3c2 | ||
|
|
f348de6a03 | ||
|
|
8df8978516 | ||
|
|
086d8fd21c | ||
|
|
7dce77adcf | ||
|
|
917a0469d8 | ||
|
|
c12431d8a3 | ||
|
|
dc0cf33d37 | ||
|
|
15d332012f | ||
|
|
99460beafd | ||
|
|
5b0cfb5c33 | ||
|
|
759e747f54 | ||
|
|
6892a679ee | ||
|
|
1b13a2bc4b | ||
|
|
63e8e10a6d | ||
|
|
0615a7e353 | ||
|
|
16acf9db91 | ||
|
|
0c19ba59d2 | ||
|
|
143528d919 | ||
|
|
07cdf378f6 | ||
|
|
f559a2f9c9 | ||
|
|
6b3e9e4676 | ||
|
|
3f72b7cc0d | ||
|
|
4ce5b0e645 | ||
|
|
e92ab8d741 | ||
|
|
6b0e414932 | ||
|
|
00927f3ba3 | ||
|
|
b0faecfa75 | ||
|
|
c15449f99a | ||
|
|
68f04c0912 | ||
|
|
c3c010443f | ||
|
|
15c8abf3d6 | ||
|
|
d0f74c1ab7 | ||
|
|
ca921c1890 | ||
|
|
3b60bbce0a | ||
|
|
8f6b384fe6 | ||
|
|
4d04264caa | ||
|
|
912fd8089e | ||
|
|
5739091773 | ||
|
|
a09c278585 | ||
|
|
a7fb49a11b | ||
|
|
3db8ae53b5 | ||
|
|
311f9a1d00 | ||
|
|
50204f8180 | ||
|
|
d639a802dc | ||
|
|
f41eafe3bd | ||
|
|
8b080eb3cc | ||
|
|
268d8a3a90 | ||
|
|
44d6c40c27 | ||
|
|
9522e25b1d | ||
|
|
db475895ca | ||
|
|
dc33509127 | ||
|
|
2ada67be04 | ||
|
|
77b17604f3 | ||
|
|
d169b3f2b1 | ||
|
|
c8210568eb | ||
|
|
2ea6430a3b | ||
|
|
ac5f997f85 | ||
|
|
e1930c0899 | ||
|
|
020281c1e6 | ||
|
|
9dc81a6280 | ||
|
|
a9906addff | ||
|
|
37269cef02 | ||
|
|
186ec00de7 | ||
|
|
abd13b756c | ||
|
|
6851683d94 | ||
|
|
2b4a3ab137 | ||
|
|
6d21bbe03a | ||
|
|
6f4a0e68a7 | ||
|
|
3de0f38049 | ||
|
|
216ccbfcef | ||
|
|
66b012cd55 | ||
|
|
8339bd3cb1 | ||
|
|
e93c62b06d | ||
|
|
43ceb33b53 | ||
|
|
ae0b45c308 | ||
|
|
bbaeff00f3 | ||
|
|
75a9697586 | ||
|
|
77bd37ca90 | ||
|
|
3a44a6a3b4 | ||
|
|
604d956d0c | ||
|
|
822327edfc | ||
|
|
3ea14f1353 | ||
|
|
7dbc077f76 | ||
|
|
e8cb661938 | ||
|
|
e5a870ed94 | ||
|
|
6116e954ba | ||
|
|
56ef7ce95c | ||
|
|
6e2e585175 | ||
|
|
8c1c0c6029 | ||
|
|
11dad79794 | ||
|
|
4b3485145f | ||
|
|
4b5a579b0b | ||
|
|
07bd09473c | ||
|
|
adba3b0d4b | ||
|
|
f6162c58f2 | ||
|
|
ed949d1dd8 | ||
|
|
5d94de418b | ||
|
|
f7fd8af124 | ||
|
|
d74734972b | ||
|
|
8736f5e387 | ||
|
|
89f08ae6c7 | ||
|
|
0b75b3847d | ||
|
|
6d27c3db11 | ||
|
|
b78065e23c | ||
|
|
c611c5c749 | ||
|
|
5b637154ea | ||
|
|
0b6edb3c38 | ||
|
|
f1ba1c55a6 | ||
|
|
2940a63d09 | ||
|
|
cc311f88a5 | ||
|
|
0911df0442 | ||
|
|
86e5dfe2ee | ||
|
|
34b5570563 | ||
|
|
2d806d8557 | ||
|
|
a792a0aa55 | ||
|
|
e7ab8441d7 | ||
|
|
d0b7efa24c |
@@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
commitmsg = ""
|
||||
|
||||
with open('.git/COMMIT_EDITMSG', mode='r') as f:
|
||||
commitmsg = f.readline().strip()
|
||||
|
||||
print("Commit message is: " + commitmsg)
|
||||
|
||||
ALLOWED_COMMIT_TYPES = [
|
||||
"cicd",
|
||||
"test",
|
||||
"refactor",
|
||||
"depbump",
|
||||
"typo",
|
||||
"fmt",
|
||||
"doc",
|
||||
"bugfix",
|
||||
"security",
|
||||
"feature",
|
||||
]
|
||||
|
||||
for allowedType in ALLOWED_COMMIT_TYPES:
|
||||
if commitmsg.startswith(allowedType + ":"):
|
||||
print("Allowing commit type: ", allowedType)
|
||||
sys.exit(0)
|
||||
|
||||
print("Commit message should start with commit type. One of: ", ", ".join(ALLOWED_COMMIT_TYPES))
|
||||
sys.exit(1)
|
||||
4
.github/ISSUE_TEMPLATE/bug_report.md
vendored
4
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -2,7 +2,9 @@
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ""
|
||||
labels: bug
|
||||
labels:
|
||||
- "type: bug"
|
||||
- "waiting-on-developer"
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
4
.github/ISSUE_TEMPLATE/feature_request.md
vendored
4
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -2,7 +2,9 @@
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
labels:
|
||||
- "type: feature-request"
|
||||
- "waiting-on-developer"
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
6
.github/ISSUE_TEMPLATE/support_request.md
vendored
6
.github/ISSUE_TEMPLATE/support_request.md
vendored
@@ -2,7 +2,9 @@
|
||||
name: Support request
|
||||
about: Need some help? Got an error message?
|
||||
title: ""
|
||||
labels: support
|
||||
labels:
|
||||
- "type: support"
|
||||
- "waiting-on-developer"
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
@@ -39,7 +41,7 @@ If possible, please copy and paste your OliveTin logs from when the error happen
|
||||
**Screenshot of WebDeveloper console logs**
|
||||
|
||||
If you know how, and if you think it's relevant, a screenshot of the
|
||||
WebDeveloper console from when you clicked a button is often really helpful.
|
||||
WebDeveloper console from when you clicked a button is often really helpful.
|
||||
|
||||
**Anything else?**
|
||||
|
||||
|
||||
20
.github/PULL_REQUEST_TEMPLATE.md
vendored
20
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -4,7 +4,7 @@ First of all, thank you for considering to raise a pull request!
|
||||
|
||||
Don’t be afraid to ask for advice before working on a contribution. If you’re thinking about a bigger change, especially that might affect the core working or architecture, it’s almost essential to talk and ask about what you’re planning might affect things. Some of the larger future plans may not be documented well so it’s difficult to understand how your change might affect the general direction and roadmap of this project without asking.
|
||||
|
||||
The preferred way to communicate is probably via Discord or GitHub issues.
|
||||
The preferred way to communicate is probably via Discord or GitHub issues.
|
||||
|
||||
Helpful information to understand the project can be found here: [CONTRIBUTING](https://github.com/OliveTin/OliveTin/blob/main/CONTRIBUTING.adoc)
|
||||
|
||||
@@ -13,10 +13,14 @@ Helpful information to understand the project can be found here: [CONTRIBUTING](
|
||||
# Checklist
|
||||
Please put a X in the boxes as evidence of reading through the checklist.
|
||||
|
||||
- [ ] I have forked the project, and raised this PR on a feature branch.
|
||||
- [ ] `make githooks` has been run, and my git commit message was accepted by the git hook.
|
||||
- [ ] `make daemon-compile` runs without any issues.
|
||||
- [ ] `make daemon-codestyle` runs without any issues.
|
||||
- [ ] `make daemon-unittests` runs without any issues.
|
||||
- [ ] `make webui-codestyle` runs without any issues.
|
||||
- [ ] I understand and accept the [AGPL-3.0 license](LICENSE) and [code of conduct](CODE_OF_CONDUCT.md), and my contributions fall under these.
|
||||
- [ ] I have read the [CONTRIBUTORS](CONTRIBUTORS.adoc) guide
|
||||
- [ ] I considered the "3 line" suggestion.
|
||||
- [ ] I followed the "1 logical change" rule.
|
||||
- [ ] I have forked the project, and raised this PR on a feature branch.
|
||||
- [ ] I ran the `pre-commit` hooks, and my commit message was validated.
|
||||
- [ ] `make -wC service compile` runs without any issues.
|
||||
- [ ] `make -wC service codestyle` runs without any issues.
|
||||
- [ ] `make -wC service unittests` runs without any issues.
|
||||
- [ ] `make -wC webui codestyle` runs without any issues.
|
||||
- [ ] `make -w it` runs without any issues.
|
||||
- [ ] I understand and accept the [AGPL-3.0 license](LICENSE) and [code of conduct](CODE_OF_CONDUCT.md), and my contributions fall under these.
|
||||
|
||||
34
.github/workflows/build-buf.yml
vendored
Normal file
34
.github/workflows/build-buf.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
name: Buf CI
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths:
|
||||
- 'proto/**'
|
||||
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, labeled, unlabeled]
|
||||
delete:
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
jobs:
|
||||
buf:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: 'service/go.mod'
|
||||
cache: true
|
||||
cache-dependency-path: 'service/go.mod'
|
||||
|
||||
- uses: bufbuild/buf-action@v1.1.0
|
||||
with:
|
||||
token: ${{ secrets.BUF_TOKEN }}
|
||||
# Change setup_only to true if you only want to set up the Action and not execute other commands.
|
||||
# Otherwise, you can delete this line--the default is false.
|
||||
setup_only: false
|
||||
# Optional GitHub token for API requests. Ensures requests aren't rate limited.
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
59
.github/workflows/build-snapshot.yml
vendored
59
.github/workflows/build-snapshot.yml
vendored
@@ -2,53 +2,80 @@
|
||||
name: "Build Snapshot"
|
||||
|
||||
on:
|
||||
- push
|
||||
- workflow_dispatch
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-snapshot:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref_type != 'tag'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up QEMU
|
||||
id: qemu
|
||||
uses: docker/setup-qemu-action@v2
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
image: tonistiigi/binfmt:latest
|
||||
platforms: arm64,arm
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
cache: 'npm'
|
||||
cache-dependency-path: webui/package-lock.json
|
||||
cache-dependency-path: webui.dev/package-lock.json
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v3
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '>=1.18.0'
|
||||
go-version-file: 'service/go.mod'
|
||||
cache: true
|
||||
cache-dependency-path: 'service/go.mod'
|
||||
|
||||
- name: Print go version
|
||||
run: go version
|
||||
|
||||
- name: grpc
|
||||
run: make grpc
|
||||
run: make -w grpc
|
||||
|
||||
- name: make service
|
||||
run: make -w service
|
||||
|
||||
- name: make webui
|
||||
run: make -w webui-dist
|
||||
|
||||
- name: unit tests
|
||||
run: make -w service-unittests
|
||||
|
||||
- name: integration tests
|
||||
run: cd integration-tests && make -w
|
||||
|
||||
- name: goreleaser
|
||||
uses: goreleaser/goreleaser-action@v4.2.0
|
||||
uses: goreleaser/goreleaser-action@v6
|
||||
with:
|
||||
distribution: goreleaser
|
||||
version: latest
|
||||
args: release --snapshot --clean --parallelism 1 --skip-docker
|
||||
args: release --snapshot --clean --parallelism 1 --skip=docker
|
||||
|
||||
- name: get date
|
||||
run: |
|
||||
echo "DATE=$(date +'%Y-%m-%d')" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Archive binaries
|
||||
uses: actions/upload-artifact@v3.1.0
|
||||
uses: actions/upload-artifact@v4.3.1
|
||||
with:
|
||||
name: "OliveTin-snapshot-${{ github.sha }}-dist"
|
||||
name: "OliveTin-snapshot-${{ env.DATE }}-${{ github.sha }}"
|
||||
path: dist/OliveTin*.*
|
||||
|
||||
- name: Archive integration tests
|
||||
uses: actions/upload-artifact@v3.1.0
|
||||
uses: actions/upload-artifact@v4.3.1
|
||||
if: always()
|
||||
with:
|
||||
name: integration-tests
|
||||
path: integration-tests
|
||||
name: "OliveTin-integration-tests-${{ env.DATE }}-${{ github.sha }}"
|
||||
path: |
|
||||
integration-tests
|
||||
!integration-tests/node_modules
|
||||
|
||||
48
.github/workflows/build-tag.yml
vendored
48
.github/workflows/build-tag.yml
vendored
@@ -11,53 +11,71 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up QEMU
|
||||
id: qemu
|
||||
uses: docker/setup-qemu-action@v2
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
image: tonistiigi/binfmt:latest
|
||||
platforms: arm64,arm
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
cache: 'npm'
|
||||
cache-dependency-path: webui/package-lock.json
|
||||
cache-dependency-path: webui.dev/package-lock.json
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v3
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '^1.18.0'
|
||||
go-version-file: 'service/go.mod'
|
||||
cache: true
|
||||
cache-dependency-path: 'service/go.mod'
|
||||
|
||||
- name: Print go version
|
||||
run: go version
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_KEY }}
|
||||
|
||||
- name: Login to ghcr
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.CONTAINER_TOKEN }}
|
||||
|
||||
- name: grpc
|
||||
run: make grpc
|
||||
run: make -w grpc
|
||||
|
||||
- name: make webui
|
||||
run: make -w webui-dist
|
||||
|
||||
- name: goreleaser
|
||||
uses: goreleaser/goreleaser-action@v2
|
||||
uses: goreleaser/goreleaser-action@v6
|
||||
with:
|
||||
distribution: goreleaser
|
||||
version: latest
|
||||
args: release --rm-dist --parallelism 1
|
||||
args: release --clean --timeout 60m
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.CONTAINER_TOKEN }}
|
||||
|
||||
- name: Archive binaries
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v4.3.1
|
||||
with:
|
||||
name: dist
|
||||
name: "OliveTin-${{ github.ref_name }}"
|
||||
path: dist/OliveTin*.*
|
||||
|
||||
- name: Archive integration tests
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v4.3.1
|
||||
with:
|
||||
name: integration-tests
|
||||
path: integration-tests
|
||||
path: |
|
||||
integration-tests
|
||||
!integration-tests/node_modules
|
||||
|
||||
20
.github/workflows/codeql-analysis.yml
vendored
20
.github/workflows/codeql-analysis.yml
vendored
@@ -17,7 +17,7 @@ on:
|
||||
paths:
|
||||
- 'cmd/**'
|
||||
- 'internal/**'
|
||||
- 'webui/**'
|
||||
- 'webui.dev/**'
|
||||
- 'integration-tests/**'
|
||||
- 'OliveTin.proto'
|
||||
branches: [main]
|
||||
@@ -42,13 +42,25 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: 'service/go.mod'
|
||||
cache: true
|
||||
cache-dependency-path: 'service/go.mod'
|
||||
|
||||
- name: grpc
|
||||
run: make -w grpc
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
uses: github/codeql-action/analyze@v3
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
||||
|
||||
21
.github/workflows/codestyle.yml
vendored
21
.github/workflows/codestyle.yml
vendored
@@ -6,7 +6,7 @@ on:
|
||||
paths:
|
||||
- 'cmd/**'
|
||||
- 'internal/**'
|
||||
- 'webui/**'
|
||||
- 'webui.dev/**'
|
||||
- 'integration-tests/**'
|
||||
- 'OliveTin.proto'
|
||||
|
||||
@@ -16,18 +16,23 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v2
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '^1.16.0'
|
||||
go-version-file: 'service/go.mod'
|
||||
cache: true
|
||||
cache-dependency-path: 'service/go.mod'
|
||||
|
||||
- name: Print go version
|
||||
run: go version
|
||||
|
||||
- name: deps
|
||||
run: make grpc
|
||||
run: make -w grpc
|
||||
|
||||
- name: daemon
|
||||
run: make daemon-codestyle
|
||||
- name: service
|
||||
run: make -wC service codestyle
|
||||
|
||||
- name: webui
|
||||
run: make webui-codestyle
|
||||
run: make -wC webui.dev codestyle
|
||||
|
||||
34
.github/workflows/devskim.yml
vendored
Normal file
34
.github/workflows/devskim.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
|
||||
name: DevSkim
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
schedule:
|
||||
- cron: '34 21 * * 2'
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: DevSkim
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Run DevSkim scanner
|
||||
uses: microsoft/DevSkim-Action@v1
|
||||
|
||||
- name: Upload DevSkim scan results to GitHub Security tab
|
||||
uses: github/codeql-action/upload-sarif@v3
|
||||
with:
|
||||
sarif_file: devskim-results.sarif
|
||||
73
.github/workflows/issue-responsibility.yml
vendored
Normal file
73
.github/workflows/issue-responsibility.yml
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
---
|
||||
name: Issue Responsibility
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
update-responsibility-labels:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Update responsibility labels
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const commentAuthor = context.payload.comment.user.login;
|
||||
const issueNumber = context.payload.issue.number;
|
||||
const owner = context.repo.owner;
|
||||
const repo = context.repo.repo;
|
||||
|
||||
const skipAction = context.payload.comment.body.includes("/skip-responsibility");
|
||||
|
||||
if (skipAction) {
|
||||
core.info("Skipping responsibility label update");
|
||||
return;
|
||||
}
|
||||
|
||||
const developers = ["jamesread"]
|
||||
const commenterIsDeveloper = developers.includes(commentAuthor);
|
||||
const commenterIsUser = !commenterIsDeveloper;
|
||||
|
||||
const issueLabels = context.payload.issue.labels.map(label => label.name);
|
||||
|
||||
if (issueLabels.includes("waiting-on-developer")) {
|
||||
if (commenterIsDeveloper) {
|
||||
await github.rest.issues.removeLabel({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issueNumber,
|
||||
name: "waiting-on-developer",
|
||||
});
|
||||
|
||||
await github.rest.issues.addLabels({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issueNumber,
|
||||
labels: ["waiting-on-requestor"],
|
||||
});
|
||||
|
||||
core.info(`Switched responsibility to user for issue #${issueNumber}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (issueLabels.includes("waiting-on-requestor")) {
|
||||
if (commenterIsUser) {
|
||||
await github.rest.issues.removeLabel({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issueNumber,
|
||||
name: "waiting-on-requestor",
|
||||
});
|
||||
|
||||
await github.rest.issues.addLabels({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issueNumber,
|
||||
labels: ["waiting-on-developer"],
|
||||
});
|
||||
|
||||
core.info(`Switched responsibility to developer for issue #${issueNumber}`);
|
||||
}
|
||||
}
|
||||
16
.gitignore
vendored
16
.gitignore
vendored
@@ -1,11 +1,15 @@
|
||||
webui/node_modules
|
||||
**/*.swp
|
||||
**/*.swo
|
||||
gen/
|
||||
/OliveTin
|
||||
/OliveTin.armhf
|
||||
/OliveTin.exe
|
||||
reports
|
||||
service/gen/
|
||||
service/OliveTin
|
||||
service/OliveTin.armhf
|
||||
service/OliveTin.exe
|
||||
service/reports
|
||||
releases/
|
||||
dist/
|
||||
installation-id.txt
|
||||
tmp/
|
||||
webui/
|
||||
webui.dev/node_modules
|
||||
webui.dev/.parcel-cache
|
||||
custom-webui
|
||||
|
||||
@@ -1,28 +1,32 @@
|
||||
project_name: OliveTin
|
||||
version: 2
|
||||
before:
|
||||
hooks:
|
||||
- go mod download
|
||||
- rm -rf webui/node_modules
|
||||
- make service-prep
|
||||
|
||||
builds:
|
||||
- env:
|
||||
- CGO_ENABLED=0
|
||||
binary: OliveTin
|
||||
main: main.go
|
||||
dir: service
|
||||
goos:
|
||||
- linux
|
||||
- windows
|
||||
- darwin
|
||||
- freebsd
|
||||
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
- arm
|
||||
- riscv64
|
||||
|
||||
goarm:
|
||||
- 5 # For old RPIs
|
||||
- 6
|
||||
- 6
|
||||
- 7
|
||||
|
||||
main: cmd/OliveTin/main.go
|
||||
|
||||
ignore:
|
||||
- goos: darwin
|
||||
goarch: arm # Mac does not work on [32bit] arm
|
||||
@@ -39,7 +43,7 @@ builds:
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
snapshot:
|
||||
name_template: "{{ .Branch }}-{{ .ShortCommit }}"
|
||||
version_template: "{{ .Branch }}-{{ .ShortCommit }}"
|
||||
changelog:
|
||||
sort: asc
|
||||
groups:
|
||||
@@ -47,7 +51,7 @@ changelog:
|
||||
regexp: '^.*?security(\([[:word:]]+\))??!?:.+$'
|
||||
order: 0
|
||||
- title: 'Features'
|
||||
regexp: '^.*?feature(\([[:word:]]+\))??!?:.+$'
|
||||
regexp: '^.*?feat.*?(\([[:word:]]+\))??!?:.+$'
|
||||
order: 1
|
||||
- title: 'Bug fixes'
|
||||
regexp: '^.*?bugfix(\([[:word:]]+\))??!?:.+$'
|
||||
@@ -62,29 +66,19 @@ changelog:
|
||||
- '^refactor:'
|
||||
|
||||
archives:
|
||||
-
|
||||
format: tar.gz
|
||||
|
||||
files:
|
||||
- formats: tar.gz
|
||||
files:
|
||||
- config.yaml
|
||||
- LICENSE
|
||||
- README.md
|
||||
- Dockerfile
|
||||
- webui
|
||||
- OliveTin.service
|
||||
- ./var/
|
||||
|
||||
replacements:
|
||||
darwin: macOS
|
||||
arm: arm32v
|
||||
|
||||
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}{{ .Arm }}"
|
||||
|
||||
wrap_in_directory: true
|
||||
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
formats: zip
|
||||
|
||||
dockers:
|
||||
- image_templates:
|
||||
@@ -96,27 +90,30 @@ dockers:
|
||||
skip_push: false
|
||||
build_flag_templates:
|
||||
- "--platform=linux/amd64"
|
||||
- "--label=org.opencontainers.image.title={{.ProjectName}}"
|
||||
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
|
||||
- "--label=org.opencontainers.image.version={{.Tag}}"
|
||||
- "--platform=linux/amd64"
|
||||
extra_files:
|
||||
- webui
|
||||
- var/entities/
|
||||
- config.yaml
|
||||
- var/helper-actions/
|
||||
|
||||
- image_templates:
|
||||
- "docker.io/jamesread/olivetin:{{ .Tag }}-arm64"
|
||||
- "ghcr.io/olivetin/olivetin:{{ .Tag }}-amd64"
|
||||
- "ghcr.io/olivetin/olivetin:{{ .Tag }}-arm64"
|
||||
dockerfile: Dockerfile.arm64
|
||||
goos: linux
|
||||
goarch: arm64
|
||||
skip_push: false
|
||||
build_flag_templates:
|
||||
- "--platform=linux/arm64"
|
||||
- "--label=org.opencontainers.image.title={{.ProjectName}}"
|
||||
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
|
||||
- "--label=org.opencontainers.image.version={{.Tag}}"
|
||||
extra_files:
|
||||
- webui
|
||||
- var/entities/
|
||||
- config.yaml
|
||||
- var/helper-actions/
|
||||
|
||||
docker_manifests:
|
||||
- name_template: docker.io/jamesread/olivetin:{{ .Version }}
|
||||
@@ -154,31 +151,20 @@ nfpms:
|
||||
file_name_template: '{{ .PackageName }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
|
||||
|
||||
contents:
|
||||
- src: OliveTin.service
|
||||
- src: var/systemd/OliveTin.service
|
||||
dst: /etc/systemd/system/OliveTin.service
|
||||
|
||||
- src: webui/main.js
|
||||
- src: webui/*
|
||||
dst: /var/www/olivetin/
|
||||
|
||||
- src: webui/index.html
|
||||
dst: /var/www/olivetin/
|
||||
|
||||
- src: webui/*.png
|
||||
dst: /var/www/olivetin/
|
||||
|
||||
- src: webui/*.svg
|
||||
dst: /var/www/olivetin/
|
||||
|
||||
- src: webui/style.css
|
||||
dst: /var/www/olivetin/
|
||||
|
||||
- src: webui/js/
|
||||
dst: /var/www/olivetin/js/
|
||||
|
||||
- src: config.yaml
|
||||
dst: /etc/OliveTin/config.yaml
|
||||
type: "config|noreplace"
|
||||
|
||||
- src: var/entities/*
|
||||
dst: /etc/OliveTin/entities/
|
||||
type: "config|noreplace"
|
||||
|
||||
- src: var/manpage/OliveTin.1.gz
|
||||
dst: /usr/share/man/man1/OliveTin.1.gz
|
||||
|
||||
@@ -198,28 +184,17 @@ nfpms:
|
||||
- src: var/openrc/OliveTin
|
||||
dst: /etc/init.d/OliveTin
|
||||
|
||||
- src: webui/main.js
|
||||
- src: webui/*
|
||||
dst: /var/www/olivetin/
|
||||
|
||||
- src: webui/index.html
|
||||
dst: /var/www/olivetin/
|
||||
|
||||
- src: webui/*.png
|
||||
dst: /var/www/olivetin/
|
||||
|
||||
- src: webui/*.svg
|
||||
dst: /var/www/olivetin/
|
||||
|
||||
- src: webui/style.css
|
||||
dst: /var/www/olivetin/
|
||||
|
||||
- src: webui/js/
|
||||
dst: /var/www/olivetin/js/
|
||||
|
||||
- src: config.yaml
|
||||
dst: /etc/OliveTin/config.yaml
|
||||
type: "config|noreplace"
|
||||
|
||||
- src: var/entities/*
|
||||
dst: /etc/OliveTin/entities/
|
||||
type: "config|noreplace"
|
||||
|
||||
- src: var/manpage/OliveTin.1.gz
|
||||
dst: /usr/share/man/man1/OliveTin.1.gz
|
||||
|
||||
@@ -233,10 +208,13 @@ release:
|
||||
|
||||
- `docker pull docker.io/jamesread/olivetin:{{ .Version }}`
|
||||
|
||||
## Upgrade warnings, or breaking changes
|
||||
|
||||
- No such issues between the last release and this version.
|
||||
|
||||
## Useful links
|
||||
|
||||
- [Which download do I need?](https://docs.olivetin.app/choose-package.html)
|
||||
- [Ask for help and chat with others users in the Discord community](https://discord.gg/jhYWWpNJ3v)
|
||||
|
||||
|
||||
Thanks for your interest in OliveTin!
|
||||
|
||||
|
||||
19
.pre-commit-config.yaml
Normal file
19
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v3.2.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
- id: check-added-large-files
|
||||
|
||||
# Alternative semantic commit checker
|
||||
- repo: https://github.com/compilerla/conventional-pre-commit
|
||||
rev: v3.1.0
|
||||
hooks:
|
||||
- id: conventional-pre-commit
|
||||
stages: [commit-msg]
|
||||
args: [] # optional: list of Conventional Commits types to allow e.g. [feat, fix, ci, chore, test]
|
||||
28
AI.md
Normal file
28
AI.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# OliveTin's AI Policy
|
||||
|
||||
## Runtime:
|
||||
|
||||
- [x] The project does not include any AI functionality at runtime.
|
||||
- [x] No data, usage, or similar is sent to, or analyized by AI.
|
||||
|
||||
## Development - Contributions
|
||||
|
||||
- [x] The project does accept contributions that were written with AI help, but the contribution must be attributed to a human username.
|
||||
-- [x] The contribution should have come from a freely accessible open source model (coderabbitai pro which the project subscribes to is an exception).
|
||||
- [x] Contributors should declare when AI has been used to help write contributions.
|
||||
- [x] The project uses AI as an **optional** part of the PR process (coderabbitai). Please raise any concerns about usage within the PR.
|
||||
-- [x] Suggestions from coderabbitai can be accepted verbaitem, but ideally it should be the PR author that uses coderabbitai as a guide, who then re-writes the contribution.
|
||||
- [x] Maintainers are the only agents permitted to accept merges.
|
||||
|
||||
## Development - Build process
|
||||
|
||||
- [x] Linters, code review tools, and others which are enabled by AI are allowed, but cannot be added as part of the standard build process.
|
||||
|
||||
## Community
|
||||
|
||||
- [x] Only project admins are allowed to run bots in the community discord server (at the time of writing, the current bot, Japella, is not AI-enabled).
|
||||
- [x] Support is currently not provided by AI.
|
||||
|
||||
## Training
|
||||
|
||||
- [x] You may use the OliveTin code base, documentation and repositories to train AI, but obviously usernames and personally identifiable information may not be stored.
|
||||
@@ -7,9 +7,17 @@ of multiple projects, your time and interest in contributing is most welcome.
|
||||
If you're not sure where to get started, raise an issue in the project.
|
||||
|
||||
Ideas may be discussed, purely on their merits and issues. Our Code of Conduct
|
||||
(CoC) is straightforward - it's important that contributors feel comfortable in
|
||||
discussion throughout the whole process. This project respects the
|
||||
link:https://www.kernel.org/doc/html/latest/process/code-of-conduct.html[Linux Kernel code of conduct].
|
||||
(CoC) is straightforward - it's important that contributors feel comfortable in
|
||||
discussion throughout the whole process. This project respects the
|
||||
link:https://www.kernel.org/doc/html/latest/process/code-of-conduct.html[Linux Kernel code of conduct].
|
||||
|
||||
== Suggestion: More than 3 lines - talk to someone first
|
||||
|
||||
If you're planning on making a change that's more than a 3 lines, please talk to someone first (raising a GitHub issue is the best way to do that). This is so that you don't waste your time on something that might not be accepted. It's also a good way to get some feedback on your idea and make sure you're on the right track.
|
||||
|
||||
== Rule: A PR should be one logical change
|
||||
|
||||
Please try to keep your pull requests small and focused. It's almost impossible to review PRs that change lots of files for lots of different reasons. If you have a big change, it's probably best to break it down into smaller, more manageable chunks, otherwise it's likely to be rejected.
|
||||
|
||||
== If you're not sure, ask!
|
||||
|
||||
@@ -18,19 +26,27 @@ contribution. If you're thinking about a bigger change, especially that might
|
||||
affect the core working or architecture, it's almost essential to talk and ask
|
||||
about what you're planning might affect things. Some of the larger future plans may not be
|
||||
documented well so it's difficult to understand how your change might affect
|
||||
the general direction and roadmap of this project without asking.
|
||||
the general direction and roadmap of this project without asking.
|
||||
|
||||
The preferred way to communicate is probably via Discord or GitHub issues.
|
||||
The preferred way to communicate is probably via Discord or GitHub issues.
|
||||
|
||||
=== Dev environment setup and clean build - Fedora
|
||||
== Dev environment setup and clean build
|
||||
|
||||
```
|
||||
dnf install git go protobuf-compiler make -y
|
||||
# Step1: setup compile env
|
||||
# - Fedora
|
||||
dnf install git go protobuf-compiler make -y
|
||||
# - Windows with chocolatey
|
||||
choco install git go protoc make python nodejs-lts -y
|
||||
|
||||
# Step2: clone and setup repo
|
||||
git clone https://github.com/OliveTin/OliveTin.git
|
||||
cd OliveTin
|
||||
make githooks
|
||||
|
||||
# `make grpc` will also run `make go-tools`, which installs "buf". This binary
|
||||
# will be put in your GOPATH/bin/, which should be on your path. buf is used to
|
||||
# Step3: compile binary for current dev env (OS, ARCH)
|
||||
# `make grpc` will also run `make go-tools`, which installs "buf". This binary
|
||||
# will be put in your GOPATH/bin/, which should be on your path. buf is used to
|
||||
# generate the protobuf / grpc stubs.
|
||||
make grpc
|
||||
make
|
||||
@@ -39,10 +55,10 @@ make
|
||||
|
||||
=== Getting started to contribute;
|
||||
|
||||
The project layout is reasonably straightforward;
|
||||
The project layout is reasonably straightforward;
|
||||
|
||||
* See the `Makefile` for common targets. This project was originally created on top of Fedora, but it should be usable on Debian/your faveourite distro with minor changes (if any).
|
||||
* The API is defined in protobuf+grpc - you will need to `make grpc`.
|
||||
* The API is defined in protobuf+grpc - you will need to `make grpc`.
|
||||
* The Go daemon is built from the `cmd` and `internal` directories mostly.
|
||||
* The webui is just a single page application with a bit of Javascript in the `webui` directory. This can happily be hosted on another webserver.
|
||||
|
||||
|
||||
34
Dockerfile
34
Dockerfile
@@ -1,23 +1,45 @@
|
||||
FROM --platform=linux/amd64 registry.fedoraproject.org/fedora-minimal:36-x86_64
|
||||
FROM --platform=linux/amd64 registry.fedoraproject.org/fedora-minimal:40-x86_64 AS olivetin-tmputils
|
||||
|
||||
RUN microdnf -y install dnf-plugins-core && \
|
||||
dnf-3 config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo && \
|
||||
microdnf install -y docker-ce-cli docker-compose-plugin && microdnf clean all
|
||||
|
||||
FROM --platform=linux/amd64 registry.fedoraproject.org/fedora-minimal:40-x86_64
|
||||
|
||||
LABEL org.opencontainers.image.source https://github.com/OliveTin/OliveTin
|
||||
LABEL org.opencontainers.image.title OliveTin
|
||||
|
||||
RUN mkdir -p /config /var/www/olivetin \
|
||||
&& microdnf install -y --nodocs --noplugins --setopt=keepcache=0 --setopt=install_weak_deps=0 \
|
||||
RUN mkdir -p /config /config/entities/ /var/www/olivetin \
|
||||
&& \
|
||||
microdnf install -y --nodocs --noplugins --setopt=keepcache=0 --setopt=install_weak_deps=0 \
|
||||
iputils \
|
||||
openssh-clients \
|
||||
kubernetes-client \
|
||||
shadow-utils \
|
||||
docker \
|
||||
apprise \
|
||||
jq \
|
||||
git \
|
||||
&& microdnf clean all
|
||||
|
||||
RUN useradd --system --create-home olivetin -u 1000
|
||||
COPY --from=olivetin-tmputils \
|
||||
/usr/bin/docker \
|
||||
/usr/bin/docker
|
||||
|
||||
EXPOSE 1337/tcp
|
||||
COPY --from=olivetin-tmputils \
|
||||
/usr/libexec/docker/cli-plugins/docker-compose \
|
||||
/usr/libexec/docker/cli-plugins/docker-compose
|
||||
|
||||
RUN useradd --system --create-home olivetin -u 1000
|
||||
|
||||
EXPOSE 1337/tcp
|
||||
|
||||
COPY config.yaml /config
|
||||
COPY var/entities/* /config/entities/
|
||||
VOLUME /config
|
||||
|
||||
COPY OliveTin /usr/bin/OliveTin
|
||||
COPY webui /var/www/olivetin/
|
||||
COPY var/helper-actions/* /usr/bin/
|
||||
|
||||
USER olivetin
|
||||
|
||||
|
||||
@@ -1,22 +1,45 @@
|
||||
FROM --platform=linux/arm64 registry.fedoraproject.org/fedora-minimal:36-aarch64
|
||||
FROM --platform=linux/arm64 registry.fedoraproject.org/fedora-minimal:40-aarch64 AS olivetin-tmputils
|
||||
|
||||
RUN microdnf -y install dnf-plugins-core && \
|
||||
dnf-3 config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo && \
|
||||
microdnf install -y docker-ce-cli docker-compose-plugin && microdnf clean all
|
||||
|
||||
FROM --platform=linux/arm64 registry.fedoraproject.org/fedora-minimal:40-aarch64
|
||||
|
||||
LABEL org.opencontainers.image.source https://github.com/OliveTin/OliveTin
|
||||
LABEL org.opencontainers.image.title OliveTin
|
||||
|
||||
RUN mkdir -p /config /var/www/olivetin \
|
||||
RUN mkdir -p /config /config/entities/ /var/www/olivetin \
|
||||
&& \
|
||||
microdnf install -y --nodocs --noplugins --setopt=keepcache=0 --setopt=install_weak_deps=0 \
|
||||
microdnf install -y --nodocs --noplugins --setopt=keepcache=0 --setopt=install_weak_deps=0 \
|
||||
iputils \
|
||||
openssh-clients \
|
||||
kubernetes-client \
|
||||
shadow-utils \
|
||||
openssh-clients
|
||||
apprise \
|
||||
jq \
|
||||
git \
|
||||
&& microdnf clean all
|
||||
|
||||
RUN useradd --system --create-home olivetin -u 1000
|
||||
COPY --from=olivetin-tmputils \
|
||||
/usr/bin/docker \
|
||||
/usr/bin/docker
|
||||
|
||||
EXPOSE 1337/tcp
|
||||
COPY --from=olivetin-tmputils \
|
||||
/usr/libexec/docker/cli-plugins/docker-compose \
|
||||
/usr/libexec/docker/cli-plugins/docker-compose
|
||||
|
||||
RUN useradd --system --create-home olivetin -u 1000
|
||||
|
||||
EXPOSE 1337/tcp
|
||||
|
||||
COPY config.yaml /config
|
||||
COPY var/entities/* /config/entities/
|
||||
VOLUME /config
|
||||
|
||||
COPY OliveTin /usr/bin/OliveTin
|
||||
COPY webui /var/www/olivetin/
|
||||
COPY var/helper-actions/* /usr/bin/
|
||||
|
||||
USER olivetin
|
||||
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
FROM --platform=linux/armhfp registry.fedoraproject.org/fedora-minimal:36-armhfp
|
||||
|
||||
LABEL org.opencontainers.image.source https://github.com/OliveTin/OliveTin
|
||||
LABEL org.opencontainers.image.title=OliveTin
|
||||
|
||||
RUN mkdir -p /config /var/www/olivetin \
|
||||
RUN mkdir -p /config /config/entities /var/www/olivetin \
|
||||
&& \
|
||||
microdnf install -y --nodocs --noplugins --setopt=keepcache=0 --setopt=install_weak_deps=0 \
|
||||
microdnf install -y --nodocs --noplugins --setopt=keepcache=0 --setopt=install_weak_deps=0 \
|
||||
iputils \
|
||||
shadow-utils \
|
||||
openssh-clients
|
||||
shadow-utils \
|
||||
openssh-clients
|
||||
|
||||
RUN useradd --system --create-home olivetin -u 1000
|
||||
RUN useradd --system --create-home olivetin -u 1000
|
||||
|
||||
EXPOSE 1337/tcp
|
||||
EXPOSE 1337/tcp
|
||||
|
||||
COPY config.yaml /config
|
||||
COPY var/entities/* /config/entities/
|
||||
VOLUME /config
|
||||
|
||||
COPY OliveTin /usr/bin/OliveTin
|
||||
COPY webui /var/www/olivetin/
|
||||
COPY var/helper-actions/* /usr/bin/
|
||||
|
||||
USER olivetin
|
||||
|
||||
|
||||
50
Jenkinsfile
vendored
50
Jenkinsfile
vendored
@@ -1,50 +0,0 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
options {
|
||||
skipDefaultCheckout(true)
|
||||
}
|
||||
|
||||
stages {
|
||||
stage ('Pre-Build') {
|
||||
steps {
|
||||
cleanWs()
|
||||
checkout scm
|
||||
|
||||
sh 'make go-tools'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Compile') {
|
||||
steps {
|
||||
withEnv(["PATH+GO=/root/go/bin/"]) {
|
||||
sh 'go env'
|
||||
sh 'echo $PATH'
|
||||
sh 'buf generate'
|
||||
sh 'make daemon-compile'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage ('Post-Compile') {
|
||||
parallel {
|
||||
stage('Codestyle') {
|
||||
steps {
|
||||
withEnv(["PATH+GO=/root/go/bin/"]) {
|
||||
sh 'make daemon-codestyle'
|
||||
sh 'make webui-codestyle'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('UnitTests') {
|
||||
steps {
|
||||
withEnv(["PATH+GO=/root/go/bin/"]) {
|
||||
sh 'make daemon-unittests'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
70
Makefile
70
Makefile
@@ -1,43 +1,28 @@
|
||||
compile: daemon-compile-x64-lin
|
||||
define delete-files
|
||||
python -c "import shutil;shutil.rmtree('$(1)', ignore_errors=True)"
|
||||
endef
|
||||
|
||||
daemon-compile-armhf:
|
||||
GOARCH=arm GOARM=6 go build -o OliveTin.armhf github.com/OliveTin/OliveTin/cmd/OliveTin
|
||||
service:
|
||||
$(MAKE) -wC service
|
||||
|
||||
daemon-compile-x64-lin:
|
||||
GOOS=linux go build -o OliveTin github.com/OliveTin/OliveTin/cmd/OliveTin
|
||||
service-prep:
|
||||
$(MAKE) -wC service prep
|
||||
|
||||
daemon-compile-x64-win:
|
||||
GOOS=windows GOARCH=amd64 go build -o OliveTin.exe github.com/OliveTin/OliveTin/cmd/OliveTin
|
||||
service-unittests:
|
||||
$(MAKE) -wC service unittests
|
||||
|
||||
daemon-compile: daemon-compile-armhf daemon-compile-x64-lin daemon-compile-x64-win
|
||||
it:
|
||||
$(MAKE) -wC integration-tests
|
||||
|
||||
daemon-codestyle:
|
||||
go fmt ./...
|
||||
go vet ./...
|
||||
gocyclo -over 4 cmd internal
|
||||
gocritic check ./...
|
||||
|
||||
daemon-unittests:
|
||||
mkdir -p reports
|
||||
go test ./... -coverprofile reports/unittests.out
|
||||
go tool cover -html=reports/unittests.out -o reports/unittests.html
|
||||
|
||||
githooks:
|
||||
cp -v .githooks/* .git/hooks/
|
||||
|
||||
go-tools:
|
||||
go install "github.com/bufbuild/buf/cmd/buf"
|
||||
go install "github.com/fzipp/gocyclo/cmd/gocyclo"
|
||||
go install "github.com/go-critic/go-critic/cmd/gocritic"
|
||||
go install "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway"
|
||||
go install "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2"
|
||||
go install "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
|
||||
go install "google.golang.org/protobuf/cmd/protoc-gen-go"
|
||||
$(MAKE) -wC service go-tools
|
||||
|
||||
proto: grpc
|
||||
|
||||
grpc: go-tools
|
||||
buf generate
|
||||
$(MAKE) -wC proto
|
||||
|
||||
dist: protoc
|
||||
dist: protoc
|
||||
|
||||
protoc:
|
||||
protoc --go_out=. --go-grpc_out=. --grpc-gateway_out=. -I .:/usr/include/ OliveTin.proto
|
||||
@@ -54,7 +39,7 @@ podman-container:
|
||||
integration-tests-docker-image:
|
||||
docker rm -f olivetin && docker rmi -f olivetin
|
||||
docker build -t olivetin:latest .
|
||||
docker create --name olivetin -p 1337:1337 -v `pwd`/integration-tests/configs/:/config/ olivetin
|
||||
docker create --name olivetin -p 1337:1337 -v `pwd`/integration-tests/configs/:/config/ olivetin
|
||||
|
||||
devrun: compile
|
||||
killall OliveTin || true
|
||||
@@ -63,11 +48,22 @@ devrun: compile
|
||||
devcontainer: compile podman-image podman-container
|
||||
|
||||
webui-codestyle:
|
||||
cd webui && npm install
|
||||
cd webui && ./node_modules/.bin/eslint main.js js/*
|
||||
cd webui && ./node_modules/.bin/stylelint style.css
|
||||
$(MAKE) -wC webui.dev codestyle
|
||||
|
||||
webui-dist:
|
||||
$(call delete-files,webui)
|
||||
$(call delete-files,webui.dev/dist)
|
||||
cd webui.dev && npm install
|
||||
cd webui.dev && npx parcel build --public-url "."
|
||||
python -c "import shutil;shutil.move('webui.dev/dist', 'webui')"
|
||||
python -c "import shutil;import glob;[shutil.copy(f, 'webui') for f in glob.glob('webui.dev/*.png')]"
|
||||
|
||||
clean:
|
||||
rm -rf dist OliveTin OliveTin.armhf OliveTin.exe reports gen
|
||||
$(call delete-files,dist)
|
||||
$(call delete-files,OliveTin)
|
||||
$(call delete-files,OliveTin.armhf)
|
||||
$(call delete-files,OliveTin.exe)
|
||||
$(call delete-files,reports)
|
||||
$(call delete-files,gen)
|
||||
|
||||
.PHONY: grpc
|
||||
.PHONY: grpc proto service
|
||||
|
||||
140
OliveTin.proto
140
OliveTin.proto
@@ -1,140 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option go_package = "gen/grpc";
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
message Action {
|
||||
string id = 1;
|
||||
string title = 2;
|
||||
string icon = 3;
|
||||
bool canExec = 4;
|
||||
|
||||
repeated ActionArgument arguments = 5;
|
||||
}
|
||||
|
||||
message ActionArgument {
|
||||
string name = 1;
|
||||
string title = 2;
|
||||
string type = 3;
|
||||
string defaultValue = 4;
|
||||
|
||||
repeated ActionArgumentChoice choices = 5;
|
||||
|
||||
string description = 6;
|
||||
}
|
||||
|
||||
message ActionArgumentChoice {
|
||||
string value = 1;
|
||||
string title = 2;
|
||||
}
|
||||
|
||||
message Entity {
|
||||
string title = 1;
|
||||
string icon = 2;
|
||||
repeated Action actions = 3;
|
||||
}
|
||||
|
||||
message GetDashboardComponentsResponse {
|
||||
string title = 1;
|
||||
repeated Action actions = 2;
|
||||
repeated Entity entities = 3;
|
||||
}
|
||||
|
||||
message GetDashboardComponentsRequest {}
|
||||
|
||||
message StartActionRequest {
|
||||
string actionName = 1;
|
||||
|
||||
repeated StartActionArgument arguments = 2;
|
||||
}
|
||||
|
||||
message StartActionArgument {
|
||||
string name = 1;
|
||||
string value = 2;
|
||||
}
|
||||
|
||||
message StartActionResponse {
|
||||
LogEntry logEntry = 1;
|
||||
}
|
||||
|
||||
message GetLogsRequest{};
|
||||
|
||||
message LogEntry {
|
||||
string datetime = 1;
|
||||
string actionTitle = 2;
|
||||
string stdout = 3;
|
||||
string stderr = 4;
|
||||
bool timedOut = 5;
|
||||
int32 exitCode = 6;
|
||||
string user = 7;
|
||||
string userClass = 8;
|
||||
string actionIcon = 9;
|
||||
repeated string tags = 10;
|
||||
}
|
||||
|
||||
message GetLogsResponse {
|
||||
repeated LogEntry logs = 1;
|
||||
}
|
||||
|
||||
message ValidateArgumentTypeRequest {
|
||||
string value = 1;
|
||||
string type = 2;
|
||||
}
|
||||
|
||||
message ValidateArgumentTypeResponse {
|
||||
bool valid = 1;
|
||||
string description = 2;
|
||||
}
|
||||
|
||||
message WhoAmIRequest {}
|
||||
|
||||
message WhoAmIResponse {
|
||||
string authenticatedUser = 1;
|
||||
}
|
||||
|
||||
message SosReportRequest {}
|
||||
|
||||
message SosReportResponse {
|
||||
string alert = 1;
|
||||
}
|
||||
|
||||
service OliveTinApi {
|
||||
rpc GetDashboardComponents(GetDashboardComponentsRequest) returns (GetDashboardComponentsResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/api/GetDashboardComponents"
|
||||
};
|
||||
}
|
||||
|
||||
rpc StartAction(StartActionRequest) returns (StartActionResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/StartAction"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc GetLogs(GetLogsRequest) returns (GetLogsResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/api/GetLogs"
|
||||
};
|
||||
}
|
||||
|
||||
rpc ValidateArgumentType(ValidateArgumentTypeRequest) returns (ValidateArgumentTypeResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/ValidateArgumentType"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc WhoAmI(WhoAmIRequest) returns (WhoAmIResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/api/WhoAmI"
|
||||
};
|
||||
}
|
||||
|
||||
rpc SosReport(SosReportRequest) returns (SosReportResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/api/sosreport"
|
||||
};
|
||||
}
|
||||
}
|
||||
95
README.md
95
README.md
@@ -1,9 +1,10 @@
|
||||
# OliveTin
|
||||
|
||||
<img alt = "project logo" src = "https://github.com/OliveTin/OliveTin/blob/main/webui/OliveTinLogo.png" align = "right" width = "160px" />
|
||||
<img alt = "project logo" src = "https://github.com/OliveTin/OliveTin/blob/main/webui.dev/OliveTinLogo.png" align = "right" width = "160px" />
|
||||
|
||||
OliveTin gives **safe** and **simple** access to predefined shell commands from a web interface.
|
||||
OliveTin gives **safe** and **simple** access to predefined shell commands from a web interface.
|
||||
|
||||
[](#none)
|
||||
[](https://discord.gg/jhYWWpNJ3v)
|
||||
[](https://github.com/awesome-selfhosted/awesome-selfhosted#automation)
|
||||
[](https://bestpractices.coreinfrastructure.org/projects/5050)
|
||||
@@ -11,7 +12,12 @@ OliveTin gives **safe** and **simple** access to predefined shell commands from
|
||||
[](https://goreportcard.com/report/github.com/OliveTin/OliveTin)
|
||||
[](https://github.com/OliveTin/OliveTin/actions/workflows/build-snapshot.yml)
|
||||
|
||||
## Use cases
|
||||
<img alt = "screenshot" src = "https://github.com/OliveTin/OliveTin/blob/main/var/marketing/screenshotDesktop.png" />
|
||||
<a href = "#screenshots">More screenshots below</a>
|
||||
|
||||
All documentation can be found at [docs.olivetin.app](https://docs.olivetin.app). This includes installation and usage guide, etc.
|
||||
|
||||
## Use cases
|
||||
|
||||
**Safely** give access to commands, for less technical people;
|
||||
|
||||
@@ -22,22 +28,22 @@ OliveTin gives **safe** and **simple** access to predefined shell commands from
|
||||
**Simplify** complex commands, make them accessible and repeatable;
|
||||
|
||||
* eg: Expose complex commands on touchscreen tablets stuck on walls around your house. `wake-on-lan aa:bb:cc:11:22:33`
|
||||
* eg: Run long running on your servers from your cell phone. `dnf update -y`
|
||||
* eg: Run long-lived commands on your servers from your cell phone. `dnf update -y`
|
||||
* eg: Define complex commands with lots of preset arguments, and turn a few arguments into dropdown select boxes. `docker rm {{ container }} && docker create {{ container }} && docker start {{ container }}`
|
||||
|
||||
[Join the community on Discord](https://discord.gg/jhYWWpNJ3v) to talk with other users about use cases, or to ask for support in getting started.
|
||||
|
||||
## YouTube demo video (6 mins)
|
||||
## YouTube demo video
|
||||
|
||||
[](https://www.youtube.com/watch?v=Ej6NM9rmZtk)
|
||||
[](https://www.youtube.com/watch?v=UBgOfNrzId4)
|
||||
|
||||
## Features
|
||||
|
||||
* **Responsive, touch-friendly UI** - great for tablets and mobile
|
||||
* **Super simple config in YAML** - because if it's not YAML now-a-days, it's not "cloud native" :-)
|
||||
* **Super simple config in YAML** - because if it's not YAML now-a-days, it's not "cloud native" :-)
|
||||
* **Dark mode** - for those of you that roll that way.
|
||||
* **Accessible** - passes all the accessibility checks in Firefox, and issues with accessibility are taken seriously.
|
||||
* **Container** - available for quickly testing and getting it up and running, great for the selfhosted community.
|
||||
* **Accessible** - passes all the accessibility checks in Firefox, and issues with accessibility are taken seriously.
|
||||
* **Container** - available for quickly testing and getting it up and running, great for the selfhosted community.
|
||||
* **Integrate with anything** - OliveTin just runs Linux shell commands, so theoretially you could integrate with a bunch of stuff just by using curl, ping, etc. However, writing your own shell scripts is a great way to extend OliveTin.
|
||||
* **Lightweight on resources** - uses only a few MB of RAM and barely any CPU. Written in Go, with a web interface written as a modern, responsive, Single Page App that uses the REST/gRPC API.
|
||||
* **Good amount of unit tests and style checks** - helps potential contributors be consistent, and helps with maintainability.
|
||||
@@ -46,69 +52,24 @@ OliveTin gives **safe** and **simple** access to predefined shell commands from
|
||||
|
||||
Desktop web browser;
|
||||
|
||||

|
||||
<p align = "center">
|
||||
<img alt = "screenshot" src = "https://github.com/OliveTin/OliveTin/blob/main/var/marketing/screenshotDesktop.png" />
|
||||
</p>
|
||||
|
||||
Desktop web browser (dark mode);
|
||||
Desktop web browser (dark mode);
|
||||
|
||||

|
||||
<p align = "center">
|
||||
<img alt = "screenshot" src = "https://github.com/OliveTin/OliveTin/blob/main/var/marketing/screenshotDesktopDark.png" />
|
||||
</p>
|
||||
|
||||
Mobile screen size (responsive layout);
|
||||
Mobile screen size (responsive layout);
|
||||
|
||||

|
||||
<p align = "center">
|
||||
<img alt = "screenshot" src = "https://github.com/OliveTin/OliveTin/blob/main/var/marketing/screenshotMobile.png" style = "height: 700px;" />
|
||||
</p>
|
||||
|
||||
## Documentation
|
||||
|
||||
All documentation can be found at http://docs.olivetin.app . This includes installation and usage guide, etc.
|
||||
|
||||
### Quickstart reference for `config.yaml`
|
||||
|
||||
This is a quick example of `config.yaml` - but again, lots of documentation for how to write your `config.yaml` can be found at [the documentation site.](https://docs.olivetin.app)
|
||||
|
||||
* (Recommended) [Linux package install (.rpm/.deb)](https://docs.olivetin.app/install-linuxpackage.html) install instructions
|
||||
* [Container (podman/docker)](https://docs.olivetin.app/install-container.html) install instructions
|
||||
* [Docker compose](https://docs.olivetin.app/install-compose.html) install instructions
|
||||
* [Helm on Kubernetes](https://docs.olivetin.app/install-helm.html) install instructions
|
||||
* [Kubernetes (manual)](https://docs.olivetin.app/install-k8s.html) install instructions
|
||||
* [.tar.gz (manual)](https://docs.olivetin.app/install-targz.html) install instructions
|
||||
|
||||
Put this `config.yaml` in `/etc/OliveTin/` if you're running a standard service, or mount it at `/config` if running in a container.
|
||||
|
||||
```yaml
|
||||
# Listen on all addresses available, port 1337
|
||||
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
||||
|
||||
# Choose from INFO (default), WARN and DEBUG
|
||||
logLevel: "INFO"
|
||||
|
||||
# Actions (buttons) to show up on the WebUI:
|
||||
actions:
|
||||
# Docs: https://docs.olivetin.app/action-container-control.html
|
||||
- title: Restart Plex
|
||||
icon: restart
|
||||
shell: docker restart plex
|
||||
|
||||
# This will send 1 ping
|
||||
# Docs: https://docs.olivetin.app/action-ping.html
|
||||
- title: Ping host
|
||||
shell: ping {{ host }} -c {{ count }}
|
||||
icon: ping
|
||||
arguments:
|
||||
- name: host
|
||||
title: host
|
||||
type: ascii_identifier
|
||||
default: example.com
|
||||
|
||||
- name: count
|
||||
title: Count
|
||||
type: int
|
||||
default: 1
|
||||
|
||||
# Restart http on host "webserver1"
|
||||
# Docs: https://docs.olivetin.app/action-ssh.html
|
||||
- title: restart httpd
|
||||
icon: restart
|
||||
shell: ssh root@webserver1 'service httpd restart'
|
||||
```
|
||||
|
||||
A full example config can be found at in this repository - [config.yaml](https://github.com/OliveTin/OliveTin/blob/main/config.yaml).
|
||||
All documentation can be found at [docs.olivetin.app](https://docs.olivetin.app). This includes installation and usage guide, etc.
|
||||
|
||||
You can find instructions in the docs on how to install as a **Linux package**, **Linux Container**, on **FreeBSD**, **Windows**, **MacOS** and other platforms, too!
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## Supported Versions
|
||||
|
||||
Currently, only the `main` branch is "supported".
|
||||
Currently, only the `main` branch is "supported".
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
@@ -10,4 +10,4 @@ Currently, only the `main` branch is "supported".
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Please email `contact@jread.com` for responsible disclosure. Accepted issues will be made public once patched, and you will be given credit.
|
||||
Please email `contact@jread.com` for responsible disclosure. Accepted issues will be made public once patched, and you will be given credit.
|
||||
|
||||
20
buf.gen.yaml
20
buf.gen.yaml
@@ -1,20 +0,0 @@
|
||||
version: v1
|
||||
plugins:
|
||||
- name: go
|
||||
out: gen/grpc/
|
||||
opt: paths=source_relative
|
||||
|
||||
- name: go-grpc
|
||||
out: gen/grpc/
|
||||
opt: paths=source_relative,require_unimplemented_servers=false
|
||||
|
||||
- name: grpc-gateway
|
||||
out: gen/grpc/
|
||||
opt: paths=source_relative
|
||||
|
||||
# - name: swagger
|
||||
# out: reports/swagger
|
||||
|
||||
# - name: openapiv2
|
||||
# out: reports/openapiv2
|
||||
|
||||
7
buf.lock
7
buf.lock
@@ -1,7 +0,0 @@
|
||||
# Generated by buf. DO NOT EDIT.
|
||||
version: v1
|
||||
deps:
|
||||
- remote: buf.build
|
||||
owner: googleapis
|
||||
repository: googleapis
|
||||
commit: e9fcfb66f77242e5b8fd4564d7a01033
|
||||
@@ -1,122 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/OliveTin/OliveTin/internal/executor"
|
||||
grpcapi "github.com/OliveTin/OliveTin/internal/grpcapi"
|
||||
"github.com/OliveTin/OliveTin/internal/installationinfo"
|
||||
"github.com/OliveTin/OliveTin/internal/oncron"
|
||||
"github.com/OliveTin/OliveTin/internal/onstartup"
|
||||
updatecheck "github.com/OliveTin/OliveTin/internal/updatecheck"
|
||||
|
||||
"github.com/OliveTin/OliveTin/internal/httpservers"
|
||||
|
||||
config "github.com/OliveTin/OliveTin/internal/config"
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/spf13/viper"
|
||||
"os"
|
||||
"path"
|
||||
)
|
||||
|
||||
var (
|
||||
cfg *config.Config
|
||||
version = "dev"
|
||||
commit = "nocommit"
|
||||
date = "nodate"
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.SetFormatter(&log.TextFormatter{
|
||||
ForceQuote: true,
|
||||
DisableTimestamp: true,
|
||||
})
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"version": version,
|
||||
"commit": commit,
|
||||
"date": date,
|
||||
}).Info("OliveTin initializing")
|
||||
|
||||
log.SetLevel(log.DebugLevel) // Default to debug, to catch cfg issues
|
||||
|
||||
var configDir string
|
||||
flag.StringVar(&configDir, "configdir", ".", "Config directory path")
|
||||
flag.Parse()
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"value": configDir,
|
||||
}).Debugf("Value of -configdir flag")
|
||||
|
||||
viper.AutomaticEnv()
|
||||
viper.SetConfigName("config.yaml")
|
||||
viper.SetConfigType("yaml")
|
||||
viper.AddConfigPath(configDir)
|
||||
viper.AddConfigPath("/config") // For containers.
|
||||
viper.AddConfigPath("/etc/OliveTin/")
|
||||
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
log.Errorf("Config file error at startup. %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
cfg = config.DefaultConfig()
|
||||
|
||||
viper.WatchConfig()
|
||||
viper.OnConfigChange(func(e fsnotify.Event) {
|
||||
if e.Op == fsnotify.Write {
|
||||
log.Info("Config file changed:", e.String())
|
||||
|
||||
reloadConfig()
|
||||
}
|
||||
})
|
||||
|
||||
reloadConfig()
|
||||
|
||||
warnIfPuidGuid()
|
||||
|
||||
installationinfo.Config = cfg
|
||||
installationinfo.Build.Version = version
|
||||
installationinfo.Build.Commit = commit
|
||||
installationinfo.Build.Date = date
|
||||
|
||||
log.Info("Init complete")
|
||||
}
|
||||
|
||||
func warnIfPuidGuid() {
|
||||
if os.Getenv("PUID") != "" || os.Getenv("PGID") != "" {
|
||||
log.Warnf("PUID or PGID seem to be set to something, but they are ignored by OliveTin. Please check https://docs.olivetin.app/no-puid-pgid.html")
|
||||
}
|
||||
}
|
||||
|
||||
func reloadConfig() {
|
||||
if err := viper.UnmarshalExact(&cfg); err != nil {
|
||||
log.Errorf("Config unmarshal error %+v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
cfg.Sanitize()
|
||||
}
|
||||
|
||||
func main() {
|
||||
configDir := path.Dir(viper.ConfigFileUsed())
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"configDir": configDir,
|
||||
}).Infof("OliveTin started")
|
||||
|
||||
log.Debugf("Config: %+v", cfg)
|
||||
|
||||
executor := executor.DefaultExecutor()
|
||||
|
||||
go onstartup.Execute(cfg, executor)
|
||||
go oncron.Schedule(cfg, executor)
|
||||
|
||||
go updatecheck.StartUpdateChecker(version, commit, cfg, configDir)
|
||||
|
||||
go grpcapi.Start(cfg, executor)
|
||||
|
||||
httpservers.StartServers(cfg)
|
||||
}
|
||||
362
config.yaml
362
config.yaml
@@ -1,79 +1,315 @@
|
||||
# There is a built-in micro proxy that will host the webui and REST API all on
|
||||
# one port (this is called the "Single HTTP Frontend") and means you just need
|
||||
# one open port in the container/firewalls/etc.
|
||||
# There is a built-in micro proxy that will host the webui and REST API all on
|
||||
# one port (this is called the "Single HTTP Frontend") and means you just need
|
||||
# one open port in the container/firewalls/etc.
|
||||
#
|
||||
# Listen on all addresses available, port 1337
|
||||
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
||||
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
||||
|
||||
# Choose from INFO (default), WARN and DEBUG
|
||||
logLevel: "INFO"
|
||||
|
||||
# Actions (buttons) to show up on the WebUI:
|
||||
actions:
|
||||
# This will run a simple script that you create.
|
||||
- title: Run backup script
|
||||
shell: /opt/backupScript.sh
|
||||
icon: backup
|
||||
# Checking for updates https://docs.olivetin.app/reference/updateChecks.html
|
||||
checkForUpdates: false
|
||||
|
||||
# This will send 1 ping (-c 1)
|
||||
# Docs: https://docs.olivetin.app/action-ping.html
|
||||
- title: Ping host
|
||||
shell: ping {{ host }} -c {{ count }}
|
||||
icon: ping
|
||||
arguments:
|
||||
- name: host
|
||||
title: host
|
||||
type: ascii_identifier
|
||||
default: example.com
|
||||
description: The host that you want to ping
|
||||
|
||||
- name: count
|
||||
title: Count
|
||||
type: int
|
||||
default: 1
|
||||
description: How many times to do you want to ping?
|
||||
|
||||
# Restart lightdm on host "server1"
|
||||
# Docs: https://docs.olivetin.app/action-ping.html
|
||||
- title: restart httpd
|
||||
icon: restart
|
||||
shell: ssh root@server1 'service httpd restart'
|
||||
|
||||
# OliveTin can run long-running jobs like Ansible playbooks.
|
||||
#
|
||||
# For such jobs, you will need to install ansible-playbook on the host where
|
||||
# you are running OliveTin, or in the container.
|
||||
# Actions are commands that are executed by OliveTin, and normally show up as
|
||||
# buttons on the WebUI.
|
||||
#
|
||||
# Docs: https://docs.olivetin.app/action_execution/create_your_first.html
|
||||
actions:
|
||||
# This is the most simple action, it just runs the command and flashes the
|
||||
# button to indicate status.
|
||||
#
|
||||
# You probably want a much longer timeout as well (so that ansible completes).
|
||||
- title: "Run Ansible Playbook"
|
||||
icon: "🇦"
|
||||
shell: ansible-playbook -i /etc/hosts /root/myRepo/myPlaybook.yaml
|
||||
timeout: 120
|
||||
# If you are running OliveTin in a container remember to pass through the
|
||||
# docker socket! https://docs.olivetin.app/solutions/container-control-panel/index.html
|
||||
- title: Ping the Internet
|
||||
shell: ping -c 3 1.1.1.1
|
||||
icon: ping
|
||||
popupOnStart: execution-dialog-stdout-only
|
||||
|
||||
# This uses `popupOnStart: execution-dialog-stdout-only` to simply show just
|
||||
# the command output.
|
||||
- title: Check disk space
|
||||
icon: disk
|
||||
shell: df -h /media
|
||||
popupOnStart: execution-dialog-stdout-only
|
||||
|
||||
# This uses `popupOnStart: execution-dialog` to show a dialog with more
|
||||
# information about the command that was run.
|
||||
- title: check dmesg logs
|
||||
shell: dmesg | tail
|
||||
icon: logs
|
||||
popupOnStart: execution-dialog
|
||||
|
||||
# This uses `popupOnStart: execution-button` to display a mini button that
|
||||
# links to the logs.
|
||||
#
|
||||
# You can also rate-limit actions too.
|
||||
- title: date
|
||||
shell: date
|
||||
timeout: 6
|
||||
icon: clock
|
||||
popupOnStart: execution-button
|
||||
maxRate:
|
||||
- limit: 3
|
||||
duration: 5m
|
||||
|
||||
# You are not limited to operating system commands, and of course you can run
|
||||
# your own scripts. Here `maxConcurrent` stops the script running multiple
|
||||
# times in parallel. There is also a timeout that will kill the command if it
|
||||
# runs for too long.
|
||||
- title: Run backup script
|
||||
shell: /opt/backupScript.sh
|
||||
shellAfterCompleted: "apprise -t 'Notification: Backup script completed' -b 'The backup script completed with code {{ exitCode}}. The log is: \n {{ output }} '"
|
||||
maxConcurrent: 1
|
||||
timeout: 10
|
||||
icon: backup
|
||||
popupOnStart: execution-dialog
|
||||
|
||||
# When you want to prompt users for input, that is when you should use
|
||||
# `arguments` - this presents a popup dialog and asks for argument values.
|
||||
#
|
||||
# Docs: https://docs.olivetin.app/action_examples/ping.html
|
||||
- title: Ping host
|
||||
id: ping_host
|
||||
shell: ping {{ host }} -c {{ count }}
|
||||
icon: ping
|
||||
timeout: 100
|
||||
popupOnStart: execution-dialog-stdout-only
|
||||
arguments:
|
||||
- name: host
|
||||
title: Host
|
||||
type: ascii_identifier
|
||||
default: example.com
|
||||
description: The host that you want to ping
|
||||
|
||||
- name: count
|
||||
title: Count
|
||||
type: int
|
||||
default: 3
|
||||
description: How many times to do you want to ping?
|
||||
|
||||
# OliveTin can control containers - docker is just a command line app.
|
||||
#
|
||||
#
|
||||
# However, if you are running in a container you will need to do some setup,
|
||||
# see the docs below.
|
||||
#
|
||||
# Docs: https://docs.olivetin.app/action-container-control.html
|
||||
- title: Restart Docker Container
|
||||
icon: restart
|
||||
shell: docker restart {{ container }}
|
||||
arguments:
|
||||
- name: container
|
||||
title: Container name
|
||||
choices:
|
||||
- value: plex
|
||||
- value: traefik
|
||||
- value: grafana
|
||||
# Docs: https://docs.olivetin.app/solutions/container-control-panel/index.html
|
||||
- title: Restart Docker Container
|
||||
icon: restart
|
||||
shell: docker restart {{ container }}
|
||||
arguments:
|
||||
- name: container
|
||||
title: Container name
|
||||
choices:
|
||||
- value: plex
|
||||
- value: traefik
|
||||
- value: grafana
|
||||
|
||||
- title: Slow Script
|
||||
shell: sleep 3
|
||||
timeout: 5
|
||||
icon: "🥱"
|
||||
# There is a special `confirmation` argument to help against accidental clicks
|
||||
# on "dangerous" actions.
|
||||
#
|
||||
# Docs: https://docs.olivetin.app/args/input_confirmation.html
|
||||
- title: Delete old backups
|
||||
icon: ashtonished
|
||||
shell: rm -rf /opt/oldBackups/
|
||||
arguments:
|
||||
- type: html
|
||||
title: Description
|
||||
default:
|
||||
The documentation for this action can be found at <a href = "example.com">example.com</a>.
|
||||
- type: confirmation
|
||||
title: Are you sure?!
|
||||
|
||||
- title: Broken Script (timeout)
|
||||
shell: sleep 5
|
||||
timeout: 5
|
||||
icon: "😪"
|
||||
# This is an action that runs a script included with OliveTin, that will
|
||||
# download themes. You will still need to set theme "themeName" in your config.
|
||||
#
|
||||
# Docs: https://docs.olivetin.app/reference/reference_themes_for_users.html
|
||||
- title: Get OliveTin Theme
|
||||
shell: olivetin-get-theme {{ themeGitRepo }} {{ themeFolderName }}
|
||||
icon: theme
|
||||
arguments:
|
||||
- name: themeGitRepo
|
||||
title: Theme's Git Repository
|
||||
description: Find new themes at https://olivetin.app/themes
|
||||
type: url
|
||||
|
||||
- name: themeFolderName
|
||||
title: Theme's Folder Name
|
||||
type: ascii_identifier
|
||||
|
||||
# Sometimes you want to run actions on other servers - don't overcomplicate
|
||||
# it, just use SSH! OliveTin includes a helper to make this easier, which is
|
||||
# entirely optional. You can also setup SSH manually.
|
||||
#
|
||||
# Docs: https://docs.olivetin.app/action_examples/ssh-easy.html
|
||||
# Docs: https://docs.olivetin.app/action_examples/ssh-manual.html
|
||||
- title: "Setup easy SSH"
|
||||
icon: ssh
|
||||
shell: olivetin-setup-easy-ssh
|
||||
popupOnStart: execution-dialog
|
||||
|
||||
# Here's how to use SSH with the "easy" config, to restart a service on
|
||||
# another server.
|
||||
#
|
||||
# Docs: https://docs.olivetin.app/action_examples/ssh-easy.html
|
||||
# Docs: https://docs.olivetin.app/action_examples/systemd_service.html
|
||||
- title: Restart httpd on server1
|
||||
id: restart_httpd
|
||||
icon: restart
|
||||
timeout: 1
|
||||
shell: ssh -F /config/ssh/easy.cfg root@server1 'service httpd restart'
|
||||
|
||||
# Lots of people use OliveTin to build web interfaces for their electronics
|
||||
# projects. It's best to install OliveTin as a native package (eg, .deb), and
|
||||
# then you can use either a python script or the `gpio` command.
|
||||
- title: Toggle GPIO light
|
||||
shell: gpioset gpiochip1 9=1
|
||||
icon: light
|
||||
|
||||
# There are several built-in shortcuts for the `icon` option, but you
|
||||
# can also just specify any HTML, this includes any unicode character,
|
||||
# or a <img = "..." /> link to a custom icon.
|
||||
#
|
||||
# Docs: https://docs.olivetin.app/action_customization/icons.html
|
||||
#
|
||||
# Lots of people use OliveTin to easily execute ansible-playbooks. You
|
||||
# probably want a much longer timeout as well (so that ansible completes).
|
||||
#
|
||||
# Docs: https://docs.olivetin.app/action_examples/ansible.html
|
||||
- title: "Run Automation Playbook"
|
||||
icon: '🤖'
|
||||
shell: ansible-playbook -i /etc/hosts /root/myRepo/myPlaybook.yaml
|
||||
timeout: 120
|
||||
|
||||
# The following actions are "dummy" actions, used in a Dashboard. As long as
|
||||
# you have these referenced in a dashboard, they will not show up in the
|
||||
# `actions` view.
|
||||
- title: Ping hypervisor1
|
||||
shell: echo "hypervisor1 online"
|
||||
|
||||
- title: Ping hypervisor2
|
||||
shell: echo "hypervisor2 online"
|
||||
|
||||
- title: "{{ server.name }} Wake on Lan"
|
||||
shell: echo "Sending Wake on LAN to {{ server.hostname }}"
|
||||
entity: server
|
||||
|
||||
- title: "{{ server.name }} Power Off"
|
||||
shell: "echo 'Power Off Server: {{ server.hostname }}'"
|
||||
entity: server
|
||||
|
||||
- title: Ping All Servers
|
||||
shell: "echo 'Ping all servers'"
|
||||
icon: ping
|
||||
|
||||
- title: Start {{ container.Names }}
|
||||
icon: box
|
||||
shell: docker start {{ container.Names }}
|
||||
entity: container
|
||||
triggers: ["Update container entity file"]
|
||||
|
||||
- title: Stop {{ container.Names }}
|
||||
icon: box
|
||||
shell: docker stop {{ container.Names }}
|
||||
entity: container
|
||||
triggers: ["Update container entity file"]
|
||||
|
||||
# Lastly, you can hide actions from the web UI, this is useful for creating
|
||||
# background helpers that execute only on startup or a cron, for updating
|
||||
# entity files.
|
||||
|
||||
# - title: Update container entity file
|
||||
# shell: 'docker ps -a --format json > /etc/OliveTin/entities/containers.json'
|
||||
# hidden: true
|
||||
# execOnStartup: true
|
||||
# execOnCron: '*/1 * * * *'
|
||||
|
||||
# An entity is something that exists - a "thing", like a VM, or a Container
|
||||
# is an entity. OliveTin allows you to then dynamically generate actions based
|
||||
# around these entities.
|
||||
#
|
||||
# This is really useful if you want to generate wake on lan or poweroff actions
|
||||
# for `server` entities, for example.
|
||||
#
|
||||
# A very popular use case that entities were designed for was for `container`
|
||||
# entities - in a similar way you could generate `start`, `stop`, and `restart`
|
||||
# container actions.
|
||||
#
|
||||
# Entities are just loaded fome files on disk, OliveTin will also watch these
|
||||
# files for updates while OliveTin is running, and update entities.
|
||||
#
|
||||
# Entities can have properties defined in those files, and those can be used
|
||||
# in your configuration as variables. For example; `container.status`,
|
||||
# or `vm.hostname`.
|
||||
#
|
||||
# Docs: https://docs.olivetin.app/entities/intro.html
|
||||
entities:
|
||||
# YAML files are the default expected format, so you can use .yml or .yaml,
|
||||
# or even .txt, as long as the file contains valid a valid yaml LIST, then it
|
||||
# will load properly.
|
||||
#
|
||||
# Docs: https://docs.olivetin.app/entities/intro.html
|
||||
- file: entities/servers.yaml
|
||||
name: server
|
||||
|
||||
- file: entities/containers.json
|
||||
name: container
|
||||
|
||||
# Dashboards are a way of taking actions from the default "actions" view, and
|
||||
# organizing them into groups - either into folders, or fieldsets.
|
||||
#
|
||||
# The only way to properly use entities, are to use them with a `fieldset` on
|
||||
# a dashboard.
|
||||
#
|
||||
# Docs: https://docs.olivetin.app/dashboards/intro.html
|
||||
dashboards:
|
||||
# Top level items are dashboards.
|
||||
- title: My Servers
|
||||
contents:
|
||||
- title: All Servers
|
||||
type: fieldset
|
||||
contents:
|
||||
# The contents of a dashboard will try to look for an action with a
|
||||
# matching title IF the `contents: ` property is empty.
|
||||
- title: Ping All Servers
|
||||
|
||||
# If you create an item with some "contents:", OliveTin will show that as
|
||||
# directory.
|
||||
- title: Hypervisors
|
||||
contents:
|
||||
- title: Ping hypervisor1
|
||||
- title: Ping hypervisor2
|
||||
|
||||
# If you specify `type: fieldset` and some `contents`, it will show your
|
||||
# actions grouped together without a folder.
|
||||
- type: fieldset
|
||||
entity: server
|
||||
title: 'Server: {{ server.hostname }}'
|
||||
contents:
|
||||
# By default OliveTin will look for an action with a matching title
|
||||
# and put it on the dashboard.
|
||||
#
|
||||
# Fieldsets also support `type: display`, which can display arbitary
|
||||
# text. This is useful for displaying things like a container's state.
|
||||
- type: display
|
||||
title: |
|
||||
Hostname: <strong>{{ server.name }}</strong>
|
||||
IP Address: <strong>{{ server.ip }}</strong>
|
||||
|
||||
# These are the actions (defined above) that we want on the dashboard.
|
||||
- title: '{{ server.name }} Wake on Lan'
|
||||
- title: '{{ server.name }} Power Off'
|
||||
|
||||
# This is the second dashboard.
|
||||
- title: My Containers
|
||||
contents:
|
||||
- title: 'Container {{ container.Names }} ({{ container.Image }})'
|
||||
entity: container
|
||||
type: fieldset
|
||||
contents:
|
||||
- type: display
|
||||
title: |
|
||||
{{ container.RunningFor }} <br /><br /><strong>{{ container.State }}</strong>
|
||||
|
||||
- title: 'Start {{ container.Names }}'
|
||||
- title: 'Stop {{ container.Names }}'
|
||||
|
||||
103
go.mod
103
go.mod
@@ -1,103 +0,0 @@
|
||||
module github.com/OliveTin/OliveTin
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/bufbuild/buf v1.15.1
|
||||
github.com/fsnotify/fsnotify v1.6.0
|
||||
github.com/fzipp/gocyclo v0.6.0
|
||||
github.com/go-critic/go-critic v0.7.0
|
||||
github.com/golang-jwt/jwt/v4 v4.5.0
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
github.com/spf13/viper v1.15.0
|
||||
github.com/stretchr/testify v1.8.2
|
||||
golang.org/x/exp v0.0.0-20230307190834-24139beb5833
|
||||
google.golang.org/grpc v1.53.0
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0
|
||||
google.golang.org/protobuf v1.30.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
|
||||
github.com/Microsoft/go-winio v0.6.0 // indirect
|
||||
github.com/bufbuild/connect-go v1.5.2 // indirect
|
||||
github.com/bufbuild/protocompile v0.5.1 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
||||
github.com/cristalhq/acmd v0.11.1 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/docker/cli v23.0.1+incompatible // indirect
|
||||
github.com/docker/distribution v2.8.1+incompatible // indirect
|
||||
github.com/docker/docker v23.0.1+incompatible // indirect
|
||||
github.com/docker/docker-credential-helpers v0.7.0 // indirect
|
||||
github.com/docker/go-connections v0.4.0 // indirect
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
github.com/felixge/fgprof v0.9.3 // indirect
|
||||
github.com/go-chi/chi/v5 v5.0.8 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-toolsmith/astcast v1.1.0 // indirect
|
||||
github.com/go-toolsmith/astcopy v1.1.0 // indirect
|
||||
github.com/go-toolsmith/astequal v1.1.0 // indirect
|
||||
github.com/go-toolsmith/astfmt v1.1.0 // indirect
|
||||
github.com/go-toolsmith/astp v1.1.0 // indirect
|
||||
github.com/go-toolsmith/pkgload v1.2.2 // indirect
|
||||
github.com/go-toolsmith/strparse v1.1.0 // indirect
|
||||
github.com/go-toolsmith/typep v1.1.0 // indirect
|
||||
github.com/gofrs/flock v0.8.1 // indirect
|
||||
github.com/gofrs/uuid/v5 v5.0.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/glog v1.0.0 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/google/go-containerregistry v0.13.0 // indirect
|
||||
github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jdxcode/netrc v0.0.0-20221124155335-4616370d1a84 // indirect
|
||||
github.com/klauspost/compress v1.16.0 // indirect
|
||||
github.com/klauspost/pgzip v1.2.5 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
|
||||
github.com/morikuni/aec v1.0.0 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pkg/profile v1.7.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/quasilyte/go-ruleguard v0.3.19 // indirect
|
||||
github.com/quasilyte/gogrep v0.5.0 // indirect
|
||||
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
|
||||
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
|
||||
github.com/rs/cors v1.8.3 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/spf13/afero v1.9.3 // indirect
|
||||
github.com/spf13/cast v1.5.0 // indirect
|
||||
github.com/spf13/cobra v1.6.1 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/subosito/gotenv v1.4.2 // indirect
|
||||
go.opentelemetry.io/otel v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.14.0 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/multierr v1.10.0 // indirect
|
||||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/crypto v0.7.0 // indirect
|
||||
golang.org/x/exp/typeparams v0.0.0-20230213192124-5e25df0256eb // indirect
|
||||
golang.org/x/mod v0.9.0 // indirect
|
||||
golang.org/x/net v0.8.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.6.0 // indirect
|
||||
golang.org/x/term v0.6.0 // indirect
|
||||
golang.org/x/text v0.8.0 // indirect
|
||||
golang.org/x/tools v0.7.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
8
integration-tests/.eslintrc.yml
Normal file
8
integration-tests/.eslintrc.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
env:
|
||||
browser: true
|
||||
es2021: true
|
||||
extends: 'eslint:recommended'
|
||||
parserOptions:
|
||||
ecmaVersion: 12
|
||||
sourceType: module
|
||||
rules: {}
|
||||
3
integration-tests/.mocharc.yml
Normal file
3
integration-tests/.mocharc.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
require:
|
||||
- mochaSetup.mjs
|
||||
@@ -1,6 +1,23 @@
|
||||
cypress:
|
||||
npm install
|
||||
./cypressRun.sh "general"
|
||||
./cypressRun.sh "hiddenNav"
|
||||
default: test-install test-run
|
||||
|
||||
.PHONY: cypress container
|
||||
test-install:
|
||||
npm install --no-fund
|
||||
|
||||
test-run:
|
||||
npx mocha -t 10000
|
||||
|
||||
find-flakey-tests:
|
||||
echo "Running test-run infinately"
|
||||
sh -c "while make test-run; do :; done"
|
||||
|
||||
nginx:
|
||||
podman-compose up -d nginx
|
||||
|
||||
clean:
|
||||
podman-compose down
|
||||
|
||||
getsnapshot:
|
||||
rm -rf /opt/OliveTin-snapshot/*
|
||||
gh run download -D /opt/OliveTin-snapshot/
|
||||
|
||||
.PHONY: default
|
||||
|
||||
@@ -1 +1,14 @@
|
||||
# OliveTin-integration-tests
|
||||
# OliveTin-integration-tests
|
||||
|
||||
## GitHub Actions (Ubuntu, Local Process)
|
||||
|
||||
- `mocha` is run with the default runner that starts and stops OliveTin as a local process (ie, localhost:1337).
|
||||
|
||||
## Running different configurations (Local Process, VM, Container)
|
||||
|
||||
- Get the snapshot you want to test `make getsnapshot`
|
||||
- To test against VMs:
|
||||
-- `export OLIVETIN_TEST_RUNNER=vm`
|
||||
-- `vagrant up fedora38` (or whatever distro you like defined in `Vagrantfile`)
|
||||
-- `. envVagrant.sh fedora38` to set the $IP and $PORT
|
||||
- `mocha`
|
||||
|
||||
39
integration-tests/Vagrantfile
vendored
39
integration-tests/Vagrantfile
vendored
@@ -2,34 +2,35 @@
|
||||
# (eg, snapshot builds on GitHub)
|
||||
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "generic/centos8"
|
||||
config.vm.provision "shell", inline: "mkdir /etc/OliveTin && chmod o+w /etc/OliveTin/", privileged: true
|
||||
config.vm.provision "file", source: "configs/config.general.yaml/.", destination: "/etc/OliveTin/config.yaml"
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.provision "shell", inline: "mkdir /etc/OliveTin && chmod o+w /etc/OliveTin/ && mkdir -p /opt/OliveTin-configs/ && chmod 0777 /opt/OliveTin-configs", privileged: true
|
||||
config.vm.provision "file", source: "configs/.", destination: "/opt/OliveTin-configs/"
|
||||
|
||||
config.vm.provider :libvirt do |libvirt|
|
||||
libvirt.management_network_device = 'virbr0'
|
||||
end
|
||||
|
||||
config.vm.define :f36 do |f36|
|
||||
f36.vm.box = "generic/fedora36"
|
||||
f36.vm.provision "file", source: "/opt/OliveTin-vagrant/linux_amd64_rpm/.", destination: "."
|
||||
f36.vm.provision "shell", inline: "rpm -U OliveTin* && systemctl enable --now OliveTin && systemctl disable --now firewalld"
|
||||
config.vm.define :stream9 do |i|
|
||||
i.vm.box = "centos/stream9"
|
||||
i.vm.provision "file", source: "/opt/OliveTin-snapshot/OliveTin_linux_amd64.rpm", destination: "$HOME/"
|
||||
i.vm.provision "shell", inline: "rpm -U OliveTin* && systemctl enable --now OliveTin && systemctl disable --now firewalld"
|
||||
end
|
||||
|
||||
config.vm.define :debian do |debian|
|
||||
debian.vm.box = "generic/debian10"
|
||||
debian.vm.provision "file", source: "/opt/OliveTin-vagrant/linux_amd64_deb/.", destination: "."
|
||||
debian.vm.provision "shell", inline: "dpkg --force-confold -i OliveTin* && systemctl enable --now OliveTin"
|
||||
config.vm.define :fedora38 do |i|
|
||||
i.vm.box = "generic/fedora38"
|
||||
i.vm.provision "file", source: "/opt/OliveTin-snapshot/OliveTin_linux_amd64.rpm", destination: "$HOME/"
|
||||
i.vm.provision "shell", inline: "rpm -U OliveTin* && systemctl enable --now OliveTin && systemctl disable --now firewalld"
|
||||
end
|
||||
|
||||
config.vm.define :ubuntu do |ubuntu|
|
||||
ubuntu.vm.box = "generic/ubuntu2110"
|
||||
ubuntu.vm.provision "file", source: "/opt/OliveTin-vagrant/linux_amd64_deb/.", destination: "."
|
||||
ubuntu.vm.provision "shell", inline: "dpkg --force-confold -i OliveTin* && systemctl enable --now OliveTin && systemctl disable --now firewalld"
|
||||
config.vm.define :debian12 do |i|
|
||||
i.vm.box = "debian/bookworm64"
|
||||
i.vm.provision "file", source: "/opt/OliveTin-snapshot/OliveTin_linux_amd64.deb", destination: "$HOME/"
|
||||
i.vm.provision "shell", inline: "dpkg --force-confold -i OliveTin* && systemctl enable --now OliveTin"
|
||||
end
|
||||
|
||||
# TODO
|
||||
#
|
||||
|
||||
config.vm.define :ubuntu2310 do |i|
|
||||
i.vm.box = "ubuntu/mantic64"
|
||||
i.vm.provision "file", source: "/opt/OliveTin-snapshot/OliveTin_linux_amd64.deb", destination: "$HOME/"
|
||||
i.vm.provision "shell", inline: "dpkg --force-confold -i OliveTin* && systemctl enable --now OliveTin && systemctl disable --now firewalld"
|
||||
end
|
||||
end
|
||||
|
||||
17
integration-tests/compose.yml
Normal file
17
integration-tests/compose.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
version: "3.8"
|
||||
services:
|
||||
nginx:
|
||||
container_name: nginx
|
||||
image: docker.io/nginx
|
||||
volumes:
|
||||
- ./proxies/nginx/:/etc/nginx/
|
||||
ports:
|
||||
- "8443:8443"
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- otproxy
|
||||
|
||||
networks:
|
||||
otproxy:
|
||||
name: otproxy
|
||||
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# Integration Test Config: emptyDashboardsAreHidden
|
||||
#
|
||||
|
||||
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
||||
|
||||
logLevel: "DEBUG"
|
||||
checkForUpdates: false
|
||||
|
||||
actions:
|
||||
- title: Ping {{ server.hostname }}
|
||||
shell: ping {{ server.hostname }}
|
||||
icon: ping
|
||||
entity: server
|
||||
|
||||
entities:
|
||||
- file: entities/servers.yaml
|
||||
name: server
|
||||
|
||||
|
||||
dashboards:
|
||||
- title: Empty Dashboard
|
||||
contents:
|
||||
- title: Ping {{ server.hostname }}
|
||||
|
||||
18
integration-tests/configs/entities/config.yaml
Normal file
18
integration-tests/configs/entities/config.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# Integration Test Config: Entities
|
||||
#
|
||||
|
||||
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
||||
|
||||
logLevel: "DEBUG"
|
||||
checkForUpdates: false
|
||||
|
||||
actions:
|
||||
- title: Ping {{ server.hostname }}
|
||||
shell: ping {{ server.hostname }}
|
||||
icon: ping
|
||||
entity: server
|
||||
|
||||
entities:
|
||||
- file: entities/servers.yaml
|
||||
name: server
|
||||
3
integration-tests/configs/entities/entities/servers.yaml
Normal file
3
integration-tests/configs/entities/entities/servers.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
- hostname: server1
|
||||
- hostname: server2
|
||||
- hostname: server3
|
||||
@@ -1,17 +1,17 @@
|
||||
#
|
||||
# Integration Test Config: General
|
||||
#
|
||||
#
|
||||
|
||||
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
||||
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
||||
|
||||
logLevel: "DEBUG"
|
||||
checkForUpdates: false
|
||||
checkForUpdates: false
|
||||
|
||||
actions:
|
||||
actions:
|
||||
- title: Ping Google.com
|
||||
shell: ping google.com -c 1
|
||||
icon: ping
|
||||
|
||||
|
||||
- title: restart lightdm
|
||||
icon: poop
|
||||
shell: ssh root@overseer 'service lightdm restart'
|
||||
@@ -24,6 +24,13 @@ actions:
|
||||
shell: sleep 5
|
||||
icon: "😪"
|
||||
|
||||
- title: dir-popup
|
||||
shell: dir
|
||||
popupOnStart: execution-dialog-stdout-only
|
||||
|
||||
- title: cd-passive
|
||||
shell: cd
|
||||
|
||||
- title: "Run Ansible Playbook"
|
||||
icon: "🇦"
|
||||
shell: ansible-playbook -i /etc/hosts /root/myRepo/myPlaybook.yaml
|
||||
@@ -32,4 +39,3 @@ actions:
|
||||
- title: Restart Plex
|
||||
icon: smile
|
||||
shell: docker restart plex
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#
|
||||
# Integration Test Config: General
|
||||
#
|
||||
#
|
||||
|
||||
showFooter: false
|
||||
checkForUpdates: false
|
||||
checkForUpdates: false
|
||||
|
||||
# Actions (buttons) to show up on the WebUI:
|
||||
actions:
|
||||
actions:
|
||||
- title: Ping example.com
|
||||
shell: ping example.com -c 1
|
||||
icon: ping
|
||||
@@ -1,14 +1,14 @@
|
||||
#
|
||||
# Integration Test Config: General
|
||||
#
|
||||
#
|
||||
|
||||
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
||||
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
||||
|
||||
showNavigation: false
|
||||
checkForUpdates: false
|
||||
checkForUpdates: false
|
||||
|
||||
# Actions (buttons) to show up on the WebUI:
|
||||
actions:
|
||||
actions:
|
||||
- title: Ping example.com
|
||||
shell: ping example.com -c 1
|
||||
icon: ping
|
||||
25
integration-tests/configs/multipleDropdowns/config.yaml
Normal file
25
integration-tests/configs/multipleDropdowns/config.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
||||
|
||||
logLevel: "DEBUG"
|
||||
checkForUpdates: false
|
||||
|
||||
actions:
|
||||
- title: Ping Google.com
|
||||
shell: ping google.com -c 1
|
||||
icon: ping
|
||||
|
||||
- title: Test multiple dropdowns
|
||||
shell: echo {{ salutation }} {{ person }}
|
||||
icon: ping
|
||||
arguments:
|
||||
- name: salutation
|
||||
choices:
|
||||
- value: Hello
|
||||
- value: Goodbye
|
||||
|
||||
- name: person
|
||||
choices:
|
||||
- value: Alice
|
||||
- value: Bob
|
||||
- value: Dave
|
||||
28
integration-tests/configs/onlyDashboards/config.yaml
Normal file
28
integration-tests/configs/onlyDashboards/config.yaml
Normal file
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# Integration Test Config: General
|
||||
#
|
||||
|
||||
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
||||
|
||||
logLevel: "DEBUG"
|
||||
checkForUpdates: false
|
||||
|
||||
actions:
|
||||
- title: action1
|
||||
shell: date
|
||||
icon: clock
|
||||
|
||||
- title: action2
|
||||
shell: date
|
||||
icon: clock
|
||||
|
||||
- title: action3
|
||||
shell: date
|
||||
icon: clock
|
||||
|
||||
dashboards:
|
||||
- title: My Dashboard
|
||||
contents:
|
||||
- title: action1
|
||||
- title: action2
|
||||
- title: action3
|
||||
15
integration-tests/configs/pageTitle/config.yaml
Normal file
15
integration-tests/configs/pageTitle/config.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# Integration Test Config: General
|
||||
#
|
||||
|
||||
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
||||
|
||||
logLevel: "DEBUG"
|
||||
checkForUpdates: false
|
||||
|
||||
pageTitle: "My Custom App"
|
||||
|
||||
actions:
|
||||
- title: sleep 2 seconds
|
||||
shell: sleep 2
|
||||
icon: "🥱"
|
||||
14
integration-tests/configs/policy-all-false/config.yaml
Normal file
14
integration-tests/configs/policy-all-false/config.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
# Integration Test Config: Policy All False
|
||||
#
|
||||
|
||||
logLevel: "DEBUG"
|
||||
checkForUpdates: false
|
||||
|
||||
defaultPolicy:
|
||||
showDiagnostics: false
|
||||
showLogList: false
|
||||
|
||||
actions:
|
||||
- title: sleep 2 seconds
|
||||
shell: sleep 2
|
||||
icon: "🥱"
|
||||
16
integration-tests/configs/prometheus/config.yaml
Normal file
16
integration-tests/configs/prometheus/config.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# Integration Test Config: General
|
||||
#
|
||||
|
||||
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
||||
|
||||
logLevel: "DEBUG"
|
||||
checkForUpdates: false
|
||||
|
||||
prometheus:
|
||||
enabled: true
|
||||
defaultGoMetrics: false
|
||||
|
||||
actions:
|
||||
- title: Hello OliveTin
|
||||
shell: echo "Hello OliveTin"
|
||||
14
integration-tests/configs/sleep/config.yaml
Normal file
14
integration-tests/configs/sleep/config.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
# Integration Test Config: Sleep
|
||||
#
|
||||
|
||||
listenAddressSingleHTTPFrontend: 0.0.0.0:1337
|
||||
|
||||
logLevel: "DEBUG"
|
||||
checkForUpdates: false
|
||||
|
||||
actions:
|
||||
- title: Sleep
|
||||
shell: sleep 10
|
||||
popupOnStart: execution-dialog
|
||||
timeout: 9
|
||||
3
integration-tests/configs/trustedHeader/config.yaml
Normal file
3
integration-tests/configs/trustedHeader/config.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
logLevel: DEBUG
|
||||
|
||||
authHttpHeaderUsername: "X-User"
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"baseUrl": "http://localhost:1337",
|
||||
"screenshotsFolder": "results/screenshots/",
|
||||
"videosFolder": "results/videos/"
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
describe('Homepage rendering', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit("/")
|
||||
});
|
||||
|
||||
it("Footer contains promo", () => {
|
||||
cy.get('footer').contains("OliveTin")
|
||||
})
|
||||
|
||||
it('Default buttons are rendered', () => {
|
||||
cy.get("#root-group button").should('have.length', 6)
|
||||
})
|
||||
|
||||
it('Switcher navigation is visible', () => {
|
||||
cy.get('#section-switcher').then($el => {
|
||||
expect(Cypress.dom.isHidden($el)).to.be.false
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
describe('Hidden Footer', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit("/")
|
||||
cy.wait(500)
|
||||
});
|
||||
|
||||
it('Footer is hidden', () => {
|
||||
cy.get('footer').then($el => {
|
||||
expect(Cypress.dom.isHidden($el)).to.be.true
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
describe('Hidden Nav', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit("/")
|
||||
cy.wait(500)
|
||||
});
|
||||
|
||||
it("Footer contains promo", () => {
|
||||
cy.get('footer').contains("OliveTin")
|
||||
})
|
||||
|
||||
it('Switcher navigation is hidden', () => {
|
||||
cy.get('#section-switcher').then($el => {
|
||||
expect(Cypress.dom.isHidden($el)).to.be.true
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
/// <reference types="cypress" />
|
||||
// ***********************************************************
|
||||
// This example plugins/index.js can be used to load plugins
|
||||
//
|
||||
// You can change the location of this file or turn off loading
|
||||
// the plugins file with the 'pluginsFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/plugins-guide
|
||||
// ***********************************************************
|
||||
|
||||
// This function is called when a project is opened or re-opened (e.g. due to
|
||||
// the project's config changing)
|
||||
|
||||
/**
|
||||
* @type {Cypress.PluginConfig}
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
module.exports = (on, config) => {
|
||||
// `on` is used to hook into various events Cypress emits
|
||||
// `config` is the resolved Cypress config
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
// ***********************************************
|
||||
// This example commands.js shows you how to
|
||||
// create various custom commands and overwrite
|
||||
// existing commands.
|
||||
//
|
||||
// For more comprehensive examples of custom
|
||||
// commands please read more here:
|
||||
// https://on.cypress.io/custom-commands
|
||||
// ***********************************************
|
||||
//
|
||||
//
|
||||
// -- This is a parent command --
|
||||
// Cypress.Commands.add('login', (email, password) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a child command --
|
||||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a dual command --
|
||||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
// ***********************************************************
|
||||
// This example support/index.js is processed and
|
||||
// loaded automatically before your test files.
|
||||
//
|
||||
// This is a great place to put global configuration and
|
||||
// behavior that modifies Cypress.
|
||||
//
|
||||
// You can change the location of this file or turn off
|
||||
// automatically serving support files with the
|
||||
// 'supportFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/configuration
|
||||
// ***********************************************************
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands'
|
||||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -o xtrace
|
||||
|
||||
echo "Running config $1"
|
||||
|
||||
cp -f ./configs/config.$1.yaml ./configs/config.yaml
|
||||
docker start olivetin
|
||||
NO_COLOR=1 ./node_modules/.bin/cypress run --headless -s cypress/integration/$1/* || true
|
||||
docker kill olivetin
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# args:
|
||||
# $1: The Vagrant VM to test against. If blank and only one VM is provisioned, it will use that.
|
||||
|
||||
IP=$(vagrant ssh-config $1 | grep HostName | awk '{print $2}')
|
||||
BASE_URL="http://$IP:1337/"
|
||||
|
||||
echo "IP: $IP, BaseURL: $BASE_URL"
|
||||
|
||||
# Only run the general test, as we cannot easily switch out configs in VMs yet.
|
||||
./node_modules/.bin/cypress run --headless -c baseUrl=$BASE_URL -s cypress/integration/general/*
|
||||
8
integration-tests/envVagrant.sh
Executable file
8
integration-tests/envVagrant.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
# Run this like `. envVagrant.sh f38` before `mocha`
|
||||
|
||||
# args:
|
||||
# $1: The Vagrant VM to test against. If blank and only one VM is provisioned, it will use that.
|
||||
|
||||
export IP=$(vagrant ssh-config $1 | grep HostName | awk '{print $2}')
|
||||
export PORT=1337
|
||||
71
integration-tests/lib/elements.js
Normal file
71
integration-tests/lib/elements.js
Normal file
@@ -0,0 +1,71 @@
|
||||
import { By } from 'selenium-webdriver'
|
||||
import fs from 'fs'
|
||||
import { expect } from 'chai'
|
||||
import { Condition } from 'selenium-webdriver'
|
||||
|
||||
export async function getActionButtons (webdriver) {
|
||||
return await webdriver.findElement(By.id('contentActions')).findElements(By.tagName('button'))
|
||||
}
|
||||
|
||||
export function takeScreenshotOnFailure (test, webdriver) {
|
||||
if (test.state === 'failed') {
|
||||
const title = test.fullTitle();
|
||||
|
||||
console.log(`Test failed, taking screenshot: ${title}`);
|
||||
takeScreenshot(webdriver, title);
|
||||
}
|
||||
}
|
||||
|
||||
export function takeScreenshot (webdriver, title) {
|
||||
return webdriver.takeScreenshot().then((img) => {
|
||||
fs.mkdirSync('screenshots', { recursive: true });
|
||||
|
||||
title = title.replaceAll(/[\(\)\|\*\<\>\:]/g, "_")
|
||||
title = 'failed-test.' + title
|
||||
|
||||
fs.writeFileSync('screenshots/' + title + '.png', img, 'base64')
|
||||
})
|
||||
}
|
||||
|
||||
export async function getRootAndWait() {
|
||||
await webdriver.get(runner.baseUrl())
|
||||
await webdriver.wait(new Condition('wait for initial-marshal-complete', async function() {
|
||||
const body = await webdriver.findElement(By.tagName('body'))
|
||||
const attr = await body.getAttribute('initial-marshal-complete')
|
||||
|
||||
if (attr == 'true') {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
export async function requireExecutionDialogStatus (webdriver, expected) {
|
||||
// It seems that webdriver will not give us text if domStatus is hidden (which it will be until complete)
|
||||
await webdriver.executeScript('window.executionDialog.domExecutionDetails.hidden = false')
|
||||
|
||||
await webdriver.wait(new Condition('wait for action to be running', async function () {
|
||||
const actual = await webdriver.executeScript('return window.executionDialog.domStatus.getText()')
|
||||
|
||||
if (actual === expected) {
|
||||
return true
|
||||
} else {
|
||||
console.log('Waiting for domStatus text to be: ', expected, ', it is currently: ', actual)
|
||||
console.log(await webdriver.executeScript('return window.executionDialog.res'))
|
||||
return false
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
export async function findExecutionDialog (webdriver) {
|
||||
return webdriver.findElement(By.id('execution-results-popup'))
|
||||
}
|
||||
|
||||
export async function getActionButton (webdriver, title) {
|
||||
const buttons = await webdriver.findElements(By.css('[title="' + title + '"]'))
|
||||
|
||||
expect(buttons).to.have.length(1)
|
||||
|
||||
return buttons[0]
|
||||
}
|
||||
18
integration-tests/mochaSetup.mjs
Normal file
18
integration-tests/mochaSetup.mjs
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Options } from 'selenium-webdriver/chrome.js'
|
||||
import { Builder, Browser } from 'selenium-webdriver'
|
||||
import getRunner from './runner.mjs'
|
||||
|
||||
export async function mochaGlobalSetup () {
|
||||
const options = new Options()
|
||||
options.addArguments('--headless')
|
||||
|
||||
global.webdriver = await new Builder().forBrowser(Browser.CHROME).setChromeOptions(options).build()
|
||||
|
||||
global.runner = getRunner()
|
||||
|
||||
console.log('Runner constructor: ' + global.runner.constructor.name)
|
||||
}
|
||||
|
||||
export async function mochaGlobalTeardown () {
|
||||
await global.webdriver.quit()
|
||||
}
|
||||
4152
integration-tests/package-lock.json
generated
4152
integration-tests/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,22 @@
|
||||
{
|
||||
"name": "olivetin-integration-tests",
|
||||
"version": "1.0.0",
|
||||
"repository": "https://github.com/OliveTin/OliveTin-integration-tests",
|
||||
"description": "The cypress WebUI tests",
|
||||
"repository": "https://github.com/OliveTin/OliveTin",
|
||||
"description": "The integration-tests for OliveTin's webui.",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-only",
|
||||
"devDependencies": {
|
||||
"chai": "^5.2.0",
|
||||
"eslint": "^9.22.0",
|
||||
"mocha": "^11.1.0",
|
||||
"selenium-webdriver": "^4.29.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"cypress": "^8.3.0"
|
||||
"wait-on": "^8.0.3"
|
||||
}
|
||||
}
|
||||
|
||||
3
integration-tests/proxies/caddy/Caddyfile
Normal file
3
integration-tests/proxies/caddy/Caddyfile
Normal file
@@ -0,0 +1,3 @@
|
||||
http://olivetin.example.com {
|
||||
reverse_proxy * http://localhost:1337
|
||||
}
|
||||
15
integration-tests/proxies/haproxy/haproxy.conf
Normal file
15
integration-tests/proxies/haproxy/haproxy.conf
Normal file
@@ -0,0 +1,15 @@
|
||||
frontend cleartext_frontend
|
||||
bind 0.0.0.0:80
|
||||
|
||||
option httplog
|
||||
|
||||
use_backend be_olivetin_webs if { hdr(Host) -i olivetin.example.com && path_beg /websocket }
|
||||
use_backend be_olivetin_http if { hdr(Host) -i olivetin.example.com }
|
||||
|
||||
backend be_olivetin_http
|
||||
server olivetinServer 127.0.0.1:1337 check
|
||||
|
||||
backend be_olivetin_webs
|
||||
timeout tunnel 1h
|
||||
option http-server-close
|
||||
server olivetinServer 127.0.0.1:1337
|
||||
9
integration-tests/proxies/httpd/OliveTin.conf
Normal file
9
integration-tests/proxies/httpd/OliveTin.conf
Normal file
@@ -0,0 +1,9 @@
|
||||
<VirtualHost *:80>
|
||||
ServerName olivetin.example.com
|
||||
ProxyPass / http://localhost:1337/
|
||||
ProxyPassReverse / http://localhost:1337/
|
||||
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_URI} ^/websocket
|
||||
RewriteRule /(.) ws://localhost:1337/websocket [P,L]
|
||||
</VirtualHost>
|
||||
22
integration-tests/proxies/nginx/conf.d/OliveTin.conf
Normal file
22
integration-tests/proxies/nginx/conf.d/OliveTin.conf
Normal file
@@ -0,0 +1,22 @@
|
||||
server {
|
||||
listen 8443 ssl;
|
||||
|
||||
ssl_certificate "/etc/nginx/conf.d/server.crt";
|
||||
ssl_certificate_key "/etc/nginx/conf.d/server.key";
|
||||
|
||||
access_log /var/log/nginx/ot.access.log main;
|
||||
error_log /var/log/nginx/ot.error.log notice;
|
||||
|
||||
server_name olivetin.example.com;
|
||||
|
||||
location / {
|
||||
proxy_pass http://host.containers.internal:1337/;
|
||||
proxy_redirect http://host.containers.internal:1337/ http://host.containers.internal/OliveTin/;
|
||||
}
|
||||
|
||||
location /websocket {
|
||||
proxy_set_header Upgrade "websocket";
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_pass http://host.containers.internal:1337/websocket;
|
||||
}
|
||||
}
|
||||
1028
integration-tests/proxies/nginx/mime.types
Normal file
1028
integration-tests/proxies/nginx/mime.types
Normal file
File diff suppressed because it is too large
Load Diff
82
integration-tests/proxies/nginx/nginx.conf
Normal file
82
integration-tests/proxies/nginx/nginx.conf
Normal file
@@ -0,0 +1,82 @@
|
||||
# For more information on configuration, see:
|
||||
# * Official English Documentation: http://nginx.org/en/docs/
|
||||
# * Official Russian Documentation: http://nginx.org/ru/docs/
|
||||
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
error_log /var/log/nginx/error.log notice;
|
||||
pid /run/nginx.pid;
|
||||
|
||||
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
|
||||
include /usr/share/nginx/modules/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 4096;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# Load modular configuration files from the /etc/nginx/conf.d directory.
|
||||
# See http://nginx.org/en/docs/ngx_core_module.html#include
|
||||
# for more information.
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name _;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
# Load configuration files for the default server block.
|
||||
include /etc/nginx/default.d/*.conf;
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /404.html {
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
}
|
||||
}
|
||||
|
||||
# Settings for a TLS enabled server.
|
||||
#
|
||||
# server {
|
||||
# listen 8443 ssl http2;
|
||||
# listen [::]:8443 ssl http2;
|
||||
# server_name _;
|
||||
# root /usr/share/nginx/html;
|
||||
#
|
||||
# ssl_certificate "/etc/pki/nginx/server.crt";
|
||||
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
|
||||
# ssl_session_cache shared:SSL:1m;
|
||||
# ssl_session_timeout 10m;
|
||||
# ssl_ciphers PROFILE=SYSTEM;
|
||||
# ssl_prefer_server_ciphers on;
|
||||
#
|
||||
# # Load configuration files for the default server block.
|
||||
# include /etc/nginx/default.d/*.conf;
|
||||
#
|
||||
# error_page 404 /404.html;
|
||||
# location = /404.html {
|
||||
# }
|
||||
#
|
||||
# error_page 500 502 503 504 /50x.html;
|
||||
# location = /50x.html {
|
||||
# }
|
||||
# }
|
||||
|
||||
}
|
||||
146
integration-tests/runner.mjs
Normal file
146
integration-tests/runner.mjs
Normal file
@@ -0,0 +1,146 @@
|
||||
import * as process from 'node:process'
|
||||
import waitOn from 'wait-on'
|
||||
import { spawn } from 'node:child_process'
|
||||
|
||||
export default function getRunner () {
|
||||
const type = process.env.OLIVETIN_TEST_RUNNER
|
||||
|
||||
console.log('OLIVETIN_TEST_RUNNER env value is: ', type)
|
||||
|
||||
switch (type) {
|
||||
case 'local':
|
||||
return new OliveTinTestRunnerStartLocalProcess()
|
||||
case 'vm':
|
||||
return new OliveTinTestRunnerVm()
|
||||
case 'container':
|
||||
return new OliveTinTestRunnerEnv()
|
||||
default:
|
||||
return new OliveTinTestRunnerStartLocalProcess()
|
||||
}
|
||||
}
|
||||
|
||||
class OliveTinTestRunner {
|
||||
BASE_URL = 'http://nohost:1337/';
|
||||
|
||||
baseUrl() {
|
||||
return this.BASE_URL
|
||||
}
|
||||
|
||||
metricsUrl() {
|
||||
return new URL('metrics', this.baseUrl());
|
||||
}
|
||||
}
|
||||
|
||||
class OliveTinTestRunnerStartLocalProcess extends OliveTinTestRunner {
|
||||
async start (cfg) {
|
||||
let stdout = ""
|
||||
let stderr = ""
|
||||
|
||||
console.log(" OliveTin starting local process...")
|
||||
|
||||
this.ot = spawn('./../service/OliveTin', ['-configdir', 'configs/' + cfg + '/'])
|
||||
|
||||
let logStdout = false
|
||||
|
||||
if (process.env.CI === 'true') {
|
||||
logStdout = true;
|
||||
} else {
|
||||
logStdout = process.env.OLIVETIN_TEST_RUNNER_LOG_STDOUT === '1'
|
||||
}
|
||||
|
||||
this.ot.stdout.on('data', (data) => {
|
||||
stdout += data
|
||||
|
||||
if (logStdout) {
|
||||
console.log(`stdout: ${data}`)
|
||||
}
|
||||
})
|
||||
|
||||
this.ot.stderr.on('data', (data) => {
|
||||
stderr += data
|
||||
|
||||
if (logStdout) {
|
||||
console.log(`stderr: ${data}`)
|
||||
}
|
||||
})
|
||||
|
||||
this.ot.on('close', (code) => {
|
||||
if (code != null) {
|
||||
console.log(`OliveTin local process exited with code ${code}`)
|
||||
console.log(stdout)
|
||||
console.log(stderr)
|
||||
console.log(this.ot.exitCode)
|
||||
}
|
||||
})
|
||||
|
||||
if (this.ot.exitCode == null) {
|
||||
this.BASE_URL = 'http://localhost:1337/'
|
||||
|
||||
console.log(" OliveTin waiting for local process to start...")
|
||||
|
||||
await waitOn({
|
||||
resources: [this.BASE_URL]
|
||||
})
|
||||
|
||||
console.log(" OliveTin local process started and webUI accessible")
|
||||
} else {
|
||||
console.log(" OliveTin local process start FAILED!")
|
||||
console.log(stdout)
|
||||
console.log(stderr)
|
||||
console.log(this.ot.exitCode)
|
||||
}
|
||||
}
|
||||
|
||||
async stop () {
|
||||
if ((await this.ot.exitCode) != null) {
|
||||
console.log(" OliveTin local process tried stop(), but it already exited with code", this.ot.exitCode)
|
||||
} else {
|
||||
await this.ot.kill()
|
||||
console.log(" OliveTin local process killed")
|
||||
}
|
||||
|
||||
if (process.env.CI === 'true') {
|
||||
// GitHub runners seem to need a bit more time to clean up
|
||||
await new Promise((res) => setTimeout(res, 3000))
|
||||
} else {
|
||||
await new Promise((res) => setTimeout(res, 100))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class OliveTinTestRunnerEnv extends OliveTinTestRunner {
|
||||
constructor () {
|
||||
super()
|
||||
|
||||
const IP = process.env.IP
|
||||
const PORT = process.env.PORT
|
||||
|
||||
this.BASE_URL = 'http://' + IP + ':' + PORT + '/'
|
||||
|
||||
console.log('Runner ENV endpoint: ' + this.BASE_URL)
|
||||
}
|
||||
|
||||
async start () {
|
||||
await waitOn({
|
||||
resources: [this.BASE_URL]
|
||||
})
|
||||
}
|
||||
|
||||
async stop () {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class OliveTinTestRunnerVm extends OliveTinTestRunnerEnv {
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
async start (cfg) {
|
||||
console.log("vagrant changing config")
|
||||
spawn('vagrant', ['ssh', '-c', '"ln -sf /etc/OliveTin/ /opt/OliveTin-configs/' + cfg + '/config.yaml"'])
|
||||
spawn('vagrant', ['ssh', '-c', '"systemctl restart OliveTin"'])
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
||||
42
integration-tests/test/emptyDashboardsAreHidden.js
Normal file
42
integration-tests/test/emptyDashboardsAreHidden.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import { describe, it, before, after } from 'mocha'
|
||||
import { expect } from 'chai'
|
||||
import { By, until, Condition } from 'selenium-webdriver'
|
||||
//import * as waitOn from 'wait-on'
|
||||
import {
|
||||
getRootAndWait,
|
||||
takeScreenshotOnFailure,
|
||||
} from '../lib/elements.js'
|
||||
|
||||
describe('config: empty dashboards are hidden', function () {
|
||||
before(async function () {
|
||||
await runner.start('emptyDashboardsAreHidden')
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
await runner.stop()
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
takeScreenshotOnFailure(this.currentTest, webdriver);
|
||||
});
|
||||
|
||||
it('Test hidden dashboard', async function () {
|
||||
await getRootAndWait()
|
||||
|
||||
const title = await webdriver.getTitle()
|
||||
expect(title).to.be.equal("OliveTin")
|
||||
|
||||
await webdriver.findElement(By.id('sidebar-toggler-button')).click()
|
||||
|
||||
const navigationLinks = await webdriver.findElements(By.css('#navigation-links a'))
|
||||
|
||||
console.log('navigationLinks', navigationLinks)
|
||||
|
||||
expect(navigationLinks).to.not.be.empty
|
||||
expect(navigationLinks.length).to.be.equal(1, 'Expected the nav to only have 1 link')
|
||||
|
||||
const firstLinkId = await navigationLinks[0].getAttribute('id')
|
||||
|
||||
expect(firstLinkId).to.be.equal('showActions', 'Expected the first link to be the actions link')
|
||||
})
|
||||
})
|
||||
38
integration-tests/test/entities.js
Normal file
38
integration-tests/test/entities.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import { describe, it, before, after } from 'mocha'
|
||||
import { expect } from 'chai'
|
||||
import { By, until } from 'selenium-webdriver'
|
||||
import {
|
||||
getRootAndWait,
|
||||
takeScreenshot,
|
||||
takeScreenshotOnFailure,
|
||||
} from '../lib/elements.js'
|
||||
|
||||
describe('config: entities', function () {
|
||||
before(async function () {
|
||||
await runner.start('entities')
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
await runner.stop()
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
takeScreenshotOnFailure(this.currentTest, webdriver);
|
||||
});
|
||||
|
||||
it('Entity buttons are rendered', async function() {
|
||||
await getRootAndWait()
|
||||
|
||||
const buttons = await webdriver.findElement(By.id('root-group')).findElements(By.tagName('button'))
|
||||
expect(buttons).to.not.be.null
|
||||
expect(buttons).to.have.length(3)
|
||||
|
||||
expect(await buttons[0].getAttribute('title')).to.be.equal('Ping server1')
|
||||
expect(await buttons[1].getAttribute('title')).to.be.equal('Ping server2')
|
||||
expect(await buttons[2].getAttribute('title')).to.be.equal('Ping server3')
|
||||
|
||||
const dialogErr = await webdriver.findElement(By.id('big-error'))
|
||||
expect(dialogErr).to.not.be.null
|
||||
expect(await dialogErr.isDisplayed()).to.be.false
|
||||
})
|
||||
})
|
||||
113
integration-tests/test/general.mjs
Normal file
113
integration-tests/test/general.mjs
Normal file
@@ -0,0 +1,113 @@
|
||||
import { describe, it, before, after } from 'mocha'
|
||||
import { expect } from 'chai'
|
||||
import { By, until, Condition } from 'selenium-webdriver'
|
||||
//import * as waitOn from 'wait-on'
|
||||
import {
|
||||
getRootAndWait,
|
||||
getActionButtons,
|
||||
takeScreenshotOnFailure,
|
||||
} from '../lib/elements.js'
|
||||
|
||||
describe('config: general', function () {
|
||||
before(async function () {
|
||||
await runner.start('general')
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
await runner.stop()
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
takeScreenshotOnFailure(this.currentTest, webdriver);
|
||||
});
|
||||
|
||||
it('Page title', async function () {
|
||||
await webdriver.get(runner.baseUrl())
|
||||
|
||||
const title = await webdriver.getTitle()
|
||||
expect(title).to.be.equal("OliveTin")
|
||||
})
|
||||
|
||||
it('Page title2', async function () {
|
||||
/*
|
||||
await webdriver.get(runner.baseUrl())
|
||||
|
||||
const title = await webdriver.getTitle()
|
||||
expect(title).to.be.equal("OliveTin")
|
||||
*/
|
||||
})
|
||||
|
||||
it('navbar contains default policy links', async function () {
|
||||
await getRootAndWait()
|
||||
|
||||
const logListLink = await webdriver.findElements(By.css('[href="/logs"]'))
|
||||
expect(logListLink).to.not.be.empty
|
||||
|
||||
const diagnosticsLink = await webdriver.findElements(By.css('[href="/diagnostics"]'))
|
||||
expect(diagnosticsLink).to.not.be.empty
|
||||
})
|
||||
|
||||
it('Footer contains promo', async function () {
|
||||
const ftr = await webdriver.findElement(By.tagName('footer')).getText()
|
||||
|
||||
expect(ftr).to.contain('Documentation')
|
||||
})
|
||||
|
||||
it('Default buttons are rendered', async function() {
|
||||
await getRootAndWait()
|
||||
|
||||
const buttons = await getActionButtons(webdriver)
|
||||
|
||||
expect(buttons).to.have.length(8)
|
||||
})
|
||||
|
||||
it('Start dir action (popup)', async function () {
|
||||
await getRootAndWait()
|
||||
|
||||
const buttons = await webdriver.findElements(By.css('[title="dir-popup"]'))
|
||||
|
||||
expect(buttons).to.have.length(1)
|
||||
|
||||
const buttonCMD = buttons[0]
|
||||
|
||||
expect(buttonCMD).to.not.be.null
|
||||
|
||||
buttonCMD.click()
|
||||
|
||||
const dialog = await webdriver.findElement(By.id('execution-results-popup'))
|
||||
expect(await dialog.isDisplayed()).to.be.true
|
||||
|
||||
const title = await webdriver.findElement(By.id('execution-dialog-title'))
|
||||
expect(await webdriver.wait(until.elementTextIs(title, 'dir-popup'), 2000))
|
||||
|
||||
const dialogErr = await webdriver.findElement(By.id('big-error'))
|
||||
expect(dialogErr).to.not.be.null
|
||||
expect(await dialogErr.isDisplayed()).to.be.false
|
||||
})
|
||||
|
||||
it('Start cd action (passive)', async function () {
|
||||
await getRootAndWait()
|
||||
|
||||
const buttons = await webdriver.findElements(By.css('[title="cd-passive"]'))
|
||||
|
||||
expect(buttons).to.have.length(1)
|
||||
|
||||
const buttonCMD = buttons[0]
|
||||
|
||||
expect(buttonCMD).to.not.be.null
|
||||
|
||||
buttonCMD.click()
|
||||
|
||||
const dialog = await webdriver.findElement(By.id('execution-results-popup'))
|
||||
expect(await dialog.isDisplayed()).to.be.false
|
||||
|
||||
const title = await webdriver.findElement(By.id('execution-dialog-title'))
|
||||
expect(await title.getAttribute('innerText')).to.be.equal('?')
|
||||
|
||||
const dialogErr = await webdriver.findElement(By.id('big-error'))
|
||||
console.log("big error is: " + dialogErr.innerHTML)
|
||||
expect(dialogErr).to.not.be.null
|
||||
expect(await dialogErr.isDisplayed()).to.be.false
|
||||
})
|
||||
|
||||
})
|
||||
31
integration-tests/test/hiddenFooter.mjs
Normal file
31
integration-tests/test/hiddenFooter.mjs
Normal file
@@ -0,0 +1,31 @@
|
||||
import { describe, it, before, after } from 'mocha'
|
||||
import { expect } from 'chai'
|
||||
|
||||
import { By } from 'selenium-webdriver'
|
||||
import {
|
||||
getRootAndWait,
|
||||
getActionButtons,
|
||||
takeScreenshotOnFailure,
|
||||
} from '../lib/elements.js'
|
||||
|
||||
describe('config: hiddenFooter', function () {
|
||||
before(async function () {
|
||||
await runner.start('hiddenFooter')
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
await runner.stop()
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
takeScreenshotOnFailure(this.currentTest, webdriver);
|
||||
});
|
||||
|
||||
it('Check that footer is hidden', async () => {
|
||||
await webdriver.get(runner.baseUrl())
|
||||
|
||||
const footer = await webdriver.findElement(By.tagName('footer'))
|
||||
|
||||
expect(await footer.isDisplayed()).to.be.false
|
||||
})
|
||||
})
|
||||
30
integration-tests/test/hiddenNav.mjs
Normal file
30
integration-tests/test/hiddenNav.mjs
Normal file
@@ -0,0 +1,30 @@
|
||||
import { expect } from 'chai'
|
||||
import { By } from 'selenium-webdriver'
|
||||
import {
|
||||
getRootAndWait,
|
||||
getActionButtons,
|
||||
takeScreenshotOnFailure,
|
||||
} from '../lib/elements.js'
|
||||
|
||||
|
||||
describe('config: hiddenNav', function () {
|
||||
before(async function () {
|
||||
await runner.start('hiddenNav')
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
await runner.stop()
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
takeScreenshotOnFailure(this.currentTest, webdriver);
|
||||
});
|
||||
|
||||
it('nav is hidden', async () => {
|
||||
await webdriver.get(runner.baseUrl())
|
||||
|
||||
const toggler = await webdriver.findElement(By.tagName('header'))
|
||||
|
||||
expect(await toggler.isDisplayed()).to.be.false
|
||||
})
|
||||
})
|
||||
53
integration-tests/test/multipleDropdowns.js
Normal file
53
integration-tests/test/multipleDropdowns.js
Normal file
@@ -0,0 +1,53 @@
|
||||
import { describe, it, before, after } from 'mocha'
|
||||
import { expect } from 'chai'
|
||||
import { By, until } from 'selenium-webdriver'
|
||||
import {
|
||||
getRootAndWait,
|
||||
getActionButtons,
|
||||
takeScreenshotOnFailure,
|
||||
} from '../lib/elements.js'
|
||||
|
||||
|
||||
describe('config: multipleDropdowns', function () {
|
||||
before(async function () {
|
||||
await runner.start('multipleDropdowns')
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
await runner.stop()
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
takeScreenshotOnFailure(this.currentTest, webdriver);
|
||||
});
|
||||
|
||||
it('Multiple dropdowns are possible', async function() {
|
||||
await getRootAndWait()
|
||||
|
||||
const buttons = await getActionButtons(webdriver)
|
||||
|
||||
let button = null
|
||||
for (const b of buttons) {
|
||||
const title = await b.getAttribute('title')
|
||||
|
||||
if (title === 'Test multiple dropdowns') {
|
||||
button = b
|
||||
}
|
||||
}
|
||||
|
||||
expect(buttons).to.have.length(2)
|
||||
expect(button).to.not.be.null
|
||||
|
||||
await button.click()
|
||||
|
||||
const dialog = await webdriver.findElement(By.id('argument-popup'))
|
||||
|
||||
await webdriver.wait(until.elementIsVisible(dialog), 3500)
|
||||
|
||||
const selects = await dialog.findElements(By.tagName('select'))
|
||||
|
||||
expect(selects).to.have.length(2)
|
||||
expect(await selects[0].findElements(By.tagName('option'))).to.have.length(2)
|
||||
expect(await selects[1].findElements(By.tagName('option'))).to.have.length(3)
|
||||
})
|
||||
})
|
||||
32
integration-tests/test/policy-all-false.mjs
Normal file
32
integration-tests/test/policy-all-false.mjs
Normal file
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
getRootAndWait,
|
||||
takeScreenshotOnFailure,
|
||||
} from '../lib/elements.js'
|
||||
|
||||
import { By } from 'selenium-webdriver'
|
||||
import { expect } from 'chai'
|
||||
|
||||
describe('config: policy-all-false', function () {
|
||||
before(async function () {
|
||||
await runner.start('policy-all-false')
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await runner.stop()
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
takeScreenshotOnFailure(this.currentTest, webdriver);
|
||||
});
|
||||
|
||||
|
||||
it('navbar should not contain default policy links', async function () {
|
||||
await getRootAndWait()
|
||||
|
||||
const logListLink = await webdriver.findElements(By.css('[href="/logs"]'))
|
||||
expect(logListLink).to.be.empty
|
||||
|
||||
const diagnosticsLink = await webdriver.findElements(By.css('[href="/diagnostics"]'))
|
||||
expect(diagnosticsLink).to.be.empty
|
||||
})
|
||||
})
|
||||
40
integration-tests/test/prometheus.mjs
Normal file
40
integration-tests/test/prometheus.mjs
Normal file
@@ -0,0 +1,40 @@
|
||||
import { describe, it, before, after } from 'mocha'
|
||||
import { expect } from 'chai'
|
||||
|
||||
import { By } from 'selenium-webdriver'
|
||||
import {
|
||||
takeScreenshotOnFailure,
|
||||
} from '../lib/elements.js'
|
||||
|
||||
let metrics = [
|
||||
{'name': 'olivetin_actions_requested_count', 'type': 'counter', 'desc': 'The actions requested count'},
|
||||
{'name': 'olivetin_config_action_count', 'type': 'gauge', 'desc': 'The number of actions in the config file'},
|
||||
{'name': 'olivetin_config_reloaded_count', 'type': 'counter', 'desc': 'The number of times the config has been reloaded'},
|
||||
{'name': 'olivetin_sv_count', 'type': 'gauge', 'desc': 'The number entries in the sv map'},
|
||||
]
|
||||
|
||||
describe('config: prometheus', function () {
|
||||
before(async function () {
|
||||
await runner.start('prometheus')
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
await runner.stop()
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
takeScreenshotOnFailure(this.currentTest, webdriver);
|
||||
});
|
||||
|
||||
it('Metrics are available with correct types', async () => {
|
||||
webdriver.get(runner.metricsUrl())
|
||||
const prometheusOutput = await webdriver.findElement(By.tagName('pre')).getText()
|
||||
|
||||
expect(prometheusOutput).to.not.be.null
|
||||
metrics.forEach(({name, type, desc}) => {
|
||||
const metaLines = `# HELP ${name} ${desc}\n`
|
||||
+ `# TYPE ${name} ${type}\n`
|
||||
expect(prometheusOutput).to.match(new RegExp(metaLines))
|
||||
})
|
||||
})
|
||||
})
|
||||
49
integration-tests/test/sleep.js
Normal file
49
integration-tests/test/sleep.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import * as process from 'node:process'
|
||||
import { describe, it, before, after } from 'mocha'
|
||||
import { expect } from 'chai'
|
||||
import { By, Condition } from 'selenium-webdriver'
|
||||
import {
|
||||
takeScreenshot,
|
||||
takeScreenshotOnFailure,
|
||||
findExecutionDialog,
|
||||
requireExecutionDialogStatus,
|
||||
getRootAndWait,
|
||||
getActionButton
|
||||
} from '../lib/elements.js'
|
||||
|
||||
describe('config: sleep', function () {
|
||||
before(async function () {
|
||||
await runner.start('sleep')
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
await runner.stop()
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
takeScreenshotOnFailure(this.currentTest, webdriver);
|
||||
});
|
||||
|
||||
it('Sleep action kill', async function() {
|
||||
await getRootAndWait()
|
||||
|
||||
const btnSleep = await getActionButton(webdriver, "Sleep")
|
||||
|
||||
const dialog = await findExecutionDialog(webdriver)
|
||||
|
||||
expect(await dialog.isDisplayed()).to.be.false
|
||||
|
||||
await btnSleep.click()
|
||||
|
||||
expect(await dialog.isDisplayed()).to.be.true
|
||||
|
||||
await requireExecutionDialogStatus(webdriver, "unknown")
|
||||
|
||||
const killButton = await webdriver.findElement(By.id('execution-dialog-kill-action'))
|
||||
expect(killButton).to.not.be.undefined
|
||||
|
||||
await killButton.click()
|
||||
|
||||
await requireExecutionDialogStatus(webdriver, "Completed")
|
||||
})
|
||||
})
|
||||
42
integration-tests/test/trustedHeader.js
Normal file
42
integration-tests/test/trustedHeader.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import { expect } from 'chai'
|
||||
import {
|
||||
getRootAndWait,
|
||||
takeScreenshotOnFailure,
|
||||
} from '../lib/elements.js'
|
||||
|
||||
describe('config: trustedHeader', function () {
|
||||
before(async function () {
|
||||
await runner.start('trustedHeader')
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
await runner.stop()
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
takeScreenshotOnFailure(this.currentTest, webdriver);
|
||||
});
|
||||
|
||||
it('req with X-User', async () => {
|
||||
await getRootAndWait()
|
||||
|
||||
const req = await fetch(runner.baseUrl() + '/api/WhoAmI', {
|
||||
headers: {
|
||||
"X-User": "fred",
|
||||
}
|
||||
})
|
||||
|
||||
if (!req.ok) {
|
||||
console.log(req)
|
||||
}
|
||||
|
||||
expect(req.ok, 'WhoAmI Request is ' + req.status).to.be.true
|
||||
|
||||
const json = await req.json()
|
||||
|
||||
expect(json).to.not.be.null
|
||||
expect(json).to.have.own.property('authenticatedUser')
|
||||
|
||||
expect(json['authenticatedUser']).to.be.equal('fred')
|
||||
})
|
||||
})
|
||||
@@ -1,136 +0,0 @@
|
||||
package acl
|
||||
|
||||
import (
|
||||
"context"
|
||||
config "github.com/OliveTin/OliveTin/internal/config"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"golang.org/x/exp/slices"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
// User respresents a person.
|
||||
type AuthenticatedUser struct {
|
||||
Username string
|
||||
Usergroup string
|
||||
|
||||
acls []string
|
||||
}
|
||||
|
||||
// IsAllowedExec checks if a AuthenticatedUser is allowed to execute an Action
|
||||
func IsAllowedExec(cfg *config.Config, user *AuthenticatedUser, action *config.Action) bool {
|
||||
for _, acl := range getRelevantAcls(cfg, action.Acls, user) {
|
||||
if acl.Permissions.Exec {
|
||||
log.WithFields(log.Fields{
|
||||
"User": user.Username,
|
||||
"Action": action.Title,
|
||||
"ACL": acl.Name,
|
||||
}).Debug("isAllowedExec - Matched ACL")
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"User": user.Username,
|
||||
"Action": action.Title,
|
||||
}).Debug("isAllowedExec - No ACLs matched")
|
||||
|
||||
return cfg.DefaultPermissions.Exec
|
||||
}
|
||||
|
||||
// IsAllowedView checks if a User is allowed to view an Action
|
||||
func IsAllowedView(cfg *config.Config, user *AuthenticatedUser, action *config.Action) bool {
|
||||
for _, acl := range getRelevantAcls(cfg, action.Acls, user) {
|
||||
if acl.Permissions.View {
|
||||
log.WithFields(log.Fields{
|
||||
"User": user.Username,
|
||||
"Action": action.Title,
|
||||
"ACL": acl.Name,
|
||||
}).Debug("isAllowedView - Matched ACL")
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"User": user.Username,
|
||||
"Action": action.Title,
|
||||
}).Debug("isAllowedView - No ACLs matched")
|
||||
|
||||
return cfg.DefaultPermissions.View
|
||||
}
|
||||
|
||||
func getMetdataKeyOrEmpty(md metadata.MD, key string) string {
|
||||
mdValues := md.Get(key)
|
||||
|
||||
if len(mdValues) > 0 {
|
||||
return mdValues[0]
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
// UserFromContext tries to find a user from a grpc context
|
||||
func UserFromContext(ctx context.Context, cfg *config.Config) *AuthenticatedUser {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
|
||||
ret := &AuthenticatedUser{}
|
||||
|
||||
if ok {
|
||||
ret.Username = getMetdataKeyOrEmpty(md, "username")
|
||||
ret.Usergroup = getMetdataKeyOrEmpty(md, "usergroup")
|
||||
}
|
||||
|
||||
buildUserAcls(cfg, ret)
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"username": ret.Username,
|
||||
"usergroup": ret.Usergroup,
|
||||
}).Infof("UserFromContext")
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func buildUserAcls(cfg *config.Config, user *AuthenticatedUser) {
|
||||
for _, acl := range cfg.AccessControlLists {
|
||||
if slices.Contains(acl.MatchUsernames, user.Username) {
|
||||
user.acls = append(user.acls, acl.Name)
|
||||
continue
|
||||
}
|
||||
|
||||
if slices.Contains(acl.MatchUsergroups, user.Usergroup) {
|
||||
user.acls = append(user.acls, acl.Name)
|
||||
continue
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func isACLRelevant(cfg *config.Config, actionAcls []string, acl config.AccessControlList, user *AuthenticatedUser) bool {
|
||||
if !slices.Contains(user.acls, acl.Name) {
|
||||
return false
|
||||
}
|
||||
|
||||
if acl.AddToEveryAction {
|
||||
return true
|
||||
}
|
||||
|
||||
if slices.Contains(actionAcls, acl.Name) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func getRelevantAcls(cfg *config.Config, actionAcls []string, user *AuthenticatedUser) []*config.AccessControlList {
|
||||
var ret []*config.AccessControlList
|
||||
|
||||
for _, acl := range cfg.AccessControlLists {
|
||||
if isACLRelevant(cfg, actionAcls, acl, user) {
|
||||
ret = append(ret, &acl)
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
package config
|
||||
|
||||
// Action represents the core functionality of OliveTin - commands that show up
|
||||
// as buttons in the UI.
|
||||
type Action struct {
|
||||
ID string
|
||||
Title string
|
||||
Icon string
|
||||
Shell string
|
||||
CSS map[string]string `mapstructure:"omitempty"`
|
||||
Timeout int
|
||||
Acls []string
|
||||
ExecOnStartup bool
|
||||
ExecOnCron []string
|
||||
Arguments []ActionArgument
|
||||
}
|
||||
|
||||
// ActionArgument objects appear on Actions.
|
||||
type ActionArgument struct {
|
||||
Name string
|
||||
Title string
|
||||
Description string
|
||||
Type string
|
||||
Default string
|
||||
Choices []ActionArgumentChoice
|
||||
}
|
||||
|
||||
// ActionArgumentChoice represents a predefined choice for an argument.
|
||||
type ActionArgumentChoice struct {
|
||||
Value string
|
||||
Title string
|
||||
}
|
||||
|
||||
// Entity represents a "thing" that can have multiple actions associated with it.
|
||||
// for example, a media player with a start and stop action.
|
||||
type Entity struct {
|
||||
Title string
|
||||
Icon string
|
||||
Actions []Action `mapstructure:"actions"`
|
||||
CSS map[string]string
|
||||
}
|
||||
|
||||
// PermissionsList defines what users can do with an action.
|
||||
type PermissionsList struct {
|
||||
View bool
|
||||
Exec bool
|
||||
}
|
||||
|
||||
// AccessControlList defines what permissions apply to a user or user group.
|
||||
type AccessControlList struct {
|
||||
Name string
|
||||
AddToEveryAction bool
|
||||
MatchUsergroups []string
|
||||
MatchUsernames []string
|
||||
Permissions PermissionsList
|
||||
}
|
||||
|
||||
// Config is the global config used through the whole app.
|
||||
type Config struct {
|
||||
UseSingleHTTPFrontend bool
|
||||
ThemeName string
|
||||
ListenAddressSingleHTTPFrontend string
|
||||
ListenAddressWebUI string
|
||||
ListenAddressRestActions string
|
||||
ListenAddressGrpcActions string
|
||||
ExternalRestAddress string
|
||||
LogLevel string
|
||||
Actions []Action `mapstructure:"actions"`
|
||||
Entities []Entity `mapstructure:"entities"`
|
||||
CheckForUpdates bool
|
||||
PageTitle string
|
||||
ShowFooter bool
|
||||
ShowNavigation bool
|
||||
ShowNewVersions bool
|
||||
AuthJwtCookieName string
|
||||
AuthJwtSecret string
|
||||
AuthJwtClaimUsername string
|
||||
AuthJwtClaimUserGroup string
|
||||
AuthHttpHeaderUsername string
|
||||
AuthHttpHeaderUserGroup string
|
||||
DefaultPermissions PermissionsList
|
||||
AccessControlLists []AccessControlList
|
||||
WebUIDir string
|
||||
}
|
||||
|
||||
// DefaultConfig gets a new Config structure with sensible default values.
|
||||
func DefaultConfig() *Config {
|
||||
config := Config{}
|
||||
config.UseSingleHTTPFrontend = true
|
||||
config.PageTitle = "OliveTin"
|
||||
config.ShowFooter = true
|
||||
config.ShowNavigation = true
|
||||
config.ShowNewVersions = true
|
||||
config.ListenAddressSingleHTTPFrontend = "0.0.0.0:1337"
|
||||
config.ListenAddressRestActions = "localhost:1338"
|
||||
config.ListenAddressGrpcActions = "localhost:1339"
|
||||
config.ListenAddressWebUI = "localhost:1340"
|
||||
config.ExternalRestAddress = "."
|
||||
config.LogLevel = "INFO"
|
||||
config.CheckForUpdates = true
|
||||
config.DefaultPermissions.Exec = true
|
||||
config.DefaultPermissions.View = true
|
||||
config.AuthJwtClaimUsername = "name"
|
||||
config.AuthJwtClaimUserGroup = "group"
|
||||
config.WebUIDir = "./webui"
|
||||
|
||||
return &config
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package config
|
||||
|
||||
var emojis = map[string]string{
|
||||
"": "😀", // default icon
|
||||
"poop": "💩",
|
||||
"smile": "😀",
|
||||
"ping": "📡",
|
||||
"backup": "💾",
|
||||
"reboot": "⏻",
|
||||
"restart": "⏻",
|
||||
}
|
||||
|
||||
func lookupHTMLIcon(keyToLookup string) string {
|
||||
if emoji, found := emojis[keyToLookup]; found {
|
||||
return emoji
|
||||
}
|
||||
|
||||
return keyToLookup
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetEmojiByShortName(t *testing.T) {
|
||||
assert.Equal(t, "😀", lookupHTMLIcon("smile"), "Find an eomji by short name")
|
||||
|
||||
assert.Equal(t, "notfound", lookupHTMLIcon("notfound"), "Find an eomji by undefined short name")
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Sanitize will look for common configuration issues, and fix them. For example,
|
||||
// populating undefined fields - name -> title, etc.
|
||||
func (cfg *Config) Sanitize() {
|
||||
cfg.sanitizeLogLevel()
|
||||
|
||||
// log.Infof("cfg %p", cfg)
|
||||
|
||||
for idx := range cfg.Actions {
|
||||
cfg.Actions[idx].sanitize()
|
||||
}
|
||||
}
|
||||
|
||||
func (cfg *Config) sanitizeLogLevel() {
|
||||
if logLevel, err := log.ParseLevel(cfg.LogLevel); err == nil {
|
||||
log.Info("Setting log level to ", logLevel)
|
||||
log.SetLevel(logLevel)
|
||||
}
|
||||
}
|
||||
|
||||
func (action *Action) sanitize() {
|
||||
if action.Timeout < 3 {
|
||||
action.Timeout = 3
|
||||
}
|
||||
|
||||
action.Icon = lookupHTMLIcon(action.Icon)
|
||||
|
||||
for idx := range action.Arguments {
|
||||
action.Arguments[idx].sanitize()
|
||||
}
|
||||
}
|
||||
|
||||
func (arg *ActionArgument) sanitize() {
|
||||
if arg.Title == "" {
|
||||
arg.Title = arg.Name
|
||||
}
|
||||
|
||||
for idx, choice := range arg.Choices {
|
||||
if choice.Title == "" {
|
||||
arg.Choices[idx].Title = choice.Value
|
||||
}
|
||||
}
|
||||
|
||||
arg.sanitizeNoType()
|
||||
|
||||
// TODO Validate the default against the type checker, but this creates a
|
||||
// import loop
|
||||
}
|
||||
|
||||
func (arg *ActionArgument) sanitizeNoType() {
|
||||
if len(arg.Choices) == 0 && arg.Type == "" {
|
||||
log.WithFields(log.Fields{
|
||||
"arg": arg.Name,
|
||||
}).Warn("Argument type isn't set, will default to 'ascii' but this may not be safe. You should set a type specifically.")
|
||||
arg.Type = "ascii"
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
package executor
|
||||
|
||||
import (
|
||||
config "github.com/OliveTin/OliveTin/internal/config"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"errors"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
typecheckRegex = map[string]string{
|
||||
"very_dangerous_raw_string": "",
|
||||
"int": "^[\\d]+$",
|
||||
"ascii": "^[a-zA-Z0-9]+$",
|
||||
"ascii_identifier": "^[a-zA-Z0-9\\-\\.\\_]+$",
|
||||
"ascii_sentence": "^[a-zA-Z0-9 \\,\\.]+$",
|
||||
}
|
||||
)
|
||||
|
||||
func parseActionArguments(rawShellCommand string, values map[string]string, action *config.Action) (string, error) {
|
||||
log.WithFields(log.Fields{
|
||||
"cmd": rawShellCommand,
|
||||
}).Infof("Before Parse Args")
|
||||
|
||||
r := regexp.MustCompile("{{ *?([a-zA-Z0-9_]+?) *?}}")
|
||||
matches := r.FindAllStringSubmatch(rawShellCommand, -1)
|
||||
|
||||
for _, match := range matches {
|
||||
argValue, argProvided := values[match[1]]
|
||||
|
||||
if !argProvided {
|
||||
log.Infof("%v", values)
|
||||
return "", errors.New("Required arg not provided: " + match[1])
|
||||
}
|
||||
|
||||
err := typecheckActionArgument(match[1], argValue, action)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"name": match[1],
|
||||
"value": argValue,
|
||||
}).Debugf("Arg assigned")
|
||||
|
||||
rawShellCommand = strings.ReplaceAll(rawShellCommand, match[0], argValue)
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"cmd": rawShellCommand,
|
||||
}).Infof("After Parse Args")
|
||||
|
||||
return rawShellCommand, nil
|
||||
}
|
||||
|
||||
func typecheckActionArgument(name string, value string, action *config.Action) error {
|
||||
arg := action.FindArg(name)
|
||||
|
||||
if arg == nil {
|
||||
return errors.New("Action arg not defined: " + name)
|
||||
}
|
||||
|
||||
if len(arg.Choices) > 0 {
|
||||
return typecheckChoice(value, arg)
|
||||
}
|
||||
|
||||
return TypeSafetyCheck(name, value, arg.Type)
|
||||
}
|
||||
|
||||
func typecheckChoice(value string, arg *config.ActionArgument) error {
|
||||
for _, choice := range arg.Choices {
|
||||
if value == choice.Value {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return errors.New("argument value is not one of the predefined choices")
|
||||
}
|
||||
|
||||
// TypeSafetyCheck checks argument values match a specific type. The types are
|
||||
// defined in typecheckRegex, and, you guessed it, uses regex to check for allowed
|
||||
// characters.
|
||||
func TypeSafetyCheck(name string, value string, argumentType string) error {
|
||||
if argumentType == "url" {
|
||||
return typeSafetyCheckUrl(name, value)
|
||||
}
|
||||
|
||||
return typeSafetyCheckRegex(name, value, argumentType)
|
||||
}
|
||||
|
||||
func typeSafetyCheckRegex(name string, value string, argumentType string) error {
|
||||
pattern, found := typecheckRegex[argumentType]
|
||||
|
||||
if !found {
|
||||
return errors.New("argument type not implemented " + argumentType)
|
||||
}
|
||||
|
||||
matches, _ := regexp.MatchString(pattern, value)
|
||||
|
||||
if !matches {
|
||||
log.WithFields(log.Fields{
|
||||
"name": name,
|
||||
"value": value,
|
||||
"type": argumentType,
|
||||
}).Warn("Arg type check safety failure")
|
||||
|
||||
return errors.New("invalid argument, doesn't match " + argumentType)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func typeSafetyCheckUrl(name string, value string) error {
|
||||
_, err := url.ParseRequestURI(value)
|
||||
|
||||
return err
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
package executor
|
||||
|
||||
import (
|
||||
config "github.com/OliveTin/OliveTin/internal/config"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSanitizeUnsafe(t *testing.T) {
|
||||
assert.Nil(t, TypeSafetyCheck("", "_zomg_ c:/ haxxor ' bobby tables && rm -rf ", "very_dangerous_raw_string"))
|
||||
}
|
||||
|
||||
func TestSanitizeUnimplemented(t *testing.T) {
|
||||
err := TypeSafetyCheck("", "I am a happy little argument", "greeting_type")
|
||||
|
||||
assert.NotNil(t, err, "Test an argument type that does not exist")
|
||||
}
|
||||
|
||||
func TestArgumentNameNumbers(t *testing.T) {
|
||||
a1 := config.Action{
|
||||
Title: "Do some tickles",
|
||||
Shell: "echo 'Tickling {{ person1name }}'",
|
||||
Arguments: []config.ActionArgument{
|
||||
{
|
||||
Name: "person1name",
|
||||
Type: "ascii",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
values := map[string]string{
|
||||
"person1name": "Fred",
|
||||
}
|
||||
|
||||
out, err := parseActionArguments(a1.Shell, values, &a1)
|
||||
|
||||
assert.Equal(t, "echo 'Tickling Fred'", out)
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestArgumentNotProvided(t *testing.T) {
|
||||
a1 := config.Action{
|
||||
Title: "Do some tickles",
|
||||
Shell: "echo 'Tickling {{ personName }}'",
|
||||
Arguments: []config.ActionArgument{
|
||||
{
|
||||
Name: "person",
|
||||
Type: "ascii",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
values := map[string]string{}
|
||||
|
||||
out, err := parseActionArguments(a1.Shell, values, &a1)
|
||||
|
||||
assert.Equal(t, "", out)
|
||||
assert.Equal(t, err.Error(), "Required arg not provided: personName")
|
||||
}
|
||||
|
||||
func TestTypeSafetyCheckUrl(t *testing.T) {
|
||||
assert.Nil(t, TypeSafetyCheck("test1", "http://google.com", "url"), "Test URL: google.com")
|
||||
assert.Nil(t, TypeSafetyCheck("test2", "http://technowax.net:80?foo=bar", "url"), "Test URL: technowax.net with query arguments")
|
||||
assert.Nil(t, TypeSafetyCheck("test3", "http://localhost:80?foo=bar", "url"), "Test URL: localhost with query arguments")
|
||||
assert.NotNil(t, TypeSafetyCheck("test4", "http://lo host:80", "url"), "Test a badly formed URL")
|
||||
assert.NotNil(t, TypeSafetyCheck("test5", "12345", "url"), "Test a badly formed URL")
|
||||
assert.NotNil(t, TypeSafetyCheck("test6", "_!23;", "url"), "Test a badly formed URL")
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
package executor
|
||||
|
||||
import (
|
||||
pb "github.com/OliveTin/OliveTin/gen/grpc"
|
||||
acl "github.com/OliveTin/OliveTin/internal/acl"
|
||||
config "github.com/OliveTin/OliveTin/internal/config"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"bytes"
|
||||
"context"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ExecutionRequest is a request to execute an action. It's passed to an
|
||||
// Executor. They're created from the grpcapi.
|
||||
type ExecutionRequest struct {
|
||||
ActionName string
|
||||
Arguments map[string]string
|
||||
Tags []string
|
||||
action *config.Action
|
||||
Cfg *config.Config
|
||||
AuthenticatedUser *acl.AuthenticatedUser
|
||||
logEntry *InternalLogEntry
|
||||
finalParsedCommand string
|
||||
}
|
||||
|
||||
// InternalLogEntry objects are created by an Executor, and represent the final
|
||||
// state of execution (even if the command is not executed). It's designed to be
|
||||
// easily serializable.
|
||||
type InternalLogEntry struct {
|
||||
Datetime string
|
||||
Stdout string
|
||||
Stderr string
|
||||
TimedOut bool
|
||||
ExitCode int32
|
||||
Tags []string
|
||||
|
||||
/*
|
||||
The following two properties are obviously on Action normally, but it's useful
|
||||
that logs are lightweight (so we don't need to have an action associated to
|
||||
logs, etc. Therefore, we duplicate those values here.
|
||||
*/
|
||||
ActionTitle string
|
||||
ActionIcon string
|
||||
}
|
||||
|
||||
type executorStepFunc func(*ExecutionRequest) bool
|
||||
|
||||
// Executor represents a helper class for executing commands. It's main method
|
||||
// is ExecRequest
|
||||
type Executor struct {
|
||||
Logs []InternalLogEntry
|
||||
|
||||
chainOfCommand []executorStepFunc
|
||||
}
|
||||
|
||||
// ExecRequest processes an ExecutionRequest
|
||||
func (e *Executor) ExecRequest(req *ExecutionRequest) *pb.StartActionResponse {
|
||||
req.logEntry = &InternalLogEntry{
|
||||
Datetime: time.Now().Format("2006-01-02 15:04:05"),
|
||||
ActionTitle: req.ActionName,
|
||||
Stdout: "",
|
||||
Stderr: "",
|
||||
ExitCode: -1337, // If an Action is not actually executed, this is the default exit code.
|
||||
}
|
||||
|
||||
for _, step := range e.chainOfCommand {
|
||||
if !step(req) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
e.Logs = append(e.Logs, *req.logEntry)
|
||||
|
||||
return &pb.StartActionResponse{
|
||||
LogEntry: &pb.LogEntry{
|
||||
ActionTitle: req.logEntry.ActionTitle,
|
||||
ActionIcon: req.logEntry.ActionIcon,
|
||||
Datetime: req.logEntry.Datetime,
|
||||
Stderr: req.logEntry.Stderr,
|
||||
Stdout: req.logEntry.Stdout,
|
||||
TimedOut: req.logEntry.TimedOut,
|
||||
ExitCode: req.logEntry.ExitCode,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultExecutor returns an Executor, with a sensible "chain of command" for
|
||||
// executing actions.
|
||||
func DefaultExecutor() *Executor {
|
||||
e := Executor{}
|
||||
e.chainOfCommand = []executorStepFunc{
|
||||
stepFindAction,
|
||||
stepACLCheck,
|
||||
stepParseArgs,
|
||||
stepLogStart,
|
||||
stepExec,
|
||||
stepLogFinish,
|
||||
}
|
||||
|
||||
return &e
|
||||
}
|
||||
|
||||
func stepFindAction(req *ExecutionRequest) bool {
|
||||
actualAction := req.Cfg.FindAction(req.ActionName)
|
||||
|
||||
if actualAction == nil {
|
||||
log.WithFields(log.Fields{
|
||||
"actionName": req.ActionName,
|
||||
}).Warnf("Action not found")
|
||||
|
||||
req.logEntry.Stderr = "Action not found"
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
req.action = actualAction
|
||||
req.logEntry.ActionIcon = actualAction.Icon
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func stepACLCheck(req *ExecutionRequest) bool {
|
||||
return acl.IsAllowedExec(req.Cfg, req.AuthenticatedUser, req.action)
|
||||
}
|
||||
|
||||
func stepParseArgs(req *ExecutionRequest) bool {
|
||||
var err error
|
||||
|
||||
req.finalParsedCommand, err = parseActionArguments(req.action.Shell, req.Arguments, req.action)
|
||||
|
||||
if err != nil {
|
||||
req.logEntry.Stdout = err.Error()
|
||||
|
||||
log.Warnf(err.Error())
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func stepLogStart(req *ExecutionRequest) bool {
|
||||
log.WithFields(log.Fields{
|
||||
"title": req.action.Title,
|
||||
"timeout": req.action.Timeout,
|
||||
}).Infof("Action starting")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func stepLogFinish(req *ExecutionRequest) bool {
|
||||
log.WithFields(log.Fields{
|
||||
"title": req.action.Title,
|
||||
"stdout": req.logEntry.Stdout,
|
||||
"stderr": req.logEntry.Stderr,
|
||||
"timedOut": req.logEntry.TimedOut,
|
||||
"exit": req.logEntry.ExitCode,
|
||||
}).Infof("Action finished")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func wrapCommandInShell(ctx context.Context, finalParsedCommand string) *exec.Cmd {
|
||||
if runtime.GOOS == "windows" {
|
||||
return exec.CommandContext(ctx, "cmd", "/C", finalParsedCommand)
|
||||
}
|
||||
|
||||
return exec.CommandContext(ctx, "sh", "-c", finalParsedCommand)
|
||||
}
|
||||
|
||||
func stepExec(req *ExecutionRequest) bool {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(req.action.Timeout)*time.Second)
|
||||
defer cancel()
|
||||
|
||||
var stdout bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
|
||||
cmd := wrapCommandInShell(ctx, req.finalParsedCommand)
|
||||
cmd.Stdout = &stdout
|
||||
cmd.Stderr = &stderr
|
||||
|
||||
runerr := cmd.Run()
|
||||
|
||||
req.logEntry.ExitCode = int32(cmd.ProcessState.ExitCode())
|
||||
req.logEntry.Stdout = stdout.String()
|
||||
req.logEntry.Stderr = stderr.String()
|
||||
|
||||
if runerr != nil {
|
||||
req.logEntry.Stderr = runerr.Error() + "\n\n" + req.logEntry.Stderr
|
||||
}
|
||||
|
||||
if ctx.Err() == context.DeadlineExceeded {
|
||||
req.logEntry.TimedOut = true
|
||||
}
|
||||
|
||||
req.logEntry.Tags = req.Tags
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
package executor
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
|
||||
acl "github.com/OliveTin/OliveTin/internal/acl"
|
||||
config "github.com/OliveTin/OliveTin/internal/config"
|
||||
)
|
||||
|
||||
func testingExecutor() (*Executor, *config.Config) {
|
||||
e := DefaultExecutor()
|
||||
|
||||
cfg := config.DefaultConfig()
|
||||
|
||||
a1 := config.Action{
|
||||
Title: "Do some tickles",
|
||||
Shell: "echo 'Tickling {{ person }}'",
|
||||
Arguments: []config.ActionArgument{
|
||||
{
|
||||
Name: "person",
|
||||
Type: "ascii",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
cfg.Actions = append(cfg.Actions, a1)
|
||||
cfg.Sanitize()
|
||||
|
||||
return e, cfg
|
||||
}
|
||||
|
||||
func TestCreateExecutorAndExec(t *testing.T) {
|
||||
e, cfg := testingExecutor()
|
||||
|
||||
req := ExecutionRequest{
|
||||
ActionName: "Do some tickles",
|
||||
AuthenticatedUser: &acl.AuthenticatedUser{Username: "Mr Tickle"},
|
||||
Cfg: cfg,
|
||||
Arguments: map[string]string{
|
||||
"person": "yourself",
|
||||
},
|
||||
}
|
||||
|
||||
e.ExecRequest(&req)
|
||||
|
||||
assert.NotNil(t, e, "Create an executor")
|
||||
|
||||
assert.NotNil(t, e.ExecRequest(&req), "Execute a request")
|
||||
assert.Equal(t, int32(0), req.logEntry.ExitCode, "Exit code is zero")
|
||||
}
|
||||
|
||||
func TestExecNonExistant(t *testing.T) {
|
||||
e, cfg := testingExecutor()
|
||||
|
||||
req := ExecutionRequest{
|
||||
ActionName: "Waffles",
|
||||
logEntry: &InternalLogEntry{},
|
||||
Cfg: cfg,
|
||||
}
|
||||
|
||||
e.ExecRequest(&req)
|
||||
|
||||
assert.Equal(t, int32(-1337), req.logEntry.ExitCode, "Log entry is set to an internal error code")
|
||||
assert.Equal(t, "", req.logEntry.ActionIcon, "Log entry icon wasnt found")
|
||||
}
|
||||
|
||||
func TestArgumentNameCamelCase(t *testing.T) {
|
||||
a1 := config.Action{
|
||||
Title: "Do some tickles",
|
||||
Shell: "echo 'Tickling {{ personName }}'",
|
||||
Arguments: []config.ActionArgument{
|
||||
{
|
||||
Name: "personName",
|
||||
Type: "ascii",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
values := map[string]string{
|
||||
"personName": "Fred",
|
||||
}
|
||||
|
||||
out, err := parseActionArguments(a1.Shell, values, &a1)
|
||||
|
||||
assert.Equal(t, "echo 'Tickling Fred'", out)
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestArgumentNameSnakeCase(t *testing.T) {
|
||||
a1 := config.Action{
|
||||
Title: "Do some tickles",
|
||||
Shell: "echo 'Tickling {{ person_name }}'",
|
||||
Arguments: []config.ActionArgument{
|
||||
{
|
||||
Name: "person_name",
|
||||
Type: "ascii",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
values := map[string]string{
|
||||
"person_name": "Fred",
|
||||
}
|
||||
|
||||
out, err := parseActionArguments(a1.Shell, values, &a1)
|
||||
|
||||
assert.Equal(t, "echo 'Tickling Fred'", out)
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
package grpcapi
|
||||
|
||||
import (
|
||||
ctx "context"
|
||||
pb "github.com/OliveTin/OliveTin/gen/grpc"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"net"
|
||||
|
||||
acl "github.com/OliveTin/OliveTin/internal/acl"
|
||||
config "github.com/OliveTin/OliveTin/internal/config"
|
||||
executor "github.com/OliveTin/OliveTin/internal/executor"
|
||||
installationinfo "github.com/OliveTin/OliveTin/internal/installationinfo"
|
||||
)
|
||||
|
||||
var (
|
||||
cfg *config.Config
|
||||
)
|
||||
|
||||
type oliveTinAPI struct {
|
||||
pb.UnimplementedOliveTinApiServer
|
||||
|
||||
executor *executor.Executor
|
||||
}
|
||||
|
||||
func (api *oliveTinAPI) StartAction(ctx ctx.Context, req *pb.StartActionRequest) (*pb.StartActionResponse, error) {
|
||||
args := make(map[string]string)
|
||||
|
||||
log.Debugf("SA %v", req)
|
||||
|
||||
for _, arg := range req.Arguments {
|
||||
args[arg.Name] = arg.Value
|
||||
}
|
||||
|
||||
execReq := executor.ExecutionRequest{
|
||||
ActionName: req.ActionName,
|
||||
Arguments: args,
|
||||
AuthenticatedUser: acl.UserFromContext(ctx, cfg),
|
||||
Cfg: cfg,
|
||||
}
|
||||
|
||||
return api.executor.ExecRequest(&execReq), nil
|
||||
}
|
||||
|
||||
func (api *oliveTinAPI) GetDashboardComponents(ctx ctx.Context, req *pb.GetDashboardComponentsRequest) (*pb.GetDashboardComponentsResponse, error) {
|
||||
user := acl.UserFromContext(ctx, cfg)
|
||||
|
||||
res := actionsCfgToPb(cfg.Actions, user)
|
||||
|
||||
if len(res.Actions) == 0 {
|
||||
log.Warn("Zero actions found - check that you have some actions defined, with a view permission")
|
||||
}
|
||||
|
||||
log.Debugf("GetDashboardComponents: %v", res)
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (api *oliveTinAPI) GetLogs(ctx ctx.Context, req *pb.GetLogsRequest) (*pb.GetLogsResponse, error) {
|
||||
ret := &pb.GetLogsResponse{}
|
||||
|
||||
// TODO Limit to 10 entries or something to prevent browser lag.
|
||||
|
||||
for _, logEntry := range api.executor.Logs {
|
||||
ret.Logs = append(ret.Logs, &pb.LogEntry{
|
||||
ActionTitle: logEntry.ActionTitle,
|
||||
ActionIcon: logEntry.ActionIcon,
|
||||
Datetime: logEntry.Datetime,
|
||||
Stdout: logEntry.Stdout,
|
||||
Stderr: logEntry.Stderr,
|
||||
TimedOut: logEntry.TimedOut,
|
||||
ExitCode: logEntry.ExitCode,
|
||||
Tags: logEntry.Tags,
|
||||
})
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
/*
|
||||
This function is ONLY a helper for the UI - the arguments are validated properly
|
||||
on the StartAction -> Executor chain. This is here basically to provide helpful
|
||||
error messages more quickly before starting the action.
|
||||
*/
|
||||
func (api *oliveTinAPI) ValidateArgumentType(ctx ctx.Context, req *pb.ValidateArgumentTypeRequest) (*pb.ValidateArgumentTypeResponse, error) {
|
||||
err := executor.TypeSafetyCheck("", req.Value, req.Type)
|
||||
desc := ""
|
||||
|
||||
if err != nil {
|
||||
desc = err.Error()
|
||||
}
|
||||
|
||||
return &pb.ValidateArgumentTypeResponse{
|
||||
Valid: err == nil,
|
||||
Description: desc,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (api *oliveTinAPI) WhoAmI(ctx ctx.Context, req *pb.WhoAmIRequest) (*pb.WhoAmIResponse, error) {
|
||||
user := acl.UserFromContext(ctx, cfg)
|
||||
|
||||
res := &pb.WhoAmIResponse{
|
||||
AuthenticatedUser: user.Username,
|
||||
}
|
||||
|
||||
log.Warnf("usergroup: %v", user.Usergroup)
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (api *oliveTinAPI) SosReport(ctx ctx.Context, req *pb.SosReportRequest) (*pb.SosReportResponse, error) {
|
||||
res := &pb.SosReportResponse{
|
||||
Alert: "Your SOS Report has been logged to OliveTin logs.",
|
||||
}
|
||||
|
||||
log.Infof("\n" + installationinfo.GetSosReport())
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Start will start the GRPC API.
|
||||
func Start(globalConfig *config.Config, ex *executor.Executor) {
|
||||
cfg = globalConfig
|
||||
|
||||
lis, err := net.Listen("tcp", cfg.ListenAddressGrpcActions)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to listen - %v", err)
|
||||
}
|
||||
|
||||
grpcServer := grpc.NewServer()
|
||||
pb.RegisterOliveTinApiServer(grpcServer, newServer(ex))
|
||||
|
||||
err = grpcServer.Serve(lis)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Could not start gRPC Server - %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func newServer(ex *executor.Executor) *oliveTinAPI {
|
||||
server := oliveTinAPI{}
|
||||
server.executor = ex
|
||||
return &server
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package grpcapi
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
pb "github.com/OliveTin/OliveTin/gen/grpc"
|
||||
acl "github.com/OliveTin/OliveTin/internal/acl"
|
||||
config "github.com/OliveTin/OliveTin/internal/config"
|
||||
)
|
||||
|
||||
func actionsCfgToPb(cfgActions []config.Action, user *acl.AuthenticatedUser) *pb.GetDashboardComponentsResponse {
|
||||
res := &pb.GetDashboardComponentsResponse{}
|
||||
|
||||
for _, action := range cfgActions {
|
||||
if !acl.IsAllowedView(cfg, user, &action) {
|
||||
continue
|
||||
}
|
||||
|
||||
btn := actionCfgToPb(action, user)
|
||||
res.Actions = append(res.Actions, btn)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func actionCfgToPb(action config.Action, user *acl.AuthenticatedUser) *pb.Action {
|
||||
btn := pb.Action{
|
||||
Id: fmt.Sprintf("%x", md5.Sum([]byte(action.Title))),
|
||||
Title: action.Title,
|
||||
Icon: action.Icon,
|
||||
CanExec: acl.IsAllowedExec(cfg, user, &action),
|
||||
}
|
||||
|
||||
for _, cfgArg := range action.Arguments {
|
||||
pbArg := pb.ActionArgument{
|
||||
Name: cfgArg.Name,
|
||||
Title: cfgArg.Title,
|
||||
Type: cfgArg.Type,
|
||||
Description: cfgArg.Description,
|
||||
DefaultValue: cfgArg.Default,
|
||||
Choices: buildChoices(cfgArg.Choices),
|
||||
}
|
||||
|
||||
btn.Arguments = append(btn.Arguments, &pbArg)
|
||||
}
|
||||
|
||||
return &btn
|
||||
}
|
||||
|
||||
func buildChoices(choices []config.ActionArgumentChoice) []*pb.ActionArgumentChoice {
|
||||
ret := []*pb.ActionArgumentChoice{}
|
||||
|
||||
for _, cfgChoice := range choices {
|
||||
pbChoice := pb.ActionArgumentChoice{
|
||||
Value: cfgChoice.Value,
|
||||
Title: cfgChoice.Title,
|
||||
}
|
||||
|
||||
ret = append(ret, &pbChoice)
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package httpservers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"net/http"
|
||||
|
||||
gw "github.com/OliveTin/OliveTin/gen/grpc"
|
||||
|
||||
config "github.com/OliveTin/OliveTin/internal/config"
|
||||
cors "github.com/OliveTin/OliveTin/internal/cors"
|
||||
)
|
||||
|
||||
var (
|
||||
cfg *config.Config
|
||||
)
|
||||
|
||||
func parseHttpHeaderForAuth(req *http.Request) (string, string) {
|
||||
username, ok := req.Header[cfg.AuthHttpHeaderUsername]
|
||||
|
||||
if !ok {
|
||||
return "", ""
|
||||
}
|
||||
|
||||
if cfg.AuthHttpHeaderUserGroup != "" {
|
||||
usergroup, ok := req.Header[cfg.AuthHttpHeaderUserGroup]
|
||||
|
||||
if ok {
|
||||
return username[0], usergroup[0]
|
||||
}
|
||||
}
|
||||
|
||||
return username[0], ""
|
||||
}
|
||||
|
||||
func parseRequestMetadata(ctx context.Context, req *http.Request) metadata.MD {
|
||||
username := ""
|
||||
usergroup := ""
|
||||
|
||||
if cfg.AuthJwtCookieName != "" {
|
||||
username, usergroup = parseJwtCookie(req)
|
||||
}
|
||||
|
||||
if cfg.AuthHttpHeaderUsername != "" {
|
||||
username, usergroup = parseHttpHeaderForAuth(req)
|
||||
}
|
||||
|
||||
md := metadata.Pairs(
|
||||
"username", username,
|
||||
"usergroup", usergroup,
|
||||
)
|
||||
|
||||
log.Debugf("jwt usable claims: %+v", md)
|
||||
|
||||
return md
|
||||
}
|
||||
|
||||
func startRestAPIServer(globalConfig *config.Config) error {
|
||||
cfg = globalConfig
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"address": cfg.ListenAddressGrpcActions,
|
||||
}).Info("Starting REST API")
|
||||
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
// The JSONPb.EmitDefaults is necssary, so "empty" fields are returned in JSON.
|
||||
mux := runtime.NewServeMux(
|
||||
runtime.WithMetadata(parseRequestMetadata),
|
||||
runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.HTTPBodyMarshaler{
|
||||
Marshaler: &runtime.JSONPb{
|
||||
MarshalOptions: protojson.MarshalOptions{
|
||||
UseProtoNames: true,
|
||||
EmitUnpopulated: true,
|
||||
},
|
||||
},
|
||||
}),
|
||||
)
|
||||
opts := []grpc.DialOption{grpc.WithInsecure()}
|
||||
|
||||
err := gw.RegisterOliveTinApiHandlerFromEndpoint(ctx, mux, cfg.ListenAddressGrpcActions, opts)
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("Could not register REST API Handler %v", err)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
return http.ListenAndServe(cfg.ListenAddressRestActions, cors.AllowCors(mux))
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package httpservers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/golang-jwt/jwt/v4"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func parseJwtToken(cookieValue string) (*jwt.Token, error) {
|
||||
return jwt.Parse(cookieValue, func(token *jwt.Token) (interface{}, error) {
|
||||
// Don't forget to validate the alg is what you expect:
|
||||
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
|
||||
return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"])
|
||||
}
|
||||
|
||||
// hmacSampleSecret is a []byte containing your secret, e.g. []byte("my_secret_key")
|
||||
return []byte(cfg.AuthJwtSecret), nil
|
||||
})
|
||||
}
|
||||
|
||||
func getClaimsFromJwtToken(cookieValue string) (jwt.MapClaims, error) {
|
||||
token, err := parseJwtToken(cookieValue)
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("jwt parse failure: %v", err)
|
||||
return nil, errors.New("jwt parse failure")
|
||||
}
|
||||
|
||||
if claims, ok := token.Claims.(jwt.MapClaims); ok && token.Valid {
|
||||
return claims, nil
|
||||
} else {
|
||||
return nil, errors.New("jwt token isn't valid")
|
||||
}
|
||||
}
|
||||
|
||||
func lookupClaimValueOrDefault(claims jwt.MapClaims, key string, def string) string {
|
||||
if val, ok := claims[key]; ok {
|
||||
return fmt.Sprintf("%s", val)
|
||||
} else {
|
||||
return def
|
||||
}
|
||||
}
|
||||
|
||||
func parseJwtCookie(request *http.Request) (string, string) {
|
||||
cookie, err := request.Cookie(cfg.AuthJwtCookieName)
|
||||
|
||||
if err != nil {
|
||||
log.Debugf("jwt cookie check %v name: %v", err, cfg.AuthJwtCookieName)
|
||||
return "", ""
|
||||
}
|
||||
|
||||
claims, err := getClaimsFromJwtToken(cookie.Value)
|
||||
|
||||
log.Debugf("jwt claims data: %+v", claims)
|
||||
|
||||
if err != nil {
|
||||
log.Warnf("jwt claim error: %+v", err)
|
||||
return "", ""
|
||||
}
|
||||
|
||||
username := lookupClaimValueOrDefault(claims, cfg.AuthJwtClaimUsername, "")
|
||||
usergroup := lookupClaimValueOrDefault(claims, cfg.AuthJwtClaimUserGroup, "")
|
||||
|
||||
return username, usergroup
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package httpservers
|
||||
|
||||
/*
|
||||
This file implements a very simple, lightweight reverse proxy so that REST and
|
||||
the webui can be accessed from a single endpoint.
|
||||
|
||||
This makes external reverse proxies (treafik, haproxy, etc) easier, CORS goes
|
||||
away, and several other issues.
|
||||
*/
|
||||
|
||||
import (
|
||||
config "github.com/OliveTin/OliveTin/internal/config"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// StartSingleHTTPFrontend will create a reverse proxy that proxies the API
|
||||
// and webui internally.
|
||||
func StartSingleHTTPFrontend(cfg *config.Config) {
|
||||
log.WithFields(log.Fields{
|
||||
"address": cfg.ListenAddressSingleHTTPFrontend,
|
||||
}).Info("Starting single HTTP frontend")
|
||||
|
||||
apiURL, _ := url.Parse("http://" + cfg.ListenAddressRestActions)
|
||||
apiProxy := httputil.NewSingleHostReverseProxy(apiURL)
|
||||
|
||||
webuiURL, _ := url.Parse("http://" + cfg.ListenAddressWebUI)
|
||||
webuiProxy := httputil.NewSingleHostReverseProxy(webuiURL)
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
||||
mux.HandleFunc("/api/", func(w http.ResponseWriter, r *http.Request) {
|
||||
log.Debugf("api req: %q", r.URL)
|
||||
apiProxy.ServeHTTP(w, r)
|
||||
})
|
||||
|
||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
log.Debugf("ui req: %q", r.URL)
|
||||
webuiProxy.ServeHTTP(w, r)
|
||||
})
|
||||
|
||||
srv := &http.Server{
|
||||
Addr: cfg.ListenAddressSingleHTTPFrontend,
|
||||
Handler: mux,
|
||||
}
|
||||
|
||||
log.Fatal(srv.ListenAndServe())
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
package httpservers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
// cors "github.com/OliveTin/OliveTin/internal/cors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
config "github.com/OliveTin/OliveTin/internal/config"
|
||||
updatecheck "github.com/OliveTin/OliveTin/internal/updatecheck"
|
||||
)
|
||||
|
||||
type webUISettings struct {
|
||||
Rest string
|
||||
ThemeName string
|
||||
ShowFooter bool
|
||||
ShowNavigation bool
|
||||
ShowNewVersions bool
|
||||
AvailableVersion string
|
||||
CurrentVersion string
|
||||
PageTitle string
|
||||
}
|
||||
|
||||
func findWebuiDir() string {
|
||||
directoriesToSearch := []string{
|
||||
cfg.WebUIDir,
|
||||
"/usr/share/OliveTin/webui/",
|
||||
"/var/www/OliveTin/",
|
||||
"/var/www/olivetin/",
|
||||
"/etc/OliveTin/webui/",
|
||||
}
|
||||
|
||||
for _, dir := range directoriesToSearch {
|
||||
if _, err := os.Stat(dir); !os.IsNotExist(err) {
|
||||
log.WithFields(log.Fields{
|
||||
"dir": dir,
|
||||
}).Infof("Found the webui directory")
|
||||
|
||||
return dir
|
||||
}
|
||||
}
|
||||
|
||||
log.Warnf("Did not find the webui directory, you will probably get 404 errors.")
|
||||
|
||||
return "./webui" // Should not exist
|
||||
}
|
||||
|
||||
func generateWebUISettings(w http.ResponseWriter, r *http.Request) {
|
||||
jsonRet, _ := json.Marshal(webUISettings{
|
||||
Rest: cfg.ExternalRestAddress + "/api/",
|
||||
ThemeName: cfg.ThemeName,
|
||||
ShowFooter: cfg.ShowFooter,
|
||||
ShowNavigation: cfg.ShowNavigation,
|
||||
ShowNewVersions: cfg.ShowNewVersions,
|
||||
AvailableVersion: updatecheck.AvailableVersion,
|
||||
CurrentVersion: updatecheck.CurrentVersion,
|
||||
PageTitle: cfg.PageTitle,
|
||||
})
|
||||
|
||||
_, err := w.Write([]byte(jsonRet))
|
||||
|
||||
if err != nil {
|
||||
log.Warnf("Could not write webui settings: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func startWebUIServer(cfg *config.Config) {
|
||||
log.WithFields(log.Fields{
|
||||
"address": cfg.ListenAddressWebUI,
|
||||
}).Info("Starting WebUI server")
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle("/", http.FileServer(http.Dir(findWebuiDir())))
|
||||
mux.HandleFunc("/webUiSettings.json", generateWebUISettings)
|
||||
|
||||
srv := &http.Server{
|
||||
Addr: cfg.ListenAddressWebUI,
|
||||
Handler: mux,
|
||||
}
|
||||
|
||||
log.Fatal(srv.ListenAndServe())
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package installationinfo
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type runtimeInfo struct {
|
||||
OS string
|
||||
OSReleasePrettyName string
|
||||
Arch string
|
||||
InContainer bool
|
||||
LastBrowserUserAgent string
|
||||
}
|
||||
|
||||
func isInContainer() bool {
|
||||
if _, err := os.Stat("/.dockerenv"); errors.Is(err, os.ErrNotExist) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func getOsReleasePrettyName() string {
|
||||
handle, err := os.Open("/etc/os-release")
|
||||
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(handle)
|
||||
scanner.Split(bufio.ScanLines)
|
||||
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
|
||||
if strings.Contains(line, "PRETTY_NAME") {
|
||||
return line
|
||||
}
|
||||
}
|
||||
|
||||
handle.Close()
|
||||
|
||||
return "notfound"
|
||||
}
|
||||
|
||||
var Runtime = &runtimeInfo{
|
||||
OS: runtime.GOOS,
|
||||
Arch: runtime.GOARCH,
|
||||
InContainer: isInContainer(),
|
||||
OSReleasePrettyName: getOsReleasePrettyName(),
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package installationinfo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
config "github.com/OliveTin/OliveTin/internal/config"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
var Config *config.Config
|
||||
|
||||
type sosReportConfig struct {
|
||||
CountOfActions int
|
||||
LogLevel string
|
||||
}
|
||||
|
||||
func configToSosreport(cfg *config.Config) *sosReportConfig {
|
||||
return &sosReportConfig{
|
||||
CountOfActions: len(cfg.Actions),
|
||||
LogLevel: cfg.LogLevel,
|
||||
}
|
||||
}
|
||||
|
||||
func GetSosReport() string {
|
||||
ret := ""
|
||||
|
||||
ret += "### SOSREPORT START (copy all text to SOSREPORT END)\n"
|
||||
|
||||
out, _ := yaml.Marshal(Build)
|
||||
ret += fmt.Sprintf("# Build: \n%+v\n", string(out))
|
||||
|
||||
out, _ = yaml.Marshal(Runtime)
|
||||
ret += fmt.Sprintf("# Runtime:\n%+v\n", string(out))
|
||||
|
||||
out, _ = yaml.Marshal(configToSosreport(Config))
|
||||
ret += fmt.Sprintf("# Config:\n%+v\n", string(out))
|
||||
ret += "### SOSREPORT END (copy all text from SOSREPORT START)\n"
|
||||
|
||||
return ret
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
package updatecheck
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
config "github.com/OliveTin/OliveTin/internal/config"
|
||||
installationinfo "github.com/OliveTin/OliveTin/internal/installationinfo"
|
||||
"github.com/google/uuid"
|
||||
"github.com/robfig/cron/v3"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
type updateRequest struct {
|
||||
CurrentVersion string
|
||||
CurrentCommit string
|
||||
OS string
|
||||
Arch string
|
||||
InstallationID string
|
||||
InContainer bool
|
||||
}
|
||||
|
||||
// AvailableVersion is updated when checking with the update service.
|
||||
var AvailableVersion = "none"
|
||||
|
||||
// CurrentVersion is set by the main cmd (which is in tern set as a compile constant)
|
||||
var CurrentVersion = "?"
|
||||
|
||||
func installationID(filename string) string {
|
||||
var content string
|
||||
contentBytes, err := ioutil.ReadFile(filename)
|
||||
|
||||
if err != nil {
|
||||
fileHandle, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_RDWR, 0644)
|
||||
|
||||
if err != nil {
|
||||
log.Warnf("Could not read + create installation ID file: %v", err)
|
||||
return "cant-create"
|
||||
}
|
||||
|
||||
content = uuid.NewString()
|
||||
fileHandle.WriteString(content)
|
||||
fileHandle.Close()
|
||||
} else {
|
||||
content = string(contentBytes)
|
||||
|
||||
_, err := uuid.Parse(content)
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("Invalid installation ID, %v", err)
|
||||
content = "invalid-installation-id"
|
||||
}
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"content": content,
|
||||
"from": filename,
|
||||
}).Infof("Installation ID")
|
||||
|
||||
return content
|
||||
}
|
||||
|
||||
// StartUpdateChecker will start a job that runs periodically, checking
|
||||
// for updates.
|
||||
func StartUpdateChecker(currentVersion string, currentCommit string, cfg *config.Config, configDir string) {
|
||||
CurrentVersion = currentVersion
|
||||
|
||||
if !cfg.CheckForUpdates {
|
||||
log.Warn("Update checking is disabled")
|
||||
return
|
||||
}
|
||||
|
||||
payload := updateRequest{
|
||||
CurrentVersion: currentVersion,
|
||||
CurrentCommit: currentCommit,
|
||||
OS: installationinfo.Runtime.OS,
|
||||
Arch: installationinfo.Runtime.Arch,
|
||||
InstallationID: installationID(configDir + "/installation-id.txt"),
|
||||
InContainer: installationinfo.Runtime.InContainer,
|
||||
}
|
||||
|
||||
s := cron.New(cron.WithSeconds())
|
||||
|
||||
// Several values have been tried here.
|
||||
// 1st: Every 24h - very spammy.
|
||||
// 2nd: Every 7d - (168 hours - much more reasonable, but it checks in at the same time/day each week.
|
||||
// Current: Every 100h is not so spammy, and has the advantage that the checkin time "shifts" hours.
|
||||
s.AddFunc("@every 100h", func() {
|
||||
actualCheckForUpdate(payload)
|
||||
})
|
||||
|
||||
go actualCheckForUpdate(payload) // On startup
|
||||
|
||||
go s.Start()
|
||||
}
|
||||
|
||||
func doRequest(jsonUpdateRequest []byte) string {
|
||||
req, err := http.NewRequest("POST", "http://update-check.olivetin.app", bytes.NewBuffer(jsonUpdateRequest))
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("Update check failed %v", err)
|
||||
return ""
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("Update check failed %v", err)
|
||||
return ""
|
||||
}
|
||||
|
||||
newVersion, _ := ioutil.ReadAll(resp.Body)
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
return string(newVersion)
|
||||
}
|
||||
|
||||
func actualCheckForUpdate(payload updateRequest) {
|
||||
jsonUpdateRequest, err := json.Marshal(payload)
|
||||
|
||||
log.Debugf("Update request payload: %+v", payload)
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("Update check failed %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
AvailableVersion = doRequest(jsonUpdateRequest)
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"NewVersion": AvailableVersion,
|
||||
}).Infof("Update check complete")
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 52 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 50 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user