Skip to content

Commit

Permalink
config: make current config as optional and move it to v0 package (#33)
Browse files Browse the repository at this point in the history
* server: make config as v0 version

* move config package to internal

* rename mod name

* go mod tidy
  • Loading branch information
scriptnull authored Nov 6, 2024
1 parent bd45667 commit ba966ba
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 38 deletions.
18 changes: 11 additions & 7 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"syscall"
"time"

restapi "github.com/ashwiniag/goKakashi/internal/restapi/server"
"github.com/ashwiniag/goKakashi/pkg/config"
"github.com/ashwiniag/goKakashi/pkg/utils"
"github.com/ashwiniag/goKakashi/pkg/web"
"github.com/robfig/cron/v3"
"github.com/shinobistack/gokakashi/internal/config/v0"
restapi "github.com/shinobistack/gokakashi/internal/restapi/server"
"github.com/shinobistack/gokakashi/pkg/utils"
"github.com/shinobistack/gokakashi/pkg/web"
"github.com/spf13/cobra"
)

Expand All @@ -25,11 +25,15 @@ var serverCmd = &cobra.Command{
var serverConfigFilePath *string

func runServer(cmd *cobra.Command, args []string) {
if *serverConfigFilePath != "" {
handleConfigV0()
return
}
}

func handleConfigV0() {
log.Println("=== Starting goKakashi Tool ===")

if *serverConfigFilePath == "" {
log.Fatal("Please provide the path to the config YAML file using --config")
}
// Load and validate the configuration file
cfg, err := config.LoadAndValidateConfig(*serverConfigFilePath)
if err != nil {
Expand Down
17 changes: 8 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
module github.com/ashwiniag/goKakashi
module github.com/shinobistack/gokakashi

go 1.22.2

toolchain go1.23.1

require (
github.com/gorilla/mux v1.8.1
github.com/robfig/cron/v3 v3.0.1
github.com/scriptnull/jsonseal v0.3.0
github.com/spf13/cobra v1.8.1
github.com/swaggest/openapi-go v0.2.54
github.com/swaggest/rest v0.2.68
github.com/swaggest/swgui v1.8.2
github.com/swaggest/usecase v1.3.1
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c
gopkg.in/yaml.v2 v2.4.0
)

Expand All @@ -17,17 +23,10 @@ require (
github.com/kr/pretty v0.3.1 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/santhosh-tekuri/jsonschema/v3 v3.1.0 // indirect
github.com/scriptnull/jsonseal v0.3.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/swaggest/form/v5 v5.1.1 // indirect
github.com/swaggest/jsonschema-go v0.3.72 // indirect
github.com/swaggest/openapi-go v0.2.54 // indirect
github.com/swaggest/refl v1.3.0 // indirect
github.com/swaggest/rest v0.2.68 // indirect
github.com/swaggest/swgui v1.8.2 // indirect
github.com/swaggest/usecase v1.3.1 // indirect
github.com/vearutop/statigz v1.4.0 // indirect
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)
26 changes: 24 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8=
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
github.com/bool64/dev v0.2.25/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg=
github.com/bool64/dev v0.2.36 h1:yU3bbOTujoxhWnt8ig8t94PVmZXIkCaRj9C57OtqJBY=
github.com/bool64/dev v0.2.36/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg=
github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E=
github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs=
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/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/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g=
github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc=
github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE=
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=
Expand All @@ -20,6 +30,7 @@ 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/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
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/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
Expand All @@ -31,12 +42,18 @@ github.com/santhosh-tekuri/jsonschema/v3 v3.1.0 h1:levPcBfnazlA1CyCMC3asL/QLZkq9
github.com/santhosh-tekuri/jsonschema/v3 v3.1.0/go.mod h1:8kzK2TC0k0YjOForaAHdNEa7ik0fokNa2k30BKJ/W7Y=
github.com/scriptnull/jsonseal v0.3.0 h1:Ku5AQx0EsB+DRitQ5YG1YcyH8kXaQzJTRnKQsGNtThE=
github.com/scriptnull/jsonseal v0.3.0/go.mod h1:Nebbv7awTxOboVQ7CDxdO4ImxTFBNvYpr5GI0/xZ1cM=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
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=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ=
github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU=
github.com/swaggest/form/v5 v5.1.1 h1:ct6/rOQBGrqWUQ0FUv3vW5sHvTUb31AwTUWj947N6cY=
github.com/swaggest/form/v5 v5.1.1/go.mod h1:X1hraaoONee20PMnGNLQpO32f9zbQ0Czfm7iZThuEKg=
github.com/swaggest/jsonschema-go v0.3.72 h1:IHaGlR1bdBUBPfhe4tfacN2TGAPKENEGiNyNzvnVHv4=
Expand All @@ -53,6 +70,10 @@ github.com/swaggest/usecase v1.3.1 h1:JdKV30MTSsDxAXxkldLNcEn8O2uf565khyo6gr5sS+
github.com/swaggest/usecase v1.3.1/go.mod h1:cae3lDd5VDmM36OQcOOOdAlEDg40TiQYIp99S9ejWqA=
github.com/vearutop/statigz v1.4.0 h1:RQL0KG3j/uyA/PFpHeZ/L6l2ta920/MxlOAIGEOuwmU=
github.com/vearutop/statigz v1.4.0/go.mod h1:LYTolBLiz9oJISwiVKnOQoIwhO1LWX1A7OECawGS8XE=
github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA=
github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg=
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M=
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand All @@ -61,4 +82,5 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV
gopkg.in/yaml.v2 v2.2.2/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.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
File renamed without changes.
6 changes: 3 additions & 3 deletions internal/imgscan/imgscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"strings"
"sync"

"github.com/ashwiniag/goKakashi/pkg/config"
"github.com/ashwiniag/goKakashi/pkg/scanner"
"github.com/ashwiniag/goKakashi/pkg/utils"
"github.com/shinobistack/gokakashi/internal/config/v0"
"github.com/shinobistack/gokakashi/pkg/scanner"
"github.com/shinobistack/gokakashi/pkg/utils"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions internal/restapi/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"net/http"
"strconv"

"github.com/ashwiniag/goKakashi/internal/restapi/v0/scan"
"github.com/ashwiniag/goKakashi/pkg/config"
"github.com/shinobistack/gokakashi/internal/config/v0"
"github.com/shinobistack/gokakashi/internal/restapi/v0/scan"
"github.com/swaggest/openapi-go/openapi31"
"github.com/swaggest/rest/web"
swgui "github.com/swaggest/swgui/v5emb"
Expand Down
2 changes: 1 addition & 1 deletion internal/restapi/v0/scan/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"os"

"github.com/ashwiniag/goKakashi/internal/imgscan"
"github.com/shinobistack/gokakashi/internal/imgscan"
"github.com/swaggest/usecase/status"
)

Expand Down
6 changes: 3 additions & 3 deletions internal/restapi/v0/scan/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
_ "strings"
"time"

"github.com/ashwiniag/goKakashi/internal/imgscan"
"github.com/ashwiniag/goKakashi/pkg/config"
_ "github.com/ashwiniag/goKakashi/pkg/utils"
"github.com/scriptnull/jsonseal"
"github.com/shinobistack/gokakashi/internal/config/v0"
"github.com/shinobistack/gokakashi/internal/imgscan"
_ "github.com/shinobistack/gokakashi/pkg/utils"
"github.com/swaggest/usecase/status"
"golang.org/x/exp/maps"
)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/ashwiniag/goKakashi/cmd"
import "github.com/shinobistack/gokakashi/cmd"

func main() {
cmd.Execute()
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/dockerhub.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os/exec"
"strings"

"github.com/ashwiniag/goKakashi/pkg/config"
"github.com/shinobistack/gokakashi/internal/config/v0"
)

type DockerHub struct{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/gcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"os/exec"

"github.com/ashwiniag/goKakashi/pkg/config"
"github.com/shinobistack/gokakashi/internal/config/v0"
)

type GCR struct{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/interface.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package registry

import "github.com/ashwiniag/goKakashi/pkg/config"
import "github.com/shinobistack/gokakashi/internal/config/v0"

// Registry interface defines methods for container registries
type Registry interface {
Expand Down
3 changes: 2 additions & 1 deletion pkg/scanner/trivy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package scanner
import (
"encoding/json"
"fmt"
"github.com/ashwiniag/goKakashi/notifier" // Import the notifier package
"log"
"os/exec"
"strings"

"github.com/shinobistack/gokakashi/notifier" // Import the notifier package
)

type TrivyScanner struct{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os"
"strings"

"github.com/ashwiniag/goKakashi/notifier"
"github.com/shinobistack/gokakashi/notifier"
)

type HashEntry struct {
Expand Down
9 changes: 5 additions & 4 deletions pkg/utils/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"path/filepath"
"strings"

"github.com/ashwiniag/goKakashi/notifier"
"github.com/ashwiniag/goKakashi/pkg/config"
"github.com/ashwiniag/goKakashi/pkg/registry"
"github.com/ashwiniag/goKakashi/pkg/scanner"
"github.com/shinobistack/gokakashi/notifier"

"github.com/shinobistack/gokakashi/internal/config/v0"
"github.com/shinobistack/gokakashi/pkg/registry"
"github.com/shinobistack/gokakashi/pkg/scanner"
)

const reportsRootDir = "reports/"
Expand Down
2 changes: 1 addition & 1 deletion pkg/web/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"path/filepath"
"text/template"

"github.com/ashwiniag/goKakashi/pkg/config"
"github.com/shinobistack/gokakashi/internal/config/v0"
)

const ReportsRootDir = "reports/"
Expand Down

0 comments on commit ba966ba

Please sign in to comment.