Skip to content

Commit

Permalink
feat(remote): add layer diff id (#56)
Browse files Browse the repository at this point in the history
* feat(remote): add layer diff id

* feat(remote): add layer diff id
  • Loading branch information
Tsuki124 authored Dec 30, 2022
1 parent 27e1e11 commit e56ed5a
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 44 deletions.
10 changes: 10 additions & 0 deletions go/pkg/binding/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,16 @@ func (h Handle) RemoteLoad(imageRef, username, password string) ([]string, error
return result.StringArray(), nil
}

func (h Handle) RemoteImageGetLayerDiffID(i int) (string, error) {
var result Handle
if err := handleError(C.veinmind_RemoteImageGetLayerDiffID(
result.Ptr(), h.ID(), C.size_t(i))); err != nil {
return "", nil
}
defer result.Free()
return result.String(), nil
}

func (h Handle) RemoteImageOpenLayer(i int) (Handle, error) {
var result Handle
if err := handleError(C.veinmind_RemoteImageOpenLayer(
Expand Down
4 changes: 4 additions & 0 deletions go/remote/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func (i *Image) NumLayers() int {
return i.image.RemoteImageNumLayers()
}

func (im *Image) GetLayerDiffID(i int) (string, error) {
return im.image.RemoteImageGetLayerDiffID(i)
}

func (i *Image) OpenLayer(index int) (api.Layer, error) {
h, err := i.image.RemoteImageOpenLayer(index)
if err != nil {
Expand Down
51 changes: 31 additions & 20 deletions python3/veinmind/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def open_image_by_id(self, image_id):

def load(self, image_ref,username,password):
with binding.Handle() as handle:
with binding.new_str(path) as hstr:
with binding.new_str(username) as ustr
with binding.new_str(password) as pstr
with binding.new_str(image_ref) as hstr:
with binding.new_str(username) as ustr:
with binding.new_str(password) as pstr:
binding.handle_error(Remote._load(
handle.ptr(), self.__handle__().val(), hstr.val(),ustr.val(),pstr.val()))
return handle.str_list()
Expand All @@ -55,25 +55,25 @@ def id(self):
with handle as handle:
return handle.str()

_opaques = binding.lookup(b"veinmind_RemoteLayerOpaques", b"VEINMIND_1.5")
def opaques(self):
"Retrieve the opaques of the remote layer."
_opaques = binding.lookup(b"veinmind_RemoteLayerOpaques", b"VEINMIND_1.5")
def opaques(self):
"Retrieve the opaques of the remote layer."

handle = binding.Handle()
binding.handle_error(Layer._opaques(
handle.ptr(), self.__handle__().val()))
with handle as handle:
return handle.str_list()
handle = binding.Handle()
binding.handle_error(Layer._opaques(
handle.ptr(), self.__handle__().val()))
with handle as handle:
return handle.str_list()

_whiteouts = binding.lookup(b"veinmind_RemoteLayerWhiteouts", b"VEINMIND_1.5")
def whiteouts(self):
"Retrieve the whiteouts of the remote layer."
_whiteouts = binding.lookup(b"veinmind_RemoteLayerWhiteouts", b"VEINMIND_1.5")
def whiteouts(self):
"Retrieve the whiteouts of the remote layer."

handle = binding.Handle()
binding.handle_error(Layer._whiteouts(
handle.ptr(), self.__handle__().val()))
with handle as handle:
return handle.str_list()
handle = binding.Handle()
binding.handle_error(Layer._whiteouts(
handle.ptr(), self.__handle__().val()))
with handle as handle:
return handle.str_list()


class Image(image.Image):
Expand All @@ -95,4 +95,15 @@ def num_layers(self):
result = C.c_size_t()
binding.handle_error(Image._num_layers(
C.pointer(result), self.__handle__().val()))
return result.value
return result.value

_get_layer_diff_id = binding.lookup(
b"veinmind_RemoteImageGetLayerDiffID", b"VEINMIND_1.5")
def get_layer_diff_id(self, i):
"Retrieve the diff ID the of remote layer without opening it."

handle = binding.Handle()
binding.handle_error(Image._get_layer_diff_id(
handle.ptr(), self.__handle__().val(), C.c_size_t(i)))
with handle as handle:
return handle.str()
45 changes: 21 additions & 24 deletions python3/veinmind/tarball.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def __init__(self, handle):
super(Layer, self).__init__(handle=handle)

_id = binding.lookup(b"veinmind_TarballLayerID", b"VEINMIND_1.3")

def id(self):
"Retrieve the diff ID of the docker layer."

Expand All @@ -61,6 +60,26 @@ def id(self):
handle.ptr(), self.__handle__().val()))
with handle as handle:
return handle.str()

_opaques = binding.lookup(b"veinmind_TarballLayerOpaques", b"VEINMIND_1.5")
def opaques(self):
"Retrieve the opaques of the tarball layer."

handle = binding.Handle()
binding.handle_error(Layer._opaques(
handle.ptr(), self.__handle__().val()))
with handle as handle:
return handle.str_list()

_whiteouts = binding.lookup(b"veinmind_TarballLayerWhiteouts", b"VEINMIND_1.5")
def whiteouts(self):
"Retrieve the whiteouts of the tarball layer."

handle = binding.Handle()
binding.handle_error(Layer._whiteouts(
handle.ptr(), self.__handle__().val()))
with handle as handle:
return handle.str_list()


class Image(image.Image):
Expand All @@ -82,26 +101,4 @@ def num_layers(self):
result = C.c_size_t()
binding.handle_error(Image._num_layers(
C.pointer(result), self.__handle__().val()))
return result.value

_opaques = binding.lookup(
b"veinmind_TarballLayerOpaques", b"VEINMIND_1.5")
def opaques(self):
"Retrieve the opaques of the tarball layer."

handle = binding.Handle()
binding.handle_error(Layer._opaques(
handle.ptr(), self.__handle__().val()))
with handle as handle:
return handle.str_list()

_whiteouts = binding.lookup(
b"veinmind_TarballLayerWhiteouts", b"VEINMIND_1.5")
def whiteouts(self):
"Retrieve the whiteouts of the tarball layer."

handle = binding.Handle()
binding.handle_error(Layer._whiteouts(
handle.ptr(), self.__handle__().val()))
with handle as handle:
return handle.str_list()
return result.value

0 comments on commit e56ed5a

Please sign in to comment.