From a4d97fdf3a2d0b9f85db5171e4bed8d0ff3c902b Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Fri, 21 Jun 2024 20:16:09 +0200 Subject: [PATCH] feature: simplify velox build configuration Signed-off-by: Valery Piashchynski --- builder/builder.go | 95 +++++++++++-------- builder/builder_test.go | 4 +- builder/template_test.go | 59 ++++++------ builder/templates/entry.go | 5 +- builder/templates/templateV2.go | 4 +- builder/templates/templateV2023.go | 16 ++-- builder/templates/templateV2024.go | 16 ++-- config.go | 22 +++-- config_test.go | 9 +- github/pool.go | 24 ++--- github/repo.go | 20 ++-- gitlab/repo.go | 14 +-- go.mod | 4 +- go.sum | 11 +-- internal/cli/build/build.go | 24 ++--- internal/cli/root.go | 14 +-- logger/logger.go | 145 ++++++----------------------- velox.toml | 123 ++++++++++++------------ velox_rr_v2024.toml | 12 +-- 19 files changed, 281 insertions(+), 340 deletions(-) diff --git a/builder/builder.go b/builder/builder.go index ce02f5b..2be5cee 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -3,6 +3,7 @@ package builder import ( "bytes" "fmt" + "log/slog" "math/rand" "os" "os/exec" @@ -11,11 +12,11 @@ import ( "regexp" "strings" "syscall" + "time" "github.com/hashicorp/go-version" "github.com/roadrunner-server/velox/v2024" "github.com/roadrunner-server/velox/v2024/builder/templates" - "go.uber.org/zap" ) const ( @@ -36,16 +37,18 @@ type Builder struct { rrTempPath string out string modules []*velox.ModulesInfo - log *zap.Logger - buildArgs []string + log *slog.Logger + debug bool + rrVersion string } -func NewBuilder(rrTmpPath string, modules []*velox.ModulesInfo, out string, log *zap.Logger, buildArgs []string) *Builder { +func NewBuilder(rrTmpPath string, modules []*velox.ModulesInfo, out, rrVersion string, debug bool, log *slog.Logger) *Builder { return &Builder{ rrTempPath: rrTmpPath, modules: modules, - buildArgs: buildArgs, out: out, + debug: debug, + rrVersion: rrVersion, log: log, } } @@ -63,9 +66,10 @@ func (b *Builder) Build(rrModule string) error { //nolint:gocyclo t.Entries = make([]*templates.Entry, len(b.modules)) for i := 0; i < len(b.modules); i++ { t.Entries[i] = &templates.Entry{ - Module: b.modules[i].ModuleName, + Module: b.modules[i].ModuleName, + // we need to set prefix to avoid collisions Prefix: randStringBytes(5), - Structure: pluginStructureStr, + StructureName: pluginStructureStr, PseudoVersion: b.modules[i].PseudoVersion, Replace: b.modules[i].Replace, } @@ -94,7 +98,7 @@ func (b *Builder) Build(rrModule string) error { //nolint:gocyclo return fmt.Errorf("unknown module version: %s", t.ModuleVersion) } - b.log.Debug("[RESULTING TEMPLATE]", zap.String("template", buf.String())) + b.log.Debug("[RESULTING TEMPLATE]", slog.String("template", buf.String())) f, err := os.Open(b.rrTempPath) if err != nil { @@ -108,7 +112,7 @@ func (b *Builder) Build(rrModule string) error { //nolint:gocyclo } for i := 0; i < len(files); i++ { - b.log.Info("[CLEANING UP]", zap.String("file/folder", files[i])) + b.log.Info("[CLEANING UP]", slog.String("file/folder", files[i])) _ = os.RemoveAll(files[i]) } }() @@ -157,7 +161,7 @@ func (b *Builder) Build(rrModule string) error { //nolint:gocyclo return fmt.Errorf("unknown module version: %s", t.ModuleVersion) } - b.log.Debug("[RESULTING TEMPLATE]", zap.String("template", buf.String())) + b.log.Debug("[RESULTING TEMPLATE]", slog.String("template", buf.String())) _, err = goModFile.Write(buf.Bytes()) if err != nil { @@ -166,7 +170,7 @@ func (b *Builder) Build(rrModule string) error { //nolint:gocyclo buf.Reset() - b.log.Info("[SWITCHING WORKING DIR]", zap.String("wd", b.rrTempPath)) + b.log.Info("[SWITCHING WORKING DIR]", slog.String("wd", b.rrTempPath)) err = syscall.Chdir(b.rrTempPath) if err != nil { return err @@ -182,7 +186,7 @@ func (b *Builder) Build(rrModule string) error { //nolint:gocyclo return err } - b.log.Info("[CHECKING OUTPUT DIR]", zap.String("dir", b.out)) + b.log.Info("[CHECKING OUTPUT DIR]", slog.String("dir", b.out)) err = os.MkdirAll(b.out, os.ModeDir) if err != nil { return err @@ -193,7 +197,7 @@ func (b *Builder) Build(rrModule string) error { //nolint:gocyclo return err } - b.log.Info("[MOVING EXECUTABLE]", zap.String("file", filepath.Join(b.rrTempPath, executableName)), zap.String("to", filepath.Join(b.out, executableName))) + b.log.Info("[MOVING EXECUTABLE]", slog.String("file", filepath.Join(b.rrTempPath, executableName)), slog.String("to", filepath.Join(b.out, executableName))) err = moveFile(filepath.Join(b.rrTempPath, executableName), filepath.Join(b.out, executableName)) if err != nil { return err @@ -203,7 +207,7 @@ func (b *Builder) Build(rrModule string) error { //nolint:gocyclo } func (b *Builder) Write(d []byte) (int, error) { - b.log.Debug("[STDERR OUTPUT]", zap.ByteString("log", d)) + b.log.Debug("[STDERR OUTPUT]", slog.Any("log", d)) return len(d), nil } @@ -232,25 +236,42 @@ func randStringBytes(n int) string { func (b *Builder) goBuildCmd(out string) error { var cmd *exec.Cmd - if len(b.buildArgs) != 0 { - buildCmdArgs := make([]string, 0, len(b.buildArgs)+5) - buildCmdArgs = append(buildCmdArgs, "build") - // verbose - buildCmdArgs = append(buildCmdArgs, "-v") - // build args - buildCmdArgs = append(buildCmdArgs, b.buildArgs...) - // output file - buildCmdArgs = append(buildCmdArgs, "-o") - // path - buildCmdArgs = append(buildCmdArgs, out) - // path to main.go - buildCmdArgs = append(buildCmdArgs, rrMainGo) - cmd = exec.Command("go", buildCmdArgs...) - } else { - cmd = exec.Command("go", "build", "-o", out, rrMainGo) - } - - b.log.Info("[EXECUTING CMD]", zap.String("cmd", cmd.String())) + + buildCmdArgs := make([]string, 0, 5) + buildCmdArgs = append(buildCmdArgs, "build", "-v", "-trimpath") + + // var ld []string + switch b.debug { + case true: + // debug flags + // turn off optimizations + buildCmdArgs = append(buildCmdArgs, "-gcflags", "-N") + // turn off inlining + buildCmdArgs = append(buildCmdArgs, "-gcflags", "-l") + // build with debug tags + buildCmdArgs = append(buildCmdArgs, "-tags", "debug") + case false: + buildCmdArgs = append(buildCmdArgs, "-ldflags", "-s") + } + + // LDFLAGS for version and build time, always appended + buildCmdArgs = append(buildCmdArgs, "-ldflags") + buildCmdArgs = append(buildCmdArgs, fmt.Sprintf( + "-X github.com/roadrunner-server/roadrunner/v2024/internal/meta.version=%s -X github.com/roadrunner-server/roadrunner/v2024/internal/meta.buildTime=%s", + b.rrVersion, + time.Now().UTC().Format(time.RFC3339)), + ) + + // output + buildCmdArgs = append(buildCmdArgs, "-o") + // path + buildCmdArgs = append(buildCmdArgs, out) + // path to main.go + buildCmdArgs = append(buildCmdArgs, rrMainGo) + + cmd = exec.Command("go", buildCmdArgs...) + + b.log.Info("[EXECUTING CMD]", slog.String("cmd", cmd.String())) cmd.Stderr = b cmd.Stdout = b err := cmd.Start() @@ -265,7 +286,7 @@ func (b *Builder) goBuildCmd(out string) error { } func (b *Builder) goModDowloadCmd() error { - b.log.Info("[EXECUTING CMD]", zap.String("cmd", "go mod download")) + b.log.Info("[EXECUTING CMD]", slog.String("cmd", "go mod download")) cmd := exec.Command("go", "mod", "download") cmd.Stderr = b err := cmd.Start() @@ -280,7 +301,7 @@ func (b *Builder) goModDowloadCmd() error { } func (b *Builder) goModTidyCmd() error { - b.log.Info("[EXECUTING CMD]", zap.String("cmd", "go mod tidy")) + b.log.Info("[EXECUTING CMD]", slog.String("cmd", "go mod tidy")) cmd := exec.Command("go", "mod", "tidy") cmd.Stderr = b err := cmd.Start() @@ -295,7 +316,7 @@ func (b *Builder) goModTidyCmd() error { } func (b *Builder) getDepsReplace(repl string) []*templates.Entry { - b.log.Info("[REPLACING DEPENDENCIES]", zap.String("dependency", repl)) + b.log.Info("[REPLACING DEPENDENCIES]", slog.String("dependency", repl)) modFile, err := os.ReadFile(path.Join(repl, goModStr)) if err != nil { return nil @@ -306,7 +327,7 @@ func (b *Builder) getDepsReplace(repl string) []*templates.Entry { for i := 0; i < len(replaces); i++ { split := strings.Split(strings.TrimSpace(replaces[i][0]), " => ") if len(split) != 2 { - b.log.Error("not enough split args", zap.String("replace", replaces[i][0])) + b.log.Error("not enough split args", slog.String("replace", replaces[i][0])) continue } diff --git a/builder/builder_test.go b/builder/builder_test.go index d2e027d..94f68a1 100644 --- a/builder/builder_test.go +++ b/builder/builder_test.go @@ -1,12 +1,12 @@ package builder import ( + "log/slog" "os" "path" "testing" "github.com/roadrunner-server/velox/v2024" - "go.uber.org/zap" ) const ( @@ -81,7 +81,7 @@ func setup() *Builder { "dummy_multiple_absolute_remote": []byte(replaceGoModMultipleRemote), } - b := NewBuilder("/tmp", []*velox.ModulesInfo{}, "", zap.NewNop(), []string{}) + b := NewBuilder("/tmp", []*velox.ModulesInfo{}, "", "v2024.1.0", false, slog.Default()) b.modules = []*velox.ModulesInfo{ { diff --git a/builder/template_test.go b/builder/template_test.go index f5b8e84..21d1ac2 100644 --- a/builder/template_test.go +++ b/builder/template_test.go @@ -2,6 +2,7 @@ package builder import ( "bytes" + "strings" "testing" "github.com/roadrunner-server/velox/v2024/builder/templates" @@ -21,7 +22,7 @@ import ( cd "github.com/roadrunner-server/http/v4" ef "github.com/roadrunner-server/grpc/v4" jk "github.com/roadrunner-server/logger/v4" - + ) func Plugins() []any { @@ -31,7 +32,7 @@ func Plugins() []any { &informer.Plugin{}, // resetter plugin (./rr reset) &resetter.Plugin{}, - + // std and custom plugins &aba.Plugin{}, &abc.Plugin{}, @@ -40,7 +41,6 @@ func Plugins() []any { &cd.Plugin{}, &ef.Plugin{}, &jk.Plugin{}, - } } ` @@ -51,47 +51,54 @@ func TestCompile(t *testing.T) { } tt.Entries = append(tt.Entries, &templates.Entry{ - Module: "github.com/roadrunner-server/some_plugin", - Structure: "Plugin{}", - Prefix: "aba", + Module: "github.com/roadrunner-server/some_plugin", + StructureName: "Plugin{}", + Prefix: "aba", }) tt.Entries = append(tt.Entries, &templates.Entry{ - Module: "github.com/roadrunner-server/some_plugin/v2", - Structure: "Plugin{}", - Prefix: "abc", + Module: "github.com/roadrunner-server/some_plugin/v2", + StructureName: "Plugin{}", + Prefix: "abc", }) tt.Entries = append(tt.Entries, &templates.Entry{ - Module: "github.com/roadrunner-server/some_plugin/v22234", - Structure: "Plugin{}", - Prefix: "abd", + Module: "github.com/roadrunner-server/some_plugin/v22234", + StructureName: "Plugin{}", + Prefix: "abd", }) tt.Entries = append(tt.Entries, &templates.Entry{ - Module: "github.com/roadrunner-server/rpc/v4", - Structure: "Plugin{}", - Prefix: "ab", + Module: "github.com/roadrunner-server/rpc/v4", + StructureName: "Plugin{}", + Prefix: "ab", }) tt.Entries = append(tt.Entries, &templates.Entry{ - Module: "github.com/roadrunner-server/http/v4", - Structure: "Plugin{}", - Prefix: "cd", + Module: "github.com/roadrunner-server/http/v4", + StructureName: "Plugin{}", + Prefix: "cd", }) tt.Entries = append(tt.Entries, &templates.Entry{ - Module: "github.com/roadrunner-server/grpc/v4", - Structure: "Plugin{}", - Prefix: "ef", + Module: "github.com/roadrunner-server/grpc/v4", + StructureName: "Plugin{}", + Prefix: "ef", }) tt.Entries = append(tt.Entries, &templates.Entry{ - Module: "github.com/roadrunner-server/logger/v4", - Structure: "Plugin{}", - Prefix: "jk", + Module: "github.com/roadrunner-server/logger/v4", + StructureName: "Plugin{}", + Prefix: "jk", }) buf := new(bytes.Buffer) - err := templates.CompileTemplateV2023(buf, tt) + err := templates.CompileTemplateV2024(buf, tt) require.NoError(t, err) - require.Equal(t, res, buf.String()) + bufstr := buf.String() + bufstr = strings.ReplaceAll(bufstr, "\t", "") + bufstr = strings.ReplaceAll(bufstr, "\n", "") + + resstr := strings.ReplaceAll(res, "\t", "") + resstr = strings.ReplaceAll(resstr, "\n", "") + + require.Equal(t, resstr, bufstr) } diff --git a/builder/templates/entry.go b/builder/templates/entry.go index a843498..935cc19 100644 --- a/builder/templates/entry.go +++ b/builder/templates/entry.go @@ -8,8 +8,9 @@ import ( // Entry represents all info about module type Entry struct { // Module is the module name (github.com/roadrunner-server/logger/v2) - Module string - Structure string + Module string + // StructureName is the structure name of the plugin (Plugin{}) + StructureName string // Prefix is the prefix for the plugin to avoid collisions Prefix string // PseudoVersion is the pseudo version of the module (v0.0.0-20210101000000-000000000000) diff --git a/builder/templates/templateV2.go b/builder/templates/templateV2.go index e1c2821..298e144 100644 --- a/builder/templates/templateV2.go +++ b/builder/templates/templateV2.go @@ -39,9 +39,9 @@ func Plugins() []any { &informer.Plugin{}, // resetter plugin (./rr reset) &resetter.Plugin{}, - + // std and custom plugins - {{range $v := .Entries}}&{{$v.Prefix}}.{{$v.Structure}}, + {{range $v := .Entries}}&{{$v.Prefix}}.{{$v.StructureName}}, {{end}} } } diff --git a/builder/templates/templateV2023.go b/builder/templates/templateV2023.go index 6387079..9dfcb0f 100644 --- a/builder/templates/templateV2023.go +++ b/builder/templates/templateV2023.go @@ -8,13 +8,13 @@ go 1.21 toolchain go1.21.5 require ( - github.com/buger/goterm v1.0.4 - github.com/dustin/go-humanize v1.0.1 - github.com/joho/godotenv v1.5.1 - github.com/olekukonko/tablewriter v0.0.5 - github.com/spf13/cobra v1.8.0 + github.com/buger/goterm v1.0.4 + github.com/dustin/go-humanize v1.0.1 + github.com/joho/godotenv v1.5.1 + github.com/olekukonko/tablewriter v0.0.5 + github.com/spf13/cobra v1.8.0 github.com/spf13/viper v1.18.2 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.2 go.uber.org/automaxprocs v1.5.2 github.com/roadrunner-server/informer/v4 latest github.com/roadrunner-server/resetter/v4 latest @@ -56,9 +56,9 @@ func Plugins() []any { &informer.Plugin{}, // resetter plugin (./rr reset) &resetter.Plugin{}, - + // std and custom plugins - {{range $v := .Entries}}&{{$v.Prefix}}.{{$v.Structure}}, + {{range $v := .Entries}}&{{$v.Prefix}}.{{$v.StructureName}}, {{end}} } } diff --git a/builder/templates/templateV2024.go b/builder/templates/templateV2024.go index 0260c2f..98151d2 100644 --- a/builder/templates/templateV2024.go +++ b/builder/templates/templateV2024.go @@ -6,14 +6,14 @@ module github.com/roadrunner-server/roadrunner/{{.ModuleVersion}} go 1.22 require ( - github.com/buger/goterm v1.0.4 - github.com/dustin/go-humanize v1.0.1 + github.com/buger/goterm v1.0.4 + github.com/dustin/go-humanize v1.0.1 github.com/fatih/color v1.17.0 - github.com/joho/godotenv v1.5.1 - github.com/olekukonko/tablewriter v0.0.5 - github.com/spf13/cobra v1.8.0 + github.com/joho/godotenv v1.5.1 + github.com/olekukonko/tablewriter v0.0.5 + github.com/spf13/cobra v1.8.0 github.com/spf13/viper v1.19.0 - github.com/stretchr/testify v1.9.0 + github.com/stretchr/testify v1.9.0 go.uber.org/automaxprocs v1.5.3 github.com/roadrunner-server/informer/v4 latest github.com/roadrunner-server/resetter/v4 latest @@ -57,9 +57,9 @@ func Plugins() []any { &informer.Plugin{}, // resetter plugin (./rr reset) &resetter.Plugin{}, - + // std and custom plugins - {{range $v := .Entries}}&{{$v.Prefix}}.{{$v.Structure}}, + {{range $v := .Entries}}&{{$v.Prefix}}.{{$v.StructureName}}, {{end}} } } diff --git a/config.go b/config.go index 0c9e519..ba40b88 100644 --- a/config.go +++ b/config.go @@ -17,10 +17,10 @@ const ( ) type Config struct { - // build args - Velox map[string][]string `mapstructure:"velox"` // Version Roadrunner map[string]string `mapstructure:"roadrunner"` + // Debug configuration + Debug *Debug `mapstructure:"debug"` // GitHub configuration GitHub *CodeHosting `mapstructure:"github"` // GitLab configuration @@ -29,6 +29,10 @@ type Config struct { Log map[string]string `mapstructure:"log"` } +type Debug struct { + Enabled bool `mapstructure:"enabled"` +} + type Token struct { Token string `mapstructure:"token"` } @@ -52,14 +56,6 @@ type PluginConfig struct { } func (c *Config) Validate() error { //nolint:gocognit,gocyclo - // build_args - for k := range c.Velox { - for j := 0; j < len(c.Velox[k]); j++ { - s := os.ExpandEnv(c.Velox[k][j]) - c.Velox[k][j] = s - } - } - if _, ok := c.Roadrunner[ref]; !ok { if c.Roadrunner == nil { c.Roadrunner = make(map[string]string) @@ -68,6 +64,12 @@ func (c *Config) Validate() error { //nolint:gocognit,gocyclo c.Roadrunner[ref] = defaultBranch } + if c.Debug == nil { + c.Debug = &Debug{ + Enabled: false, + } + } + if c.GitHub == nil || c.GitHub.Token == nil || c.GitHub.Token.Token == "" { return errors.New("github section should contain a token to download RoadRunner") } diff --git a/config_test.go b/config_test.go index 78e854c..c254a11 100644 --- a/config_test.go +++ b/config_test.go @@ -17,8 +17,10 @@ func TestExpandEnvs(t *testing.T) { require.NoError(t, os.Setenv("VERSION", "v2.10.5")) require.NoError(t, os.Setenv("TOKEN", token)) c := &Config{ - Velox: map[string][]string{"build_args": {"github.com/roadrunner-server/roadrunner/v2/internal/meta.buildTime=${TIME}", "github.com/roadrunner-server/roadrunner/v2/internal/meta.version=${VERSION}"}}, Roadrunner: map[string]string{"": ""}, + Debug: &Debug{ + Enabled: true, + }, GitHub: &CodeHosting{ BaseURL: nil, Token: &Token{Token: "${TOKEN}"}, @@ -46,16 +48,13 @@ func TestExpandEnvs(t *testing.T) { require.NoError(t, c.Validate()) - assert.Equal(t, "github.com/roadrunner-server/roadrunner/v2/internal/meta.buildTime="+tn, c.Velox["build_args"][0]) - assert.Equal(t, "github.com/roadrunner-server/roadrunner/v2/internal/meta.version=v2.10.5", c.Velox["build_args"][1]) assert.Equal(t, token, c.GitHub.Token.Token) assert.Equal(t, token, c.GitLab.Token.Token) } func TestNils(t *testing.T) { c := &Config{ - Velox: map[string][]string{"build_args": {"github.com/roadrunner-server/roadrunner/v2/internal/meta.buildTime=${TIME}", "github.com/roadrunner-server/roadrunner/v2/internal/meta.version=${VERSION}"}}, - Log: nil, + Log: nil, } require.Error(t, c.Validate()) diff --git a/github/pool.go b/github/pool.go index f31d016..08d65f2 100644 --- a/github/pool.go +++ b/github/pool.go @@ -5,6 +5,7 @@ import ( "context" "errors" "fmt" + "log/slog" "net/http" "path" "strings" @@ -13,7 +14,6 @@ import ( "github.com/google/go-github/v61/github" "github.com/roadrunner-server/velox/v2024" - "go.uber.org/zap" ) const ( @@ -26,7 +26,7 @@ type processor struct { errs []error wg sync.WaitGroup mu sync.Mutex - log *zap.Logger + log *slog.Logger queueCh chan *pcfg modinfo []*velox.ModulesInfo client *github.Client @@ -37,7 +37,7 @@ type pcfg struct { name string } -func newPool(log *zap.Logger, client *github.Client) *processor { +func newPool(log *slog.Logger, client *github.Client) *processor { p := &processor{ maxWorkers: 10, log: log, @@ -61,11 +61,11 @@ func (p *processor) run() { for v := range p.queueCh { modInfo := new(velox.ModulesInfo) p.log.Debug("[FETCHING PLUGIN DATA]", - zap.String("repository", v.pluginCfg.Repo), - zap.String("owner", v.pluginCfg.Owner), - zap.String("folder", v.pluginCfg.Folder), - zap.String("plugin", v.name), - zap.String("ref", v.pluginCfg.Ref), + slog.String("repository", v.pluginCfg.Repo), + slog.String("owner", v.pluginCfg.Owner), + slog.String("folder", v.pluginCfg.Folder), + slog.String("plugin", v.name), + slog.String("ref", v.pluginCfg.Ref), ) if v.pluginCfg.Ref == "" { @@ -93,7 +93,7 @@ func (p *processor) run() { line := scanner.Text() switch { //nolint:gocritic case strings.HasPrefix(line, modLine): - p.log.Debug("[READING MODULE INFO]", zap.String("plugin", v.name), zap.String("module", line)) + p.log.Debug("[READING MODULE INFO]", slog.String("plugin", v.name), slog.String("module", line)) // module github.com/roadrunner-server/logger/v2, we split and get the second part retMod := strings.Split(line, " ") @@ -115,10 +115,10 @@ func (p *processor) run() { err = resp.Body.Close() if err != nil { - p.log.Warn("[FAILED TO CLOSE RESPONSE BODY]", zap.Error(err)) + p.log.Warn("[FAILED TO CLOSE RESPONSE BODY]", slog.Any("error", err)) } - p.log.Debug("[REQUESTING COMMIT SHA-1]", zap.String("plugin", v.name), zap.String("ref", v.pluginCfg.Ref)) + p.log.Debug("[REQUESTING COMMIT SHA-1]", slog.String("plugin", v.name), slog.String("ref", v.pluginCfg.Ref)) commits, rsp, err := p.client.Repositories.ListCommits(context.Background(), v.pluginCfg.Owner, v.pluginCfg.Repo, &github.CommitsListOptions{ SHA: v.pluginCfg.Ref, Until: time.Now(), @@ -155,7 +155,7 @@ func (p *processor) run() { if v.pluginCfg.Replace != "" { modInfo.Replace = v.pluginCfg.Replace - p.log.Debug("[REPLACE REQUESTED]", zap.String("plugin", v.name), zap.String("path", v.pluginCfg.Replace)) + p.log.Debug("[REPLACE REQUESTED]", slog.String("plugin", v.name), slog.String("path", v.pluginCfg.Replace)) } p.mu.Lock() diff --git a/github/repo.go b/github/repo.go index a5df9da..94d321f 100644 --- a/github/repo.go +++ b/github/repo.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "io" + "log/slog" "net/http" "os" "path" @@ -15,7 +16,6 @@ import ( "github.com/google/go-github/v61/github" "github.com/roadrunner-server/velox/v2024" - "go.uber.org/zap" "golang.org/x/oauth2" ) @@ -31,10 +31,10 @@ GHRepo represents template repository type GHRepo struct { client *github.Client config *velox.Config - log *zap.Logger + log *slog.Logger } -func NewGHRepoInfo(cfg *velox.Config, log *zap.Logger) *GHRepo { +func NewGHRepoInfo(cfg *velox.Config, log *slog.Logger) *GHRepo { var client *http.Client // if a token exists, use it to increase rate limiter @@ -53,7 +53,7 @@ func NewGHRepoInfo(cfg *velox.Config, log *zap.Logger) *GHRepo { // DownloadTemplate downloads template repository -> func (r *GHRepo) DownloadTemplate(tmp, version string) (string, error) { //nolint:gocyclo - r.log.Info("[GET ARCHIVE LINK]", zap.String("owner", rrOwner), zap.String("repository", rrRepo), zap.String("encoding", "zip"), zap.String("ref", version)) + r.log.Info("[GET ARCHIVE LINK]", slog.String("owner", rrOwner), slog.String("repository", rrRepo), slog.String("encoding", "zip"), slog.String("ref", version)) url, resp, err := r.client.Repositories.GetArchiveLink(context.Background(), rrOwner, rrRepo, github.Zipball, &github.RepositoryContentGetOptions{Ref: version}, 10) if err != nil { return "", err @@ -63,14 +63,14 @@ func (r *GHRepo) DownloadTemplate(tmp, version string) (string, error) { //nolin return "", fmt.Errorf("wrong response status, got: %d", resp.StatusCode) } - r.log.Info("[REQUESTING REPO]", zap.String("url", url.String())) + r.log.Info("[REQUESTING REPO]", slog.String("url", url.String())) request, err := r.client.NewRequest(http.MethodGet, url.String(), nil) if err != nil { return "", err } buf := new(bytes.Buffer) - r.log.Info("[FETCHING CONTENT]", zap.String("url", url.String())) + r.log.Info("[FETCHING CONTENT]", slog.String("url", url.String())) do, err := r.client.Do(context.Background(), request, buf) if err != nil { return "", err @@ -85,7 +85,7 @@ func (r *GHRepo) DownloadTemplate(tmp, version string) (string, error) { //nolin name := path.Join(tmp, "roadrunner-server-"+version) _ = os.RemoveAll(name) - r.log.Debug("[FLUSHING DATA ON THE DISK]", zap.String("path", name+zipExt)) + r.log.Debug("[FLUSHING DATA ON THE DISK]", slog.String("path", name+zipExt)) f, err := os.Create(name + zipExt) if err != nil { return "", err @@ -100,7 +100,7 @@ func (r *GHRepo) DownloadTemplate(tmp, version string) (string, error) { //nolin return "", err } - r.log.Debug("[SAVED]", zap.Int("bytes written", n)) + r.log.Debug("[SAVED]", slog.Int("bytes written", n)) rc, err := zip.OpenReader(name + zipExt) if err != nil { @@ -142,14 +142,14 @@ func (r *GHRepo) DownloadTemplate(tmp, version string) (string, error) { //nolin outDir := rc.File[0].Name for _, zf := range rc.File { - r.log.Debug("[EXTRACTING]", zap.String("file", zf.Name), zap.String("path", dest)) + r.log.Debug("[EXTRACTING]", slog.String("file", zf.Name), slog.String("path", dest)) err = extract(dest, zf) if err != nil { return "", err } } - r.log.Info("[REPOSITORY SUCCESSFULLY SAVED]", zap.String("path", filepath.Join(dest, outDir))) //nolint:gosec + r.log.Info("[REPOSITORY SUCCESSFULLY SAVED]", slog.String("path", filepath.Join(dest, outDir))) //nolint:gosec // first name is the output path return filepath.Join(dest, outDir), nil //nolint:gosec } diff --git a/gitlab/repo.go b/gitlab/repo.go index 09ed548..4fecc01 100644 --- a/gitlab/repo.go +++ b/gitlab/repo.go @@ -6,6 +6,7 @@ import ( "encoding/base64" "errors" "fmt" + "log/slog" "net/http" "path" "strings" @@ -13,7 +14,6 @@ import ( "github.com/roadrunner-server/velox/v2024" "github.com/xanzy/go-gitlab" - "go.uber.org/zap" ) /* @@ -22,10 +22,10 @@ GLRepo represents template repository type GLRepo struct { client *gitlab.Client config *velox.Config - log *zap.Logger + log *slog.Logger } -func NewGLRepoInfo(cfg *velox.Config, log *zap.Logger) (*GLRepo, error) { +func NewGLRepoInfo(cfg *velox.Config, log *slog.Logger) (*GLRepo, error) { glc, err := gitlab.NewClient(cfg.GitLab.Token.Token, gitlab.WithBaseURL(cfg.GitLab.BaseURL.BaseURL)) if err != nil { return nil, err @@ -43,7 +43,7 @@ func (r *GLRepo) GetPluginsModData() ([]*velox.ModulesInfo, error) { for k, v := range r.config.GitLab.Plugins { modInfo := new(velox.ModulesInfo) - r.log.Debug("[FETCHING PLUGIN DATA]", zap.String("repository", v.Repo), zap.String("owner", v.Owner), zap.String("folder", v.Folder), zap.String("plugin", k), zap.String("ref", v.Ref)) + r.log.Debug("[FETCHING PLUGIN DATA]", slog.String("repository", v.Repo), slog.String("owner", v.Owner), slog.String("folder", v.Folder), slog.String("plugin", k), slog.String("ref", v.Ref)) if v.Ref == "" { return nil, errors.New("ref can't be empty") @@ -70,7 +70,7 @@ func (r *GLRepo) GetPluginsModData() ([]*velox.ModulesInfo, error) { scanner.Scan() ret := scanner.Text() - r.log.Debug("[READING MODULE INFO]", zap.String("plugin", k), zap.String("mod", ret)) + r.log.Debug("[READING MODULE INFO]", slog.String("plugin", k), slog.String("mod", ret)) // module github.com/roadrunner-server/logger/v2, we split and get the second part retMod := strings.Split(ret, " ") @@ -85,7 +85,7 @@ func (r *GLRepo) GetPluginsModData() ([]*velox.ModulesInfo, error) { modInfo.ModuleName = strings.TrimRight(retMod[1], "\n") - r.log.Debug("[REQUESTING REPO BY REF]", zap.String("plugin", k), zap.String("ref", v.Ref)) + r.log.Debug("[REQUESTING REPO BY REF]", slog.String("plugin", k), slog.String("ref", v.Ref)) commits, rsp, err := r.client.Commits.ListCommits(v.Repo, &gitlab.ListCommitsOptions{ ListOptions: gitlab.ListOptions{ Page: 1, @@ -123,7 +123,7 @@ func (r *GLRepo) GetPluginsModData() ([]*velox.ModulesInfo, error) { modInfo.PseudoVersion = velox.ParseModuleInfo(modInfo.ModuleName, *at, modInfo.Version) if v.Replace != "" { - r.log.Debug("[REPLACE REQUESTED]", zap.String("plugin", k), zap.String("path", v.Replace)) + r.log.Debug("[REPLACE REQUESTED]", slog.String("plugin", k), slog.String("path", v.Replace)) } modInfo.Replace = v.Replace diff --git a/go.mod b/go.mod index c95d3eb..22085f0 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,6 @@ require ( github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.9.0 github.com/xanzy/go-gitlab v0.105.0 - go.uber.org/zap v1.27.0 golang.org/x/mod v0.18.0 golang.org/x/oauth2 v0.21.0 ) @@ -37,7 +36,8 @@ require ( github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect - go.uber.org/multierr v1.11.0 // indirect + go.uber.org/atomic v1.9.0 // indirect + go.uber.org/multierr v1.9.0 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/sys v0.21.0 // indirect golang.org/x/text v0.16.0 // indirect diff --git a/go.sum b/go.sum index ad3ad9a..ccb27de 100644 --- a/go.sum +++ b/go.sum @@ -71,6 +71,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= @@ -80,12 +81,10 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/xanzy/go-gitlab v0.105.0 h1:3nyLq0ESez0crcaM19o5S//SvezOQguuIHZ3wgX64hM= github.com/xanzy/go-gitlab v0.105.0/go.mod h1:ETg8tcj4OhrB84UEgeE8dSuV/0h4BBL1uOV/qK0vlyI= -go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= -go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= +go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY= golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= diff --git a/internal/cli/build/build.go b/internal/cli/build/build.go index 0f29ac2..7f9d215 100644 --- a/internal/cli/build/build.go +++ b/internal/cli/build/build.go @@ -1,6 +1,7 @@ package build import ( + "log/slog" "os" "syscall" @@ -9,15 +10,13 @@ import ( "github.com/roadrunner-server/velox/v2024/github" "github.com/roadrunner-server/velox/v2024/gitlab" "github.com/spf13/cobra" - "go.uber.org/zap" ) const ( - ref string = "ref" - buildArgs string = "build_args" + ref string = "ref" ) -func BindCommand(cfg *velox.Config, out *string, zlog *zap.Logger) *cobra.Command { +func BindCommand(cfg *velox.Config, out *string, zlog *slog.Logger) *cobra.Command { return &cobra.Command{ Use: "build", Short: "Build RR", @@ -32,7 +31,7 @@ func BindCommand(cfg *velox.Config, out *string, zlog *zap.Logger) *cobra.Comman var mi []*velox.ModulesInfo if cfg.GitLab != nil { - rp, err := gitlab.NewGLRepoInfo(cfg, zlog) + rp, err := gitlab.NewGLRepoInfo(cfg, zlog.WithGroup("GITLAB")) if err != nil { return err } @@ -44,15 +43,17 @@ func BindCommand(cfg *velox.Config, out *string, zlog *zap.Logger) *cobra.Comman } // roadrunner located on the github - rp := github.NewGHRepoInfo(cfg, zlog) + rp := github.NewGHRepoInfo(cfg, zlog.WithGroup("GITHUB")) path, err := rp.DownloadTemplate(os.TempDir(), cfg.Roadrunner[ref]) if err != nil { - zlog.Fatal("[DOWNLOAD TEMPLATE]", zap.Error(err)) + zlog.Error("downloading template", slog.Any("error", err)) + os.Exit(1) } pMod, err := rp.GetPluginsModData() if err != nil { - zlog.Fatal("[PLUGINS GET MOD INFO]", zap.Error(err)) + zlog.Error("get plugins mod data", slog.Any("error", err)) + os.Exit(1) } // append data from gitlab @@ -60,12 +61,13 @@ func BindCommand(cfg *velox.Config, out *string, zlog *zap.Logger) *cobra.Comman pMod = append(pMod, mi...) } - err = builder.NewBuilder(path, pMod, *out, zlog, cfg.Velox[buildArgs]).Build(cfg.Roadrunner[ref]) + err = builder.NewBuilder(path, pMod, *out, cfg.Roadrunner[ref], cfg.Debug.Enabled, zlog.WithGroup("BUILDER")).Build(cfg.Roadrunner[ref]) if err != nil { - zlog.Fatal("[BUILD FAILED]", zap.Error(err)) + zlog.Error("fatal", slog.Any("error", err)) + os.Exit(1) } - zlog.Info("[BUILD]", zap.String("build finished, path", *out)) + zlog.Info("========= build finished successfully =========", slog.Any("RoadRunner can be found at", *out)) return nil }, } diff --git a/internal/cli/root.go b/internal/cli/root.go index 62b4d37..8b3f0e0 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -2,6 +2,7 @@ package cli import ( "fmt" + "log/slog" "runtime" "github.com/pkg/errors" @@ -11,12 +12,11 @@ import ( "github.com/roadrunner-server/velox/v2024/logger" "github.com/spf13/cobra" "github.com/spf13/viper" - "go.uber.org/zap" ) func NewCommand(executableName string) *cobra.Command { var config = &velox.Config{} // velox configuration - var zapLogger = &zap.Logger{} + var lg = slog.Default() var cfgPath = strPtr("") var ( @@ -61,12 +61,8 @@ func NewCommand(executableName string) *cobra.Command { // [log] // level = "debug" // mode = "development" - zlog, err := logger.BuildLogger(config.Log["level"], config.Log["mode"]) - if err != nil { - return err - } - - *zapLogger = *zlog + zlog := logger.BuildLogger(config.Log["level"], config.Log["mode"]) + *lg = *zlog return nil }, @@ -77,7 +73,7 @@ func NewCommand(executableName string) *cobra.Command { flag.StringVarP(&outputFile, "out", "o", ".", "Output path: -o /usr/local/bin") cmd.AddCommand( - build.BindCommand(config, cfgPath, zapLogger), + build.BindCommand(config, cfgPath, lg), ) return cmd } diff --git a/logger/logger.go b/logger/logger.go index 2d35f43..847a4e1 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -1,136 +1,53 @@ package logger import ( + "log/slog" + "os" "strings" - - "github.com/fatih/color" - "go.uber.org/zap" - "go.uber.org/zap/zapcore" ) // Mode represents available logger modes const ( - none string = "none" - off string = "off" production string = "production" development string = "development" - raw string = "raw" ) // BuildLogger converts config into Zap configuration. -func BuildLogger(level, mode string) (*zap.Logger, error) { - var zCfg zap.Config +func BuildLogger(level, mode string) *slog.Logger { switch mode { - case off, none: - return zap.NewNop(), nil case production: - zCfg = zap.Config{ - Level: zap.NewAtomicLevelAt(zap.InfoLevel), - Development: false, - Encoding: "json", - EncoderConfig: zapcore.EncoderConfig{ - TimeKey: "ts", - LevelKey: "level", - NameKey: "logger", - CallerKey: zapcore.OmitKey, - FunctionKey: zapcore.OmitKey, - MessageKey: "msg", - StacktraceKey: zapcore.OmitKey, - EncodeLevel: zapcore.LowercaseLevelEncoder, - EncodeTime: zapcore.EpochTimeEncoder, - EncodeDuration: zapcore.SecondsDurationEncoder, - EncodeCaller: zapcore.ShortCallerEncoder, - }, - OutputPaths: []string{"stderr"}, - ErrorOutputPaths: []string{"stderr"}, - } + lg := slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{ + AddSource: false, + Level: stringToSlogLevel(level), + }) + + return slog.New(lg) case development: - zCfg = zap.Config{ - Level: zap.NewAtomicLevelAt(zap.DebugLevel), - Development: true, - Encoding: "console", - EncoderConfig: zapcore.EncoderConfig{ - TimeKey: "ts", - LevelKey: "level", - NameKey: "logger", - CallerKey: zapcore.OmitKey, - FunctionKey: zapcore.OmitKey, - MessageKey: "msg", - StacktraceKey: zapcore.OmitKey, - EncodeLevel: ColoredLevelEncoder, - EncodeName: ColoredNameEncoder, - EncodeTime: zapcore.ISO8601TimeEncoder, - EncodeDuration: zapcore.StringDurationEncoder, - EncodeCaller: zapcore.ShortCallerEncoder, - }, - OutputPaths: []string{"stderr"}, - ErrorOutputPaths: []string{"stderr"}, - } - case raw: - zCfg = zap.Config{ - Level: zap.NewAtomicLevelAt(zap.InfoLevel), - Encoding: "console", - EncoderConfig: zapcore.EncoderConfig{ - MessageKey: "message", - EncodeLevel: ColoredLevelEncoder, - }, - OutputPaths: []string{"stderr"}, - ErrorOutputPaths: []string{"stderr"}, - } + lg := slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{ + AddSource: true, + Level: stringToSlogLevel(level), + }) + return slog.New(lg) default: - zCfg = zap.Config{ - Level: zap.NewAtomicLevelAt(zap.DebugLevel), - Encoding: "console", - EncoderConfig: zapcore.EncoderConfig{ - TimeKey: "T", - LevelKey: "L", - NameKey: "N", - CallerKey: zapcore.OmitKey, - FunctionKey: zapcore.OmitKey, - MessageKey: "M", - StacktraceKey: zapcore.OmitKey, - EncodeLevel: ColoredLevelEncoder, - EncodeName: ColoredNameEncoder, - EncodeTime: zapcore.ISO8601TimeEncoder, - EncodeDuration: zapcore.StringDurationEncoder, - EncodeCaller: zapcore.ShortCallerEncoder, - }, - OutputPaths: []string{"stderr"}, - ErrorOutputPaths: []string{"stderr"}, - } - } - - if level != "" { - lvl := zap.NewAtomicLevel() - if err := lvl.UnmarshalText([]byte(level)); err == nil { - zCfg.Level = lvl - } - } - - return zCfg.Build() -} - -// ColoredLevelEncoder colorizes log levels. -func ColoredLevelEncoder(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder) { - switch level { - case zapcore.DebugLevel: - enc.AppendString(color.HiWhiteString(level.CapitalString())) - case zapcore.InfoLevel: - enc.AppendString(color.HiCyanString(level.CapitalString())) - case zapcore.WarnLevel: - enc.AppendString(color.HiYellowString(level.CapitalString())) - case zapcore.ErrorLevel, zapcore.DPanicLevel: - enc.AppendString(color.HiRedString(level.CapitalString())) - case zapcore.PanicLevel, zapcore.FatalLevel, zapcore.InvalidLevel: - enc.AppendString(color.HiMagentaString(level.CapitalString())) + return slog.Default() } } -// ColoredNameEncoder colorizes service names. -func ColoredNameEncoder(s string, enc zapcore.PrimitiveArrayEncoder) { - if len(s) < 12 { - s += strings.Repeat(" ", 12-len(s)) +func stringToSlogLevel(level string) slog.Level { + switch strings.ToLower(level) { + case "debug": + return slog.LevelDebug + case "info": + return slog.LevelInfo + case "warn": + return slog.LevelWarn + case "error": + return slog.LevelError + case "fatal": + return slog.LevelError + case "panic": + return slog.LevelError + default: + return slog.LevelDebug } - - enc.AppendString(color.HiGreenString(s)) } diff --git a/velox.toml b/velox.toml index a30d408..eca57a8 100644 --- a/velox.toml +++ b/velox.toml @@ -1,89 +1,88 @@ [velox] -build_args = ['-trimpath', '-ldflags', '-s -X github.com/roadrunner-server/roadrunner/v2/internal/meta.version=${VERSION} -X github.com/roadrunner-server/roadrunner/v2/internal/meta.buildTime=${TIME}'] +build_args = [ + '-trimpath', + '-ldflags', + '-s -X github.com/roadrunner-server/roadrunner/v2/internal/meta.version=${VERSION} -X github.com/roadrunner-server/roadrunner/v2/internal/meta.buildTime=${TIME}', +] [roadrunner] ref = "v2.12.3" [github] - [github.token] - token = "${RT_TOKEN}" +[github.token] +token = "${RT_TOKEN}" - # ref -> master, commit or tag - [github.plugins] - # LOGS - appLogger = { ref = "v3.2.0", owner = "roadrunner-server", repository = "app-logger" } - logger = { ref = "v3.2.0", owner = "roadrunner-server", repository = "logger" } +# ref -> master, commit or tag +[github.plugins] +# LOGS +appLogger = { ref = "v3.2.0", owner = "roadrunner-server", repository = "app-logger" } +logger = { ref = "v3.2.0", owner = "roadrunner-server", repository = "logger" } - # CENTRIFUGE BROADCASTING PLATFORM - centrifuge = { ref = "v3.2.0", owner = "roadrunner-server", repository = "centrifuge" } +# CENTRIFUGE BROADCASTING PLATFORM +centrifuge = { ref = "v3.2.0", owner = "roadrunner-server", repository = "centrifuge" } - # WORKFLOWS ENGINE - temporal = { ref = "v3.0.0", owner = "temporalio", repository = "roadrunner-temporal" } +# WORKFLOWS ENGINE +temporal = { ref = "v3.0.0", owner = "temporalio", repository = "roadrunner-temporal" } - # METRICS - metrics = { ref = "v3.3.0", owner = "roadrunner-server", repository = "metrics" } +# METRICS +metrics = { ref = "v3.3.0", owner = "roadrunner-server", repository = "metrics" } - # HTTP + MIDDLEWARE - http = { ref = "v3.2.0", owner = "roadrunner-server", repository = "http" } - gzip = { ref = "v3.2.0", owner = "roadrunner-server", repository = "gzip" } - prometheus = { ref = "v3.2.0", owner = "roadrunner-server", repository = "prometheus" } - headers = { ref = "v3.2.0", owner = "roadrunner-server", repository = "headers" } - static = { ref = "v3.2.0", owner = "roadrunner-server", repository = "static" } - otel = { ref = "v3.2.0", owner = "roadrunner-server", repository = "otel" } +# HTTP + MIDDLEWARE +http = { ref = "v3.2.0", owner = "roadrunner-server", repository = "http" } +gzip = { ref = "v3.2.0", owner = "roadrunner-server", repository = "gzip" } +prometheus = { ref = "v3.2.0", owner = "roadrunner-server", repository = "prometheus" } +headers = { ref = "v3.2.0", owner = "roadrunner-server", repository = "headers" } +static = { ref = "v3.2.0", owner = "roadrunner-server", repository = "static" } +otel = { ref = "v3.2.0", owner = "roadrunner-server", repository = "otel" } - # RELOAD (for the DEV) - reload = { ref = "v3.2.0", owner = "roadrunner-server", repository = "reload" } +# RELOAD (for the DEV) +reload = { ref = "v3.2.0", owner = "roadrunner-server", repository = "reload" } - # SERVER - server = { ref = "v3.2.0", owner = "roadrunner-server", repository = "server" } +# SERVER +server = { ref = "v3.2.0", owner = "roadrunner-server", repository = "server" } - # SERVICE aka lightweit systemd - service = { ref = "v3.2.0", owner = "roadrunner-server", repository = "service" } +# SERVICE aka lightweit systemd +service = { ref = "v3.2.0", owner = "roadrunner-server", repository = "service" } - # JOBS - jobs = { ref = "v3.2.0", owner = "roadrunner-server", repository = "jobs" } - amqp = { ref = "v3.3.0", owner = "roadrunner-server", repository = "amqp" } - sqs = { ref = "v3.3.0", owner = "roadrunner-server", repository = "sqs" } - beanstalk = { ref = "v3.2.0", owner = "roadrunner-server", repository = "beanstalk" } - nats = { ref = "v3.2.0", owner = "roadrunner-server", repository = "nats" } - kafka = { ref = "v3.0.4", owner = "roadrunner-server", repository = "kafka" } +# JOBS +jobs = { ref = "v3.2.0", owner = "roadrunner-server", repository = "jobs" } +amqp = { ref = "v3.3.0", owner = "roadrunner-server", repository = "amqp" } +sqs = { ref = "v3.3.0", owner = "roadrunner-server", repository = "sqs" } +beanstalk = { ref = "v3.2.0", owner = "roadrunner-server", repository = "beanstalk" } +nats = { ref = "v3.2.0", owner = "roadrunner-server", repository = "nats" } +kafka = { ref = "v3.0.4", owner = "roadrunner-server", repository = "kafka" } - # KV - kv = { ref = "v3.2.0", owner = "roadrunner-server", repository = "kv" } - boltdb = { ref = "v3.2.0", owner = "roadrunner-server", repository = "boltdb" } - memory = { ref = "v3.3.0", owner = "roadrunner-server", repository = "memory" } - redis = { ref = "v3.2.0", owner = "roadrunner-server", repository = "redis" } - memcached = { ref = "v3.2.0", owner = "roadrunner-server", repository = "memcached" } +# KV +kv = { ref = "v3.2.0", owner = "roadrunner-server", repository = "kv" } +boltdb = { ref = "v3.2.0", owner = "roadrunner-server", repository = "boltdb" } +memory = { ref = "v3.3.0", owner = "roadrunner-server", repository = "memory" } +redis = { ref = "v3.2.0", owner = "roadrunner-server", repository = "redis" } +memcached = { ref = "v3.2.0", owner = "roadrunner-server", repository = "memcached" } - # FILESERVER (static files) - fileserver = { ref = "v3.2.0", owner = "roadrunner-server", repository = "fileserver" } +# FILESERVER (static files) +fileserver = { ref = "v3.2.0", owner = "roadrunner-server", repository = "fileserver" } - # gRPC plugin - grpc = { ref = "v3.3.0", owner = "roadrunner-server", repository = "grpc" } +# gRPC plugin +grpc = { ref = "v3.3.0", owner = "roadrunner-server", repository = "grpc" } - # HEALTHCHECKS + READINESS CHECKS - status = { ref = "v3.2.0", owner = "roadrunner-server", repository = "status" } +# HEALTHCHECKS + READINESS CHECKS +status = { ref = "v3.2.0", owner = "roadrunner-server", repository = "status" } - # TCP for the RAW TCP PAYLOADS - tcp = { ref = "v3.2.0", owner = "roadrunner-server", repository = "tcp" } +# TCP for the RAW TCP PAYLOADS +tcp = { ref = "v3.2.0", owner = "roadrunner-server", repository = "tcp" } [gitlab] - [gitlab.token] - # api, read-api, read-repo - token = "${GL_TOKEN}" +[gitlab.token] +# api, read-api, read-repo +token = "${GL_TOKEN}" -[gitlab] - [gitlab.token] - # api, read-api, read-repo - token = "${GL_TOKEN}" - - [gitlab.endpoint] - endpoint = "https://gitlab.com" +[gitlab.endpoint] +endpoint = "https://gitlab.com" - [gitlab.plugins] - # ref -> master, commit or tag - test_plugin_1 = { ref = "main", owner = "rustatian", repository = "36405203" } - test_plugin_2 = { ref = "main", owner = "rustatian", repository = "36405235" } +[gitlab.plugins] +# ref -> master, commit or tag +test_plugin_1 = { ref = "main", owner = "rustatian", repository = "36405203" } +test_plugin_2 = { ref = "main", owner = "rustatian", repository = "36405235" } [log] level = "debug" diff --git a/velox_rr_v2024.toml b/velox_rr_v2024.toml index 6ef3d73..b947123 100644 --- a/velox_rr_v2024.toml +++ b/velox_rr_v2024.toml @@ -1,13 +1,11 @@ -[velox] -build_args = [ - '-trimpath', - '-ldflags', - '-s -X github.com/roadrunner-server/roadrunner/v2024/internal/meta.version=${VERSION} -X github.com/roadrunner-server/roadrunner/v2024/internal/meta.buildTime=${TIME}', -] - [roadrunner] +# ref -> reference, can be a tag, commit or branch ref = "v2024.1.5" +# debug option is used to build RR with debug symbols to profile it with pprof +[debug] +enabled = true + [github] [github.token] token = "${RT_TOKEN}"