-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(backport to 3.4.x)fix(kconfig): remove kong version from kconfig.js-…
…FTI-5557 (#146) * fix(kconfig): remove kong version from kconfig.js * fix(kconfig): retrieve edition from info instead of from kconfig.js
- Loading branch information
1 parent
e7f96ac
commit 24732eb
Showing
13 changed files
with
224 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import { reactive } from 'vue' | ||
import { config } from 'config' | ||
import { useInfoStore } from '@/stores/info' | ||
import type { KongManagerBaseEntityConfig } from '@kong-ui/entities-shared' | ||
import { useAdminApiUrl } from './useAdminApiUrl' | ||
|
||
const infoStore = useInfoStore() | ||
|
||
export const useDetailGeneralConfig = () => { | ||
return reactive({ | ||
app: 'kongManager' as const, | ||
workspace: '', | ||
gatewayInfo: { | ||
edition: config.GATEWAY_EDITION, | ||
version: config.GATEWAY_VERSION, | ||
edition: infoStore.kongEdition, | ||
version: infoStore.kongVersion, | ||
}, | ||
apiBaseUrl: useAdminApiUrl(), | ||
apiBaseUrl: config.ADMIN_API_URL, | ||
} as Pick<KongManagerBaseEntityConfig, 'app' | 'workspace' | 'gatewayInfo' | 'apiBaseUrl'>) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import { reactive } from 'vue' | ||
import { config } from 'config' | ||
import { useInfoStore } from '@/stores/info' | ||
import type { KongManagerBaseFormConfig } from '@kong-ui/entities-shared' | ||
import { useAdminApiUrl } from './useAdminApiUrl' | ||
|
||
const infoStore = useInfoStore() | ||
|
||
export const useFormGeneralConfig = () => { | ||
return reactive({ | ||
app: 'kongManager' as const, | ||
workspace: '', | ||
gatewayInfo: { | ||
edition: config.GATEWAY_EDITION, | ||
version: config.GATEWAY_VERSION, | ||
edition: infoStore.kongEdition, | ||
version: infoStore.kongVersion, | ||
}, | ||
apiBaseUrl: useAdminApiUrl(), | ||
apiBaseUrl: config.ADMIN_API_URL, | ||
} as Pick<KongManagerBaseFormConfig, 'app' | 'workspace' | 'gatewayInfo' | 'apiBaseUrl'>) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
import { reactive } from 'vue' | ||
import { config } from 'config' | ||
import { useInfoStore } from '@/stores/info' | ||
import type { KongManagerBaseTableConfig } from '@kong-ui/entities-shared' | ||
import { useAdminApiUrl } from './useAdminApiUrl' | ||
|
||
const infoStore = useInfoStore() | ||
|
||
export const useListGeneralConfig = () => { | ||
return reactive({ | ||
app: 'kongManager' as const, | ||
workspace: '', | ||
gatewayInfo: { | ||
edition: config.GATEWAY_EDITION, | ||
version: config.GATEWAY_VERSION, | ||
edition: infoStore.kongEdition, | ||
version: infoStore.kongVersion, | ||
}, | ||
apiBaseUrl: useAdminApiUrl(), | ||
apiBaseUrl: config.ADMIN_API_URL, | ||
// Kong Gateway OSS only supports exact match and does not support sorting | ||
isExactMatch: true, | ||
disableSorting: true, | ||
} as Pick<KongManagerBaseTableConfig, 'app' | 'workspace' | 'gatewayInfo' | 'isExactMatch' | 'apiBaseUrl' | 'disableSorting'>) | ||
isExactMatch: infoStore.kongEdition === 'community', | ||
disableSorting: infoStore.kongEdition === 'community', | ||
}) as Pick<KongManagerBaseTableConfig, 'app' | 'workspace' | 'gatewayInfo' | 'isExactMatch' | 'apiBaseUrl' | 'disableSorting'> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import axios, { | ||
type AxiosInstance, | ||
type AxiosRequestConfig, | ||
} from 'axios' | ||
import { config } from 'config' | ||
|
||
const adminApiUrl = config.ADMIN_API_URL | ||
|
||
class ApiService { | ||
instance: AxiosInstance | ||
|
||
constructor () { | ||
this.instance = axios.create({ | ||
timeout: 30000, | ||
}) | ||
} | ||
|
||
getInfo () { | ||
return this.instance.get(`${adminApiUrl}`) | ||
} | ||
|
||
// entity-specific methods | ||
findAll (entity: string, params: Pick<AxiosRequestConfig, 'params'> = {}) { | ||
return this.instance.get(`${adminApiUrl}/${entity}`, { params }) | ||
} | ||
|
||
findRecord (entity: string, id: string) { | ||
return this.instance.get(`${adminApiUrl}/${entity}/${id}`) | ||
} | ||
|
||
createRecord (entity: string, data: Record<string, unknown>) { | ||
return this.instance.post(`${adminApiUrl}/${entity}`, data) | ||
} | ||
|
||
updateRecord (entity: string, id: string, data: Record<string, unknown>) { | ||
return this.instance.patch(`${adminApiUrl}/${entity}/${id}`, data) | ||
} | ||
|
||
deleteRecord (entity: string, id: string) { | ||
return this.instance.delete(`${adminApiUrl}/${entity}/${id}`) | ||
} | ||
|
||
// generic methods | ||
get (url = '', config: AxiosRequestConfig = {}) { | ||
return this.instance.get(`${adminApiUrl}/${url}`, config) | ||
} | ||
|
||
post (url = '', data?: Record<string, unknown>, config: AxiosRequestConfig = {}) { | ||
return this.instance.post(`${adminApiUrl}/${url}`, data, config) | ||
} | ||
|
||
put (url = '', data?: Record<string, unknown>, config: AxiosRequestConfig = {}) { | ||
return this.instance.put(`${adminApiUrl}/${url}`, data, config) | ||
} | ||
|
||
patch (url = '', data?: Record<string, unknown>, config: AxiosRequestConfig = {}) { | ||
return this.instance.patch(`${adminApiUrl}/${url}`, data, config) | ||
} | ||
|
||
delete (url = '', config: AxiosRequestConfig = {}) { | ||
return this.instance.delete(`${adminApiUrl}/${url}`, config) | ||
} | ||
} | ||
|
||
export const apiService = new ApiService() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { apiService } from '@/services/apiService' | ||
import { defineStore } from 'pinia' | ||
import type { AnyObject, Info } from './types' | ||
|
||
interface State { | ||
info: Info; | ||
} | ||
|
||
export const useInfoStore = defineStore('info', { | ||
state: (): State => ({ | ||
info: {}, | ||
}), | ||
|
||
getters: { | ||
kongVersion: state => state.info.version, | ||
kongEdition: state => state.info.edition, | ||
infoConfig: (state) => { | ||
const config = state.info.configuration || {} | ||
if (!config?.node) { | ||
config.node = {} | ||
config.node.version = state.info.version | ||
config.node.edition = state.info.edition | ||
config.node.tagline = state.info.tagline | ||
config.node.hostname = state.info.hostname | ||
config.node.lua_version = state.info.lua_version | ||
} | ||
|
||
return config | ||
}, | ||
isHybridMode: (state) => { | ||
return (state.info.configuration?.role ?? 'traditional') !== 'traditional' | ||
}, | ||
plugins: (state) => ({ | ||
enabledInCluster: state.info.plugins?.enabled_in_cluster ?? [], | ||
availableOnServer: state.info.plugins?.available_on_server ?? [], | ||
}), | ||
}, | ||
|
||
actions: { | ||
async getInfo (payload: AnyObject = { silent: true, force: false }) { | ||
const { silent = true, force = false } = payload | ||
|
||
// Return the info if it's already loaded unless force is true | ||
if (this.info?.version && !force) { | ||
return this.info | ||
} | ||
|
||
return apiService.getInfo() | ||
.then((info) => { | ||
this.info = info.data | ||
|
||
return info.data | ||
}) | ||
.catch(err => { | ||
if (silent) { | ||
return | ||
} | ||
|
||
throw err | ||
}) | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { GatewayEdition } from '@/config' | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export type AnyObject = Record<string, any> | ||
|
||
export interface Info { | ||
configuration?: { | ||
database?: string | ||
node?: { | ||
hostname?: string | ||
lua_version?: string | ||
tagline?: string | ||
version?: string | ||
edition?: GatewayEdition | ||
} | ||
role?: 'traditional' | 'control_plane' | 'data_plane' | ||
admin_listen?: string[] | ||
admin_gui_listeners?: Array<{ port: number, ssl?: boolean }> | ||
proxy_listeners?: Array<{ port: number, ssl?: boolean }> | ||
pg_user?: string | ||
pg_host?: string | ||
pg_port?: number | ||
pg_ssl?: boolean | ||
} & AnyObject | ||
license?: AnyObject | ||
version?: string, | ||
edition?: GatewayEdition, | ||
timers?: AnyObject | ||
plugins?: AnyObject | ||
hostname?: string | ||
tagline?: string | ||
lua_version?: string | ||
} |
Oops, something went wrong.