change doc URL if UI is running in k8s (#2484)
Co-authored-by: Prakash Senthil Vel <23444145+prakashsvmx@users.noreply.github.com>
This commit is contained in:
@@ -6379,6 +6379,9 @@ func init() {
|
||||
"isDirectPV": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"isK8S": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"loginStrategy": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -14681,6 +14684,9 @@ func init() {
|
||||
"isDirectPV": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"isK8S": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"loginStrategy": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
|
||||
@@ -31,6 +31,7 @@ import (
|
||||
authApi "github.com/minio/console/restapi/operations/auth"
|
||||
"github.com/minio/madmin-go/v2"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"github.com/minio/pkg/env"
|
||||
)
|
||||
|
||||
func registerLoginHandlers(api *operations.ConsoleAPI) {
|
||||
@@ -153,6 +154,15 @@ func getLoginResponse(params authApi.LoginParams) (*models.LoginResponse, *model
|
||||
return loginResponse, nil
|
||||
}
|
||||
|
||||
// isKubernetes returns true if minio is running in kubernetes.
|
||||
func isKubernetes() bool {
|
||||
// Kubernetes env used to validate if we are
|
||||
// indeed running inside a kubernetes pod
|
||||
// is KUBERNETES_SERVICE_HOST
|
||||
// https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/kubelet_pods.go#L541
|
||||
return env.Get("KUBERNETES_SERVICE_HOST", "") != ""
|
||||
}
|
||||
|
||||
// getLoginDetailsResponse returns information regarding the Console authentication mechanism.
|
||||
func getLoginDetailsResponse(params authApi.LoginDetailParams, openIDProviders oauth2.OpenIDPCfg) (*models.LoginDetails, *models.Error) {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
@@ -193,6 +203,7 @@ func getLoginDetailsResponse(params authApi.LoginDetailParams, openIDProviders o
|
||||
loginDetails = &models.LoginDetails{
|
||||
LoginStrategy: loginStrategy,
|
||||
RedirectRules: redirectRules,
|
||||
IsK8S: isKubernetes(),
|
||||
}
|
||||
return loginDetails, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user