1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-24 08:02:18 +02:00
woodpecker/woodpecker-go
Alconety 8c63c7a836
Pipeline errors must be an array (#3276)
This PR addresses 
``json: cannot unmarshal array into Go struct field Pipeline.errors of
type woodpecker.PipelineError``
when executing 
``woodpecker-cli pipeline ls X``

According to API schema, pipeline.errors should contain an array

Fixes #3119

Co-authored-by: Alberto Alcón <albertoalcon@bit2me.com>
2024-01-25 20:16:56 +02:00
..
woodpecker Pipeline errors must be an array (#3276) 2024-01-25 20:16:56 +02:00
LICENSE pre-commit fixes (#2669) 2023-10-31 09:14:09 +01:00
README.md Update go module path for major version 2 (#2905) 2023-12-08 08:15:08 +01:00

woodpecker-go

import (
  "go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
  "golang.org/x/oauth2"
)

const (
  token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
  host  = "http://woodpecker.company.tld"
)

func main() {
  // create an http client with oauth authentication.
  config := new(oauth2.Config)
  authenticator := config.Client(
    oauth2.NoContext,
    &oauth2.Token{
      AccessToken: token,
    },
  )

  // create the woodpecker client with authenticator
  client := woodpecker.NewClient(host, authenticator)

  // gets the current user
  user, err := client.Self()
  fmt.Println(user, err)

  // gets the named repository information
  repo, err := client.RepoLookup("woodpecker-ci/woodpecker")
  fmt.Println(repo, err)
}