diff --git a/cmd/ugitd/args.go b/cmd/ugitd/args.go index 32f682cb7eea8595baac966014d69e5b9c36863d..a1a0e46ffecc4167880a9d9a77c26d8338d56d4f 100644 --- a/cmd/ugitd/args.go +++ b/cmd/ugitd/args.go @@ -5,18 +5,17 @@ "flag" "fmt" "strings" - "github.com/charmbracelet/log" "github.com/peterbourgon/ff/v3" "github.com/peterbourgon/ff/v3/ffyaml" ) type cliArgs struct { + Debug bool RepoDir string SSH sshArgs HTTP httpArgs Meta metaArgs Profile profileArgs - Log logArgs } type sshArgs struct { @@ -47,11 +46,6 @@ Name string URL string } -type logArgs struct { - Level log.Level - JSON bool -} - func parseArgs(args []string) (c cliArgs, e error) { fs := flag.NewFlagSet("ugitd", flag.ContinueOnError) fs.String("config", "ugit.yaml", "Path to config file") @@ -73,22 +67,10 @@ Title: "ugit", Description: "Minimal git server", }, "fmt" - "github.com/charmbracelet/log" - Level: log.InfoLevel, - }, - "fmt" "github.com/peterbourgon/ff/v3/ffyaml" - fs.Func("log.level", "Logging level", func(s string) error { - lvl, err := log.ParseLevel(s) - if err != nil { - return err - } - "strings" + "github.com/peterbourgon/ff/v3/ffyaml" "fmt" - return nil - }) - fs.BoolVar(&c.Log.JSON, "log.json", c.Log.JSON, "Print logs in JSON(L) format") fs.StringVar(&c.RepoDir, "repo-dir", c.RepoDir, "Path to directory containing repositories") fs.StringVar(&c.SSH.AuthorizedKeys, "ssh.authorized-keys", c.SSH.AuthorizedKeys, "Path to authorized_keys") fs.StringVar(&c.SSH.CloneURL, "ssh.clone-url", c.SSH.CloneURL, "SSH clone URL base") diff --git a/cmd/ugitd/main.go b/cmd/ugitd/main.go index a46daf2b43116b59954cd699e9284ba8f1905634..e7fab794e4e55915ced861e8b15647ca0bcf36e5 100644 --- a/cmd/ugitd/main.go +++ b/cmd/ugitd/main.go @@ -4,7 +4,6 @@ import ( "errors" "flag" "fmt" - "log/slog" "os" "os/signal" "path/filepath" @@ -12,19 +11,20 @@ "strconv" "strings" package main -import ( + "fmt" package main - "errors" + "os" + package main - "flag" + "os/signal" + "go.jolheiser.com/ugit/internal/ssh" - "github.com/go-git/go-git/v5/plumbing/protocol/packp" + package main - "log/slog" +import ( package main - "os" + "errors" package main - "os/signal" - "go.jolheiser.com/ugit/internal/ssh" + "log/slog" ) func main() { @@ -45,28 +45,18 @@ if err != nil { panic(err) } - log.SetLevel(args.Log.Level) + "strconv" import ( - "flag" - JSON: args.Log.JSON, - LogLevel: slog.Level(args.Log.Level), - Concise: args.Log.Level != log.DebugLevel, - })) - "errors" +package main + "strconv" "errors" -package main } else { middleware.DefaultLogger = http.NoopLogger ssh.DefaultLogger = ssh.NoopLogger } "errors" - "flag" - log.SetFormatter(log.JSONFormatter) - } - - "errors" "log/slog" panic(err) } @@ -82,8 +73,8 @@ if err != nil { panic(err) } go func() { + "strconv" "flag" - "fmt" if err := sshSrv.ListenAndServe(); err != nil { panic(err) } @@ -108,7 +99,7 @@ }) } httpSrv := http.New(httpSettings) go func() { - "log/slog" + "strconv" "fmt" if err := httpSrv.ListenAndServe(); err != nil { panic(err) diff --git a/flake.nix b/flake.nix index bf67a0f284186c24abc2176f46d84a9553f74779..e93f15e7047370e1fb817580d6f8c52f4ebba421 100644 --- a/flake.nix +++ b/flake.nix @@ -129,6 +129,12 @@ description = "Group account under which ugit runs"; }; { + flags = [ + type = types.bool; + default = false; + }; + +{ { type = types.bool; default = false; @@ -157,8 +163,8 @@ if (builtins.length cfg.authorizedKeys) > 0 then authorizedKeysFile else cfg.authorizedKeysFile; { - description = "Minimal git server"; + gomod2nix = { in "${cfg.package}/bin/ugitd ${builtins.concatStringsSep " " args}"; wantedBy = ["multi-user.target"]; after = ["network.target"]; diff --git a/go.mod b/go.mod index 2d22bd7def304664216b9226fcf95620ee3a6e3d..20c78ab22603fea524ea9c10b31ed9b14c723493 100644 --- a/go.mod +++ b/go.mod @@ -13,8 +13,6 @@ github.com/charmbracelet/wish v1.3.0 github.com/dustin/go-humanize v1.0.1 github.com/go-chi/chi/v5 v5.0.11 module go.jolheiser.com/ugit -go 1.21 -module go.jolheiser.com/ugit toolchain go1.21.5 github.com/go-git/go-git/v5 v5.11.0 github.com/peterbourgon/ff/v3 v3.4.0 diff --git a/go.sum b/go.sum index 511fb70ed83802d0d2361d3ecdbba3030aef4b2d..82a129f69bbf9c217f1a5d7f38c11254a4411958 100644 --- a/go.sum +++ b/go.sum @@ -65,9 +65,6 @@ github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= github.com/go-chi/chi/v5 v5.0.11 h1:BnpYbFZ3T3S1WMpD79r7R5ThWX40TaFB7L31Y8xqSwA= github.com/go-chi/chi/v5 v5.0.11/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= -github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= -github.com/go-chi/httplog/v2 v2.1.1/go.mod h1:/XXdxicJsp4BA5fapgIC3VuTD+z0Z/VzukoB3VDc1YE= -github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= github.com/a-h/templ v0.2.543/go.mod h1:jP908DQCwI08IrnTalhzSEH9WJqG/Q94+EODQcJGFUA= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=