-
Notifications
You must be signed in to change notification settings - Fork 555
Closed
Description
Failing Test Code
const kc = new k8s.KubeConfig();
kc.addCluster({
name: 'test',
server: `https://localhost:9889`,
skipTLSVerify: true,
})
///TypeError: Cannot read property 'forEach' of undefined
/// at KubeConfig.addCluster (/Users/test/project/node_modules/@kubernetes/client-node/dist/config.js:176:23)
kc.addUser({
token: 'test',
username: 'test',
name: 'test',
})
kc.addContext({
cluster: 'test',
name: 'test',
user: 'test',
})
kc.setCurrentContext('test')
Code Referenced By StackTrace
// ...
addCluster(cluster) {
this.clusters.forEach((c, ix) => {
if (c.name === cluster.name) {
throw new Error(`Duplicate cluster: ${c.name}`);
}
});
this.clusters.push(cluster);
}
addUser(user) {
this.users.forEach((c, ix) => {
if (c.name === user.name) {
throw new Error(`Duplicate user: ${c.name}`);
}
});
this.users.push(user);
}
addContext(ctx) {
this.contexts.forEach((c, ix) => {
if (c.name === ctx.name) {
throw new Error(`Duplicate context: ${c.name}`);
}
});
this.contexts.push(ctx);
}
// ...
It looks like it's as simple as this.clusters
, this.users
, this.contexts
not being defined when the KubeConfig
is created. The fix would be to just define them when the object is created.
I would create a PR, but I've been fighting the CLA for a while now, and never got it figured out.
Metadata
Metadata
Assignees
Labels
No labels