mirror of
https://github.com/projectatomic/atomic.git
synced 2026-02-06 03:45:28 +01:00
Fix filtering
Change the format of "Created" for images to match containers, fix filtering for partial keywords, and update auto-complete and man pages. Signed-off-by: Yu Qi Zhang <jerzhang@redhat.com> Closes: #923 Approved by: giuseppe
This commit is contained in:
@@ -187,7 +187,7 @@ class Images(Atomic):
|
||||
else:
|
||||
indicator = indicator + str(self.skull, "utf-8") + space
|
||||
_id = image.short_id if self.args.truncate else image.id
|
||||
util.write_out(col_out.format(indicator, image.repo or "<none>", image.tag or "<none>", _id, image.timestamp,
|
||||
util.write_out(col_out.format(indicator, image.repo or "<none>", image.tag or "<none>", _id, image.created[0:16],
|
||||
image.virtual_size, image.backend.backend))
|
||||
util.write_out("")
|
||||
return
|
||||
@@ -241,7 +241,7 @@ class Images(Atomic):
|
||||
shutil.rmtree(tmpdir)
|
||||
|
||||
def _filter_include_image(self, image_obj):
|
||||
filterables = ["repo", "tag", "id", "created", "size", "type", "dangling"]
|
||||
filterables = ["repo", "tag", "id", "image", "created", "size", "type", "is_dangling"]
|
||||
for i in self.args.filter:
|
||||
try:
|
||||
var, value = str(i).split("=")
|
||||
@@ -259,10 +259,11 @@ class Images(Atomic):
|
||||
"Please choose from {}".format(var, filterables))
|
||||
if var == "type":
|
||||
var = "str_backend"
|
||||
if getattr(image_obj, var, None).lower() != value.lower():
|
||||
return False
|
||||
|
||||
return True
|
||||
if hasattr(image_obj, var) and value.lower() in str(getattr(image_obj, var)).lower():
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def _mark_used(self, images):
|
||||
assert isinstance(images, list)
|
||||
|
||||
@@ -2,8 +2,9 @@ from Atomic.util import Decompose, output_json
|
||||
from Atomic.discovery import RegistryInspect
|
||||
from Atomic.objects.layer import Layer
|
||||
from Atomic.client import no_shaw
|
||||
import datetime
|
||||
import math
|
||||
import time
|
||||
import numbers
|
||||
|
||||
|
||||
class Image(object):
|
||||
@@ -18,7 +19,7 @@ class Image(object):
|
||||
self.image = None
|
||||
self.tag = None
|
||||
self.repotags = None
|
||||
self.created = None
|
||||
self._created = None
|
||||
self.size = None
|
||||
self.original_structure = None
|
||||
self._backend = backend
|
||||
@@ -154,7 +155,7 @@ class Image(object):
|
||||
|
||||
def populate_remote_inspect_info(self):
|
||||
remote_inspect_info = self.remote_inspect()
|
||||
self.created = remote_inspect_info['Created']
|
||||
self._created = remote_inspect_info['Created']
|
||||
self.name = remote_inspect_info['Name']
|
||||
self.os = remote_inspect_info['Os']
|
||||
self.digest = remote_inspect_info['Digest']
|
||||
@@ -238,8 +239,19 @@ class Image(object):
|
||||
return self.id[:12]
|
||||
|
||||
@property
|
||||
def timestamp(self):
|
||||
return time.strftime("%F %H:%M", time.localtime(self.created))
|
||||
def created(self):
|
||||
if (isinstance(self._created, numbers.Number)):
|
||||
return str(datetime.datetime.fromtimestamp(self._created))
|
||||
|
||||
return self._created
|
||||
|
||||
@property
|
||||
def created_raw(self):
|
||||
return self._created
|
||||
|
||||
@created.setter
|
||||
def created(self, value):
|
||||
self._created = value
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
|
||||
@@ -523,12 +523,12 @@ _atomic_containers_list() {
|
||||
"
|
||||
|
||||
local filterables="
|
||||
id
|
||||
container
|
||||
image
|
||||
command
|
||||
created
|
||||
status
|
||||
state
|
||||
backend
|
||||
runtime
|
||||
"
|
||||
|
||||
@@ -799,6 +799,7 @@ _atomic_images_list() {
|
||||
created
|
||||
size
|
||||
type
|
||||
is_dangling
|
||||
"
|
||||
|
||||
local options_with_args_glob=$(__atomic_to_extglob "$options_with_args")
|
||||
|
||||
@@ -70,9 +70,9 @@ Can use --set to update environment variables.
|
||||
Print all the installed containers
|
||||
|
||||
**-f** **--filter**
|
||||
Filter output based on given filters, example usage: `--filter id=foo` will list all containers that has "foo" as part of their ID.
|
||||
Filter output based on given filters, example usage: `--filter container=foo` will list all containers that has "foo" as part of their container ID.
|
||||
|
||||
Filterables: `container (id)`, `image`, `command`, `created`, `status`, `runtime`
|
||||
Filterables: `backend`, `command`, `container`, `created`, `image`, `runtime`, `state`
|
||||
|
||||
**--json**
|
||||
Print in a machine parsable format
|
||||
|
||||
@@ -99,8 +99,9 @@ Atomic --assumeyes option can be used
|
||||
Show all images, including intermediate images
|
||||
|
||||
[**-f|--filter**]
|
||||
Filter output based on given filters, example usage: '--filter repo=foo'
|
||||
will list all images that has "foo" as part of their repository name.
|
||||
Filter output based on given filters, example usage: '--filter repo=foo' will list all images that has "foo" as part of their repository name.
|
||||
|
||||
Filterables: `created`, `id`, `image`, `is_dangling`, `repo`, `size`, `tag`, `type`
|
||||
|
||||
[**-n|--noheading**]
|
||||
Do not print heading when listing the images
|
||||
|
||||
Reference in New Issue
Block a user