From 9f0611d1a152e2e50b36065c6331469ba9764ebe Mon Sep 17 00:00:00 2001 From: John Olheiser Date: Tue, 3 Dec 2024 12:58:42 -0600 Subject: [PATCH] fix: addon JSON pointers (#4508) Signed-off-by: jolheiser --- docs/docs/30-administration/11-forges/100-addon.md | 2 +- server/forge/addon/client.go | 4 ++-- server/forge/addon/server.go | 14 +++++++------- server/services/config/forge.go | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/docs/30-administration/11-forges/100-addon.md b/docs/docs/30-administration/11-forges/100-addon.md index e280ed420..fca20ac95 100644 --- a/docs/docs/30-administration/11-forges/100-addon.md +++ b/docs/docs/30-administration/11-forges/100-addon.md @@ -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. diff --git a/server/forge/addon/client.go b/server/forge/addon/client.go index 46d600e6e..ba44c05aa 100644 --- a/server/forge/addon/client.go +++ b/server/forge/addon/client.go @@ -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 } diff --git a/server/forge/addon/server.go b/server/forge/addon/server.go index a65967eaa..fc810ae23 100644 --- a/server/forge/addon/server.go +++ b/server/forge/addon/server.go @@ -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 } diff --git a/server/services/config/forge.go b/server/services/config/forge.go index ce59076ca..d7c5d2758 100644 --- a/server/services/config/forge.go +++ b/server/services/config/forge.go @@ -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 {