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:
@@ -41,6 +41,9 @@ type LoginDetails struct {
|
||||
// is direct p v
|
||||
IsDirectPV bool `json:"isDirectPV,omitempty"`
|
||||
|
||||
// is k8 s
|
||||
IsK8S bool `json:"isK8S,omitempty"`
|
||||
|
||||
// login strategy
|
||||
// Enum: [form redirect service-account redirect-service-account]
|
||||
LoginStrategy string `json:"loginStrategy,omitempty"`
|
||||
|
||||
@@ -3626,6 +3626,9 @@ func init() {
|
||||
"isDirectPV": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"isK8S": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"loginStrategy": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -9622,6 +9625,9 @@ func init() {
|
||||
"isDirectPV": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"isK8S": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"loginStrategy": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
xoauth2 "golang.org/x/oauth2"
|
||||
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"github.com/minio/pkg/env"
|
||||
|
||||
"github.com/minio/console/restapi"
|
||||
|
||||
@@ -93,6 +94,15 @@ func login(credentials restapi.ConsoleCredentialsI) (*string, error) {
|
||||
return &token, 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) (*models.LoginDetails, *models.Error) {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
@@ -129,6 +139,7 @@ func getLoginDetailsResponse(params authApi.LoginDetailParams) (*models.LoginDet
|
||||
LoginStrategy: loginStrategy,
|
||||
RedirectRules: redirectRules,
|
||||
IsDirectPV: getDirectPVEnabled(),
|
||||
IsK8S: isKubernetes(),
|
||||
}
|
||||
return loginDetails, nil
|
||||
}
|
||||
|
||||
@@ -291,7 +291,8 @@ const Login = () => {
|
||||
);
|
||||
const navigateTo = useSelector((state: AppState) => state.login.navigateTo);
|
||||
|
||||
const directPVMode = useSelector((state: AppState) => state.login.isDirectPV);
|
||||
const isDirectPV = useSelector((state: AppState) => state.login.isDirectPV);
|
||||
const isK8S = useSelector((state: AppState) => state.login.isK8S);
|
||||
|
||||
const isOperator =
|
||||
loginStrategy.loginStrategy === loginStrategyType.serviceAccount ||
|
||||
@@ -479,12 +480,18 @@ const Login = () => {
|
||||
let modeLogo: "console" | "directpv" | "operator" | "kes" | "subnet" =
|
||||
"console";
|
||||
|
||||
if (directPVMode) {
|
||||
if (isDirectPV) {
|
||||
modeLogo = "directpv";
|
||||
} else if (isOperator) {
|
||||
modeLogo = "operator";
|
||||
}
|
||||
|
||||
let docsURL = "https://min.io/docs/minio/linux/index.html?ref=con";
|
||||
if (isK8S) {
|
||||
docsURL =
|
||||
"https://min.io/docs/minio/kubernetes/upstream/index.html?ref=con";
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<MainError />
|
||||
@@ -493,11 +500,7 @@ const Login = () => {
|
||||
form={loginComponent}
|
||||
formFooter={
|
||||
<Fragment>
|
||||
<a
|
||||
href="https://min.io/docs/minio/linux/index.html?ref=con"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
<a href={docsURL} target="_blank" rel="noreferrer">
|
||||
Documentation
|
||||
</a>
|
||||
<span className={classes.separator}>|</span>
|
||||
|
||||
@@ -38,6 +38,7 @@ export interface LoginState {
|
||||
latestMinIOVersion: string;
|
||||
loadingVersion: boolean;
|
||||
isDirectPV: boolean;
|
||||
isK8S: boolean;
|
||||
|
||||
navigateTo: string;
|
||||
}
|
||||
@@ -57,6 +58,7 @@ const initialState: LoginState = {
|
||||
latestMinIOVersion: "",
|
||||
loadingVersion: true,
|
||||
isDirectPV: false,
|
||||
isK8S: false,
|
||||
|
||||
navigateTo: "",
|
||||
};
|
||||
@@ -110,6 +112,7 @@ export const loginSlice = createSlice({
|
||||
if (action.payload) {
|
||||
state.loginStrategy = action.payload;
|
||||
state.isDirectPV = !!action.payload.isDirectPV;
|
||||
state.isK8S = !!action.payload.isK8S;
|
||||
}
|
||||
})
|
||||
.addCase(doLoginAsync.pending, (state, action) => {
|
||||
|
||||
@@ -18,6 +18,7 @@ export interface ILoginDetails {
|
||||
loginStrategy: loginStrategyType;
|
||||
redirectRules: redirectRule[];
|
||||
isDirectPV?: boolean;
|
||||
isK8S?: boolean;
|
||||
}
|
||||
|
||||
export interface redirectRule {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -4057,6 +4057,8 @@ definitions:
|
||||
$ref: "#/definitions/redirectRule"
|
||||
isDirectPV:
|
||||
type: boolean
|
||||
isK8S:
|
||||
type: boolean
|
||||
loginOauth2AuthRequest:
|
||||
type: object
|
||||
required:
|
||||
|
||||
@@ -1645,6 +1645,8 @@ definitions:
|
||||
$ref: "#/definitions/redirectRule"
|
||||
isDirectPV:
|
||||
type: boolean
|
||||
isK8S:
|
||||
type: boolean
|
||||
loginRequest:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
Reference in New Issue
Block a user