Skip to content

Commit

Permalink
fix(*): revert last two commit (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-cj authored Dec 10, 2020
1 parent aee808b commit eea74a8
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 54 deletions.
2 changes: 1 addition & 1 deletion cmd/ormb-storage-initializer/cmd/pull-and-export.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var pullExportCmd = &cobra.Command{
}

// Pull the model from the remote registry.
if err := ormbClient.Pull(modelURI, false); err != nil {
if err := ormbClient.Pull(modelURI); err != nil {
return err
}
// Export it to the specified directory.
Expand Down
2 changes: 1 addition & 1 deletion cmd/ormb/cmd/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This will store the model in the local registry cache to be used later.`,
RunE: func(cmd *cobra.Command, args []string) error {
// TODO(gaocegege): Validate.

return ormbClient.Pull(args[0], plainHTTPOpt)
return ormbClient.Pull(args[0])
},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/ormb/cmd/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Must first run "ormb save" or "ormb pull".`,
PreRunE: preRunE,
RunE: func(cmd *cobra.Command, args []string) error {
// TODO(gaocegege): Validate.
return ormbClient.Push(args[0], plainHTTPOpt)
return ormbClient.Push(args[0])
},
}

Expand Down
5 changes: 0 additions & 5 deletions pkg/oras/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ func NewClient(opts ...ClientOption) (Interface, error) {
return client, nil
}

// SetPlainHTTP set plainHTTP opt.
func (c *Client) SetPlainHTTP(plainHTTP bool) {
c.plainHTTP = plainHTTP
}

// Login logs into a registry
func (c *Client) Login(hostname string, username string, password string, insecure bool) error {
if insecure {
Expand Down
2 changes: 0 additions & 2 deletions pkg/oras/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (

// Interface is the interface of the client.
type Interface interface {
SetPlainHTTP(plainHTTP bool)

Login(hostname string, username string, password string, insecure bool) error
Logout(hostname string) error
SaveModel(ch *model.Model, ref *oci.Reference) error
Expand Down
12 changes: 0 additions & 12 deletions pkg/oras/mock/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions pkg/ormb/mock/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 4 additions & 12 deletions pkg/ormb/ormb.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
// models with a remote registry.
type Interface interface {
Login(hostname, username, password string, insecureOpt bool) error
Push(refStr string, plainHTTP bool) error
Pull(refStr string, plainHTTP bool) error
Push(refStr string) error
Pull(refStr string) error
Export(refStr, dst string) error
Save(src, refStr string) error
Tag(refStr, targetStr string) error
Expand All @@ -41,27 +41,19 @@ func New(opts ...oras.ClientOption) (Interface, error) {
}, nil
}

func (o ORMB) SetPlainHTTP(plainHTTP bool) {
o.client.SetPlainHTTP(plainHTTP)
}

func (o ORMB) Login(hostname, username, password string, insecureOpt bool) error {
return o.client.Login(hostname, username, password, insecureOpt)
}

func (o ORMB) Push(refStr string, plainHTTP bool) error {
o.client.SetPlainHTTP(plainHTTP)

func (o ORMB) Push(refStr string) error {
ref, err := oci.ParseReference(refStr)
if err != nil {
return err
}
return o.client.PushModel(ref)
}

func (o ORMB) Pull(refStr string, plainHTTP bool) error {
o.client.SetPlainHTTP(plainHTTP)

func (o ORMB) Pull(refStr string) error {
ref, err := oci.ParseReference(refStr)
if err != nil {
return err
Expand Down
10 changes: 2 additions & 8 deletions pkg/ormb/ormb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ var _ = Describe("ormb golang library", func() {
ociORMB.client.(*orasmock.MockInterface).EXPECT().PushModel(
gomock.Eq(ref),
).Return(nil).Times(1)
ociORMB.client.(*orasmock.MockInterface).EXPECT().SetPlainHTTP(
true,
).Times(1)
Expect(ociORMB.Push(refStr, true)).To(BeNil())
Expect(ociORMB.Push(refStr)).To(BeNil())
})

It("Should pull the model successfully", func() {
Expand All @@ -64,10 +61,7 @@ var _ = Describe("ormb golang library", func() {
ociORMB.client.(*orasmock.MockInterface).EXPECT().PullModel(
gomock.Eq(ref),
).Return(nil).Times(1)
ociORMB.client.(*orasmock.MockInterface).EXPECT().SetPlainHTTP(
true,
).Times(1)
Expect(ociORMB.Pull(refStr, true)).To(BeNil())
Expect(ociORMB.Pull(refStr)).To(BeNil())
})

It("Should save the model successfully", func() {
Expand Down

0 comments on commit eea74a8

Please sign in to comment.