You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, patch-example.js doesn't work with kc.loadFromCluster() instead of kc.loadFromDefault(). The app is running in a pod, and it causes Error: Cluster is undefined#2117 (comment)
I'm not sure if it's a bug or if there is another usage to fix it. At least, loadFromCluster works in v0 for me.
it looks like currentCluster is undefined in the loadFromCluster function. You could try substituting getClusters()[0] instead of getCurrentCluster() and see if that works.
But we should probably check and fix to make it so that getCurrentCluster() works.
changed the title [-]patch-example.js doesn't work with kc.loadFromCluster()[/-][+]kc.loadFromCluster() doesn't setup `getCurrentCluster()` correctly.[/+]on Jan 21, 2025
The call to kc.getCurrentContext() always returns the value 'inClusterContext'.
So, you're always executing kc.getCluster('inClusterContext'). Internally, this searches the list of clusters for one whose name is 'inClusterContext'. A cluster with the same name as the context does not exist.
@koooge can you confirm if changing the code from kc.getCluster(currentContext); to kc.getCurrentCluster(); gets you past that error. It seems to me like the example should be using that code.
Activity
brendandburns commentedon Jan 21, 2025
it looks like
currentClusteris undefined in theloadFromClusterfunction. You could try substitutinggetClusters()[0]instead ofgetCurrentCluster()and see if that works.But we should probably check and fix to make it so that
getCurrentCluster()works.[-]patch-example.js doesn't work with kc.loadFromCluster()[/-][+]kc.loadFromCluster() doesn't setup `getCurrentCluster()` correctly.[/+]cjihrig commentedon Jan 30, 2025
I think this is a minimal reproduction:
When
kc.loadFromCluster()is called,kc.clustersis set to:The call to
kc.getCurrentContext()always returns the value'inClusterContext'.So, you're always executing
kc.getCluster('inClusterContext'). Internally, this searches the list of clusters for one whosenameis'inClusterContext'. A cluster with the same name as the context does not exist.cjihrig commentedon Jan 30, 2025
It looks like that does work.
cjihrig commentedon Jan 31, 2025
@koooge can you confirm if changing the code from
kc.getCluster(currentContext);tokc.getCurrentCluster();gets you past that error. It seems to me like the example should be using that code.brendandburns commentedon Jan 31, 2025
@cjihrig thanks for looking closer at this. You are correct, there is a bug in the code from @koooge
It should be:
kc.getCluster(kc.getContextObject(kc.getCurrentContext()).cluster)but really
kc.getCurrentCluster()is easier.I did notice that our code coverage for this code is low, so I added #2191
I'm going to close this as working as intended.
examples: fix confusing patch example code