Skip to content

Commit

Permalink
New methods to lint the config file
Browse files Browse the repository at this point in the history
  • Loading branch information
thedae committed Dec 20, 2024
1 parent a0dd9a6 commit 4e678ae
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ RPM_OPTS =--rpm-user $(USER) \

all: test

build:
build: cmd/krakend-ce/schema/schema.json
@echo "Building the binary..."
@go get .
@go build -ldflags="-X ${MODULE}/pkg.Version=${VERSION} -X github.com/luraproject/lura/v2/core.KrakendVersion=${VERSION} \
Expand All @@ -65,6 +65,10 @@ build:
test: build
go test -v ./tests

cmd/krakend-ce/schema/schema.json:
@echo "Fetching v${SCHEMA_VERSION} schema"
@wget -qO $@ https://raw.githubusercontent.com/krakend/krakend-schema/refs/heads/main/v${SCHEMA_VERSION}/krakend.json

# Build KrakenD using docker (defaults to whatever the golang container uses)
build_on_docker: docker-builder-linux
docker run --rm -it -v "${PWD}:/app" -w /app krakend/builder:${VERSION}-linux-generic sh -c "git config --global --add safe.directory /app && make -e build"
Expand Down Expand Up @@ -174,5 +178,6 @@ rpm-release: builder/skel/rpm-release/etc/krakend/krakend.json
.PHONY: clean
clean:
rm -rf builder/skel/*
rm -f krakend
rm -f ${BIN_NAME}
rm -rf vendor/
rm -f cmd/krakend-ce/schema/schema.json
6 changes: 5 additions & 1 deletion cmd/krakend-ce/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package main

import (
"context"
_ "embed"
"log"
"os"
"os/signal"
Expand All @@ -24,6 +25,9 @@ const (
fcEnable = "FC_ENABLE"
)

//go:embed schema/schema.json
var embedSchema string

func main() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
Expand Down Expand Up @@ -59,7 +63,7 @@ func main() {

commandsToLoad := []cmd.Command{
cmd.RunCommand,
cmd.CheckCommand,
cmd.NewCheckCmd(embedSchema),
cmd.PluginCommand,
cmd.VersionCommand,
cmd.AuditCommand,
Expand Down
1 change: 1 addition & 0 deletions cmd/krakend-ce/schema/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.json
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/krakendio/krakend-botdetector/v2 v2.1.0
github.com/krakendio/krakend-cel/v2 v2.0.1
github.com/krakendio/krakend-circuitbreaker/v2 v2.0.1
github.com/krakendio/krakend-cobra/v2 v2.4.2
github.com/krakendio/krakend-cobra/v2 v2.4.3-0.20241220092810-7d31ee55edde
github.com/krakendio/krakend-cors/v2 v2.1.1
github.com/krakendio/krakend-flexibleconfig/v2 v2.2.0
github.com/krakendio/krakend-gelf/v2 v2.0.1
Expand All @@ -36,7 +36,7 @@ require (
github.com/krakendio/krakend-viper/v2 v2.0.1
github.com/krakendio/krakend-xml/v2 v2.1.0
github.com/luraproject/lura/v2 v2.8.0
github.com/spf13/cobra v1.8.0
github.com/spf13/cobra v1.8.1
github.com/xeipuuv/gojsonschema v1.2.1-0.20200424115421-065759f9c3d7
golang.org/x/sync v0.10.0
)
Expand Down Expand Up @@ -204,7 +204,7 @@ require (
github.com/rs/cors v1.11.0 // indirect
github.com/rs/cors/wrapper/gin v0.0.0-20240515105523-1562b1715b35 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sony/gobreaker v0.5.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
Expand Down
14 changes: 7 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJ
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
Expand Down Expand Up @@ -486,8 +486,8 @@ github.com/krakendio/krakend-cel/v2 v2.0.1 h1:7qRPelchTia94O7cY3fHSH8CUWxm9Z1KIz
github.com/krakendio/krakend-cel/v2 v2.0.1/go.mod h1:TuOf89sSyRkpQWjSoEOTDjWpWDJlUccSF2i58QBmfSA=
github.com/krakendio/krakend-circuitbreaker/v2 v2.0.1 h1:rX5TAbdQa+mISIULDxYdviR7/7yOYCjSimuaXJHFrUA=
github.com/krakendio/krakend-circuitbreaker/v2 v2.0.1/go.mod h1:PCbRQGfUOToK2Uw48gm9rZ8Mzb4qLGZnX4876Fu9CpQ=
github.com/krakendio/krakend-cobra/v2 v2.4.2 h1:pkNgmgrRD+ziQwYJ89ji3fGL/tVwffEmIT/CjlelDRE=
github.com/krakendio/krakend-cobra/v2 v2.4.2/go.mod h1:UluR1IW7XM/pkfYMcRXYaED7riaOnK5YSUDZXpwCOXs=
github.com/krakendio/krakend-cobra/v2 v2.4.3-0.20241220092810-7d31ee55edde h1:N9PvN90hVZ1IkhN2sv2TBMJ8WvvYKy4Abk5yrU2/7p0=
github.com/krakendio/krakend-cobra/v2 v2.4.3-0.20241220092810-7d31ee55edde/go.mod h1:DynOF7SjLbzFdQLn+GWLziMGXd/075vjgWhKvuOEVBM=
github.com/krakendio/krakend-cors/v2 v2.1.1 h1:C+7GHwt/47pNGIuw5Ua4s+B5REIql/yqgZkYTY4QSTw=
github.com/krakendio/krakend-cors/v2 v2.1.1/go.mod h1:V8T2CmOrDm9+ZhopV17FabGAFQUss69PntQ8KZXpfUY=
github.com/krakendio/krakend-flexibleconfig/v2 v2.2.0 h1:8WjaZekJyoPQTHHjDAOJrlRv0ZWoVLVXvObyd5bj8gc=
Expand Down Expand Up @@ -663,8 +663,8 @@ github.com/rs/cors/wrapper/gin v0.0.0-20240515105523-1562b1715b35/go.mod h1:742I
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk=
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 h1:TToq11gyfNlrMFZiYujSekIsPd9AmsA2Bj/iv+s4JHE=
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0/go.mod h1:FKdcjfQW6rpZSnxxUvEA5H/cDPdvJ/SZJQLWWXWGrZ0=
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 h1:PKK9DyHxif4LZo+uQSgXNqs0jj5+xZwwfKHgph2lxBw=
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
Expand All @@ -678,8 +678,8 @@ github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNo
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
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/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
Expand Down

0 comments on commit 4e678ae

Please sign in to comment.