-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(queue)!: register endpoint to use QueueInfo type (#957)
* change register endpoint to return WorkerRegistration as a body * add comments * make clean * add test for signing.go * rename registerToken to WorkerRegistration * add mock * Update router/middleware/signing.go Co-authored-by: David May <[email protected]> * Update router/middleware/signing.go Co-authored-by: David May <[email protected]> * add validation to setup * fix setup_test * fix tests * queue creds endpoint * Update router/middleware/signing.go Co-authored-by: Jacob Floyd <[email protected]> * cleanup #1 * cleanup * cleanup * update types * make clean * address feedback * revert setup validation * remove type check * address feedback * move checks to opts.go * fix typo * make clean * make clean * make clean * Update api/queue/queue.go Co-authored-by: Easton Crupper <[email protected]> * change post to get * Update api/queue/queue.go Co-authored-by: dave vader <[email protected]> * Update router/admin.go Co-authored-by: dave vader <[email protected]> * Update router/queue.go Co-authored-by: dave vader <[email protected]> * Update api/queue/queue.go Co-authored-by: dave vader <[email protected]> * Update api/queue/queue.go Co-authored-by: dave vader <[email protected]> * Update api/queue/queue.go Co-authored-by: dave vader <[email protected]> * change to QueueRegistration * fix typo * add mock for 401 * Update router/queue.go Co-authored-by: David May <[email protected]> * Update queue/redis/opts.go Co-authored-by: David May <[email protected]> * Update queue/redis/opts.go Co-authored-by: David May <[email protected]> * Update queue/setup.go Co-authored-by: David May <[email protected]> * Update queue/redis/opts.go Co-authored-by: David May <[email protected]> * add linter ignore * sort imports * fix linter * add queue_key to docker compose * fix linter * fix typo * add schedule allowist * Update api/queue/queue.go Co-authored-by: dave vader <[email protected]> * change to /info * change to /info * change to QueueInfo struct * remove comments from docker compose * remove comments from docker compose * change to single quote --------- Co-authored-by: Easton Crupper <[email protected]> Co-authored-by: David May <[email protected]> Co-authored-by: TimHuynh <[email protected]> Co-authored-by: Jacob Floyd <[email protected]> Co-authored-by: dave vader <[email protected]>
- Loading branch information
1 parent
7ee3ae3
commit ab85e96
Showing
19 changed files
with
293 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) 2023 Target Brands, Inc. All rights reserved. | ||
// | ||
// Use of this source code is governed by the LICENSE file in this repository. | ||
|
||
package queue | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/go-vela/server/router/middleware/claims" | ||
"github.com/go-vela/types/library" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
// swagger:operation POST /api/v1/queue/info queue Info | ||
// | ||
// Get queue credentials | ||
// | ||
// --- | ||
// produces: | ||
// - application/json | ||
// security: | ||
// - ApiKeyAuth: [] | ||
// responses: | ||
// '200': | ||
// description: Successfully retrieved queue credentials | ||
// schema: | ||
// "$ref": "#/definitions/QueueInfo" | ||
// '401': | ||
// description: Unauthorized | ||
// schema: | ||
// "$ref": "#/definitions/Error" | ||
|
||
// Info represents the API handler to | ||
// retrieve queue credentials as part of worker onboarding. | ||
func Info(c *gin.Context) { | ||
cl := claims.Retrieve(c) | ||
|
||
logrus.WithFields(logrus.Fields{ | ||
"user": cl.Subject, | ||
}).Info("requesting queue credentials with registration token") | ||
|
||
// extract the public key that was packed into gin context | ||
k := c.MustGet("public-key").(string) | ||
|
||
// extract the queue-address that was packed into gin context | ||
a := c.MustGet("queue-address").(string) | ||
|
||
wr := library.QueueInfo{ | ||
QueuePublicKey: &k, | ||
QueueAddress: &a, | ||
} | ||
|
||
c.JSON(http.StatusOK, wr) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.