diff --git a/Dockerfile b/Dockerfile index b95f251..bcd89e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ RUN go mod tidy COPY . . # Build the Go binary for amd64 -RUN GOARCH=amd64 go build -o goKakashi ./cmd/goKakashi.go +RUN GOARCH=amd64 go build -o gokakashi # Stage 2: Final image for running the application with Alpine FROM alpine:3.20 @@ -48,7 +48,7 @@ WORKDIR /app RUN mkdir -p /app/website # Copy the Go binary from the builder stage -COPY --from=builder /app/goKakashi /app/goKakashi +COPY --from=builder /app/gokakashi /app/gokakashi # Expose ports EXPOSE 8080 @@ -60,7 +60,7 @@ ENV DOCKER_PASSWORD="your-dockerhub-password" ENV LINEAR_API_KEY="your-linear-api-key" # Make sure the binary is executable -RUN chmod +x /app/goKakashi +RUN chmod +x /app/gokakashi # Set the entrypoint to the application binary -ENTRYPOINT ["/app/goKakashi"] +ENTRYPOINT ["/app/gokakashi"] diff --git a/cmd/root.go b/cmd/root.go new file mode 100644 index 0000000..95ab2af --- /dev/null +++ b/cmd/root.go @@ -0,0 +1,29 @@ +package cmd + +import ( + "fmt" + "os" + + "github.com/spf13/cobra" +) + +var rootCmd = &cobra.Command{ + Use: "gokakashi", + Short: "GoKakashi - The Container image vulnerability management platform", + Run: func(cmd *cobra.Command, args []string) { + _ = cmd.Help() + }, +} + +func init() { + rootCmd.AddCommand(versionCmd) + rootCmd.AddCommand(serverCmd) + rootCmd.AddCommand(scanCmd) +} + +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } +} diff --git a/cmd/scan.go b/cmd/scan.go new file mode 100644 index 0000000..7ed8f8e --- /dev/null +++ b/cmd/scan.go @@ -0,0 +1,14 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +var scanCmd = &cobra.Command{ + Use: "scan", + Short: "Scan a container image", + Run: scanImage, +} + +func scanImage(cmd *cobra.Command, args []string) { +} diff --git a/cmd/goKakashi.go b/cmd/server.go similarity index 93% rename from cmd/goKakashi.go rename to cmd/server.go index 878a20c..36e1e43 100644 --- a/cmd/goKakashi.go +++ b/cmd/server.go @@ -1,4 +1,4 @@ -package main +package cmd import ( "flag" @@ -14,9 +14,16 @@ import ( "github.com/ashwiniag/goKakashi/pkg/utils" "github.com/ashwiniag/goKakashi/pkg/web" "github.com/robfig/cron/v3" + "github.com/spf13/cobra" ) -func main() { +var serverCmd = &cobra.Command{ + Use: "server", + Short: "Start the GoKakshi Server", + Run: runServer, +} + +func runServer(cmd *cobra.Command, args []string) { log.Println("=== Starting goKakashi Tool ===") // Get config file from command-line argument diff --git a/cmd/version.go b/cmd/version.go new file mode 100644 index 0000000..916efe5 --- /dev/null +++ b/cmd/version.go @@ -0,0 +1,15 @@ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +var versionCmd = &cobra.Command{ + Use: "version", + Short: "Print version", + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("v0.0.4") + }, +} diff --git a/go.mod b/go.mod index 5d349b8..4af9d33 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,10 @@ require ( ) require ( + github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect + github.com/spf13/cobra v1.8.1 // indirect + github.com/spf13/pflag v1.0.5 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect ) diff --git a/go.sum b/go.sum index 5f122da..ecd8043 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,9 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -14,8 +17,14 @@ github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzG github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/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/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.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go new file mode 100644 index 0000000..b200982 --- /dev/null +++ b/main.go @@ -0,0 +1,7 @@ +package main + +import "github.com/ashwiniag/goKakashi/cmd" + +func main() { + cmd.Execute() +}