Skip to content

Commit

Permalink
(Fixes tektoncd#481) prevent e2e-test script from overriding task sid…
Browse files Browse the repository at this point in the history
…ecar

The end to end test attaches a sidecar with a image registry for tasks to push into to. This task is optional and is encouraged to be used for testing. However, the function add_sidecar_registry sets the sidecar registry instead of appending it. Allowing the sidecar-registry to run alongside with other tasks will fix this bug. tektoncd#481
  • Loading branch information
popcor255 committed Aug 12, 2020
1 parent 71983fd commit 5f5b024
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions task/jib-maven/0.1/jib-maven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ spec:
env:
- name: HOME
value: /workspace
- name: "DOCKER_CONFIG"
value: $(credentials.path)/.docker/
volumeMounts:
- name: $(params.CACHE)
mountPath: /workspace/.m2
Expand Down
3 changes: 1 addition & 2 deletions test/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ source $(dirname $0)/../vendor/github.com/tektoncd/plumbing/scripts/e2e-tests.sh
# from our tests withouth having to go to an external registry.
function add_sidecar_registry() {
cp ${1} ${TMPF}.read

cat ${TMPF}.read | python3 -c 'import yaml;f=open(0, encoding="utf-8"); data=yaml.load(f.read(), Loader=yaml.FullLoader);data["spec"]["sidecars"]=[{"image":"registry", "name": "registry"}];print(yaml.dump(data, default_flow_style=False));' > ${TMPF}
cat ${TMPF}.read | python3 utils.py add_sidecar_to_yaml_file > ${TMPF}
rm -f ${TMPF}.read
}

Expand Down
17 changes: 17 additions & 0 deletions test/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import sys
import yaml

def add_sidecar_to_yaml_file():
with sys.stdin as file:
# Load yaml file passed by stdin
data = yaml.load(file, Loader=yaml.FullLoader)
# If sidecars doesnt have any entries create an array for data manipulation
if 'sidecars' not in data['spec']:
data['spec']['sidecars'] = []
# Append the local image registry to the yaml file
data['spec']['sidecars'].append({"image": "registry", "name": "registry"})
# Dump the changes to the stdout
print(yaml.dump(data, default_flow_style=False))

if __name__ == '__main__':
globals()[sys.argv[1]]()

0 comments on commit 5f5b024

Please sign in to comment.