From e2ae96b82de6518bc102caa62035b8e02d32525f Mon Sep 17 00:00:00 2001 From: Griffin-Sullivan Date: Wed, 11 Sep 2024 15:45:54 -0400 Subject: [PATCH] Set up staticcheck linter for BFF Signed-off-by: Griffin-Sullivan --- .github/workflows/ui-bff-build.yml | 5 +++++ clients/ui/bff/Makefile | 4 ++++ clients/ui/bff/api/middleware.go | 5 +++-- clients/ui/bff/api/registered_models_handler.go | 2 +- clients/ui/bff/staticcheck.conf | 1 + 5 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 clients/ui/bff/staticcheck.conf diff --git a/.github/workflows/ui-bff-build.yml b/.github/workflows/ui-bff-build.yml index 3957f5b3f..ffaacfdcf 100644 --- a/.github/workflows/ui-bff-build.yml +++ b/.github/workflows/ui-bff-build.yml @@ -24,6 +24,11 @@ jobs: working-directory: clients/ui/bff run: make clean + - uses: dominikh/staticcheck-action@v1 + with: + version: "latest" + working-directory: clients/ui/bff + - name: Build working-directory: clients/ui/bff run: make build diff --git a/clients/ui/bff/Makefile b/clients/ui/bff/Makefile index 3049355f6..bbd540eb6 100644 --- a/clients/ui/bff/Makefile +++ b/clients/ui/bff/Makefile @@ -35,6 +35,10 @@ build: fmt vet test run: fmt vet go run ./cmd/main.go --port=$(PORT) --mock-k8s-client=$(MOCK_K8S_CLIENT) --mock-mr-client=$(MOCK_MR_CLIENT) +.PHONY: lint +lint: + staticcheck ./... + .PHONY: docker-build docker-build: $(CONTAINER_TOOL) build -t ${IMG} . diff --git a/clients/ui/bff/api/middleware.go b/clients/ui/bff/api/middleware.go index b7d0385b4..ca12b2e21 100644 --- a/clients/ui/bff/api/middleware.go +++ b/clients/ui/bff/api/middleware.go @@ -3,10 +3,11 @@ package api import ( "context" "fmt" + "net/http" + "github.com/julienschmidt/httprouter" "github.com/kubeflow/model-registry/ui/bff/integrations" "k8s.io/client-go/rest" - "net/http" ) type contextKey string @@ -39,7 +40,7 @@ func (app *App) enableCORS(next http.Handler) http.Handler { func (app *App) AttachRESTClient(handler func(http.ResponseWriter, *http.Request, httprouter.Params)) httprouter.Handle { return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { - modelRegistryID := ps.ByName(ModelRegistryId) + modelRegistryID := ps.ByName(ModelRegistryID) modelRegistryBaseURL, err := resolveModelRegistryURL(modelRegistryID, app.kubernetesClient) if err != nil { diff --git a/clients/ui/bff/api/registered_models_handler.go b/clients/ui/bff/api/registered_models_handler.go index e456083e3..fe7f97f33 100644 --- a/clients/ui/bff/api/registered_models_handler.go +++ b/clients/ui/bff/api/registered_models_handler.go @@ -101,7 +101,7 @@ func (app *App) GetRegisteredModelHandler(w http.ResponseWriter, r *http.Request return } - model, err := app.modelRegistryClient.GetRegisteredModel(client, ps.ByName(RegisteredModelId)) + model, err := app.modelRegistryClient.GetRegisteredModel(client, ps.ByName(RegisteredModelID)) if err != nil { app.serverErrorResponse(w, r, err) return diff --git a/clients/ui/bff/staticcheck.conf b/clients/ui/bff/staticcheck.conf new file mode 100644 index 000000000..4462f30c5 --- /dev/null +++ b/clients/ui/bff/staticcheck.conf @@ -0,0 +1 @@ +checks = ["all", "-U1000", "-ST1000"] \ No newline at end of file