Skip to content

Commit

Permalink
feat: registry insecure
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsuki124 committed Feb 3, 2023
1 parent 611bbf7 commit 85985a6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
11 changes: 9 additions & 2 deletions go/pkg/binding/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ func RemoteNew(root string) (Handle, error) {
return result, nil
}

func (h Handle) RemoteLoad(imageRef, username, password string) ([]string, error) {
func (h Handle) RemoteLoad(imageRef, username, password string, insecure bool) ([]string, error) {
result := new(Handle)
imageRefStr := NewString(imageRef)
defer imageRefStr.Free()
Expand All @@ -743,7 +743,14 @@ func (h Handle) RemoteLoad(imageRef, username, password string) ([]string, error
passwordStr := NewString(password)
defer passwordStr.Free()

if err := handleError(C.veinmind_RemoteLoad(result.Ptr(), h.ID(), imageRefStr.ID(), usernameStr.ID(), passwordStr.ID())); err != nil {
insecureVal := func() int32 {
if insecure {
return 1
}
return 0
}()

if err := handleError(C.veinmind_RemoteLoad(result.Ptr(), h.ID(), imageRefStr.ID(), usernameStr.ID(), passwordStr.ID(), C.int(insecureVal))); err != nil {
return nil, err
}
defer result.Free()
Expand Down
7 changes: 7 additions & 0 deletions go/remote/option.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package remote

type loadOptions struct {
insecure bool
username string
password string
}
Expand All @@ -15,3 +16,9 @@ func WithAuth(username, password string) LoadOption {
o.password = password
}
}

func WithInsecure() LoadOption {
return func(o *loadOptions) {
o.insecure = true
}
}
2 changes: 1 addition & 1 deletion go/remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (t *Runtime) Load(imageRef string, opts ...LoadOption) ([]string, error) {
for _, o := range opts {
o(options)
}
return t.runtime.RemoteLoad(imageRef, options.username, options.password)
return t.runtime.RemoteLoad(imageRef, options.username, options.password, options.insecure)
}

func (t *Runtime) Close() error {
Expand Down
9 changes: 5 additions & 4 deletions python3/veinmind/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ def open_image_by_id(self, image_id):
_load = binding.lookup(
b"veinmind_RemoteLoad", b"VEINMIND_1.4")

def load(self, image_ref,username,password):
def load(self, image_ref,username,password,insecure):
with binding.Handle() as handle:
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()
with binding.new_str(insecure) as iptr:
binding.handle_error(Remote._load(
handle.ptr(), self.__handle__().val(), hstr.val(),ustr.val(),pstr.val(),iptr.val()))
return handle.str_list()


class Layer(filesystem.FileSystem):
Expand Down

0 comments on commit 85985a6

Please sign in to comment.