Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: addon JSON pointers (#4508) #4512

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docs/30-administration/11-forges/100-addon.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions server/forge/addon/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
14 changes: 7 additions & 7 deletions server/forge/addon/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions server/services/config/forge.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ 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
files, err := f.forge.Dir(c, f.user, f.repo, f.pipeline, strings.TrimSuffix(fileOrFolder, "/"))
Expand Down