goharbor / go-client

Client library with golang for accessing Harbor API.
Apache License 2.0
41 stars 19 forks source link

all api response have problem #6

Closed schecterdamien closed 2 years ago

schecterdamien commented 2 years ago

my env

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

lubronzhan commented 2 years ago

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

lubronzhan commented 2 years ago

Right now main branch also has the working code