godaddy / kubernetes-client

Simplified Kubernetes API client for Node.js.
MIT License
961 stars 192 forks source link

Storage API not found #670

Closed TairuiWang closed 4 years ago

TairuiWang commented 4 years ago

I can use some other APIs like apis and v1. However, I got storage not defined error during using the storage API. Here is part of my code

import { Client1_10, config } from 'kubernetes-client';

...

client = new Client1_10({ config: config.fromKubeconfig(), version: '1.9'});
client.loadSpec();

...

const response: any = await client.apis.storage.k8s.io.v1beta1.storageclasses.get();

This is the error I got:

[8/28/2020, 5:34:55 PM] ERROR [ 'TypeError: Cannot read property \'k8s\' of undefined\n    at ...]

However, if I print the client.apis, I can find the storage.k8s.io under it.

templatedEndpoints: null,
    parameter: null,
    splits: [ 'apis' ],
    http: Request { requestOptions: [Object], authProvider: [Object] },
    getNames: [Function],
    children:
     [ 'autoscaling',
       'apps',
       'app',
       'rbac.authorization.k8s.io',
       'v1',
       'policy',
       'networking.k8s.io',
       'extensions',
       'extension',
       'events.k8s.io',
       'batch',
       'settings.k8s.io',
       'storage.k8s.io',
       'scheduling.k8s.io',
       'apiregistration.k8s.io',
       'apiextensions.k8s.io',
       'admissionregistration.k8s.io',
       'certificates.k8s.io',
       'authorization.k8s.io',
       'authentication.k8s.io' ],
TairuiWang commented 4 years ago

my bad, wrong api call