Remove base
This commit is contained in:
parent
0d6e8bc4a0
commit
d7fbea4380
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
.cuddle/
|
||||
.env
|
@ -1 +0,0 @@
|
||||
# Configuration server
|
Binary file not shown.
Before Width: | Height: | Size: 32 KiB |
@ -1,10 +0,0 @@
|
||||
<svg width="1000" height="1000" viewBox="0 0 1000 1000" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M975 568C975 830.335 762.335 497 500 497C237.665 497 25 830.335 25 568C25 305.665 237.665 93 500 93C762.335 93 975 305.665 975 568Z" fill="#52DB78"/>
|
||||
<path d="M237.436 856.185C165.693 827.571 320.875 755.464 377.754 612.854C434.634 470.243 371.672 311.132 443.414 339.746C515.157 368.36 527.205 507.165 470.326 649.776C413.446 792.386 309.178 884.799 237.436 856.185Z" fill="#52DB78"/>
|
||||
<path d="M428.353 849.847C353.918 829.229 500.308 740.627 541.293 592.663C582.278 444.699 502.337 293.405 576.773 314.023C651.208 334.641 678.325 471.303 637.34 619.267C596.355 767.231 502.788 870.465 428.353 849.847Z" fill="#52DB78"/>
|
||||
<path d="M598.707 855.902C523.231 839.498 664.415 742.813 697.024 592.781C729.634 442.748 641.321 296.183 716.797 312.588C792.272 328.992 827.022 463.916 794.413 613.948C761.803 763.98 674.183 872.307 598.707 855.902Z" fill="#52DB78"/>
|
||||
<path d="M47.896 838.855C-19.3259 800.817 144.17 750.323 219.784 616.698C295.397 483.073 254.495 316.918 321.717 354.956C388.938 392.994 382.136 532.155 306.522 665.78C230.909 799.405 115.118 876.893 47.896 838.855Z" fill="#52DB78"/>
|
||||
<ellipse cx="605.35" cy="265.255" rx="57.5" ry="36.5" transform="rotate(-40.9544 605.35 265.255)" fill="white"/>
|
||||
<ellipse cx="359.35" cy="265.255" rx="57.5" ry="36.5" transform="rotate(-40.9544 359.35 265.255)" fill="white"/>
|
||||
<path d="M385.635 374C385.635 374 391.199 435.298 463.528 438.425C535.857 441.553 538.492 380.61 538.492 380.61" stroke="white" stroke-width="8"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.5 KiB |
@ -1,61 +0,0 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/cli"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/commands"
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func CreateOctopushProcessCmd(logger *zap.Logger) *cobra.Command {
|
||||
|
||||
var (
|
||||
actionsRepo string
|
||||
branch string
|
||||
path string
|
||||
)
|
||||
cmd := &cobra.Command{
|
||||
Use: "process",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if err := cmd.ParseFlags(args); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ctx := cmd.Context()
|
||||
|
||||
deps, cleanupFunc, err := cli.Start(ctx, logger)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
ctx, _ = context.WithTimeout(ctx, time.Second*5)
|
||||
if err := cleanupFunc(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
|
||||
err = commands.
|
||||
NewProcessRepos(logger, deps).
|
||||
Process(ctx, actionsRepo, branch, path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
pf := cmd.PersistentFlags()
|
||||
|
||||
pf.StringVar(&actionsRepo, "actions-repo", "", "actions repo is the location of your actions, not where to apply the actions themselves, that should be self contained")
|
||||
cmd.MarkPersistentFlagRequired("actions-repo")
|
||||
pf.StringVar(&branch, "branch", "main", "which branch to look for actions in, will default to main")
|
||||
pf.StringVar(&path, "path", "", "the location of the path inside the repository")
|
||||
cmd.MarkPersistentFlagRequired("path")
|
||||
|
||||
return cmd
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"git.front.kjuulh.io/kjuulh/octopush/cmd/octopush/commands/server"
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func CreateOctopushCmd(logger *zap.Logger) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "octopush",
|
||||
}
|
||||
|
||||
cmd.AddCommand(CreateOctopushProcessCmd(logger))
|
||||
cmd.AddCommand(server.CreateOctopushServerCmd(logger))
|
||||
|
||||
return cmd
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func CreateOctopushProcessCmd() *cobra.Command {
|
||||
|
||||
var (
|
||||
actionsRepo string
|
||||
branch string
|
||||
path string
|
||||
)
|
||||
cmd := &cobra.Command{
|
||||
Use: "process",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if err := cmd.ParseFlags(args); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
client := http.Client{}
|
||||
|
||||
var buf bytes.Buffer
|
||||
err := json.NewEncoder(&buf).
|
||||
Encode(struct {
|
||||
Repository string `json:"repository"`
|
||||
Branch string `json:"branch"`
|
||||
Path string `json:"path"`
|
||||
}{
|
||||
Repository: actionsRepo,
|
||||
Branch: branch,
|
||||
Path: path,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(
|
||||
cmd.Context(),
|
||||
http.MethodPost,
|
||||
"http://localhost:3000/commands/processRepos",
|
||||
&buf,
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if resp.StatusCode >= 300 {
|
||||
panic(resp.Status)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
pf := cmd.PersistentFlags()
|
||||
|
||||
pf.StringVar(&actionsRepo, "actions-repo", "", "actions repo is the location of your actions, not where to apply the actions themselves, that should be self contained")
|
||||
cmd.MarkPersistentFlagRequired("actions-repo")
|
||||
pf.StringVar(&branch, "branch", "main", "which branch to look for actions in, will default to main")
|
||||
pf.StringVar(&path, "path", "", "the location of the path inside the repository")
|
||||
cmd.MarkPersistentFlagRequired("path")
|
||||
|
||||
return cmd
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func CreateOctopushServerCmd(logger *zap.Logger) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "server",
|
||||
}
|
||||
|
||||
cmd.AddCommand(CreateOctopushProcessCmd())
|
||||
|
||||
return cmd
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/octopush/cmd/octopush/commands"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/logger"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func main() {
|
||||
logger, err := logger.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_ = logger.Sync()
|
||||
|
||||
zap.ReplaceGlobals(logger)
|
||||
|
||||
Execute(logger)
|
||||
}
|
||||
|
||||
func Execute(logger *zap.Logger) {
|
||||
err := commands.CreateOctopushCmd(logger).Execute()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func CreateServerCmd(logger *zap.Logger) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "octopushserver",
|
||||
}
|
||||
|
||||
cmd.AddCommand(NewStartServerCommand(logger))
|
||||
|
||||
return cmd
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/server"
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func NewStartServerCommand(logger *zap.Logger) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "start",
|
||||
Short: "Start the octopush server",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return server.Start(logger)
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/octopush/cmd/server/commands"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/logger"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func main() {
|
||||
logger, err := logger.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_ = logger.Sync()
|
||||
|
||||
zap.ReplaceGlobals(logger)
|
||||
|
||||
Execute(logger)
|
||||
}
|
||||
|
||||
func Execute(logger *zap.Logger) {
|
||||
err := commands.CreateServerCmd(logger).Execute()
|
||||
if err != nil {
|
||||
logger.Error("execution failed", zap.Error(err))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
-----BEGIN PGP PRIVATE KEY BLOCK-----
|
||||
|
||||
lIYEYx8kxRYJKwYBBAHaRw8BAQdAwlYhGGWpLSSxZoHUmzvl6iJeZgtfKu/8/cjt
|
||||
LLQ8Swf+BwMCGPF3fdZbweT7+Y/bMMnelXmhYsTgEk30h+FeXOnGy/ZvJgnqoBed
|
||||
eRPRO5VDN4xq30D8zp04em8tgPXXS50yXvf7PUIKcx4u0IDteTC/Q7QjS3Jha2Vu
|
||||
IDxrcmFrZW5Aa2FzcGVyaGVybWFuc2VuLmNvbT6IkwQTFgoAOxYhBKh3AMKI2yc/
|
||||
qX90YXHawJCw+EZkBQJjHyTFAhsDBQsJCAcCAiICBhUKCQgLAgQWAgMBAh4HAheA
|
||||
AAoJEHHawJCw+EZkJMQA/AgeMkam18RasuPcl9kiiFkE2EA2TvO25IieZesbCEf5
|
||||
APwLjuXkMNYrPSAGPk0VZY7Eq8hWQd3qh9GHV9vDEUvND5yLBGMfJMUSCisGAQQB
|
||||
l1UBBQEBB0D4pGbjQW+s2aYO3DZX7M0yyq4JkZ+Wana3v2BuAXXYEwMBCAf+BwMC
|
||||
7hV7XuPdNrP7q1BylZe5GKz0TP0LSRbVjPgnetTyDqOaWEtdRzc996rBR0WcvUJO
|
||||
xN7oRR8XNMp1v6Up2LcvUs6XDpJ4f1MBGh3npytF7oh4BBgWCgAgFiEEqHcAwojb
|
||||
Jz+pf3RhcdrAkLD4RmQFAmMfJMUCGwwACgkQcdrAkLD4RmTvQgEAqGhqQuiZQskW
|
||||
Zbr27HBpQIukcIOVFle+wNXNyhKTJlkBAKoM/wTrQNIyS2gnGPQ1IE/AtDhMvwsV
|
||||
hCIzhb/ybLMH
|
||||
=9Nw9
|
||||
-----END PGP PRIVATE KEY BLOCK-----
|
61
go.mod
61
go.mod
@ -1,61 +0,0 @@
|
||||
module git.front.kjuulh.io/kjuulh/octopush
|
||||
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
code.gitea.io/sdk/gitea v0.15.1
|
||||
git.front.kjuulh.io/kjuulh/curre v1.3.5
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4
|
||||
github.com/gin-contrib/zap v0.1.0
|
||||
github.com/gin-gonic/gin v1.8.1
|
||||
github.com/go-git/go-git/v5 v5.4.2
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/spf13/cobra v1.6.1
|
||||
github.com/stretchr/testify v1.8.1
|
||||
github.com/whilp/git-urls v1.0.0
|
||||
go.uber.org/zap v1.23.0
|
||||
golang.org/x/net v0.2.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Microsoft/go-winio v0.5.2 // indirect
|
||||
github.com/acomagu/bufpipe v1.0.3 // indirect
|
||||
github.com/cloudflare/circl v1.1.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/emirpasic/gods v1.18.1 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-git/gcfg v1.5.0 // indirect
|
||||
github.com/go-git/go-billy/v5 v5.3.1 // indirect
|
||||
github.com/go-playground/locales v0.14.0 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
||||
github.com/go-playground/validator/v10 v10.10.0 // indirect
|
||||
github.com/goccy/go-json v0.9.7 // indirect
|
||||
github.com/hashicorp/go-version v1.2.1 // indirect
|
||||
github.com/imdario/mergo v0.3.12 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.1 // indirect
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/kevinburke/ssh_config v1.2.0 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/sergi/go-diff v1.2.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/ugorji/go/codec v1.2.7 // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.2 // indirect
|
||||
go.opentelemetry.io/otel v1.10.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.10.0 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/multierr v1.8.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
|
||||
golang.org/x/sys v0.2.0 // indirect
|
||||
golang.org/x/text v0.4.0 // indirect
|
||||
google.golang.org/protobuf v1.28.0 // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
285
go.sum
285
go.sum
@ -1,285 +0,0 @@
|
||||
code.gitea.io/gitea-vet v0.2.1/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE=
|
||||
code.gitea.io/sdk/gitea v0.15.1 h1:WJreC7YYuxbn0UDaPuWIe/mtiNKTvLN8MLkaw71yx/M=
|
||||
code.gitea.io/sdk/gitea v0.15.1/go.mod h1:klY2LVI3s3NChzIk/MzMn7G1FHrfU7qd63iSMVoHRBA=
|
||||
git.front.kjuulh.io/kjuulh/curre v1.3.5 h1:oKYh5Z0vInjViLnS4ppzK0G2Mnj7vXq8mA5i/rsWId4=
|
||||
git.front.kjuulh.io/kjuulh/curre v1.3.5/go.mod h1:m7WpSehONLqPh/XF3F0BI0UOpLOfGuDmDEFI1XsM6fE=
|
||||
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
|
||||
github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
|
||||
github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA=
|
||||
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20220822140716-1678d6eb0cbe h1:R2HeCk7SG/XpoYZlEeI1v7sId7w2AMWwzOaVqXn45FE=
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20220822140716-1678d6eb0cbe/go.mod h1:UBYPn8k0D56RtnR8RFQMjmh4KrZzWJ5o7Z9SYjossQ8=
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4 h1:ra2OtmuW0AE5csawV4YXMNGNQQXvLRps3z2Z59OPO+I=
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4/go.mod h1:UBYPn8k0D56RtnR8RFQMjmh4KrZzWJ5o7Z9SYjossQ8=
|
||||
github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk=
|
||||
github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
|
||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
|
||||
github.com/cloudflare/circl v1.1.0 h1:bZgT/A+cikZnKIwn7xL2OBj012Bmvho/o6RpRvv3GKY=
|
||||
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
|
||||
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
|
||||
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-contrib/zap v0.0.2 h1:VnIucI+kUsxgzmcrX0gMk19a2I12KirTxi+ufuT2xZk=
|
||||
github.com/gin-contrib/zap v0.0.2/go.mod h1:2vZj8gTuOYOfottCirxZr9gNM/Q1yk2iSVn15SUVG5A=
|
||||
github.com/gin-contrib/zap v0.1.0 h1:RMSFFJo34XZogV62OgOzvrlaMNmXrNxmJ3bFmMwl6Cc=
|
||||
github.com/gin-contrib/zap v0.1.0/go.mod h1:hvnZaPs478H1PGvRP8w89ZZbyJUiyip4ddiI/53WG3o=
|
||||
github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U=
|
||||
github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8=
|
||||
github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk=
|
||||
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
|
||||
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
||||
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
|
||||
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
|
||||
github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
|
||||
github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34=
|
||||
github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
|
||||
github.com/go-git/go-git-fixtures/v4 v4.2.1 h1:n9gGL1Ct/yIw+nfsfr8s4+sbhT+Ncu2SubfXjIWgci8=
|
||||
github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0=
|
||||
github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4=
|
||||
github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
|
||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
||||
github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU=
|
||||
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
|
||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||
github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
|
||||
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
|
||||
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
||||
github.com/go-playground/validator/v10 v10.10.0 h1:I7mrTYv78z8k8VXa/qJlOlEXn/nBh+BF8dHX5nt/dr0=
|
||||
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
|
||||
github.com/goccy/go-json v0.9.7 h1:IcB+Aqpx/iMHu5Yooh7jEzJk1JZ7Pjtmys2ukPr7EeM=
|
||||
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI=
|
||||
github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
|
||||
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
|
||||
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
|
||||
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
|
||||
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
|
||||
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
|
||||
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
|
||||
github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A=
|
||||
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/pelletier/go-toml/v2 v2.0.1 h1:8e3L2cCQzLFi2CR4g7vGFuFxX7Jl1kKX8gW+iV0GUKU=
|
||||
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
|
||||
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
|
||||
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
|
||||
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
|
||||
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
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/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
|
||||
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
|
||||
github.com/whilp/git-urls v1.0.0 h1:95f6UMWN5FKW71ECsXRUd3FVYiXdrE7aX4NZKcPmIjU=
|
||||
github.com/whilp/git-urls v1.0.0/go.mod h1:J16SAmobsqc3Qcy98brfl5f5+e0clUvg1krgwk/qCfE=
|
||||
github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0=
|
||||
github.com/xanzy/ssh-agent v0.3.2 h1:eKj4SX2Fe7mui28ZgnFW5fmTz1EIr7ugo5s6wDxdHBM=
|
||||
github.com/xanzy/ssh-agent v0.3.2/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
go.opentelemetry.io/otel v1.10.0 h1:Y7DTJMR6zs1xkS/upamJYk0SxxN4C9AqRd77jmZnyY4=
|
||||
go.opentelemetry.io/otel v1.10.0/go.mod h1:NbvWjCthWHKBEUMpf0/v8ZRZlni86PpGFEMA9pnQSnQ=
|
||||
go.opentelemetry.io/otel/trace v1.10.0 h1:npQMbR8o7mum8uF95yFbOEJffhs1sbCOfDh8zAJiH5E=
|
||||
go.opentelemetry.io/otel/trace v1.10.0/go.mod h1:Sij3YYczqAdz+EhmGhE6TpTxUO5/F/AzrK+kxfGqySM=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
|
||||
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
|
||||
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
|
||||
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
|
||||
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
|
||||
go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI=
|
||||
go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY=
|
||||
go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY=
|
||||
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM=
|
||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220909164309-bea034e7d591 h1:D0B/7al0LLrVC8aWF4+oxpv/m8bc7ViFfVS8/gXGdqI=
|
||||
golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||
golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=
|
||||
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
|
||||
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
|
||||
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220909162455-aba9fc2a8ff2 h1:wM1k/lXfpc5HdkJJyW9GELpd8ERGdnh8sMGL6Gzq3Ho=
|
||||
golang.org/x/sys v0.0.0-20220909162455-aba9fc2a8ff2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
|
||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200325010219-a49f79bcc224/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
@ -1,25 +0,0 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
package integrationtest_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/server"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func MainTest(t *testing.M) {
|
||||
logger, err := zap.NewDevelopment()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = server.Start(logger)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
os.Exit(t.Run())
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
package integrationtest_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/storage"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestInitializeStorage(t *testing.T) {
|
||||
t.Parallel()
|
||||
storage, cfg := prepareService(t)
|
||||
err := storage.InitializeStorage(context.Background())
|
||||
require.NoError(t, err)
|
||||
|
||||
if _, err := os.Stat(path.Join(cfg.Path, "storage")); os.IsNotExist(err) {
|
||||
require.NoError(t, err, "could not create storage directory")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCleanupStorage(t *testing.T) {
|
||||
t.Parallel()
|
||||
storage, _ := prepareService(t)
|
||||
err := storage.InitializeStorage(context.Background())
|
||||
require.NoError(t, err)
|
||||
|
||||
err = storage.CleanupStorage(context.Background())
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestCreateArea(t *testing.T) {
|
||||
t.Parallel()
|
||||
storage, cfg := prepareService(t)
|
||||
err := storage.InitializeStorage(context.Background())
|
||||
require.NoError(t, err)
|
||||
|
||||
area, err := storage.CreateArea(context.Background())
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, area)
|
||||
require.NotEmpty(t, area.Path)
|
||||
require.Contains(t, area.Path, cfg.Path)
|
||||
}
|
||||
|
||||
func TestRemoveArea(t *testing.T) {
|
||||
t.Parallel()
|
||||
storage, _ := prepareService(t)
|
||||
err := storage.InitializeStorage(context.Background())
|
||||
require.NoError(t, err)
|
||||
area, err := storage.CreateArea(context.Background())
|
||||
require.NoError(t, err)
|
||||
|
||||
err = storage.RemoveArea(context.Background(), area)
|
||||
require.NoError(t, err)
|
||||
|
||||
if _, err := os.Stat(area.Path); os.IsNotExist(err) {
|
||||
require.Error(t, err, "directory could not be removed")
|
||||
return
|
||||
}
|
||||
t.Fatal("directory could not be removed")
|
||||
}
|
||||
|
||||
func prepareService(t *testing.T) (*storage.Service, *storage.StorageConfig) {
|
||||
cfg := &storage.StorageConfig{
|
||||
Path: t.TempDir(),
|
||||
}
|
||||
|
||||
return storage.NewService(cfg), cfg
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
package actions
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/actions/builders"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/actions/querier"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/schema"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/storage"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type Action struct {
|
||||
Schema *schema.OctopushSchema
|
||||
SchemaPath string
|
||||
}
|
||||
|
||||
func (a *Action) Execute(ctx context.Context, area *storage.Area) error {
|
||||
for _, action := range a.Schema.Actions {
|
||||
switch action.Type {
|
||||
case "go":
|
||||
exe, err := builders.NewGo(zap.L()).Build(ctx, a.SchemaPath, action.Entry)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = exe(ctx, area.Path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
zap.L().Debug("Execution done")
|
||||
|
||||
case "docker-build":
|
||||
zap.L().Debug("Building docker-build")
|
||||
runCmd, err := builders.NewDockerBuild(zap.L()).Build(ctx, a.SchemaPath, action.Entry)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = runCmd(ctx, area.Path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.New("could not determine action type")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Action) Query(ctx context.Context, area *storage.Area) ([]string, bool, error) {
|
||||
for _, query := range a.Schema.Queries {
|
||||
switch query.Type {
|
||||
case "grep":
|
||||
exe, err := querier.NewRipGrep(zap.L()).Build(ctx, a.SchemaPath, query.Query)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
output, found, err := exe(ctx, area.Path)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
zap.L().Debug("Execution done")
|
||||
|
||||
return output, found, nil
|
||||
|
||||
default:
|
||||
return nil, false, errors.New("could not determine query type")
|
||||
}
|
||||
}
|
||||
|
||||
return nil, false, nil
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
package actions
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/schema"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/providers"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/storage"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type (
|
||||
ActionCreatorOps struct {
|
||||
RepositoryUrl string
|
||||
Branch string
|
||||
Path string
|
||||
}
|
||||
|
||||
ActionCreator struct {
|
||||
logger *zap.Logger
|
||||
storage *storage.Service
|
||||
git *providers.GoGit
|
||||
}
|
||||
|
||||
ActionCreatorDeps interface {
|
||||
GetStorageService() *storage.Service
|
||||
GetGitProvider() *providers.GoGit
|
||||
}
|
||||
)
|
||||
|
||||
func NewActionCreator(logger *zap.Logger, deps ActionCreatorDeps) *ActionCreator {
|
||||
return &ActionCreator{
|
||||
logger: logger,
|
||||
storage: deps.GetStorageService(),
|
||||
git: deps.GetGitProvider(),
|
||||
}
|
||||
}
|
||||
|
||||
func (ac *ActionCreator) Prepare(ctx context.Context, ops *ActionCreatorOps) (*Action, error) {
|
||||
area, err := ac.storage.CreateArea(ctx)
|
||||
if err != nil {
|
||||
ac.logger.Error("failed to allocate area", zap.Error(err))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cloneCtx, _ := context.WithTimeout(ctx, time.Second*10)
|
||||
_, err = ac.git.CloneBranch(cloneCtx, area, ops.RepositoryUrl, ops.Branch)
|
||||
if err != nil {
|
||||
ac.logger.Error("could not clone repo", zap.Error(err))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
executorUrl := path.Join(area.Path, ops.Path)
|
||||
if _, err = os.Stat(executorUrl); os.IsNotExist(err) {
|
||||
return nil, fmt.Errorf("path is invalid: %s", ops.Path)
|
||||
}
|
||||
|
||||
contents, err := os.ReadFile(path.Join(executorUrl, "octopush.yml"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
octopushSchema, err := schema.Unmarshal(string(contents))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ac.logger.Debug("Action creator done")
|
||||
return &Action{
|
||||
Schema: octopushSchema,
|
||||
SchemaPath: executorUrl,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (ac *ActionCreator) Cleanup(ctx context.Context, area *storage.Area) {
|
||||
ac.logger.Debug("Removing area", zap.String("path", area.Path))
|
||||
err := ac.storage.RemoveArea(ctx, area)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
package builders
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapio"
|
||||
)
|
||||
|
||||
type DockerBuild struct {
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
func NewDockerBuild(logger *zap.Logger) *DockerBuild {
|
||||
return &DockerBuild{logger: logger}
|
||||
}
|
||||
|
||||
type DockerRunCommand func(ctx context.Context, victimPath string) error
|
||||
|
||||
func (g *DockerBuild) Build(ctx context.Context, modulePath, entryPath string) (DockerRunCommand, error) {
|
||||
g.logger.Debug("Building docker image", zap.String("actiondir", modulePath), zap.String("entry", entryPath))
|
||||
|
||||
if _, err := os.Stat(fmt.Sprintf("%s/%s", modulePath, entryPath)); os.IsNotExist(err) {
|
||||
return nil, errors.New("could not find entry")
|
||||
}
|
||||
|
||||
b := make([]byte, 20)
|
||||
_, err := rand.Reader.Read(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tag := hex.EncodeToString(b)
|
||||
buildDockerCmd := fmt.Sprintf("(cd %s; docker build -f %s --tag octopush/%s .)", modulePath, entryPath, tag)
|
||||
g.logger.Debug("Running command", zap.String("command", buildDockerCmd))
|
||||
|
||||
cmd := exec.CommandContext(
|
||||
ctx,
|
||||
"/bin/bash",
|
||||
"-c",
|
||||
buildDockerCmd,
|
||||
)
|
||||
|
||||
debugwriter := &zapio.Writer{
|
||||
Log: g.logger,
|
||||
Level: zap.DebugLevel,
|
||||
}
|
||||
defer debugwriter.Close()
|
||||
|
||||
cmd.Stdout = debugwriter
|
||||
cmd.Stderr = debugwriter
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = cmd.Wait()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
g.logger.Debug("Docker image built!")
|
||||
|
||||
return func(ctx context.Context, victimPath string) error {
|
||||
g.logger.Debug("Executing script", zap.String("victim", victimPath))
|
||||
|
||||
cmd := exec.CommandContext(
|
||||
ctx,
|
||||
"/bin/bash",
|
||||
"-c",
|
||||
fmt.Sprintf("docker run --rm -v %s/:/src/work/ octopush/%s", victimPath, tag),
|
||||
)
|
||||
|
||||
runDockerWriter := &zapio.Writer{
|
||||
Log: g.logger,
|
||||
Level: zap.DebugLevel,
|
||||
}
|
||||
defer runDockerWriter.Close()
|
||||
|
||||
cmd.Stdout = runDockerWriter
|
||||
cmd.Stderr = runDockerWriter
|
||||
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return cmd.Wait()
|
||||
}, nil
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package builders
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type Go struct {
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
func NewGo(logger *zap.Logger) *Go {
|
||||
return &Go{logger: logger}
|
||||
}
|
||||
|
||||
type GoExecutable func(ctx context.Context, victimPath string) error
|
||||
|
||||
func (g *Go) Build(ctx context.Context, modulePath, entryPath string) (GoExecutable, error) {
|
||||
g.logger.Debug("Building go binary", zap.String("actiondir", modulePath), zap.String("entry", entryPath))
|
||||
|
||||
if _, err := os.Stat(fmt.Sprintf("%s/%s", modulePath, entryPath)); os.IsNotExist(err) {
|
||||
return nil, errors.New("could not find entry")
|
||||
}
|
||||
|
||||
err := exec.CommandContext(
|
||||
ctx,
|
||||
"/bin/bash",
|
||||
"-c",
|
||||
fmt.Sprintf("(cd %s; go build -o main %s)", modulePath, entryPath),
|
||||
).Run()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
g.logger.Debug("Go binary built!")
|
||||
|
||||
return func(ctx context.Context, victimPath string) error {
|
||||
g.logger.Debug("Executing script", zap.String("victim", victimPath))
|
||||
return exec.CommandContext(ctx, "/bin/bash", "-c", fmt.Sprintf("(cd %s; %s/main)", victimPath, modulePath)).Run()
|
||||
}, nil
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
package querier
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapio"
|
||||
)
|
||||
|
||||
type RipGrep struct {
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
func NewRipGrep(logger *zap.Logger) *RipGrep {
|
||||
return &RipGrep{logger: logger}
|
||||
}
|
||||
|
||||
type RipGrepCommand func(ctx context.Context, victimPath string) ([]string, bool, error)
|
||||
|
||||
func (g *RipGrep) Build(ctx context.Context, modulePath, query string) (RipGrepCommand, error) {
|
||||
g.logger.Debug("Pulling docker image", zap.String("actiondir", modulePath), zap.String("query", query))
|
||||
|
||||
pullDockerImage := "docker pull mbologna/docker-ripgrep"
|
||||
g.logger.Debug("Running command", zap.String("command", pullDockerImage))
|
||||
|
||||
cmd := exec.CommandContext(
|
||||
ctx,
|
||||
"/bin/bash",
|
||||
"-c",
|
||||
pullDockerImage,
|
||||
)
|
||||
|
||||
debugwriter := &zapio.Writer{
|
||||
Log: g.logger,
|
||||
Level: zap.DebugLevel,
|
||||
}
|
||||
defer debugwriter.Close()
|
||||
|
||||
cmd.Stdout = debugwriter
|
||||
cmd.Stderr = debugwriter
|
||||
err := cmd.Start()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = cmd.Wait()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
g.logger.Debug("Docker image pulled")
|
||||
|
||||
return func(ctx context.Context, victimPath string) ([]string, bool, error) {
|
||||
g.logger.Debug("Executing script", zap.String("victim", victimPath))
|
||||
|
||||
runRipGrepCmd := fmt.Sprintf("docker run --rm -v %s/:/data:ro mbologna/docker-ripgrep rg -i '%s' || true", victimPath, query)
|
||||
|
||||
g.logger.Debug("Execute ripgrep query", zap.String("command", runRipGrepCmd))
|
||||
|
||||
cmd := exec.CommandContext(
|
||||
ctx,
|
||||
"/bin/bash",
|
||||
"-c",
|
||||
runRipGrepCmd,
|
||||
)
|
||||
|
||||
runDockerWriter := &zapio.Writer{
|
||||
Log: g.logger,
|
||||
Level: zap.DebugLevel,
|
||||
}
|
||||
defer runDockerWriter.Close()
|
||||
|
||||
builder := &strings.Builder{}
|
||||
combinedWriter := io.MultiWriter(runDockerWriter, builder)
|
||||
|
||||
cmd.Stdout = combinedWriter
|
||||
cmd.Stderr = combinedWriter
|
||||
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
err = cmd.Wait()
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
contents := strings.Split(builder.String(), "\n")
|
||||
validatedOutput := make([]string, 0)
|
||||
|
||||
for _, c := range contents {
|
||||
if !strings.Contains(c, "WARNING:") {
|
||||
validatedOutput = append(validatedOutput, c)
|
||||
}
|
||||
}
|
||||
|
||||
found := len(validatedOutput) > 0
|
||||
|
||||
return validatedOutput, found, nil
|
||||
}, nil
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func HealthRoute(app *gin.Engine) {
|
||||
healthRoute := app.Group("/health")
|
||||
healthRoute.GET("/ready", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "healthy",
|
||||
})
|
||||
})
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/commands"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/serverdeps"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/jobs"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func CommandRoute(logger *zap.Logger, app *gin.Engine, deps *serverdeps.ServerDeps) {
|
||||
commandRoute := app.Group("commands")
|
||||
commandRoute.POST("processRepos", func(c *gin.Context) {
|
||||
type processReposRequest struct {
|
||||
Repository string `json:"repository"`
|
||||
Branch string `json:"branch"`
|
||||
Path string `json:"path"`
|
||||
}
|
||||
var request processReposRequest
|
||||
err := c.BindJSON(&request)
|
||||
if err != nil {
|
||||
logger.Info("could not bind request", zap.String("request", "processRepo"), zap.Error(err))
|
||||
c.AbortWithStatus(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
jobId := uuid.New().String()
|
||||
|
||||
go func(repository string, branch string, path string, jobId string) {
|
||||
ctx := context.WithValue(context.Background(), jobs.JobId{}, jobId)
|
||||
processRepos := commands.NewProcessRepos(logger, deps)
|
||||
err = processRepos.Process(ctx, repository, branch, path)
|
||||
if err != nil {
|
||||
logger.Error("could not process repo", zap.Error(err))
|
||||
}
|
||||
}(request.Repository, request.Branch, request.Path, jobId)
|
||||
|
||||
c.Status(http.StatusAccepted)
|
||||
})
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/serverdeps"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func BuildApi(logger *zap.Logger, app *gin.Engine, deps *serverdeps.ServerDeps) {
|
||||
HealthRoute(app)
|
||||
CommandRoute(logger, app, deps)
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/curre"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/server"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/serverdeps"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/signer"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func Start(ctx context.Context, logger *zap.Logger) (*serverdeps.ServerDeps, curre.CleanupFunc, error) {
|
||||
deps := serverdeps.NewServerDeps(logger)
|
||||
|
||||
readyChan := make(chan curre.ComponentsAreReady, 1)
|
||||
|
||||
cleanupFunc, err := curre.NewManager().
|
||||
Register(
|
||||
server.NewStorageServer(logger.With(zap.Namespace("storage")), deps),
|
||||
).
|
||||
Register(
|
||||
signer.NewOpenPGPApp(deps.GetOpenPGP()),
|
||||
).
|
||||
RunNonBlocking(ctx, readyChan)
|
||||
|
||||
<-readyChan
|
||||
|
||||
return deps, cleanupFunc, err
|
||||
}
|
@ -1,241 +0,0 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/actions"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/gitproviders"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/schema"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/providers"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/storage"
|
||||
giturls "github.com/whilp/git-urls"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type (
|
||||
ProcessRepos struct {
|
||||
logger *zap.Logger
|
||||
storage *storage.Service
|
||||
git *providers.GoGit
|
||||
actionCreator *actions.ActionCreator
|
||||
gitea *gitproviders.Gitea
|
||||
}
|
||||
|
||||
ProcessReposDeps interface {
|
||||
GetStorageService() *storage.Service
|
||||
GetGitProvider() *providers.GoGit
|
||||
GetActionCreator() *actions.ActionCreator
|
||||
GetGitea() *gitproviders.Gitea
|
||||
}
|
||||
)
|
||||
|
||||
func NewProcessRepos(logger *zap.Logger, deps ProcessReposDeps) *ProcessRepos {
|
||||
return &ProcessRepos{
|
||||
logger: logger,
|
||||
storage: deps.GetStorageService(),
|
||||
git: deps.GetGitProvider(),
|
||||
actionCreator: deps.GetActionCreator(),
|
||||
gitea: deps.GetGitea(),
|
||||
}
|
||||
}
|
||||
|
||||
func (pr *ProcessRepos) Process(ctx context.Context, repository string, branch string, actionPath string) error {
|
||||
action, err := pr.actionCreator.Prepare(ctx, &actions.ActionCreatorOps{
|
||||
RepositoryUrl: repository,
|
||||
Branch: branch,
|
||||
Path: actionPath,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
repositoryUrls, err := pr.getRepoUrls(ctx, action.Schema)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(len(repositoryUrls))
|
||||
|
||||
for _, repoUrl := range repositoryUrls {
|
||||
go func(ctx context.Context, repoUrl string) {
|
||||
defer func() {
|
||||
wg.Done()
|
||||
}()
|
||||
err := pr.processRepo(ctx, repoUrl, action)
|
||||
if err != nil {
|
||||
pr.logger.Error("could not process repo", zap.Error(err))
|
||||
}
|
||||
}(ctx, repoUrl)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
pr.logger.Debug("finished processing all repos", zap.Strings("repos", repositoryUrls))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pr *ProcessRepos) getRepoUrls(ctx context.Context, schema *schema.OctopushSchema) ([]string, error) {
|
||||
repoUrls := make([]string, 0)
|
||||
|
||||
repoUrls = append(repoUrls, schema.Select.Repositories...)
|
||||
|
||||
for _, provider := range schema.Select.Providers {
|
||||
repos, err := pr.gitea.ListRepositoriesForOrganization(ctx, provider.Gitea, provider.Organisation)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
repoUrls = append(repoUrls, repos...)
|
||||
}
|
||||
|
||||
return repoUrls, nil
|
||||
}
|
||||
|
||||
func (pr *ProcessRepos) processRepo(ctx context.Context, repoUrl string, action *actions.Action) error {
|
||||
cleanup, area, err := pr.prepareAction(ctx)
|
||||
defer func() {
|
||||
if cleanup != nil {
|
||||
cleanup(ctx)
|
||||
}
|
||||
}()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
repo, err := pr.clone(ctx, area, repoUrl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(action.Schema.Queries) > 0 {
|
||||
result, found, err := action.Query(ctx, area)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if found {
|
||||
pr.logger.Info("Query result", zap.Strings("result", result))
|
||||
// TODO: Append to real result, and return together
|
||||
}
|
||||
}
|
||||
|
||||
if len(action.Schema.Actions) > 0 {
|
||||
err = action.Execute(ctx, area)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = pr.commit(ctx, area, repo, repoUrl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
pr.logger.Debug("processing done", zap.String("path", area.Path), zap.String("repoUrl", repoUrl))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pr *ProcessRepos) prepareAction(
|
||||
ctx context.Context,
|
||||
) (func(ctx context.Context), *storage.Area, error) {
|
||||
pr.logger.Debug("Creating area")
|
||||
area, err := pr.storage.CreateArea(ctx)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
cleanupfunc := func(ctx context.Context) {
|
||||
pr.logger.Debug("Removing area", zap.String("path", area.Path))
|
||||
err = pr.storage.RemoveArea(ctx, area)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
return cleanupfunc, area, nil
|
||||
}
|
||||
|
||||
func (pr *ProcessRepos) clone(ctx context.Context, area *storage.Area, repoUrl string) (*providers.GoGitRepo, error) {
|
||||
pr.logger.Debug("Cloning repo", zap.String("path", area.Path), zap.String("repoUrl", repoUrl))
|
||||
cloneCtx, _ := context.WithTimeout(ctx, time.Second*5)
|
||||
repo, err := pr.git.Clone(cloneCtx, area, repoUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = pr.git.CreateBranch(ctx, repo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return repo, nil
|
||||
}
|
||||
|
||||
func (pr *ProcessRepos) commit(ctx context.Context, area *storage.Area, repo *providers.GoGitRepo, repoUrl string) error {
|
||||
wt, err := pr.git.Add(ctx, area, repo)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not add file: %w", err)
|
||||
}
|
||||
|
||||
status, err := wt.Status()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if status.IsClean() {
|
||||
// TODO: check for pr
|
||||
pr.logger.Info("Returning early, as no modifications are detected")
|
||||
//return nil
|
||||
}
|
||||
|
||||
err = pr.git.Commit(ctx, repo)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not get diff: %w", err)
|
||||
}
|
||||
|
||||
dryrun := false
|
||||
if !dryrun {
|
||||
|
||||
err = pr.git.Push(ctx, repo)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not push to repo: %w", err)
|
||||
}
|
||||
|
||||
url, err := giturls.Parse(repoUrl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
head, err := repo.GetHEAD()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
path := strings.Split(url.Path, "/")
|
||||
pr.logger.Debug("path string", zap.Strings("paths", path), zap.String("HEAD", head))
|
||||
|
||||
org := path[0]
|
||||
repoName := path[1]
|
||||
semanticName, _, ok := strings.Cut(repoName, ".")
|
||||
if !ok {
|
||||
semanticName = repoName
|
||||
}
|
||||
|
||||
originHead, err := pr.git.GetOriginHEADForRepo(ctx, repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = pr.gitea.CreatePr(ctx, fmt.Sprintf("%s://%s", "https", url.Host), org, semanticName, head, originHead, "octopush-apply")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
@ -1,143 +0,0 @@
|
||||
package gitproviders
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type Gitea struct {
|
||||
logger *zap.Logger
|
||||
giteamu sync.Mutex
|
||||
giteaClients map[string]*gitea.Client
|
||||
}
|
||||
|
||||
func NewGitea(logger *zap.Logger) *Gitea {
|
||||
return &Gitea{
|
||||
logger: logger,
|
||||
giteamu: sync.Mutex{},
|
||||
giteaClients: make(map[string]*gitea.Client, 0),
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Gitea) ListRepositoriesForOrganization(
|
||||
ctx context.Context,
|
||||
server string,
|
||||
organization string,
|
||||
) ([]string, error) {
|
||||
client, err := g.getOrCreateClient(ctx, server)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
g.logger.Debug("Listing repos for gitea", zap.String("server", server))
|
||||
repos, resp, err := client.ListOrgRepos(organization, gitea.ListOrgReposOptions{
|
||||
ListOptions: gitea.ListOptions{
|
||||
Page: 0,
|
||||
PageSize: 20,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not list repos: %w", err)
|
||||
}
|
||||
|
||||
if resp.StatusCode >= 300 {
|
||||
return nil, fmt.Errorf("gitea responded with a non 200 status code (gitea response: %s)", resp.Status)
|
||||
}
|
||||
|
||||
repoUrls := make([]string, len(repos))
|
||||
for i, repo := range repos {
|
||||
repoUrls[i] = repo.SSHURL
|
||||
}
|
||||
|
||||
return repoUrls, err
|
||||
}
|
||||
|
||||
func (g *Gitea) CreatePr(
|
||||
ctx context.Context,
|
||||
server string,
|
||||
organization string,
|
||||
repository string,
|
||||
head string,
|
||||
base string,
|
||||
actionName string,
|
||||
) error {
|
||||
client, err := g.getOrCreateClient(ctx, server)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
prs, _, err := client.ListRepoPullRequests(organization, repository, gitea.ListPullRequestsOptions{
|
||||
ListOptions: gitea.ListOptions{
|
||||
Page: 0,
|
||||
PageSize: 30,
|
||||
},
|
||||
State: gitea.StateOpen,
|
||||
Sort: "recentupdate",
|
||||
Milestone: 0,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf(
|
||||
"could not list repos, needed because we need to check for conflicts. Original error: %w",
|
||||
err,
|
||||
)
|
||||
}
|
||||
for _, pr := range prs {
|
||||
if pr.Head.Name == head {
|
||||
g.logger.Info(
|
||||
"returning early from creating pull-request, as it already exists.",
|
||||
zap.String("repository", repository),
|
||||
zap.String("pull-request", pr.URL),
|
||||
)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
pr, _, err := client.CreatePullRequest(organization, repository, gitea.CreatePullRequestOption{
|
||||
Head: head,
|
||||
Base: base,
|
||||
Title: actionName,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
g.logger.Debug(
|
||||
"Created pr",
|
||||
zap.String("repository", repository),
|
||||
zap.String("branch", head),
|
||||
zap.String("pull-request", pr.URL),
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *Gitea) getOrCreateClient(ctx context.Context, server string) (*gitea.Client, error) {
|
||||
g.giteamu.Lock()
|
||||
defer g.giteamu.Unlock()
|
||||
client, ok := g.giteaClients[server]
|
||||
if !ok || client == nil {
|
||||
c, err := gitea.NewClient(server)
|
||||
username, ok := os.LookupEnv("GITEA_USERNAME")
|
||||
if !ok {
|
||||
return nil, errors.New("missing environment variable GITEA_USERNAME")
|
||||
}
|
||||
apitoken, ok := os.LookupEnv("GITEA_API_TOKEN")
|
||||
if !ok {
|
||||
return nil, errors.New("missing environment variable GITEA_API_TOKEN")
|
||||
}
|
||||
c.SetBasicAuth(username, apitoken)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
g.giteaClients[server] = c
|
||||
return c, nil
|
||||
}
|
||||
|
||||
return client, nil
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
func New() (*zap.Logger, error) {
|
||||
highPriority := zap.LevelEnablerFunc(func(lvl zapcore.Level) bool {
|
||||
return lvl >= zapcore.ErrorLevel
|
||||
})
|
||||
lowPriority := zap.LevelEnablerFunc(func(lvl zapcore.Level) bool {
|
||||
return lvl < zapcore.ErrorLevel // && lvl > zapcore.DebugLevel
|
||||
})
|
||||
|
||||
config := zap.NewDevelopmentEncoderConfig()
|
||||
config.EncodeTime = nil
|
||||
config.EncodeLevel = zapcore.CapitalColorLevelEncoder
|
||||
consoleEncoder := zapcore.NewConsoleEncoder(config)
|
||||
consoleDebugging := zapcore.Lock(os.Stdout)
|
||||
consoleErrors := zapcore.Lock(os.Stderr)
|
||||
|
||||
core := zapcore.NewTee(
|
||||
zapcore.NewCore(consoleEncoder, consoleErrors, highPriority),
|
||||
zapcore.NewCore(consoleEncoder, consoleDebugging, lowPriority),
|
||||
)
|
||||
|
||||
logger := zap.New(core)
|
||||
|
||||
return logger, nil
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package schema
|
||||
|
||||
import "gopkg.in/yaml.v3"
|
||||
|
||||
type OctopushSchema struct {
|
||||
ApiVersion string `yaml:"apiVersion"`
|
||||
Name string `yaml:"name"`
|
||||
Select struct {
|
||||
Repositories []string `yaml:"repositories"`
|
||||
Providers []struct {
|
||||
Gitea string `yaml:"gitea"`
|
||||
Organisation string `yaml:"organisation"`
|
||||
} `yaml:"providers"`
|
||||
} `yaml:"select"`
|
||||
Actions []struct {
|
||||
Type string `yaml:"type"`
|
||||
Entry string `yaml:"entry"`
|
||||
} `yaml:"actions"`
|
||||
Queries []struct {
|
||||
Type string `yaml:"type"`
|
||||
Query string `yaml:"query"`
|
||||
} `yaml:"queries"`
|
||||
}
|
||||
|
||||
func Unmarshal(raw string) (*OctopushSchema, error) {
|
||||
k := &OctopushSchema{}
|
||||
err := yaml.Unmarshal([]byte(raw), k)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return k, nil
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/curre"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/api"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/serverdeps"
|
||||
ginzap "github.com/gin-contrib/zap"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func NewGinHttpServer(logger *zap.Logger, deps *serverdeps.ServerDeps) curre.Component {
|
||||
var app *gin.Engine
|
||||
var server *http.Server
|
||||
|
||||
return curre.NewFunctionalComponent(&curre.FunctionalComponent{
|
||||
InitFunc: func(_ *curre.FunctionalComponent, _ context.Context) error {
|
||||
app = gin.New()
|
||||
app.UseH2C = true
|
||||
app.Use(ginzap.Ginzap(logger, time.RFC3339, true))
|
||||
app.Use(ginzap.RecoveryWithZap(logger, true))
|
||||
|
||||
api.BuildApi(logger, app, deps)
|
||||
|
||||
server = &http.Server{
|
||||
Addr: "127.0.0.1:3000",
|
||||
Handler: app,
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
StartFunc: func(_ *curre.FunctionalComponent, _ context.Context) error {
|
||||
if server != nil {
|
||||
err := server.ListenAndServe()
|
||||
if err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
StopFunc: func(_ *curre.FunctionalComponent, ctx context.Context) error {
|
||||
ctx, _ = context.WithTimeout(ctx, time.Second*10)
|
||||
if server != nil {
|
||||
server.Shutdown(ctx)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
})
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/curre"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/serverdeps"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/signer"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func Start(logger *zap.Logger) error {
|
||||
ctx := context.Background()
|
||||
|
||||
deps := serverdeps.NewServerDeps(logger)
|
||||
|
||||
return curre.NewManager().
|
||||
Register(NewGinHttpServer(logger.With(zap.Namespace("ginHttpServer")), deps)).
|
||||
Register(NewStorageServer(logger.With(zap.Namespace("storageServer")), deps)).
|
||||
Register(signer.NewOpenPGPApp(deps.GetOpenPGP())).
|
||||
Run(ctx)
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/curre"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/serverdeps"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func NewStorageServer(logger *zap.Logger, deps *serverdeps.ServerDeps) curre.Component {
|
||||
storage := deps.GetStorageService()
|
||||
return curre.NewFunctionalComponent(&curre.FunctionalComponent{
|
||||
InitFunc: func(_ *curre.FunctionalComponent, ctx context.Context) error {
|
||||
logger.Debug("Initializing storage")
|
||||
return storage.InitializeStorage(ctx)
|
||||
},
|
||||
StartFunc: func(fc *curre.FunctionalComponent, ctx context.Context) error {
|
||||
return nil
|
||||
},
|
||||
StopFunc: func(_ *curre.FunctionalComponent, ctx context.Context) error {
|
||||
logger.Debug("Cleaning up storage")
|
||||
ctx, _ = context.WithTimeout(ctx, time.Second*10)
|
||||
return storage.CleanupStorage(ctx)
|
||||
},
|
||||
})
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
package serverdeps
|
||||
|
||||
import (
|
||||
actionc "git.front.kjuulh.io/kjuulh/octopush/internal/actions"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/gitproviders"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/actions"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/providers"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/signer"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/storage"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type ServerDeps struct {
|
||||
logger *zap.Logger
|
||||
|
||||
storageConfig *storage.StorageConfig
|
||||
gitCfg *providers.GitConfig
|
||||
|
||||
openPGP *signer.OpenPGP
|
||||
}
|
||||
|
||||
func NewServerDeps(logger *zap.Logger) *ServerDeps {
|
||||
deps := &ServerDeps{
|
||||
logger: logger.With(zap.Namespace("serverdeps")),
|
||||
}
|
||||
|
||||
if storageCfg, err := storage.NewDefaultStorageConfig(); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
deps.storageConfig = storageCfg
|
||||
}
|
||||
|
||||
deps.gitCfg = &providers.GitConfig{
|
||||
AuthOption: providers.GIT_AUTH_SSH,
|
||||
User: "git",
|
||||
Password: "",
|
||||
AccessToken: "",
|
||||
SshPublicKeyFilePath: "/Users/kah/.ssh/id_ed25519",
|
||||
SshPrivateKeyPassword: "",
|
||||
}
|
||||
|
||||
openPGPConfig := &signer.OpenPgpConfig{
|
||||
PrivateKeyFilePath: "./example/testkey.private.pgp",
|
||||
PrivateKeyPassword: "somepassword",
|
||||
PrivateKeyIdentity: "kraken@kasperhermansen.com",
|
||||
}
|
||||
deps.openPGP = signer.NewOpenPGP(logger.With(zap.Namespace("openpgp")), openPGPConfig)
|
||||
|
||||
return deps
|
||||
}
|
||||
|
||||
func (deps *ServerDeps) GetStorageService() *storage.Service {
|
||||
return storage.NewService(deps.logger.With(zap.Namespace("storage")), deps.storageConfig)
|
||||
}
|
||||
|
||||
func (deps *ServerDeps) GetGitProvider() *providers.GoGit {
|
||||
return providers.NewGit(deps.logger.With(zap.Namespace("gitProvider")), deps.gitCfg, deps.openPGP)
|
||||
}
|
||||
|
||||
func (deps *ServerDeps) GetAction() *actions.Action {
|
||||
return actions.NewAction(deps.logger.With(zap.Namespace("action")))
|
||||
}
|
||||
|
||||
func (deps *ServerDeps) GetActionCreator() *actionc.ActionCreator {
|
||||
return actionc.NewActionCreator(deps.logger.With(zap.Namespace("action")), deps)
|
||||
}
|
||||
|
||||
func (deps *ServerDeps) GetGitea() *gitproviders.Gitea {
|
||||
return gitproviders.NewGitea(deps.logger.With(zap.Namespace("gitea")))
|
||||
}
|
||||
|
||||
func (deps *ServerDeps) GetOpenPGP() *signer.OpenPGP {
|
||||
return deps.openPGP
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package actions
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/storage"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type Predicate func(ctx context.Context, area *storage.Area) (bool, error)
|
||||
type ActionFunc func(ctx context.Context, area *storage.Area) error
|
||||
|
||||
type Action struct {
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
func NewAction(logger *zap.Logger) *Action {
|
||||
return &Action{logger: logger}
|
||||
}
|
||||
|
||||
func (a *Action) Run(ctx context.Context, area *storage.Area, predicate Predicate, action ActionFunc, dryrun bool) error {
|
||||
matches, err := predicate(ctx, area)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !matches {
|
||||
a.logger.Debug("repo doesn't match, skipping", zap.String("path", area.Path))
|
||||
return nil
|
||||
}
|
||||
|
||||
if dryrun {
|
||||
a.logger.Panic("dryrun selected, but not implemented yet")
|
||||
return nil
|
||||
}
|
||||
|
||||
err = action(ctx, area)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package jobs
|
||||
|
||||
type JobId struct {
|
||||
}
|
@ -1 +0,0 @@
|
||||
package providers
|
@ -1,339 +0,0 @@
|
||||
package providers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/signer"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/services/storage"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/config"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"github.com/go-git/go-git/v5/plumbing/object"
|
||||
"github.com/go-git/go-git/v5/plumbing/transport"
|
||||
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
||||
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapio"
|
||||
)
|
||||
|
||||
// GoGit is a native git provider, it can clone, pull
|
||||
// , push and as in abstraction on native git operations
|
||||
type GoGit struct {
|
||||
logger *zap.Logger
|
||||
gitConfig *GitConfig
|
||||
openPGP *signer.OpenPGP
|
||||
}
|
||||
|
||||
type GoGitRepo struct {
|
||||
repo *git.Repository
|
||||
}
|
||||
|
||||
func (gr *GoGitRepo) GetHEAD() (string, error) {
|
||||
head, err := gr.repo.Head()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return head.Name().Short(), nil
|
||||
}
|
||||
|
||||
type GitAuth string
|
||||
|
||||
const (
|
||||
GIT_AUTH_SSH GitAuth = "ssh"
|
||||
GIT_AUTH_USERNAME_PASSWORD GitAuth = "username_password"
|
||||
GIT_AUTH_ACCESS_TOKEN GitAuth = "access_token"
|
||||
GIT_AUTH_ANONYMOUS GitAuth = "anonymous"
|
||||
GIT_AUTH_SSH_AGENT GitAuth = "ssh_agent"
|
||||
)
|
||||
|
||||
type GitConfig struct {
|
||||
AuthOption GitAuth
|
||||
User string
|
||||
Password string
|
||||
AccessToken string
|
||||
SshPublicKeyFilePath string
|
||||
SshPrivateKeyPassword string
|
||||
}
|
||||
|
||||
func NewGit(logger *zap.Logger, gitConfig *GitConfig, openPGP *signer.OpenPGP) *GoGit {
|
||||
return &GoGit{logger: logger, gitConfig: gitConfig, openPGP: openPGP}
|
||||
}
|
||||
|
||||
func (g *GoGit) GetOriginHEADForRepo(ctx context.Context, gitRepo *GoGitRepo) (string, error) {
|
||||
auth, err := g.GetAuth()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
remote, err := gitRepo.repo.Remote("origin")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
refs, err := remote.ListContext(ctx, &git.ListOptions{
|
||||
Auth: auth,
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
headRef := ""
|
||||
for _, ref := range refs {
|
||||
//g.logger.Debug(ref.String())
|
||||
if ref.Target().IsBranch() {
|
||||
headRef = ref.Target().Short()
|
||||
}
|
||||
}
|
||||
|
||||
if headRef == "" {
|
||||
return "", errors.New("no upstream HEAD branch could be found")
|
||||
}
|
||||
|
||||
return headRef, nil
|
||||
}
|
||||
|
||||
func (g *GoGit) CloneBranch(ctx context.Context, storageArea *storage.Area, repoUrl string, branch string) (*GoGitRepo, error) {
|
||||
g.logger.Debug(
|
||||
"cloning repository",
|
||||
zap.String("repoUrl", repoUrl),
|
||||
zap.String("path", storageArea.Path),
|
||||
)
|
||||
|
||||
auth, err := g.GetAuth()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cloneOptions := git.CloneOptions{
|
||||
URL: repoUrl,
|
||||
Auth: auth,
|
||||
RemoteName: "origin",
|
||||
ReferenceName: plumbing.NewBranchReferenceName(branch),
|
||||
SingleBranch: false,
|
||||
NoCheckout: false,
|
||||
Depth: 1,
|
||||
RecurseSubmodules: 1,
|
||||
Progress: g.getProgressWriter(),
|
||||
Tags: 0,
|
||||
InsecureSkipTLS: false,
|
||||
CABundle: []byte{},
|
||||
}
|
||||
|
||||
repo, err := git.PlainCloneContext(ctx, storageArea.Path, false, &cloneOptions)
|
||||
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
g.logger.Debug("done cloning repo")
|
||||
|
||||
return &GoGitRepo{repo: repo}, nil
|
||||
}
|
||||
|
||||
func (g *GoGit) Clone(ctx context.Context, storageArea *storage.Area, repoUrl string) (*GoGitRepo, error) {
|
||||
g.logger.Debug(
|
||||
"cloning repository",
|
||||
zap.String("repoUrl", repoUrl),
|
||||
zap.String("path", storageArea.Path),
|
||||
)
|
||||
|
||||
auth, err := g.GetAuth()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cloneOptions := git.CloneOptions{
|
||||
URL: repoUrl,
|
||||
Auth: auth,
|
||||
RemoteName: "origin",
|
||||
ReferenceName: "",
|
||||
SingleBranch: false,
|
||||
NoCheckout: false,
|
||||
Depth: 1,
|
||||
RecurseSubmodules: 1,
|
||||
Progress: g.getProgressWriter(),
|
||||
Tags: 0,
|
||||
InsecureSkipTLS: false,
|
||||
CABundle: []byte{},
|
||||
}
|
||||
|
||||
repo, err := git.PlainCloneContext(ctx, storageArea.Path, false, &cloneOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
g.logger.Debug("done cloning repo")
|
||||
|
||||
return &GoGitRepo{repo: repo}, nil
|
||||
}
|
||||
|
||||
func (g *GoGit) getProgressWriter() *zapio.Writer {
|
||||
return &zapio.Writer{
|
||||
Log: g.logger.With(zap.String("process", "go-git")),
|
||||
Level: zap.DebugLevel,
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GoGit) Add(ctx context.Context, storageArea *storage.Area, gitRepo *GoGitRepo) (*git.Worktree, error) {
|
||||
worktree, err := gitRepo.repo.Worktree()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = worktree.AddWithOptions(&git.AddOptions{
|
||||
All: true,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
status, err := worktree.Status()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
g.logger.Debug("git status", zap.String("status", status.String()))
|
||||
|
||||
return worktree, nil
|
||||
}
|
||||
|
||||
func (g *GoGit) CreateBranch(ctx context.Context, gitRepo *GoGitRepo) error {
|
||||
worktree, err := gitRepo.repo.Worktree()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
refSpec := plumbing.NewBranchReferenceName("octopush-apply")
|
||||
err = gitRepo.repo.CreateBranch(&config.Branch{
|
||||
Name: "octopush-apply",
|
||||
Remote: "origin",
|
||||
Merge: refSpec,
|
||||
Rebase: "",
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create branch: %w", err)
|
||||
}
|
||||
|
||||
err = worktree.Checkout(&git.CheckoutOptions{
|
||||
Branch: plumbing.ReferenceName(refSpec.String()),
|
||||
Create: true,
|
||||
Force: false,
|
||||
Keep: false,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not checkout branch: %w", err)
|
||||
}
|
||||
|
||||
//remoteRef := plumbing.NewRemoteReferenceName("origin", "octopush-apply")
|
||||
//ref := plumbing.NewSymbolicReference(refSpec, remoteRef)
|
||||
//err = gitRepo.repo.Storer.SetReference(ref)
|
||||
//if err != nil {
|
||||
// return fmt.Errorf("could not set reference: %w", err)
|
||||
//}
|
||||
|
||||
auth, err := g.GetAuth()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = worktree.PullContext(ctx, &git.PullOptions{
|
||||
RemoteName: "origin",
|
||||
ReferenceName: "",
|
||||
SingleBranch: false,
|
||||
Depth: 1,
|
||||
Auth: auth,
|
||||
RecurseSubmodules: 1,
|
||||
Progress: g.getProgressWriter(),
|
||||
Force: true,
|
||||
InsecureSkipTLS: false,
|
||||
CABundle: []byte{},
|
||||
})
|
||||
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
|
||||
return fmt.Errorf("could not pull from origin: %w", err)
|
||||
}
|
||||
|
||||
g.logger.Debug("done creating branches")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *GoGit) Commit(ctx context.Context, gitRepo *GoGitRepo) error {
|
||||
worktree, err := gitRepo.repo.Worktree()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = worktree.Commit("some-commit", &git.CommitOptions{
|
||||
All: true,
|
||||
Author: &object.Signature{Name: "octopush", Email: "octopush@kasperhermansen.com", When: time.Now()},
|
||||
Committer: &object.Signature{Name: "octopush", Email: "octopush@kasperhermansen.com", When: time.Now()},
|
||||
SignKey: g.openPGP.SigningKey,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
g.logger.Debug("done commiting objects")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *GoGit) Push(ctx context.Context, gitRepo *GoGitRepo) error {
|
||||
auth, err := g.GetAuth()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = gitRepo.repo.PushContext(ctx, &git.PushOptions{
|
||||
RemoteName: "origin",
|
||||
RefSpecs: []config.RefSpec{},
|
||||
Auth: auth,
|
||||
Progress: g.getProgressWriter(),
|
||||
Prune: false,
|
||||
Force: true,
|
||||
InsecureSkipTLS: false,
|
||||
CABundle: []byte{},
|
||||
RequireRemoteRefs: []config.RefSpec{},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
g.logger.Debug("done pushing branch")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *GoGit) GetAuth() (transport.AuthMethod, error) {
|
||||
switch g.gitConfig.AuthOption {
|
||||
case GIT_AUTH_SSH:
|
||||
sshKey, err := ssh.NewPublicKeysFromFile(
|
||||
g.gitConfig.User,
|
||||
g.gitConfig.SshPublicKeyFilePath,
|
||||
g.gitConfig.SshPrivateKeyPassword,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return sshKey, nil
|
||||
case GIT_AUTH_USERNAME_PASSWORD:
|
||||
return &http.BasicAuth{
|
||||
Username: g.gitConfig.User,
|
||||
Password: g.gitConfig.Password,
|
||||
}, nil
|
||||
case GIT_AUTH_ACCESS_TOKEN:
|
||||
return &http.BasicAuth{
|
||||
Username: "required-username",
|
||||
Password: g.gitConfig.AccessToken,
|
||||
}, nil
|
||||
case GIT_AUTH_ANONYMOUS:
|
||||
return nil, nil
|
||||
case GIT_AUTH_SSH_AGENT:
|
||||
return ssh.NewSSHAgentAuth(g.gitConfig.User)
|
||||
default:
|
||||
return nil, nil
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
package signer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/curre"
|
||||
"github.com/ProtonMail/go-crypto/openpgp"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type OpenPGP struct {
|
||||
logger *zap.Logger
|
||||
SigningKey *openpgp.Entity
|
||||
config *OpenPgpConfig
|
||||
}
|
||||
|
||||
type OpenPgpConfig struct {
|
||||
PrivateKeyFilePath string
|
||||
PrivateKeyPassword string
|
||||
PrivateKeyIdentity string
|
||||
}
|
||||
|
||||
func NewOpenPGP(logger *zap.Logger, config *OpenPgpConfig) *OpenPGP {
|
||||
return &OpenPGP{
|
||||
logger: logger,
|
||||
config: config,
|
||||
}
|
||||
}
|
||||
|
||||
func NewOpenPGPApp(openPGP *OpenPGP) curre.Component {
|
||||
return curre.NewFunctionalComponent(&curre.FunctionalComponent{
|
||||
InitFunc: func(_ *curre.FunctionalComponent, ctx context.Context) error {
|
||||
keyring, err := buildKeyring(ctx, openPGP)
|
||||
if err != nil {
|
||||
openPGP.logger.Panic("could not build keyring", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
|
||||
openPGP.SigningKey = keyring
|
||||
|
||||
return nil
|
||||
},
|
||||
StartFunc: func(fc *curre.FunctionalComponent, ctx context.Context) error {
|
||||
return nil
|
||||
},
|
||||
StopFunc: func(fc *curre.FunctionalComponent, ctx context.Context) error {
|
||||
return nil
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func buildKeyring(_ context.Context, openPGP *OpenPGP) (*openpgp.Entity, error) {
|
||||
content, err := os.ReadFile(openPGP.config.PrivateKeyFilePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
reader := strings.NewReader(string(content))
|
||||
|
||||
es, err := openpgp.ReadArmoredKeyRing(reader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, key := range es {
|
||||
for k := range key.Identities {
|
||||
if strings.Contains(k, openPGP.config.PrivateKeyIdentity) {
|
||||
err = key.PrivateKey.Decrypt([]byte(openPGP.config.PrivateKeyPassword))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return key, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, errors.New("could not find key matching identity")
|
||||
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package storage
|
||||
|
||||
type (
|
||||
Area struct {
|
||||
Path string
|
||||
}
|
||||
)
|
@ -1,77 +0,0 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// The idea behind storage is that we have file dir, with a git repo.
|
||||
// This file repo can now take certain actions
|
||||
|
||||
type StorageConfig struct {
|
||||
Path string
|
||||
}
|
||||
|
||||
func NewDefaultStorageConfig() (*StorageConfig, error) {
|
||||
tempDir, err := os.MkdirTemp(os.TempDir(), "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &StorageConfig{
|
||||
Path: path.Join(tempDir, "octopush"),
|
||||
}, nil
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
logger *zap.Logger
|
||||
cfg *StorageConfig
|
||||
}
|
||||
|
||||
func NewService(logger *zap.Logger, cfg *StorageConfig) *Service {
|
||||
return &Service{logger: logger, cfg: cfg}
|
||||
}
|
||||
|
||||
func (s *Service) getStoragePath(ctx context.Context) string {
|
||||
return path.Join(s.cfg.Path, "storage")
|
||||
}
|
||||
|
||||
func (s *Service) InitializeStorage(ctx context.Context) error {
|
||||
return os.MkdirAll(s.getStoragePath(ctx), 0755)
|
||||
}
|
||||
|
||||
func (s *Service) CleanupStorage(ctx context.Context) error {
|
||||
doneRemovingChan := make(chan struct{}, 1)
|
||||
go func(ctx context.Context) {
|
||||
s.logger.Debug("Removing all temp storage")
|
||||
os.RemoveAll(s.getStoragePath(ctx))
|
||||
doneRemovingChan <- struct{}{}
|
||||
}(ctx)
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return errors.New("could not cleanup storage aborting")
|
||||
case <-doneRemovingChan:
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) CreateArea(ctx context.Context) (*Area, error) {
|
||||
dir, err := os.MkdirTemp(s.getStoragePath(ctx), "*")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Area{
|
||||
Path: dir,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Service) RemoveArea(ctx context.Context, area *Area) error {
|
||||
return os.RemoveAll(area.Path)
|
||||
}
|
63
roadmap.md
63
roadmap.md
@ -1,63 +0,0 @@
|
||||
# Roadmap
|
||||
|
||||
## POC:
|
||||
|
||||
- [x] Add cuddle
|
||||
- [x] Create storage mechanism
|
||||
- [x] Pull repository into storage
|
||||
- [x] Create test action to run on repository
|
||||
- [x] Sign commit using gpg
|
||||
- [x] Push commits to branch
|
||||
|
||||
### Not in scope
|
||||
|
||||
- Pooled runners
|
||||
- CLI with options
|
||||
- Server app
|
||||
- Git hosting providers
|
||||
|
||||
## Version 0.1
|
||||
|
||||
- [x] Setup a way to choose actions and predicates
|
||||
- [x] Allow instantiation of actions, octopush template repo etc.
|
||||
- [x] Implement docker action
|
||||
- [x] Create pr for gitea provider
|
||||
- [x] Providing query results
|
||||
- [x] Create CLI to trigger action
|
||||
|
||||
## Version 0.2
|
||||
|
||||
- [x] Write README
|
||||
- [x] Fix git issues
|
||||
- [x] Allow octopush to run directly on the cli
|
||||
|
||||
## Version 0.3
|
||||
|
||||
- [ ] Make select depend on query
|
||||
- [ ] Make configurable ssh user
|
||||
- [ ] Make configurable gpg keyset
|
||||
- [ ] Make configurable git provider
|
||||
- [ ] Add github
|
||||
- [ ] Create templating function for easily creating new actions
|
||||
- [ ] Add way to see progress of runners
|
||||
- [ ] Implement global .octopush store for easy access to settings
|
||||
- [ ] Move builders to start instead of every building on every action
|
||||
- [ ] Setup releases on github
|
||||
- [ ] Setup CI
|
||||
- [ ] Setup static analysis
|
||||
- [ ] Setup releases on gitea using drone
|
||||
- [ ] Figure out a license (probably MIT)
|
||||
|
||||
## Version 0.4
|
||||
|
||||
- [ ] Create setup version for local actions
|
||||
- [ ] Create setup version for server actions
|
||||
- [ ] Create json schema
|
||||
- [ ] Move roadmap to release / changelog
|
||||
|
||||
## Version 0.x
|
||||
|
||||
- Think about some sort of isolation
|
||||
- Run authenticated on servers
|
||||
- Create queuing system
|
||||
- Setup pool of runners
|
@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
git remote add github git@github.com:kjuulh/octopush.git || true
|
||||
|
||||
git push -f github main
|
@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
run_server="cuddle_cli x run_server"
|
||||
|
||||
$run_server &
|
||||
|
||||
sleep 1s
|
||||
|
||||
cuddle_cli x run_client
|
||||
|
||||
sleep 5s
|
||||
|
||||
kill %1
|
@ -1,13 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
current_branch=$(git branch --show-current)
|
||||
|
||||
export $(cat .env | xargs)
|
||||
|
||||
#go run cmd/octopush/octopush.go process --actions-repo "git@git.front.kjuulh.io:kjuulh/octopush.git" --branch "$current_branch" --path "_examples/actions/write_a_readme"
|
||||
go run cmd/octopush/octopush.go process \
|
||||
--actions-repo "git@git.front.kjuulh.io:kjuulh/octopush.git"\
|
||||
--branch "$current_branch" \
|
||||
--path "_examples/actions/add_releaserc"
|
@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
export $(cat .env | xargs)
|
||||
|
||||
go run cmd/server/server.go start
|
@ -1,7 +0,0 @@
|
||||
FROM golang
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN go build cmd/server/server.go
|
||||
|
||||
CMD [ "server", "start" ]
|
Loading…
Reference in New Issue
Block a user