Skip to content

Commit 63e7e4c

Browse files
ofir-amireranco74
authored andcommitted
tests fixes
1 parent 9797c98 commit 63e7e4c

File tree

6 files changed

+118
-53
lines changed

6 files changed

+118
-53
lines changed

skipper/cli.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ def run(ctx, interactive, name, env, cache, command):
220220
ctx.obj['build_container_tag'],
221221
ctx.obj['git_revision'],
222222
ctx.obj['container_context'],
223-
ctx.obj['username'],
224-
ctx.obj['password'],
223+
ctx.obj.get('username'),
224+
ctx.obj.get('password'),
225225
cache)
226226
return runner.run(list(command),
227227
fqdn_image=build_container,
@@ -254,8 +254,8 @@ def make(ctx, interactive, name, env, makefile, cache, make_params):
254254
ctx.obj['build_container_tag'],
255255
ctx.obj['git_revision'],
256256
ctx.obj['container_context'],
257-
ctx.obj['username'],
258-
ctx.obj['password'],
257+
ctx.obj.get('username'),
258+
ctx.obj.get('password'),
259259
cache)
260260
command = ['make', '-f', makefile] + list(make_params)
261261
return runner.run(command,
@@ -286,8 +286,8 @@ def shell(ctx, env, name, cache):
286286
ctx.obj['build_container_tag'],
287287
ctx.obj['git_revision'],
288288
ctx.obj['container_context'],
289-
ctx.obj['username'],
290-
ctx.obj['password'],
289+
ctx.obj.get('username'),
290+
ctx.obj.get('password'),
291291
cache)
292292
return runner.run(['bash'],
293293
fqdn_image=build_container,

skipper/runner.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,31 +91,31 @@ def _run_nested(fqdn_image, environment, command, interactive, name, net, volume
9191
def handle_volumes_bind_mount(docker_cmd, homedir, volumes, workspace):
9292
volumes = volumes or []
9393
volumes.extend(['%(homedir)s/.netrc:%(homedir)s/.netrc:ro' % dict(homedir=homedir),
94-
'%(homedir)s/.gitconfig:%(homedir)s/.gitconfig:ro' % dict(homedir=homedir)])
94+
'%(homedir)s/.gitconfig:%(homedir)s/.gitconfig:ro' % dict(homedir=homedir),
95+
'%(homedir)s/.docker/config.json:%(homedir)s/.docker/config.json:ro' % dict(homedir=homedir)])
9596

96-
# required for docker login
97-
if os.path.exists('%(homedir)s/.docker/config.json' % dict(homedir=homedir)):
98-
volumes.append('%(homedir)s/.docker/config.json:%(homedir)s/.docker/config.json:ro' % dict(homedir=homedir))
97+
# required for docker login (certificates)
9998
if os.path.exists('/etc/docker'):
10099
volumes.append('/etc/docker:/etc/docker:ro')
101100

102-
# Will fail on Mac
103-
if os.path.exists('/var/lib/osmosis'):
104-
volumes.append('/var/lib/osmosis:/var/lib/osmosis:rw')
105-
106101
if utils.get_runtime_command() == utils.PODMAN:
107102
volumes.extend([
108103
'%(workspace)s:%(workspace)s:rw,shared' % dict(workspace=workspace),
109104
'%s:/opt/skipper/skipper-entrypoint.sh:rw' % utils.get_extra_file("skipper-entrypoint.sh"),
110105
])
111106
if os.path.exists('/var/run/docker.sock'):
112107
volumes.append('/var/run/docker.sock:/var/run/docker.sock:rw')
108+
if os.path.exists('/var/lib/osmosis'):
109+
volumes.append('/var/lib/osmosis:/var/lib/osmosis:rw')
113110
else:
114111
volumes.extend([
115112
'%(workspace)s:%(workspace)s:rw,Z' % dict(workspace=workspace),
116113
'/var/run/docker.sock:/var/run/docker.sock:Z',
117114
'%s:/opt/skipper/skipper-entrypoint.sh:Z' % utils.get_extra_file("skipper-entrypoint.sh"),
118115
])
116+
# Will fail on Mac
117+
if os.path.exists('/var/lib/osmosis'):
118+
volumes.append('/var/lib/osmosis:/var/lib/osmosis:rw,Z')
119119

120120
for volume in volumes:
121121
if ":" not in volume:
@@ -144,9 +144,9 @@ def create_vol_localpath_if_needed(volume):
144144
# that's why we create it as file
145145
# 2. .docker/config.json - if it is required and doesn't exists we want to create is as file with {} as data
146146
if ".gitconfig" in host_path and not os.path.exists(host_path):
147-
utils.create_path_and_add_data(host_path, data="", is_file=True)
147+
utils.create_path_and_add_data(full_path=host_path, data="", is_file=True)
148148
elif "docker/config.json" in host_path and not os.path.exists(host_path):
149-
utils.create_path_and_add_data(host_path, data="{}", is_file=True)
149+
utils.create_path_and_add_data(full_path=host_path, data="{}", is_file=True)
150150
elif not os.path.exists(host_path):
151151
# If the local directory of a mount entry doesn't exist, docker will by
152152
# default create a directory in that path. Docker runs in systemd context,

skipper/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ def get_image_digest(registry, image, tag, username, password):
119119
def delete_image_from_registry(registry, image, tag, username, password):
120120
digest = get_image_digest(registry, image, tag, username, password)
121121
url = MANIFEST_URL % dict(registry=registry, image=image, reference=digest)
122-
headers = {"Accept": "application/vnd.docker.distribution.manifest.v2+json"}
123-
response = requests.delete(url=url, headers=headers, verify=False, auth=HttpBearerAuth(username, password))
122+
response = requests.delete(url=url, verify=False, auth=HttpBearerAuth(username, password))
124123
if not response.ok:
125124
raise Exception(response.content)
126125

0 commit comments

Comments
 (0)