Client library with golang for accessing Harbor API.

go-client

Client library with golang for accessing Harbor API.

Client Types

There are 3 swagger files in this repo.

api/
    v2.0/
        legacy_swagger.yaml    # legacy client
        swagger.yaml           # v2 client
    swagger.yaml               # assist client contains version and chart healthcheck

Generate Clients

make gen-harbor-api

To use the Clients

There is ClientSet defined inside pkg/harbor/client.go to construct Clients

Create a Config first then use it to create ClientSet

For Example:

c := Config{
    URL: url,
	Transport: tr,
	AuthInfo: ai,
}

cs := NewClientSet(c)

cs.V2() // v2 client
cs.Legacy() // legacy client
cs.Assist() // assist client
Owner
Harbor
An open source registry that secures artifacts with policies and RBAC, ensures images are scanned and free from vulnerabilities, and signs images as trusted.
Harbor
Comments
  • all api response have problem

    all api response have problem

    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

  • Refactor the ClientSet with ClientSetConfig

    Refactor the ClientSet with ClientSetConfig

    1. Currently, the each ToConfig will change the same config, fix the logic.
    2. ClientSet has as simple Config ClientSetConfig with some simple parameters
    3. Add more integration tests.
  • get V2() client should wrap basePath automatically

    get V2() client should wrap basePath automatically

    harborClient.V2() will return a client without basePath, and if call sdk methods will cause error(404/405 ...).

    maybe can wrap like this.

    func (c *Config) ToV2Config() v2client.Config {
    	return v2client.Config{
    		URL:       c.URL + "/v2.0/api",
    		Transport: insecureTransport,
    		AuthInfo:  c.AuthInfo,
    	}
    }
    
  • Add clients for harbor

    Add clients for harbor

    Including 3 clients: v2: newest 2.4 client legacy: legacy client assist: contains client for chart heathcheck or version

    pkg/harbor/client.go is a client wrapper for creating these 3 harbor clients

  • Can't delete artifact tag

    Can't delete artifact tag

    Good afternoon. Please suggest what is wrong with my request. Execute command in code _, err = cs.V2().Artifact.DeleteTag(context.TODO(), &artifact.DeleteTagParams{ Reference: reference, TagName: reference, ProjectName: *r.Project, RepositoryName: repositoryName, }) and i get an error [DELETE /projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/tags/{tag_name}][401] deleteTagUnauthorized &{Errors:[0xc000236500]}

    Methods for getting tags work fine with the same authorization data. In Harbor UI, I can delete the tag with these authorization data

    Version: github.com/goharbor/go-client v0.25.0

  • Pagination works unexpected

    Pagination works unexpected

    Assuming one has 360 artifacts and uses ListArtifacts to fetch them with a maximum page size of 100, so

    	params := artifact.ListArtifactsParams{
    		Page:           page,
    		PageSize:       100,
    		ProjectName:  "myproject",
    		RepositoryName: "myimage"
    	}
    

    We should assume to fetch 4 pages, while the last page only includes 60 artifacts. In fact, the last page includes 100 artifacts instead.

    We start with page 0 end end up page 3, fetching 4x100, instead of 3x100+1x60

  • Vulnerability additions content type

    Vulnerability additions content type

    When call the vulnerabilities additions content type we receive a error message json: cannot unmarshal object into Go value of type string The api shows that the content type of this object is a string, but in fact it needs to be a structure.

Related tags
brickset is a Go client library for accessing the brickset.com API v3.

brickset is a Go client library for accessing the brickset.com API v3.

May 21, 2022
Godaddy-domains-client-go - Godaddy domains api Client golang - Write automaticly from swagger codegen

Go API client for swagger Overview This API client was generated by the swagger-codegen project. By using the swagger-spec from a remote server, you c

Jan 9, 2022
iceportal-api is a Golang client implementation to interact with the REST API of iceportal.de when connected to the WiFi-Network offered in German ICE Trains.
iceportal-api is a Golang client implementation to interact with the REST API of iceportal.de when connected to the WiFi-Network offered in German ICE Trains.

iceportal-api is a Golang client implementation to interact with the REST API of iceportal.de when connected to the WiFi-Network offered in German ICE Trains.

Aug 20, 2022
Tailscale-client-go - A client implementation for the Tailscale HTTP API

tailscale-client-go A client implementation for the Tailscale HTTP API Example p

Sep 8, 2022
Go/Golang client library to interact with the Stein API

go-stein This Go / Golang client helps you interact with the Stein API. Stein is a suite of programs to help you turn any Google Sheet to a database.

Aug 23, 2022
An API Client package for Studyplus for School SYNC API

Studyplus for School SYNC API Client This project is currently alpha, possibility having breaking changes. studyplus_for_school_sync_go is a API clien

Aug 2, 2021
Go API Client for Metasploit RPC API

go-msf-rpc Golang based RPC client to communicate with Metasploit. Based on code initially developed by Wyatt Dahlenburg repo. Extended to include oth

Nov 18, 2022
Golang client for querying SecurityTrails API data
Golang client for querying SecurityTrails API data

haktrails haktrails is a Golang client for querying SecurityTrails API data, sponsored by SecurityTrails. SecurityTrails $50 Bug Bounty Hunter Plan Sa

Jan 4, 2023
Autify's web API client for Golang

autify-go This is a Go wrapper for working with Autify's Web API. This project tries to connect the Web API Endpoint easily by using this library. Ins

Nov 9, 2021
Prisma Client Go is an auto-generated and fully type-safe database client

Prisma Client Go Typesafe database access for Go Quickstart • Website • Docs • API reference • Blog • Slack • Twitter Prisma Client Go is an auto-gene

Jan 9, 2023
The Dual-Stack Dynamic DNS client, the world's first dynamic DNS client built for IPv6.

dsddns DsDDNS is the Dual-Stack Dynamic DNS client. A dynamic DNS client keeps your DNS records in sync with the IP addresses associated with your hom

Sep 27, 2022
Go Substrate RPC Client (GSRPC)Go Substrate RPC Client (GSRPC)

Go Substrate RPC Client (GSRPC) Substrate RPC client in Go. It provides APIs and types around Polkadot and any Substrate-based chain RPC calls. This c

Nov 11, 2021
Server and client implementation of the grpc go libraries to perform unary, client streaming, server streaming and full duplex RPCs from gRPC go introduction

Description This is an implementation of a gRPC client and server that provides route guidance from gRPC Basics: Go tutorial. It demonstrates how to u

Nov 24, 2021
Comunicación de envios de archivos entres cliente-servidor, client-client.

Client - Server - Client Estes es un proyecto simple de comunicacion de envios de archivos del cliente al servidor y viceversamente, y de cliente a cl

Jul 16, 2022
Simple mDNS client/server library in Golang

mdns Simple mDNS client/server library in Golang. mDNS or Multicast DNS can be used to discover services on the local network without the use of an au

Jan 4, 2023
A golang library about socks5, supports all socks5 commands. That Provides server and client and easy to use. Compatible with socks4 and socks4a.

socks5 This is a Golang implementation of the Socks5 protocol library. To see in this SOCKS Protocol Version 5. This library is also compatible with S

Nov 22, 2022
Go PowerDNS 4.x API Client

PowerDNS 4.x API bindings for Golang This community project provides bindings for the currently latest version of PowerDNS Authoritative Server. Featu

Dec 12, 2022
Go client for the Notion API.

go-notion go-notion is a client for the Notion API, written in Go. Features The client supports all (non-deprecated) endpoints available in the Notion

Jan 2, 2023