v0.2 (#14)
Co-authored-by: kjuulh <contact@kjuulh.io> Reviewed-on: https://git.front.kjuulh.io/kjuulh/octopush/pulls/14
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
package commands
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
func CreateKrakenCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "kraken",
|
||||
// Run: func(cmd *cobra.Command, args []string) { },
|
||||
}
|
||||
|
||||
cmd.AddCommand(CreateKrakenProcessCmd())
|
||||
|
||||
return cmd
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/kraken/cmd/kraken/commands"
|
||||
)
|
||||
|
||||
func main() {
|
||||
Execute()
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
err := commands.CreateKrakenCmd().Execute()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
61
cmd/octopush/commands/process.go
Normal file
61
cmd/octopush/commands/process.go
Normal file
@@ -0,0 +1,61 @@
|
||||
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
|
||||
}
|
18
cmd/octopush/commands/root.go
Normal file
18
cmd/octopush/commands/root.go
Normal file
@@ -0,0 +1,18 @@
|
||||
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,4 +1,4 @@
|
||||
package commands
|
||||
package server
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func CreateKrakenProcessCmd() *cobra.Command {
|
||||
func CreateOctopushProcessCmd() *cobra.Command {
|
||||
|
||||
var (
|
||||
actionsRepo string
|
16
cmd/octopush/commands/server/server.go
Normal file
16
cmd/octopush/commands/server/server.go
Normal file
@@ -0,0 +1,16 @@
|
||||
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
|
||||
}
|
28
cmd/octopush/octopush.go
Normal file
28
cmd/octopush/octopush.go
Normal file
@@ -0,0 +1,28 @@
|
||||
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)
|
||||
}
|
||||
}
|
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
func CreateServerCmd(logger *zap.Logger) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "krakenserver",
|
||||
Use: "octopushserver",
|
||||
}
|
||||
|
||||
cmd.AddCommand(NewStartServerCommand(logger))
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/server"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/server"
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
func NewStartServerCommand(logger *zap.Logger) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "start",
|
||||
Short: "Start the kraken server",
|
||||
Short: "Start the octopush server",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return server.Start(logger)
|
||||
},
|
||||
|
@@ -3,8 +3,8 @@ package main
|
||||
import (
|
||||
"os"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/kraken/cmd/server/commands"
|
||||
"git.front.kjuulh.io/kjuulh/kraken/internal/logger"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/cmd/server/commands"
|
||||
"git.front.kjuulh.io/kjuulh/octopush/internal/logger"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user