From 87e41a948ff41d72b778d4906480ee97e9898388 Mon Sep 17 00:00:00 2001 From: Vadim Gedz Date: Tue, 17 Oct 2023 19:09:34 +0300 Subject: [PATCH] chore: add error body when returning 401 due to invalid token --- cmd/argo-watcher/router.go | 4 +++- go.mod | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/argo-watcher/router.go b/cmd/argo-watcher/router.go index 10c456f6..a450630d 100644 --- a/cmd/argo-watcher/router.go +++ b/cmd/argo-watcher/router.go @@ -121,7 +121,9 @@ func (env *Env) addTask(c *gin.Context) { } else if deployToken != "" && deployToken != env.config.DeployToken { // if token is provided, but it's not valid we should not process the task log.Warn().Msgf("deploy token is invalid for app %s, aborting", task.App) - c.JSON(http.StatusUnauthorized, models.TaskStatus{}) + c.JSON(http.StatusUnauthorized, models.TaskStatus{ + Status: "invalid token", + }) return } else { log.Debug().Msgf("deploy token is not provided for app %s", task.App) diff --git a/go.mod b/go.mod index a7343a39..6a01c05a 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/stretchr/testify v1.8.3 github.com/swaggo/files v1.0.1 github.com/swaggo/gin-swagger v1.6.0 + github.com/swaggo/swag v1.16.1 go.uber.org/mock v0.2.0 gopkg.in/yaml.v2 v2.4.0 gorm.io/datatypes v1.2.0 @@ -78,7 +79,6 @@ require ( github.com/prometheus/procfs v0.10.1 // indirect github.com/sergi/go-diff v1.1.0 // indirect github.com/skeema/knownhosts v1.2.0 // indirect - github.com/swaggo/swag v1.16.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect