fix: addon JSON pointers (#4508)

Signed-off-by: jolheiser <git@jolheiser.com>
This commit is contained in:
John Olheiser 2024-12-03 12:58:42 -06:00 committed by GitHub
parent db45794091
commit 9f0611d1a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11 additions and 11 deletions

View file

@ -38,7 +38,7 @@ Addons use RPC to communicate to the server and are implemented using the [`go-p
This example will use the Go language.
Directly import Woodpecker's Go packages (`go.woodpecker-ci.org/woodpecker/woodpecker/v2`) and use the interfaces and types defined there.
Directly import Woodpecker's Go packages (`go.woodpecker-ci.org/woodpecker/v2`) and use the interfaces and types defined there.
In the `main` function, just call `"go.woodpecker-ci.org/woodpecker/v2/server/forge/addon".Serve` with a `"go.woodpecker-ci.org/woodpecker/v2/server/forge".Forge` as argument.
This will take care of connecting the addon forge to the server.

View file

@ -139,8 +139,8 @@ func (g *RPC) Repo(_ context.Context, u *model.User, remoteID model.ForgeRemoteI
return nil, err
}
var resp *modelRepo
err = json.Unmarshal(jsonResp, resp)
var resp modelRepo
err = json.Unmarshal(jsonResp, &resp)
if err != nil {
return nil, err
}

View file

@ -54,8 +54,8 @@ func (s *RPCServer) URL(_ []byte, resp *string) error {
}
func (s *RPCServer) Teams(args []byte, resp *[]byte) error {
var a *modelUser
err := json.Unmarshal(args, a)
var a modelUser
err := json.Unmarshal(args, &a)
if err != nil {
return err
}
@ -82,8 +82,8 @@ func (s *RPCServer) Repo(args []byte, resp *[]byte) error {
}
func (s *RPCServer) Repos(args []byte, resp *[]byte) error {
var a *modelUser
err := json.Unmarshal(args, a)
var a modelUser
err := json.Unmarshal(args, &a)
if err != nil {
return err
}
@ -261,12 +261,12 @@ func (s *RPCServer) Hook(args []byte, resp *[]byte) error {
}
func (s *RPCServer) Login(args []byte, resp *[]byte) error {
var a *types.OAuthRequest
err := json.Unmarshal(args, a)
var a types.OAuthRequest
err := json.Unmarshal(args, &a)
if err != nil {
return err
}
user, red, err := s.Impl.Login(mkCtx(), a)
user, red, err := s.Impl.Login(mkCtx(), &a)
if err != nil {
return err
}

View file

@ -140,9 +140,9 @@ func (f *forgeFetcherContext) checkPipelineFile(c context.Context, config string
func (f *forgeFetcherContext) getFirstAvailableConfig(c context.Context, configs []string) ([]*types.FileMeta, error) {
var forgeErr []error
for _, fileOrFolder := range configs {
log.Trace().Msgf("fetching %s from forge", fileOrFolder)
if strings.HasSuffix(fileOrFolder, "/") {
// config is a folder
log.Trace().Msgf("fetching %s from forge", fileOrFolder)
files, err := f.forge.Dir(c, f.user, f.repo, f.pipeline, strings.TrimSuffix(fileOrFolder, "/"))
// if folder is not supported we will get a "Not implemented" error and continue
if err != nil {