goharbor/go-client

all api response have problem

schecterdamien opened this issue · 2 comments

my env

  • go version: go1.16
  • os sys: macos catalina

test code in main.go:

package main

import (
	"context"
	"fmt"
	"net/http"
	"net/url"

	"github.com/goharbor/go-client/pkg/sdk/v2.0/client/user"

	httptransport "github.com/go-openapi/runtime/client"
	"github.com/goharbor/go-client/pkg/harbor"
)

func main() {
	urlObj, err := url.Parse("https://my-harbor-addr")
	if err != nil {
		fmt.Println(err)
	}

	cs := harbor.NewClientSet(&harbor.Config{
		URL:       urlObj,
		Transport: http.DefaultTransport,
		AuthInfo:  httptransport.BasicAuth("admin", "********"),
	})

	res, err := cs.V2().User.ListUsers(context.TODO(), &user.ListUsersParams{})
	fmt.Println("get res: ", res)
	fmt.Println("get error: ", err)
}

go run main.go will output :

get res:  <nil>
get error:  X-Total-Count in header must be of type int64: ""

if change the request api to

res, err := cs.V2().User.GetUser(context.TODO(), &user.GetUserParams{UserID: 6})

will output

get res:  <nil>
get error:  &{false  0001-01-01T00:00:00.000Z  <nil>  false 0001-01-01T00:00:00.000Z 0 } (*models.UserResp) is not supported by the TextConsumer, can be resolved by supporting TextUnmarshaler interface

I try many api request,no one can work

Hi @schecterdamien thanks for trying it out!
Sorry we are still actively trying to fix the issue since we just published this repo.
You can try the v0.24.3 tag for use. That was verified

Right now main branch also has the working code