Files
orchard/internal/controller/api_controller.go
T
Nikolay EdigaryevandFedor Korotkov 77656517fd Controller info endpoint and API integration examples (#75)
* Controller API: introduce controller's information endpoint

* Prevent generation of empty events after channel closure

* Allow events to be buffered in the events channel

* Controller API: introduce controller's information endpoint[1]

* IntegrationGuide.md: a couple of Python and Golang examples

* Rephrase a sentence

Co-authored-by: Fedor Korotkov <fedor.korotkov@gmail.com>

---------

Co-authored-by: Fedor Korotkov <fedor.korotkov@gmail.com>
2023-04-11 07:28:46 +00:00

23 lines
619 B
Go

package controller
import (
"github.com/cirruslabs/orchard/internal/responder"
"github.com/cirruslabs/orchard/internal/version"
v1pkg "github.com/cirruslabs/orchard/pkg/resource/v1"
"github.com/gin-gonic/gin"
"net/http"
)
func (controller *Controller) controllerInfo(ctx *gin.Context) responder.Responder {
// Only require the service account to be valid,
// no roles are needed to query this endpoint
if responder := controller.authorize(ctx); responder != nil {
return responder
}
return responder.JSON(http.StatusOK, &v1pkg.ControllerInfo{
Version: version.Version,
Commit: version.Commit,
})
}