Skip to content

Commit 35fc60f

Browse files
committed
feature: complete rework of how downloads/builder work
Signed-off-by: Valery Piashchynski <[email protected]>
1 parent ecbcbe9 commit 35fc60f

File tree

25 files changed

+1602
-389
lines changed

25 files changed

+1602
-389
lines changed

.claude/CLAUDE.md

Lines changed: 175 additions & 279 deletions
Large diffs are not rendered by default.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*.so
66
*.dylib
77
.venv
8+
.DS_Store
89

910
# Test binary, built with `go test -c`
1011
*.test

api/request/v1/request.proto

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ message PluginInfo {
3535
}
3636

3737
message Plugin {
38-
string name = 1 [(buf.validate.field).required = false]; // optional, if not set, ref+owner+repository will be used
39-
string ref = 2 [(buf.validate.field).required = true]; // git ref, branch, tag, commit
40-
string owner = 3 [(buf.validate.field).required = true]; // roadrunner-server
41-
string repository = 4 [(buf.validate.field).required = true]; // static
38+
string module_name = 1 [(buf.validate.field).required = true];
39+
string tag = 2 [(buf.validate.field).required = true];
4240
}

builder/builder.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"math/rand"
88
"os"
99
"os/exec"
10-
"path"
1110
"path/filepath"
1211
"regexp"
1312
"strings"
@@ -133,22 +132,22 @@ func (b *Builder) Build(rrModule string) error { //nolint:gocyclo
133132
}()
134133

135134
// remove old plugins.go
136-
err = os.Remove(path.Join(b.rrTempPath, pluginsPath))
135+
err = os.Remove(filepath.Join(b.rrTempPath, pluginsPath))
137136
if err != nil {
138137
return err
139138
}
140139

141-
err = os.WriteFile(path.Join(b.rrTempPath, pluginsPath), buf.Bytes(), 0600)
140+
err = os.WriteFile(filepath.Join(b.rrTempPath, pluginsPath), buf.Bytes(), 0600)
142141
if err != nil {
143142
return err
144143
}
145144

146-
err = os.Remove(path.Join(b.rrTempPath, goModStr))
145+
err = os.Remove(filepath.Join(b.rrTempPath, goModStr))
147146
if err != nil {
148147
return err
149148
}
150149

151-
goModFile, err := os.Create(path.Join(b.rrTempPath, goModStr))
150+
goModFile, err := os.Create(filepath.Join(b.rrTempPath, goModStr))
152151
if err != nil {
153152
return err
154153
}
@@ -349,7 +348,7 @@ func (b *Builder) exec(cmd []string) error {
349348

350349
func (b *Builder) getDepsReplace(repl string) []*templates.Entry {
351350
b.log.Info("found replace, processing", zap.String("dependency", repl))
352-
modFile, err := os.ReadFile(path.Join(repl, goModStr))
351+
modFile, err := os.ReadFile(filepath.Join(repl, goModStr))
353352
if err != nil {
354353
return nil
355354
}
@@ -367,7 +366,7 @@ func (b *Builder) getDepsReplace(repl string) []*templates.Entry {
367366
moduleReplace := split[1]
368367

369368
if strings.HasPrefix(moduleReplace, ".") {
370-
moduleReplace = path.Join(repl, moduleReplace)
369+
moduleReplace = filepath.Join(repl, moduleReplace)
371370
}
372371

373372
result = append(result, &templates.Entry{

builder/builder_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package builder
22

33
import (
44
"os"
5-
"path"
5+
"path/filepath"
66
"testing"
77

88
"github.com/roadrunner-server/velox/v2025"
@@ -119,7 +119,7 @@ func setup(version string) *Builder {
119119

120120
for _, v := range b.modules {
121121
_ = os.Mkdir(v.Replace, rights)
122-
_ = os.WriteFile(path.Join(v.Replace, goModStr), associated[v.ModuleName], rights)
122+
_ = os.WriteFile(filepath.Join(v.Replace, goModStr), associated[v.ModuleName], rights)
123123
}
124124

125125
return b

builder/templates/templateV2025.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ require (
3131
)
3232
3333
replace (
34-
github.com/uber-go/tally/v4 => github.com/uber-go/tally/v4 v4.1.10
3534
{{range $v := .Entries}}{{if (ne $v.Replace "")}}{{$v.Module}} => {{$v.Replace}}
3635
{{end}}{{end}}
3736
)

gen/go/api/request/v1/request.pb.go

Lines changed: 11 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/pool.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import (
66
"errors"
77
"fmt"
88
"net/http"
9-
"path"
9+
"path/filepath"
1010
"strings"
1111
"sync"
1212
"time"
1313

14-
"github.com/google/go-github/v71/github"
14+
"github.com/google/go-github/v74/github"
1515
"github.com/roadrunner-server/velox/v2025"
1616
"go.uber.org/zap"
1717
)
@@ -76,7 +76,7 @@ func (p *processor) run() {
7676
rc, resp, err := p.client.Repositories.DownloadContents(context.Background(),
7777
v.pluginCfg.Owner,
7878
v.pluginCfg.Repo,
79-
path.Join(v.pluginCfg.Folder, gomod), &github.RepositoryContentGetOptions{Ref: v.pluginCfg.Ref},
79+
filepath.Join(v.pluginCfg.Folder, gomod), &github.RepositoryContentGetOptions{Ref: v.pluginCfg.Ref},
8080
)
8181
if err != nil {
8282
p.appendErr(err)

github/repo.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ import (
99
"io"
1010
"net/http"
1111
"os"
12-
"path"
1312
"path/filepath"
1413
"strings"
1514

16-
"github.com/google/go-github/v71/github"
15+
"github.com/google/go-github/v74/github"
1716
"github.com/roadrunner-server/velox/v2025"
1817
"go.uber.org/zap"
1918
"golang.org/x/oauth2"
@@ -82,7 +81,7 @@ func (r *GHRepo) DownloadTemplate(tmp, version string) (string, error) { //nolin
8281
// replace '/' in the branch name or tag with the '_' to prevent using '/' as a path separator
8382
version = strings.ReplaceAll(version, "/", "_")
8483

85-
name := path.Join(tmp, "roadrunner-server-"+version)
84+
name := filepath.Join(tmp, "roadrunner-server-"+version)
8685
_ = os.RemoveAll(name)
8786

8887
r.log.Debug("saving repository in temporary folder", zap.String("path", name+zipExt))

gitlab/repo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"errors"
88
"fmt"
99
"net/http"
10-
"path"
10+
"path/filepath"
1111
"strings"
1212
"time"
1313

@@ -49,7 +49,7 @@ func (r *GLRepo) GetPluginsModData() ([]*velox.ModulesInfo, error) {
4949
return nil, errors.New("ref can't be empty")
5050
}
5151

52-
file, resp, err := r.client.RepositoryFiles.GetFile(v.Repo, path.Join(v.Folder, "go.mod"), &gitlab.GetFileOptions{
52+
file, resp, err := r.client.RepositoryFiles.GetFile(v.Repo, filepath.Join(v.Folder, "go.mod"), &gitlab.GetFileOptions{
5353
Ref: toPtr(v.Ref),
5454
})
5555
if err != nil {

0 commit comments

Comments
 (0)