Add route for version information
This commit is contained in:
@ -106,6 +106,20 @@ paths:
|
|||||||
"204":
|
"204":
|
||||||
description: Everything okay
|
description: Everything okay
|
||||||
|
|
||||||
|
/version:
|
||||||
|
get:
|
||||||
|
summary: Retrieve the version of Poseidon
|
||||||
|
description: Return hash-like release information.
|
||||||
|
tags:
|
||||||
|
- miscellaneous
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: The release information could be returned.
|
||||||
|
"404":
|
||||||
|
$ref: "#/components/responses/NotFound"
|
||||||
|
"500":
|
||||||
|
$ref: "#/components/responses/InternalServerError"
|
||||||
|
|
||||||
/runners:
|
/runners:
|
||||||
post:
|
post:
|
||||||
summary: Provide a runner
|
summary: Provide a runner
|
||||||
|
@ -53,3 +53,6 @@ sentry:
|
|||||||
dsn: https://example.io
|
dsn: https://example.io
|
||||||
# The environment to be sent with events.
|
# The environment to be sent with events.
|
||||||
# environment: staging
|
# environment: staging
|
||||||
|
# This release information is used by Poseidon to provide the version route.
|
||||||
|
# Normally it is set by the deployment process.
|
||||||
|
# release: this is replaced in the deployment process
|
||||||
|
@ -3,6 +3,7 @@ package api
|
|||||||
import (
|
import (
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/openHPI/poseidon/internal/api/auth"
|
"github.com/openHPI/poseidon/internal/api/auth"
|
||||||
|
"github.com/openHPI/poseidon/internal/config"
|
||||||
"github.com/openHPI/poseidon/internal/environment"
|
"github.com/openHPI/poseidon/internal/environment"
|
||||||
"github.com/openHPI/poseidon/internal/runner"
|
"github.com/openHPI/poseidon/internal/runner"
|
||||||
"github.com/openHPI/poseidon/pkg/logging"
|
"github.com/openHPI/poseidon/pkg/logging"
|
||||||
@ -14,6 +15,7 @@ var log = logging.GetLogger("api")
|
|||||||
const (
|
const (
|
||||||
BasePath = "/api/v1"
|
BasePath = "/api/v1"
|
||||||
HealthPath = "/health"
|
HealthPath = "/health"
|
||||||
|
VersionPath = "/version"
|
||||||
RunnersPath = "/runners"
|
RunnersPath = "/runners"
|
||||||
EnvironmentsPath = "/execution-environments"
|
EnvironmentsPath = "/execution-environments"
|
||||||
)
|
)
|
||||||
@ -40,6 +42,7 @@ func configureV1Router(router *mux.Router, runnerManager runner.Manager, environ
|
|||||||
})
|
})
|
||||||
v1 := router.PathPrefix(BasePath).Subrouter()
|
v1 := router.PathPrefix(BasePath).Subrouter()
|
||||||
v1.HandleFunc(HealthPath, Health).Methods(http.MethodGet)
|
v1.HandleFunc(HealthPath, Health).Methods(http.MethodGet)
|
||||||
|
v1.HandleFunc(VersionPath, Version).Methods(http.MethodGet)
|
||||||
|
|
||||||
runnerController := &RunnerController{manager: runnerManager}
|
runnerController := &RunnerController{manager: runnerManager}
|
||||||
environmentController := &EnvironmentController{manager: environmentManager}
|
environmentController := &EnvironmentController{manager: environmentManager}
|
||||||
@ -59,3 +62,14 @@ func configureV1Router(router *mux.Router, runnerManager runner.Manager, environ
|
|||||||
configureRoutes(v1)
|
configureRoutes(v1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Version handles the version route.
|
||||||
|
// It responds the release information stored in the configuration.
|
||||||
|
func Version(writer http.ResponseWriter, _ *http.Request) {
|
||||||
|
release := config.Config.Sentry.Release
|
||||||
|
if len(release) > 0 {
|
||||||
|
sendJSON(writer, release, http.StatusOK)
|
||||||
|
} else {
|
||||||
|
writer.WriteHeader(http.StatusNotFound)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user