-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathmocks.sh
More file actions
61 lines (58 loc) · 2.26 KB
/
Copy pathmocks.sh
File metadata and controls
61 lines (58 loc) · 2.26 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
#!/usr/bin/env bash
set -x
# mocks to be injected into task step scripts
function skopeo() {
echo Mock skopeo called with: $* >&2
if [[ "$1" == "inspect" ]]; then
if [[ "$*" == *"config"* ]]; then
if [[ "$*" == *"quay.io/mismatch-ver-target-digest"* ]]; then
echo '{ "config": { "Labels": { "com.redhat.index.delivery.version": "v4.13"} } }'
else
echo '{ "config": { "Labels": { "com.redhat.index.delivery.version": "v4.12"} } }'
fi
return 0
# Handle `skopeo inspect`
elif [[ "$*" == *"docker://quay.io/match-target-digest"* ]]; then
echo "sha256:match1234567890" # Mock target digest for idempotency check
return 0
elif [[ "$*" == *"docker://quay.io/target"* ]]; then
echo "sha256:target1234567890"
return 0
elif [[ "$*" == *"--tls-verify=false --src-creds source docker://quay.io/source"* ]]; then
echo "sha256:abcdef1234567890"
return 0
elif [[ "$*" == *"--tls-verify=false docker://registry-proxy.engineering.redhat.com/foo"* ]]; then
echo "sha256:0987654321fedcba"
return 0
elif [[ "$*" == *"--tls-verify=false docker://registry-proxy.engineering.redhat.com/fail"* ]]; then
return 1
elif [[ "$*" == *"registry-proxy.engineering.redhat.com/mismatchver@sha256:1234567890"* ]]; then
echo "sha256:target1234567890"
return 0
elif [[ "$*" == *"quay.io/mismatch-ver-target-digest"* ]]; then
echo "sha256:0987654321fedcba"
return 0
else
echo "Error: Unexpected inspect call"
exit 1
fi
elif [[ "$1" == "copy" ]]; then
# Handle `skopeo copy`
if [[ "$*" == *"--src-tls-verify=false --src-creds source docker://quay.io/source"* ]]; then
return 0
elif [[ "$*" == *"--src-tls-verify=false docker://registry-proxy.engineering.redhat.com/foo"* ]]; then
return 0
elif [[ "$*" == *"--src-tls-verify=false docker://registry-proxy.engineering.redhat.com/fail"* ]]; then
return 1
elif [[ "$*" == *"--src-tls-verify=false --src-creds source docker://quay.io/match-source-digest"* ]]; then
echo "Error: Copy should not be triggered when digests match"
exit 1
else
echo "Error: Unexpected copy call"
exit 1
fi
else
echo "Error: Unknown skopeo command"
exit 1
fi
}