Repository: kubernetes-client/javascript
Pull request #1074 (2023-05-04 16:52:33)

chore: update examples node fetch
This fixes a few of the examples in the `FETCH_MIGRATION` markdown file. The ones I have checked off I have tested. I have also updated a few more I will include in another PR that I have not been able to successfully test because of this issue:
https://github.com/kubernetes-client/javascript/issues/893

I also added the typescript examples to the document, as they will need to be upgraded as well.

k8s-ci-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes-client/javascript/pull/1074#" title="Author self-approved">clintonmedbery</a>*, *<a href="https://github.com/kubernetes-client/javascript/pull/1074#pullrequestreview-1414290480" title="Approved">mstruebing</a>*
**Once this PR has been reviewed and has the lgtm label**, please assign drubin for approval. For more information see [the Kubernetes Code Review Process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process).

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes-client%2Fjavascript).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/kubernetes-client/javascript/blob/release-1.x/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["drubin"]} -->
brendandburns: One minor comment.

Patch:
diff --git a/FETCH_MIGRATION.md b/FETCH_MIGRATION.md
index 3b72954e..36be2b8c 100644
--- a/FETCH_MIGRATION.md
+++ b/FETCH_MIGRATION.md
@@ -52,29 +52,41 @@ Code will be on the `master` branch.
 -   [x] Fix errors in /src folder (due to new api)
     -   [x] migrate src/auth.ts, the dependent implementations (ex: azure_auth, gcp_auth etc) and tests to fetch api from request
     -   [x] migrate src/log.ts and its tests to fetch api from request
-        -  [x] major remaining work is fixing up async signatures and return piping
+        -   [x] major remaining work is fixing up async signatures and return piping
     -   [x] migrate src/watch.ts and its tests to fetch api from request
-        -  [x] remove decprecated requestImpl and RequestInterface
-        -  [x] implement queryParams parameter in watch method by injecting them into the fetch call
-        -  [x] update tests in src/watch_test.ts
+        -   [x] remove decprecated requestImpl and RequestInterface
+        -   [x] implement queryParams parameter in watch method by injecting them into the fetch call
+        -   [x] update tests in src/watch_test.ts
 -   [x] Fix errors in test (due to new api)
 -   [ ] Test all features
--   [ ] Fix examples and validate their param signatures (due to new api)
+-   [ ] Fix JavaScript examples and validate their param signatures (due to new api)
 
-    -   [ ] cache-example
-    -   [ ] example
-    -   [ ] follow-logs
+    -   [x] cache-example
+    -   [x] example
+    -   [x] follow-logs
     -   [ ] in-cluster-create-job-from-cronjob
-    -   [ ] in-cluster
-    -   [ ] ingress
+    -   [x] in-cluster
+    -   [x] ingress
     -   [ ] namespace
     -   [ ] patch-example
     -   [ ] raw-example (note: uses request lib directly, will require full fetch migration not just client param swap)
     -   [ ] scale-deployment
-    -   [ ] top_pods
-    -   [ ] top
+    -   [x] top_pods
+    -   [x] top
     -   [ ] yaml-example
 
+-   [ ] Fix TypeScript examples and validate their param signatures (due to new api)
+
+    -   [ ] apply-example
+    -   [ ] attach-example
+    -   [ ] cp-example
+    -   [ ] exec-example
+    -   [ ] informer-with-label-selector
+    -   [ ] informer
+    -   [ ] port-forward
+    -   [ ] example
+    -   [ ] watch-example
+
 -   [ ] Update docs
     -   [ ] Update README examples
 -   [ ] Document breaking changes for users
diff --git a/build-package.sh b/build-package.sh
index 54b2a13d..23285301 100755
--- a/build-package.sh
+++ b/build-package.sh
@@ -6,9 +6,6 @@ set -e
 # validate branches
 . ./pre-check.sh
 
-npm run clean
-npm install
-
 # pre-requisites
 npm run lint
 npm test
diff --git a/examples/cache-example.js b/examples/cache-example.js
index e489633e..3094f80a 100644
--- a/examples/cache-example.js
+++ b/examples/cache-example.js
@@ -1,4 +1,5 @@
-const k8s = require('@kubernetes/client-node');
+// in a real program use require('@kubernetes/client-node')
+const k8s = require('../dist/index');
 
 const kc = new k8s.KubeConfig();
 kc.loadFromDefault();
@@ -8,7 +9,7 @@ const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
 const path = '/api/v1/pods';
 const watch = new k8s.Watch(kc);
 
-const listFn = () => k8sApi.listPodForAllNamespaces()
+const listFn = () => k8sApi.listPodForAllNamespaces();
 
 const cache = new k8s.ListWatch(path, watch, listFn);
 
@@ -22,6 +23,6 @@ const looper = () => {
         console.log(names.join(','));
     }
     setTimeout(looper, 2000);
-}
+};
 
 looper();
diff --git a/examples/example.js b/examples/example.js
index 414922cf..849c0d2e 100644
--- a/examples/example.js
+++ b/examples/example.js
@@ -1,12 +1,16 @@
-const k8s = require('@kubernetes/client-node');
+// in a real program use require('@kubernetes/client-node')
+const k8s = require('../dist/index');
 
 const kc = new k8s.KubeConfig();
 kc.loadFromDefault();
 
 const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
 
-k8sApi.listNamespacedPod('default')
+k8sApi
+    .listNamespacedPod({ namespace: 'default' })
     .then((res) => {
-	console.log(res.body);
+        console.log(res);
+    })
+    .catch((err) => {
+        console.error(err);
     });
-
diff --git a/examples/follow-logs.js b/examples/follow-logs.js
index caa7e982..40fabbdc 100644
--- a/examples/follow-logs.js
+++ b/examples/follow-logs.js
@@ -1,5 +1,6 @@
 const stream = require('stream');
-const k8s = require('@kubernetes/client-node');
+// in a real program use require('@kubernetes/client-node')
+const k8s = require('../dist/index');
 
 const kc = new k8s.KubeConfig();
 kc.loadFromDefault();
@@ -9,15 +10,23 @@ const log = new k8s.Log(kc);
 const logStream = new stream.PassThrough();
 
 logStream.on('data', (chunk) => {
-	// use write rather than console.log to prevent double line feed
-	process.stdout.write(chunk);
+    // use write rather than console.log to prevent double line feed
+    process.stdout.write(chunk);
 });
 
-log.log('default', 'pod1', 'container1', logStream, {follow: true, tailLines: 50, pretty: false, timestamps: false})
-.catch(err => {console.log(err)})
-.then(req => {
-	// disconnects after 5 seconds
-	setTimeout(function(){
-		req.abort();
-	}, 5000);
-});
+log.log('default', 'pod1', 'container1', logStream, {
+    follow: true,
+    tailLines: 50,
+    pretty: false,
+    timestamps: false,
+})
+    .catch((err) => {
+        console.error(err);
+    })
+    .then((req) => {
+        // disconnects after 5 seconds
+        setTimeout(function () {
+            //Note: You might have to install AbortController if you are using node version < 15.0.0
+            req.abort();
+        }, 5000);
+    });
diff --git a/examples/in-cluster.js b/examples/in-cluster.js
index db221e53..5e99afbf 100644
--- a/examples/in-cluster.js
+++ b/examples/in-cluster.js
@@ -1,15 +1,16 @@
-const k8s = require('@kubernetes/client-node');
+// in a real program use require('@kubernetes/client-node')
+const k8s = require('../dist/index');
 
 const kc = new k8s.KubeConfig();
 kc.loadFromCluster();
 
 const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
 
-k8sApi.listNamespacedPod('default')
+k8sApi
+    .listNamespacedPod({ namespace: 'default' })
     .then((res) => {
-	console.log(res.body);
+        console.log(res);
     })
     .catch((err) => {
-        console.log(err);
+        console.error(err);
     });
-
diff --git a/examples/ingress.js b/examples/ingress.js
index 566511d7..0b382161 100644
--- a/examples/ingress.js
+++ b/examples/ingress.js
@@ -1,27 +1,41 @@
-const k8s = require('@kubernetes/client-node')
-const kc = new k8s.KubeConfig()
-kc.loadFromDefault()
+// in a real program use require('@kubernetes/client-node')
+const k8s = require('../dist/index');
 
-const k8sApi = kc.makeApiClient(k8s.NetworkingV1beta1Api) // before 1.14 use extensions/v1beta1
-const clientIdentifier = 'my-subdomain'
+const kc = new k8s.KubeConfig();
+kc.loadFromDefault();
 
-k8sApi.createNamespacedIngress('default', {
-  apiVersions: 'networking.k8s.io/v1beta1',
-  kind: 'Ingress',
-  metadata: { name: `production-custom-${clientIdentifier}` },
-  spec: {
-    rules: [{
-      host: `${clientIdentifier}.example.com`,
-      http: {
-        paths: [{
-          backend: {
-            serviceName: 'production-auto-deploy',
-            servicePort: 5000
-          },
-          path: '/'
-        }]
-      }
-    }],
-    tls: [{ hosts: [`${clientIdentifier}.example.com`] }]
-  }
-}).catch(e => console.log(e))
+const k8sApi = kc.makeApiClient(k8s.NetworkingV1Api);
+const clientIdentifier = 'my-subdomain';
+
+k8sApi
+    .createNamespacedIngress({
+        namespace: 'default',
+        body: {
+            apiVersion: 'networking.k8s.io/v1',
+            kind: 'Ingress',
+            metadata: { name: `production-custom-${clientIdentifier}` },
+            spec: {
+                rules: [
+                    {
+                        host: `${clientIdentifier}.example.com`,
+                        http: {
+                            paths: [
+                                {
+                                    backend: {
+                                        service: {
+                                            name: 'production-auto-deploy',
+                                            port: { number: 5000 },
+                                        },
+                                    },
+                                    path: '/',
+                                    pathType: 'ImplementationSpecific',
+                                },
+                            ],
+                        },
+                    },
+                ],
+                tls: [{ hosts: [`${clientIdentifier}.example.com`] }],
+            },
+        },
+    })
+    .catch((e) => console.error(e));
diff --git a/examples/top_pods.js b/examples/top_pods.js
index 1f3bd5b1..37e94c74 100644
--- a/examples/top_pods.js
+++ b/examples/top_pods.js
@@ -1,3 +1,4 @@
+// in a real program use require('@kubernetes/client-node')
 const k8s = require('../dist/index');
 
 const kc = new k8s.KubeConfig();
@@ -6,34 +7,30 @@ kc.loadFromDefault();
 const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
 const metricsClient = new k8s.Metrics(kc);
 
-k8s.topPods(k8sApi, metricsClient, "kube-system")
-.then((pods) => {
-
+k8s.topPods(k8sApi, metricsClient, 'kube-system').then((pods) => {
     const podsColumns = pods.map((pod) => {
         return {
-            "POD": pod.Pod.metadata.name,
-            "CPU(cores)": pod.CPU.CurrentUsage,
-            "MEMORY(bytes)": pod.Memory.CurrentUsage,
-        }
+            POD: pod.Pod.metadata?.name,
+            'CPU(cores)': pod.CPU.CurrentUsage,
+            'MEMORY(bytes)': pod.Memory.CurrentUsage,
+        };
     });
-    console.log("TOP PODS")
-    console.table(podsColumns)
+    console.log('TOP PODS');
+    console.table(podsColumns);
 });
 
-k8s.topPods(k8sApi, metricsClient, "kube-system")
-.then((pods) => {
-
+k8s.topPods(k8sApi, metricsClient, 'kube-system').then((pods) => {
     const podsAndContainersColumns = pods.flatMap((pod) => {
-        return pod.Containers.map(containerUsage => {
+        return pod.Containers.map((containerUsage) => {
             return {
-                "POD": pod.Pod.metadata.name,
-                "NAME": containerUsage.Container,
-                "CPU(cores)": containerUsage.CPUUsage.CurrentUsage,
-                "MEMORY(bytes)": containerUsage.MemoryUsage.CurrentUsage,
+                POD: pod.Pod.metadata?.name,
+                NAME: containerUsage.Container,
+                'CPU(cores)': containerUsage.CPUUsage.CurrentUsage,
+                'MEMORY(bytes)': containerUsage.MemoryUsage.CurrentUsage,
             };
-        })
+        });
     });
 
-    console.log("TOP CONTAINERS")
-    console.table(podsAndContainersColumns)
-});
\ No newline at end of file
+    console.log('TOP CONTAINERS');
+    console.table(podsAndContainersColumns);
+});
diff --git a/package-lock.json b/package-lock.json
index 8d4d53e2..25643ebc 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -454,6 +454,14 @@
             "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.1.tgz",
             "integrity": "sha512-xdOvNmXmrZqqPy3kuCQ+fz6wA0xU5pji9cd1nDrflWaAWtYLLGk5ykW0H6yg5TVyehHP1pfmuuSaZkhP+kspVA=="
         },
+        "node_modules/@types/minipass": {
+            "version": "2.2.0",
+            "resolved": "https://registry.npmjs.org/@types/minipass/-/minipass-2.2.0.tgz",
+            "integrity": "sha512-wuzZksN4w4kyfoOv/dlpov4NOunwutLA/q7uc00xU02ZyUY+aoM5PWIXEKBMnm0NHd4a+N71BMjq+x7+2Af1fg==",
+            "dependencies": {
+                "@types/node": "*"
+            }
+        },
         "node_modules/@types/mocha": {
             "version": "10.0.1",
             "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.1.tgz",
@@ -505,20 +513,12 @@
             }
         },
         "node_modules/@types/tar": {
-            "version": "6.1.4",
-            "resolved": "https://registry.npmjs.org/@types/tar/-/tar-6.1.4.tgz",
-            "integrity": "sha512-Cp4oxpfIzWt7mr2pbhHT2OTXGMAL0szYCzuf8lRWyIMCgsx6/Hfc3ubztuhvzXHXgraTQxyOCmmg7TDGIMIJJQ==",
+            "version": "6.1.1",
+            "resolved": "https://registry.npmjs.org/@types/tar/-/tar-6.1.1.tgz",
+            "integrity": "sha512-8mto3YZfVpqB1CHMaYz1TUYIQfZFbh/QbEq5Hsn6D0ilCfqRVCdalmc89B7vi3jhl9UYIk+dWDABShNfOkv5HA==",
             "dependencies": {
-                "@types/node": "*",
-                "minipass": "^4.0.0"
-            }
-        },
-        "node_modules/@types/tar/node_modules/minipass": {
-            "version": "4.2.8",
-            "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.8.tgz",
-            "integrity": "sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==",
-            "engines": {
-                "node": ">=8"
+                "@types/minipass": "*",
+                "@types/node": "*"
             }
         },
         "node_modules/@types/underscore": {
@@ -2232,9 +2232,9 @@
             }
         },
         "node_modules/nock": {
-            "version": "13.3.1",
-            "resolved": "https://registry.npmjs.org/nock/-/nock-13.3.1.tgz",
-            "integrity": "sha512-vHnopocZuI93p2ccivFyGuUfzjq2fxNyNurp7816mlT5V5HF4SzXu8lvLrVzBbNqzs+ODooZ6OksuSUNM7Njkw==",
+            "version": "13.2.9",
+            "resolved": "https://registry.npmjs.org/nock/-/nock-13.2.9.tgz",
+            "integrity": "sha512-1+XfJNYF1cjGB+TKMWi29eZ0b82QOvQs2YoLNzbpWGqFMtRQHTa57osqdGj4FrFPgkO4D4AZinzUJR9VvW3QUA==",
             "dev": true,
             "dependencies": {
                 "debug": "^4.1.0",
@@ -2997,27 +2997,19 @@
             }
         },
         "node_modules/tar": {
-            "version": "6.1.14",
-            "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.14.tgz",
-            "integrity": "sha512-piERznXu0U7/pW7cdSn7hjqySIVTYT6F76icmFk7ptU7dDYlXTm5r9A6K04R2vU3olYgoKeo1Cg3eeu5nhftAw==",
+            "version": "6.1.11",
+            "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz",
+            "integrity": "sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==",
             "dependencies": {
                 "chownr": "^2.0.0",
                 "fs-minipass": "^2.0.0",
-                "minipass": "^5.0.0",
+                "minipass": "^3.0.0",
                 "minizlib": "^2.1.1",
                 "mkdirp": "^1.0.3",
                 "yallist": "^4.0.0"
             },
             "engines": {
-                "node": ">=10"
-            }
-        },
-        "node_modules/tar/node_modules/minipass": {
-            "version": "5.0.0",
-            "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz",
-            "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==",
-            "engines": {
-                "node": ">=8"
+                "node": ">= 10"
             }
         },
         "node_modules/tar/node_modules/mkdirp": {
@@ -3915,6 +3907,14 @@
             "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.1.tgz",
             "integrity": "sha512-xdOvNmXmrZqqPy3kuCQ+fz6wA0xU5pji9cd1nDrflWaAWtYLLGk5ykW0H6yg5TVyehHP1pfmuuSaZkhP+kspVA=="
         },
+        "@types/minipass": {
+            "version": "2.2.0",
+            "resolved": "https://registry.npmjs.org/@types/minipass/-/minipass-2.2.0.tgz",
+            "integrity": "sha512-wuzZksN4w4kyfoOv/dlpov4NOunwutLA/q7uc00xU02ZyUY+aoM5PWIXEKBMnm0NHd4a+N71BMjq+x7+2Af1fg==",
+            "requires": {
+                "@types/node": "*"
+            }
+        },
         "@types/mocha": {
             "version": "10.0.1",
             "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.1.tgz",
@@ -3965,19 +3965,12 @@
             }
         },
         "@types/tar": {
-            "version": "6.1.4",
-            "resolved": "https://registry.npmjs.org/@types/tar/-/tar-6.1.4.tgz",
-            "integrity": "sha512-Cp4oxpfIzWt7mr2pbhHT2OTXGMAL0szYCzuf8lRWyIMCgsx6/Hfc3ubztuhvzXHXgraTQxyOCmmg7TDGIMIJJQ==",
+            "version": "6.1.1",
+            "resolved": "https://registry.npmjs.org/@types/tar/-/tar-6.1.1.tgz",
+            "integrity": "sha512-8mto3YZfVpqB1CHMaYz1TUYIQfZFbh/QbEq5Hsn6D0ilCfqRVCdalmc89B7vi3jhl9UYIk+dWDABShNfOkv5HA==",
             "requires": {
-                "@types/node": "*",
-                "minipass": "^4.0.0"
-            },
-            "dependencies": {
-                "minipass": {
-                    "version": "4.2.8",
-                    "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.8.tgz",
-                    "integrity": "sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ=="
-                }
+                "@types/minipass": "*",
+                "@types/node": "*"
             }
         },
         "@types/underscore": {
@@ -5256,9 +5249,9 @@
             "dev": true
         },
         "nock": {
-            "version": "13.3.1",
-            "resolved": "https://registry.npmjs.org/nock/-/nock-13.3.1.tgz",
-            "integrity": "sha512-vHnopocZuI93p2ccivFyGuUfzjq2fxNyNurp7816mlT5V5HF4SzXu8lvLrVzBbNqzs+ODooZ6OksuSUNM7Njkw==",
+            "version": "13.2.9",
+            "resolved": "https://registry.npmjs.org/nock/-/nock-13.2.9.tgz",
+            "integrity": "sha512-1+XfJNYF1cjGB+TKMWi29eZ0b82QOvQs2YoLNzbpWGqFMtRQHTa57osqdGj4FrFPgkO4D4AZinzUJR9VvW3QUA==",
             "dev": true,
             "requires": {
                 "debug": "^4.1.0",
@@ -5829,23 +5822,18 @@
             }
         },
         "tar": {
-            "version": "6.1.14",
-            "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.14.tgz",
-            "integrity": "sha512-piERznXu0U7/pW7cdSn7hjqySIVTYT6F76icmFk7ptU7dDYlXTm5r9A6K04R2vU3olYgoKeo1Cg3eeu5nhftAw==",
+            "version": "6.1.11",
+            "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz",
+            "integrity": "sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==",
             "requires": {
                 "chownr": "^2.0.0",
                 "fs-minipass": "^2.0.0",
-                "minipass": "^5.0.0",
+                "minipass": "^3.0.0",
                 "minizlib": "^2.1.1",
                 "mkdirp": "^1.0.3",
                 "yallist": "^4.0.0"
             },
             "dependencies": {
-                "minipass": {
-                    "version": "5.0.0",
-                    "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz",
-                    "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ=="
-                },
                 "mkdirp": {
                     "version": "1.0.4",
                     "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
diff --git a/pre-check.sh b/pre-check.sh
index 1dfa663c..86c101d6 100644
--- a/pre-check.sh
+++ b/pre-check.sh
@@ -2,8 +2,8 @@
 
 branch=$(git rev-parse --abbrev-ref HEAD)
 
-if [[ "${branch}" != "release-1.x" ]]; then
-  echo "This script can only be run on the release-1.x branch. Current branch is ${branch}"
+if [[ "${branch}" != "master" ]]; then
+  echo "This script can only be run on the master branch. Current branch is ${branch}"
   exit 1
 fi
 
diff --git a/src/cache.ts b/src/cache.ts
index 169a4139..d5233a73 100644
--- a/src/cache.ts
+++ b/src/cache.ts
@@ -132,8 +132,7 @@ export class ListWatch<T extends KubernetesObject> implements ObjectCache<T>, In
         this.callbackCache[CONNECT].forEach((elt: ErrorCallback) => elt(undefined));
         if (!this.resourceVersion) {
             const promise = this.listFn();
-            const result = await promise;
-            const list = result.body;
+            const list = await promise;
             this.objects = deleteItems(this.objects, list.items, this.callbackCache[DELETE].slice());
             Object.keys(this.indexCache).forEach((key) => {
                 const updateObjects = deleteItems(this.indexCache[key], list.items);
diff --git a/src/informer.ts b/src/informer.ts
index bde49b82..c652dabc 100644
--- a/src/informer.ts
+++ b/src/informer.ts
@@ -3,15 +3,10 @@ import { KubeConfig } from './config';
 import { KubernetesListObject, KubernetesObject } from './types';
 import { Watch } from './watch';
 
-import http = require('http');
-
 export type ObjectCallback<T extends KubernetesObject> = (obj: T) => void;
 export type ErrorCallback = (err?: any) => void;
 export type ListCallback<T extends KubernetesObject> = (list: T[], ResourceVersion: string) => void;
-export type ListPromise<T extends KubernetesObject> = () => Promise<{
-    response: http.IncomingMessage;
-    body: KubernetesListObject<T>;
-}>;
+export type ListPromise<T extends KubernetesObject> = () => Promise<KubernetesListObject<T>>;
 
 // These are issued per object
 export const ADD: string = 'add';


Test patch:
diff --git a/src/cache_test.ts b/src/cache_test.ts
index 49c13dd0..559440d4 100644
--- a/src/cache_test.ts
+++ b/src/cache_test.ts
@@ -46,23 +46,15 @@ const fakeConfig: {
 describe('ListWatchCache', () => {
     it('should throw on unknown update', () => {
         const fake = mock.mock(Watch);
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>(
-                (resolve, reject) => {
-                    resolve({
-                        response: {} as http.IncomingMessage,
-                        body: {
-                            metadata: {
-                                resourceVersion: '12345',
-                            } as V1ListMeta,
-                            items: [],
-                        } as V1NamespaceList,
-                    });
-                },
-            );
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve, reject) => {
+                resolve({
+                    metadata: {
+                        resourceVersion: '12345',
+                    } as V1ListMeta,
+                    items: [],
+                } as V1NamespaceList);
+            });
         };
         const lw = new ListWatch('/some/path', fake, listFn);
         const verb = 'FOOBAR';
@@ -109,19 +101,14 @@ describe('ListWatchCache', () => {
         } as V1NamespaceList;
 
         let calls = 0;
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>(
-                (resolve, reject) => {
-                    if (calls++ === 0) {
-                        resolve({ response: {} as http.IncomingMessage, body: listObj });
-                    } else {
-                        resolve({ response: {} as http.IncomingMessage, body: emptyObj });
-                    }
-                },
-            );
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve, reject) => {
+                if (calls++ === 0) {
+                    resolve(listObj);
+                } else {
+                    resolve(emptyObj);
+                }
+            });
         };
         const promise = new Promise((resolve) => {
             mock.when(
@@ -219,15 +206,10 @@ describe('ListWatchCache', () => {
             items: list,
         } as V1NamespaceList;
 
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>(
-                (resolve, reject) => {
-                    resolve({ response: {} as http.IncomingMessage, body: listObj });
-                },
-            );
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve, reject) => {
+                resolve(listObj);
+            });
         };
         const promise = new Promise((resolve) => {
             mock.when(
@@ -308,15 +290,10 @@ describe('ListWatchCache', () => {
             items: list,
         } as V1NamespaceList;
 
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>(
-                (resolve, reject) => {
-                    resolve({ response: {} as http.IncomingMessage, body: listObj });
-                },
-            );
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve, reject) => {
+                resolve(listObj);
+            });
         };
         const promise = new Promise((resolve) => {
             mock.when(
@@ -371,15 +348,10 @@ describe('ListWatchCache', () => {
             items: [],
         } as V1NamespaceList;
 
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>(
-                (resolve, reject) => {
-                    resolve({ response: {} as http.IncomingMessage, body: listObj });
-                },
-            );
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve, reject) => {
+                resolve(listObj);
+            });
         };
         const promise = new Promise((resolve) => {
             mock.when(
@@ -440,15 +412,10 @@ describe('ListWatchCache', () => {
             items: list,
         } as V1NamespaceList;
 
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>(
-                (resolve, reject) => {
-                    resolve({ response: {} as http.IncomingMessage, body: listObj });
-                },
-            );
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve, reject) => {
+                resolve(listObj);
+            });
         };
         let promise = new Promise((resolve) => {
             mock.when(
@@ -516,15 +483,10 @@ describe('ListWatchCache', () => {
             items: list,
         } as V1NamespaceList;
 
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>(
-                (resolve, reject) => {
-                    resolve({ response: {} as http.IncomingMessage, body: listObj });
-                },
-            );
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve, reject) => {
+                resolve(listObj);
+            });
         };
         let promise = new Promise((resolve) => {
             mock.when(
@@ -596,15 +558,10 @@ describe('ListWatchCache', () => {
             items: list,
         } as V1NamespaceList;
 
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>(
-                (resolve, reject) => {
-                    resolve({ response: {} as http.IncomingMessage, body: listObj });
-                },
-            );
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve, reject) => {
+                resolve(listObj);
+            });
         };
         const promise = new Promise((resolve) => {
             mock.when(
@@ -720,12 +677,9 @@ describe('ListWatchCache', () => {
             } as V1ListMeta,
             items: list,
         } as V1NamespaceList;
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>((resolve) => {
-                resolve({ response: {} as http.IncomingMessage, body: listObj });
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve) => {
+                resolve(listObj);
             });
         };
         const watchCalled = new Promise((resolve) => {
@@ -779,12 +733,9 @@ describe('ListWatchCache', () => {
             } as V1ListMeta,
             items: list,
         } as V1NamespaceList;
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>((resolve) => {
-                resolve({ response: {} as http.IncomingMessage, body: listObj });
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve) => {
+                resolve(listObj);
             });
         };
         const watchCalled = new Promise((resolve) => {
@@ -840,14 +791,11 @@ describe('ListWatchCache', () => {
             items: list,
         } as V1NamespaceList;
 
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>((resolve) => {
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve) => {
                 // setImmediate will defer the resolve to the next message loop to keep the list from being immediately available
                 setImmediate(() => {
-                    resolve({ response: {} as http.IncomingMessage, body: listObj });
+                    resolve(listObj);
                 });
             });
         };
@@ -867,12 +815,9 @@ describe('ListWatchCache', () => {
             } as V1ListMeta,
             items: list,
         } as V1NamespaceList;
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>((resolve) => {
-                resolve({ response: {} as http.IncomingMessage, body: listObj });
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve) => {
+                resolve(listObj);
             });
         };
         const watchCalled = new Promise((resolve) => {
@@ -945,15 +890,10 @@ describe('ListWatchCache', () => {
             items: list,
         } as V1NamespaceList;
 
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>(
-                (resolve, reject) => {
-                    resolve({ response: {} as http.IncomingMessage, body: listObj });
-                },
-            );
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve, reject) => {
+                resolve(listObj);
+            });
         };
         const promise = new Promise((resolve) => {
             mock.when(
@@ -1008,15 +948,10 @@ describe('ListWatchCache', () => {
             items: list,
         } as V1NamespaceList;
 
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>(
-                (resolve, reject) => {
-                    resolve({ response: {} as http.IncomingMessage, body: listObj });
-                },
-            );
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve, reject) => {
+                resolve(listObj);
+            });
         };
         const promise = new Promise((resolve) => {
             mock.when(
@@ -1054,13 +989,10 @@ describe('ListWatchCache', () => {
             items: list,
         } as V1NamespaceList;
 
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>((resolve) => {
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve) => {
                 listCalls++;
-                resolve({ response: {} as http.IncomingMessage, body: listObj });
+                resolve(listObj);
             });
         };
         let promise = new Promise((resolve) => {
@@ -1110,13 +1042,10 @@ describe('ListWatchCache', () => {
         } as V1NamespaceList;
 
         let listCalls = 0;
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>((resolve) => {
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve) => {
                 listCalls++;
-                resolve({ response: {} as http.IncomingMessage, body: listObj });
+                resolve(listObj);
             });
         };
         let promise = new Promise((resolve) => {
@@ -1200,15 +1129,10 @@ describe('ListWatchCache', () => {
             items: list,
         } as V1NamespaceList;
 
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>(
-                (resolve, reject) => {
-                    resolve({ response: {} as http.IncomingMessage, body: listObj });
-                },
-            );
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve, reject) => {
+                resolve(listObj);
+            });
         };
 
         const kc = new KubeConfig();
@@ -1320,15 +1244,10 @@ describe('delete items', () => {
             items: [],
         } as V1NamespaceList;
 
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>(
-                (resolve, reject) => {
-                    resolve({ response: {} as http.IncomingMessage, body: listObj });
-                },
-            );
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve, reject) => {
+                resolve(listObj);
+            });
         };
         const informer = new ListWatch('/some/path', mock.instance(fakeWatch), listFn, false);
         const connectPromise = new Promise<boolean>((resolve: (boolean) => void) => {
@@ -1364,15 +1283,10 @@ describe('delete items', () => {
             items: list,
         } as V1NamespaceList;
 
-        const listFn: ListPromise<V1Namespace> = function (): Promise<{
-            response: http.IncomingMessage;
-            body: V1NamespaceList;
-        }> {
-            return new Promise<{ response: http.IncomingMessage; body: V1NamespaceList }>(
-                (resolve, reject) => {
-                    resolve({ response: {} as http.IncomingMessage, body: listObj });
-                },
-            );
+        const listFn: ListPromise<V1Namespace> = function (): Promise<V1NamespaceList> {
+            return new Promise<V1NamespaceList>((resolve, reject) => {
+                resolve(listObj);
+            });
         };
         const promise = new Promise((resolve) => {
             mock.when(