-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New API method get_pods_for_build() (fixes #238)
- Loading branch information
Showing
10 changed files
with
447 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
""" | ||
Copyright (c) 2015 Red Hat, Inc | ||
All rights reserved. | ||
This software may be modified and distributed under the terms | ||
of the BSD license. See the LICENSE file for details. | ||
""" | ||
from __future__ import print_function, absolute_import, unicode_literals | ||
|
||
import json | ||
import logging | ||
|
||
from osbs.utils import graceful_chain_get | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class PodResponse(object): | ||
""" | ||
Wrapper for JSON describing build pod | ||
""" | ||
|
||
def __init__(self, pod): | ||
""" | ||
:param request: http.Request | ||
""" | ||
self._json = pod | ||
|
||
@property | ||
def json(self): | ||
return self._json | ||
|
||
def get_container_image_ids(self): | ||
""" | ||
Find the image IDs the containers use. | ||
:return: dict, container name to ID | ||
""" | ||
|
||
statuses = graceful_chain_get(self.json, "status", "containerStatuses") | ||
if statuses is None: | ||
return {} | ||
|
||
def remove_prefix(image_id, prefix): | ||
if image_id.startswith(prefix): | ||
return image_id[len(prefix):] | ||
|
||
return image_id | ||
|
||
return dict([(status['name'], remove_prefix(status['imageID'], | ||
'docker://')) | ||
for status in statuses]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.