-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathmocks.sh
More file actions
66 lines (62 loc) · 1.79 KB
/
Copy pathmocks.sh
File metadata and controls
66 lines (62 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
set -eux
# mocks to be injected into task step scripts
function internal-request() {
echo Mock internal-request called with: $*
echo $* >> $(params.dataDir)/mock_internal-request.txt
# set to async
/home/utils/internal-request $@ -s false
# mimic the sync output
echo "Sync flag set to true. Waiting for the InternalRequest to be completed."
sleep 2
}
function kubectl() {
if [[ "$*" == *"get internalrequest"*"-o json"* ]]
then
# Check if this is the failure test case by looking for a marker file in dataDir
# The dataDir is mounted at /var/workdir/release by default
if [ -f /var/workdir/release/.test-failure-marker ]; then
echo '{
"status": {
"conditions": [
{
"type": "Succeeded",
"status": "False",
"reason": "Failed",
"message": "Failed to publish index image: permission denied to registry"
}
],
"results": {
"requestMessage": "Error: Failed to push image"
}
}
}'
else
# Return successful status for normal tests
echo '{
"status": {
"conditions": [
{
"type": "Succeeded",
"status": "True",
"reason": "Succeeded",
"message": ""
}
],
"results": {
"requestMessage": "Index Image Published successfully"
}
}
}'
fi
elif [[ "$*" == *"get internalrequest"*"jsonpath"*"status.results"* ]]
then
if [ -f /var/workdir/release/.test-failure-marker ]; then
echo '{"requestMessage":"Error: Failed to push image"}'
else
echo '{"requestMessage":"Index Image Published successfully"}'
fi
else
/usr/bin/kubectl $*
fi
}