Skip to content

Commit cf3581f

Browse files
Zhan MilenkovZhan Milenkov
Zhan Milenkov
authored and
Zhan Milenkov
committed
adding types to jsdocs
1 parent 6630da1 commit cf3581f

File tree

5 files changed

+113
-81
lines changed

5 files changed

+113
-81
lines changed

src/core/errors.mjs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@
1414
* limitations under the License.
1515
*
1616
*/
17+
'use strict'
18+
1719
export class FullstackTestingError extends Error {
1820
/**
1921
* Create a custom error object
2022
*
2123
* error metadata will include the `cause`
2224
*
23-
* @param message error message
24-
* @param cause source error (if any)
25-
* @param meta additional metadata (if any)
25+
* @param {string} message error message
26+
* @param {Error | Object} cause source error (if any)
27+
* @param {Object} meta additional metadata (if any)
2628
*/
2729
constructor (message, cause = {}, meta = {}) {
2830
super(message)
@@ -43,9 +45,9 @@ export class ResourceNotFoundError extends FullstackTestingError {
4345
*
4446
* error metadata will include `resource`
4547
*
46-
* @param message error message
47-
* @param resource name of the resource
48-
* @param cause source error (if any)
48+
* @param {string} message - error message
49+
* @param {string} resource - name of the resource
50+
* @param {Error|Object} cause - source error (if any)
4951
*/
5052
constructor (message, resource, cause = {}) {
5153
super(message, cause, { resource })
@@ -56,8 +58,8 @@ export class MissingArgumentError extends FullstackTestingError {
5658
/**
5759
* Create a custom error for missing argument scenario
5860
*
59-
* @param message error message
60-
* @param cause source error (if any)
61+
* @param {string} message - error message
62+
* @param {Error|Object} cause - source error (if any)
6163
*/
6264
constructor (message, cause = {}) {
6365
super(message, cause)
@@ -70,9 +72,9 @@ export class IllegalArgumentError extends FullstackTestingError {
7072
*
7173
* error metadata will include `value`
7274
*
73-
* @param message error message
74-
* @param value value of the invalid argument
75-
* @param cause source error (if any)
75+
* @param {string} message - error message
76+
* @param {*} value - value of the invalid argument
77+
* @param {Error|Object} cause - source error (if any)
7678
*/
7779
constructor (message, value = '', cause = {}) {
7880
super(message, cause, { value })
@@ -85,10 +87,10 @@ export class DataValidationError extends FullstackTestingError {
8587
*
8688
* error metadata will include `expected` and `found` values.
8789
*
88-
* @param message error message
89-
* @param expected expected value
90-
* @param found value found
91-
* @param cause source error (if any)
90+
* @param {string} message - error message
91+
* @param {*} expected - expected value
92+
* @param {*} found - value found
93+
* @param {Error|Object} [cause] - source error (if any)
9294
*/
9395
constructor (message, expected, found, cause = {}) {
9496
super(message, cause, { expected, found })

src/core/helm.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*
1616
*/
17+
'use strict'
1718
import os from 'os'
1819
import { constants } from './index.mjs'
1920
import { ShellRunner } from './shell_runner.mjs'

src/core/helpers.mjs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*
1616
*/
17+
'use strict'
1718
import fs from 'fs'
1819
import os from 'os'
1920
import path from 'path'
@@ -32,7 +33,7 @@ const CUR_FILE_DIR = paths.dirname(fileURLToPath(import.meta.url))
3233

3334
/**
3435
* @param {number} ms
35-
* @returns {Promise}
36+
* @returns {Promise<void>}
3637
*/
3738
export function sleep (ms) {
3839
return new Promise((resolve) => {
@@ -305,7 +306,7 @@ export function getNodeAccountMap (nodeIDs) {
305306
/**
306307
* @param {AccountManager} accountManager
307308
* @param {string} namespace
308-
* @param fileNum
309+
* @param {number} fileNum
309310
* @returns {Promise<string>}
310311
*/
311312
export async function getFileContents (accountManager, namespace, fileNum) {
@@ -316,11 +317,20 @@ export async function getFileContents (accountManager, namespace, fileNum) {
316317
return Buffer.from(await queryFees.execute(client)).toString('hex')
317318
}
318319

320+
/**
321+
* @param {Array} envVarArray
322+
* @param {string} name
323+
* @returns {string|null}
324+
*/
319325
export function getEnvValue (envVarArray, name) {
320326
const kvPair = envVarArray.find(v => v.startsWith(`${name}=`))
321327
return kvPair ? kvPair.split('=')[1] : null
322328
}
323329

330+
/**
331+
* @param {string} ipAddress
332+
* @returns {Uint8Array}
333+
*/
324334
export function parseIpAddressToUint8Array (ipAddress) {
325335
const parts = ipAddress.split('.')
326336
const uint8Array = new Uint8Array(4)

src/core/k8.mjs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*
1616
*/
17+
'use strict'
1718
import * as k8s from '@kubernetes/client-node'
1819
import fs from 'fs'
1920
import net from 'net'
@@ -62,6 +63,9 @@ export class K8 {
6263
return c.init()
6364
}
6465

66+
/**
67+
* @returns {k8s.KubeConfig}
68+
*/
6569
getKubeConfig () {
6670
return this.kubeConfig
6771
}
@@ -92,7 +96,7 @@ export class K8 {
9296
* Apply filters to metadata
9397
* @param {Array} items - list of items
9498
* @param {Object} [filters] - an object with metadata fields and value
95-
* @returns a list of items that match the filters
99+
* @returns {Array} a list of items that match the filters
96100
*/
97101
applyMetadataFilter (items, filters = {}) {
98102
if (!filters) throw new MissingArgumentError('filters are required')
@@ -160,7 +164,7 @@ export class K8 {
160164

161165
/**
162166
* Get a list of namespaces
163-
* @returns list of namespaces
167+
* @returns {string[]} list of namespaces
164168
*/
165169
async getNamespaces () {
166170
const resp = await this.kubeClient.listNamespace()
@@ -440,6 +444,12 @@ export class K8 {
440444
) === 'true'
441445
}
442446

447+
/**
448+
* @param {string} podName
449+
* @param {string} containerName
450+
* @param {string} destPath
451+
* @returns {Promise<string>}
452+
*/
443453
async mkdir (podName, containerName, destPath) {
444454
return this.execContainer(
445455
podName,
@@ -453,7 +463,7 @@ export class K8 {
453463
*
454464
* It overwrites any existing file inside the container at the destination directory
455465
*
456-
* @param {string} podName - podName name
466+
* @param {string} podName
457467
* @param {string} containerName
458468
* @param {string} srcPath - source file path in the local
459469
* @param {string} destDir - destination directory in the container
@@ -519,7 +529,7 @@ export class K8 {
519529
*
520530
* It overwrites any existing file at the destination directory
521531
*
522-
* @param {string} podName - podName name
532+
* @param {string} podName
523533
* @param {string} containerName
524534
* @param {string} srcPath - source file path in the container
525535
* @param {string} destDir - destination directory in the local

0 commit comments

Comments
 (0)