Skip to content

Commit

Permalink
chore: add error body when returning 401 due to invalid token
Browse files Browse the repository at this point in the history
  • Loading branch information
shini4i committed Oct 17, 2023
1 parent d4a3377 commit 87e41a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cmd/argo-watcher/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})

Check warning on line 126 in cmd/argo-watcher/router.go

View check run for this annotation

Codecov / codecov/patch

cmd/argo-watcher/router.go#L124-L126

Added lines #L124 - L126 were not covered by tests
return
} else {
log.Debug().Msgf("deploy token is not provided for app %s", task.App)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 87e41a9

Please sign in to comment.