-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: unauthenticated status endpoints
- Loading branch information
Showing
3 changed files
with
136 additions
and
0 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,65 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package build | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/go-vela/server/router/middleware/build" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
// swagger:operation GET /status/{org}/{repo}/{build} builds GetStatus | ||
// | ||
// Get a build status | ||
// | ||
// --- | ||
// produces: | ||
// - application/json | ||
// parameters: | ||
// - in: path | ||
// name: org | ||
// description: Name of the organization | ||
// required: true | ||
// type: string | ||
// - in: path | ||
// name: repo | ||
// description: Name of the repository | ||
// required: true | ||
// type: string | ||
// - in: path | ||
// name: build | ||
// description: Build number | ||
// required: true | ||
// type: integer | ||
// security: | ||
// - ApiKeyAuth: [] | ||
// responses: | ||
// '200': | ||
// description: Successfully retrieved the build | ||
// schema: | ||
// "$ref": "#/definitions/Build" | ||
// '400': | ||
// description: Invalid request payload or path | ||
// schema: | ||
// "$ref": "#/definitions/Build" | ||
// '401': | ||
// description: Unauthorized | ||
// schema: | ||
// "$ref": "#/definitions/Build" | ||
// '404': | ||
// description: Not found | ||
// schema: | ||
// "$ref": "#/definitions/Build" | ||
|
||
// GetStatus represents the API handler to return "status", a lite representation of the resource with limited fields for unauthenticated access. | ||
func GetStatus(c *gin.Context) { | ||
// capture middleware values | ||
l := c.MustGet("logger").(*logrus.Entry) | ||
b := build.Retrieve(c) | ||
|
||
l.Debug("reading status for build") | ||
|
||
c.JSON(http.StatusOK, b) | ||
} |
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,61 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package repo | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/sirupsen/logrus" | ||
|
||
"github.com/go-vela/server/router/middleware/repo" | ||
) | ||
|
||
// swagger:operation GET /status/{org}/{repo} repos GetStatus | ||
// | ||
// Get a repository status | ||
// | ||
// --- | ||
// produces: | ||
// - application/json | ||
// parameters: | ||
// - in: path | ||
// name: org | ||
// description: Name of the organization | ||
// required: true | ||
// type: string | ||
// - in: path | ||
// name: repo | ||
// description: Name of the repository | ||
// required: true | ||
// type: string | ||
// security: | ||
// - ApiKeyAuth: [] | ||
// responses: | ||
// '200': | ||
// description: Successfully retrieved the repo | ||
// schema: | ||
// "$ref": "#/definitions/Repo" | ||
// '400': | ||
// description: Invalid request payload or path | ||
// schema: | ||
// "$ref": "#/definitions/Repo" | ||
// '401': | ||
// description: Unauthorized | ||
// schema: | ||
// "$ref": "#/definitions/Repo" | ||
// '404': | ||
// description: Not found | ||
// schema: | ||
// "$ref": "#/definitions/Repo" | ||
|
||
// GetStatus represents the API handler to return "status", a lite representation of the resource with limited fields for unauthenticated access. | ||
func GetStatus(c *gin.Context) { | ||
// capture middleware values | ||
l := c.MustGet("logger").(*logrus.Entry) | ||
r := repo.Retrieve(c) | ||
|
||
l.Debug("reading status for repo") | ||
|
||
c.JSON(http.StatusOK, r) | ||
} |
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