Skip to content

Commit

Permalink
Added PhotonOS sample Dockerfile
Browse files Browse the repository at this point in the history
- Added new Dockerfile to samples
- Added a snippet listing for packages installed using
tyum
- Added back the module to print the list of snippets that
are run in the container. Changed the name of the module
to more accurately imply this
- Fixed history module in metadata to account for no 'created_by'
key in a Docker image history. This is usually the case for the
first line in a Dockerfile that imports from another Docker image
- Removed completed TODO comment in commands.py

Signed-off-by: Nisha K <[email protected]>
  • Loading branch information
Nisha K committed Nov 7, 2017
1 parent a9d4507 commit 394ea3f
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 6 deletions.
23 changes: 23 additions & 0 deletions command_lib/snippets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,26 @@ apt-get:
1:
container:
- './apt_get_sources.sh {package}'
tyum:
install: 'install'
remove: 'remove'
ignore:
- 'check-update'
packages:
- name: default
version:
invoke:
1:
container:
- 'list=`tdnf list installed {package}`'
- 'c=0; for l in $list; do if [ $c == 1 ]; then echo $l; fi; c=$(((c+1)%3)); done;'
license:
invoke:
1:
container:
- 'tdnf info {package} | head -10 | tail -1 | cut -f2 -d":" | xargs'
src_url:
invoke:
1:
container:
- 'tdnf info {package} | head -9 | tail -1 | cut -f2-3 -d":" | xargs'
29 changes: 25 additions & 4 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,36 @@ def get_image_tag_string(image_tag_tuple):
return image_tag_tuple[0] + df.tag_separator + image_tag_tuple[1]


def print_invoke_list(info_dict, info):
'''Given the dictionary from the base or snippet library and the
info to retrieve, return the list of snippets that will be invoked
info is either 'names', 'versions', 'licenses' or 'src_urls' in the base
library or 'name', 'version', 'license' or 'src_url' in the snippet
library'''
report = ''
if 'invoke' in info_dict[info]:
report = report + info + ':\n'
for step in range(1, len(info_dict[info]['invoke'].keys()) + 1):
if 'container' in info_dict[info]['invoke'][step]:
report = report + '\tin container:\n'
for snippet in info_dict[info]['invoke'][step]['container']:
report = report + '\t' + snippet
else:
for value in info_dict[info]:
report = report + ' ' + value
report = report + '\n'
return report


def print_image_info(base_image_tag):
'''Given the base image and tag in a tuple return a string containing
the command_lib/base.yml'''
info = cmds.get_base_info(base_image_tag)
report = ''
report = report + print_info_list(info, 'names')
report = report + print_info_list(info, 'versions')
report = report + print_info_list(info, 'licenses')
report = report + print_info_list(info, 'src_urls')
report = report + print_invoke_list(info, 'names')
report = report + print_invoke_list(info, 'versions')
report = report + print_invoke_list(info, 'licenses')
report = report + print_invoke_list(info, 'src_urls')
report = report + '\n'
return report

Expand Down
3 changes: 3 additions & 0 deletions samples/photon_openjre/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM vmware/photon:1.0

RUN tyum install -y openjre && tyum clean all
1 change: 0 additions & 1 deletion utils/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def get_packages_per_run(docker_run_command):
{installed: [list of packages installed]
removed: [list of packaged removed]},...}
unrecognized: [list shell commands that were not recognized]'''
# TODO: this makes get_package_listing obsolete so remove it
docker_inst = docker_run_command[0] + ' ' + docker_run_command[1]
pkg_dict = {'instruction': docker_inst,
'recognized': {},
Expand Down
5 changes: 4 additions & 1 deletion utils/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ def get_nonempty_history(config):
history = []
for item in config['history']:
if 'empty_layer' not in item.keys():
history.append(item['created_by'])
if 'created_by' in item.keys():
history.append(item['created_by'])
else:
history.append(item['comment'])
return history


Expand Down

0 comments on commit 394ea3f

Please sign in to comment.