mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Review fixes.
Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
parent
6d64f10fae
commit
6e08008630
@ -75,7 +75,7 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
|
|||||||
public onData = new EventEmitter<[D, Response]>();
|
public onData = new EventEmitter<[D, Response]>();
|
||||||
public onError = new EventEmitter<[JsonApiErrorParsed, Response]>();
|
public onError = new EventEmitter<[JsonApiErrorParsed, Response]>();
|
||||||
|
|
||||||
private getRequestOptions?: () => Promise<RequestInit>;
|
private getRequestOptions?: JsonApiConfig["getRequestOptions"];
|
||||||
|
|
||||||
get<T = D>(path: string, params?: P, reqInit: RequestInit = {}) {
|
get<T = D>(path: string, params?: P, reqInit: RequestInit = {}) {
|
||||||
return this.request<T>(path, params, { ...reqInit, method: "get" });
|
return this.request<T>(path, params, { ...reqInit, method: "get" });
|
||||||
|
|||||||
@ -135,13 +135,6 @@ export function forCluster<T extends KubeObject>(cluster: ILocalKubeApiConfig, k
|
|||||||
|
|
||||||
export function forRemoteCluster<T extends KubeObject>(config: IRemoteKubeApiConfig, kubeClass: KubeObjectConstructor<T>): KubeApi<T> {
|
export function forRemoteCluster<T extends KubeObject>(config: IRemoteKubeApiConfig, kubeClass: KubeObjectConstructor<T>): KubeApi<T> {
|
||||||
const reqInit: RequestInit = {};
|
const reqInit: RequestInit = {};
|
||||||
const token = config.user.token;
|
|
||||||
|
|
||||||
if (token && !isFunction(token)) {
|
|
||||||
reqInit.headers = {
|
|
||||||
"Authorization": `Bearer ${token}`
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const agentOptions: AgentOptions = {};
|
const agentOptions: AgentOptions = {};
|
||||||
|
|
||||||
@ -165,14 +158,15 @@ export function forRemoteCluster<T extends KubeObject>(config: IRemoteKubeApiCon
|
|||||||
reqInit.agent = new Agent(agentOptions);
|
reqInit.agent = new Agent(agentOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const token = config.user.token;
|
||||||
const request = new KubeJsonApi({
|
const request = new KubeJsonApi({
|
||||||
serverAddress: config.cluster.server,
|
serverAddress: config.cluster.server,
|
||||||
apiBase: "",
|
apiBase: "",
|
||||||
debug: isDevelopment,
|
debug: isDevelopment,
|
||||||
...(isFunction(token) ? {
|
...(token ? {
|
||||||
getRequestOptions: async () => ({
|
getRequestOptions: async () => ({
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": `Bearer ${await token()}`
|
"Authorization": `Bearer ${isFunction(token) ? await token() : token}`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} : {})
|
} : {})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user