1- 'use client'
21
32import React , { createContext , useContext , useMemo , useState } from 'react'
4- import { KubernetesClient } from 'kubernetesjs '
3+ import { KubernetesClient } from './swagger-client '
54import { QueryClient , QueryClientProvider } from '@tanstack/react-query'
65
76// Configuration types
87export interface KubernetesConfig {
98 restEndpoint : string
10- namespace ?: string
119 headers ?: Record < string , string >
1210}
1311
1412// Context types
1513interface KubernetesContextValue {
1614 client : KubernetesClient
17- config : KubernetesConfig
18- namespace : string
19- setNamespace : ( namespace : string ) => void
20- updateConfig : ( config : Partial < KubernetesConfig > ) => void
2115}
2216
2317// Create context
@@ -47,34 +41,19 @@ export function KubernetesProvider({
4741 initialConfig
4842} : KubernetesProviderProps ) {
4943 const [ config , setConfig ] = useState < KubernetesConfig > ( {
50- restEndpoint : initialConfig ?. restEndpoint || process . env . NEXT_PUBLIC_K8S_API_URL || '/api/k8s' ,
51- namespace : initialConfig ?. namespace || 'default' ,
44+ restEndpoint : initialConfig ?. restEndpoint ,
5245 headers : initialConfig ?. headers || { } ,
5346 } )
5447
55- const [ namespace , setNamespace ] = useState ( config . namespace || 'default' )
56-
5748 // Create client instance
5849 const client = useMemo ( ( ) => {
5950 return new KubernetesClient ( {
6051 restEndpoint : config . restEndpoint ,
6152 } )
6253 } , [ config . restEndpoint ] )
6354
64- // Update config function
65- const updateConfig = ( newConfig : Partial < KubernetesConfig > ) => {
66- setConfig ( prev => ( { ...prev , ...newConfig } ) )
67- if ( newConfig . namespace ) {
68- setNamespace ( newConfig . namespace )
69- }
70- }
71-
7255 const contextValue : KubernetesContextValue = {
73- client,
74- config,
75- namespace,
76- setNamespace,
77- updateConfig,
56+ client
7857 }
7958
8059 return (
@@ -96,4 +75,4 @@ export function useKubernetes() {
9675}
9776
9877// Export query client for use in hooks
99- export { queryClient }
78+ export { queryClient } ;
0 commit comments