Skip to content

Commit 71f179c

Browse files
author
John Sartore
committed
Added support for secret data types
2 parents 13a4942 + ee5c00d commit 71f179c

File tree

11 files changed

+154
-16
lines changed

11 files changed

+154
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ typings/
4949

5050
# Optional npm cache directory
5151
.npm
52+
.npmrc
5253

5354
# Optional eslint cache
5455
.eslintcache

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx --no-install commitlint --edit $1

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npm test

.husky/pre-push

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npm run build && npx jest test/

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ jobs:
1818
- npm run build
1919
- npm run test-unit-travis || travis_terminate 1
2020
- npm run lint
21-
- npm run check-packages
21+
- npm run check-packages

CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## [0.1.5](https://github.com/IBM/code-engine-node-sdk/compare/v0.1.4...v0.1.5) (2021-09-07)
2+
3+
4+
### Bug Fixes
5+
6+
* **build:** fixed integration test execution ([bb6a0e1](https://github.com/IBM/code-engine-node-sdk/commit/bb6a0e1a33b25dcbf22557f5f2a893e00d2332d3))
7+
8+
## [0.1.4](https://github.com/IBM/code-engine-node-sdk/compare/v0.1.3...v0.1.4) (2021-09-07)
9+
10+
11+
### Bug Fixes
12+
13+
* **build:** remove reference to example ([e9b4740](https://github.com/IBM/code-engine-node-sdk/commit/e9b47404205ef7429d4b49b66602c388d8f1347c))
14+
15+
## [0.1.3](https://github.com/IBM/code-engine-node-sdk/compare/v0.1.2...v0.1.3) (2021-09-07)
16+
17+
18+
### Bug Fixes
19+
20+
* **build:** exclude example directory from npm module ([797481e](https://github.com/IBM/code-engine-node-sdk/commit/797481e163e563ca62832150f5839c7878a31be0))
21+
* **build:** remove dry-run flag ([08921d9](https://github.com/IBM/code-engine-node-sdk/commit/08921d9c47b0ea917caf8c78954d55d65ff4134c))
22+
* **build:** updated publish configuration ([d1645bd](https://github.com/IBM/code-engine-node-sdk/commit/d1645bd7f987786072b915f8f411732c3fa64dca))
23+
24+
## [0.1.2](https://github.com/IBM/code-engine-node-sdk/compare/v0.1.1...v0.1.2) (2021-09-07)
25+
26+
27+
### Bug Fixes
28+
29+
* **build:** remove dry-run flag to enable npm publish ([3cd56ab](https://github.com/IBM/code-engine-node-sdk/commit/3cd56ab3b209b241415074f989d0f2f38466b335))
30+
31+
## [0.1.1](https://github.com/IBM/code-engine-node-sdk/compare/v0.1.0...v0.1.1) (2021-09-07)
32+
33+
34+
### Bug Fixes
35+
36+
* **build:** added coverage badge ([8fc995e](https://github.com/IBM/code-engine-node-sdk/commit/8fc995e0f943c9e9e80f55e1eba962ee7a14d3d2))
37+
* **build:** check husky ([7767ee0](https://github.com/IBM/code-engine-node-sdk/commit/7767ee0b3703f489d0f111d5e97f316dbcdb0061))
38+
* **build:** enable semantic-releases ([90fbf80](https://github.com/IBM/code-engine-node-sdk/commit/90fbf80764e2e92d3eeb043778400cc6057174c4))
39+
* **build:** fixed pre-push hook ([cdfb3f2](https://github.com/IBM/code-engine-node-sdk/commit/cdfb3f2986d255473dada2ba0237a5220ad898d9))
40+
* activated semantic releases ([8205efd](https://github.com/IBM/code-engine-node-sdk/commit/8205efd0a7a768b5ee5f9d08f201879327175564))

README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
<!--
2-
[![Build Status](https://travis-ci.com/IBM/code-engine-node-sdk.svg?token=eW5FVD71iyte6tTby8gr&branch=master)](https://travis.ibm.com/IBM/code-engine-node-sdk)
1+
[![Build Status](https://travis-ci.com/IBM/code-engine-node-sdk.svg?branch=main)](https://travis-ci.com/IBM/code-engine-node-sdk)
32
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
4-
[![npm-version](https://img.shields.io/npm/v/IBM/code-engine-node-sdk.svg)](https://www.npmjs.com/package/code-engine-sdk)
5-
[![codecov](https://codecov.io/gh/IBM/code-engine-node-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/IBM/code-engine-node-sdk)
3+
[![codecov](https://codecov.io/gh/IBM/code-engine-node-sdk/branch/main/graph/badge.svg)](https://codecov.io/gh/IBM/code-engine-node-sdk)
4+
5+
<!--[![npm-version](https://img.shields.io/npm/v/IBM/ibm-code-engine-node-sdk.svg)](https://www.npmjs.com/package/ibm-code-engine-sdk)
6+
67
-->
78
# NodeJS SDK for IBM Cloud Code Engine
89
Node.js client library to interact with the [Code Engine API](https://cloud.ibm.com/apidocs/codeengine).
@@ -21,15 +22,17 @@ Node.js client library to interact with the [Code Engine API](https://cloud.ibm.
2122

2223
<!-- toc -->
2324

24-
- [Overview](#overview)
25-
- [Prerequisites](#prerequisites)
26-
- [Installation](#installation)
27-
- [Using the SDK](#using-the-sdk)
28-
- [Questions](#questions)
29-
- [Issues](#issues)
30-
- [Open source @ IBM](#open-source--ibm)
31-
- [Contributing](#contributing)
32-
- [License](#license)
25+
- [NodeJS SDK for IBM Cloud Code Engine](#nodejs-sdk-for-ibm-cloud-code-engine)
26+
- [Table of Contents](#table-of-contents)
27+
- [Overview](#overview)
28+
- [Prerequisites](#prerequisites)
29+
- [Installation](#installation)
30+
- [Using the SDK](#using-the-sdk)
31+
- [Questions](#questions)
32+
- [Issues](#issues)
33+
- [Open source @ IBM](#open-source--ibm)
34+
- [Contributing](#contributing)
35+
- [License](#license)
3336

3437
<!-- tocstop -->
3538

commitlint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { extends: ['@commitlint/config-conventional'] };

example/example_deprecated.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* eslint-disable no-console */
2+
/* eslint-disable require-jsdoc */
3+
/* eslint-disable node/no-unpublished-require */
4+
const CodeEngineV1 = require('../dist/ibm-cloud-code-engine/v1'); // require('ibm-code-engine-sdk/ibm-cloud-code-engine/v1');
5+
const { IamAuthenticator } = require('../dist/auth'); // require('ibm-code-engine-sdk/auth');
6+
const k8s = require('@kubernetes/client-node');
7+
8+
if (!process.env.CE_API_KEY || !process.env.CE_PROJECT_ID || !process.env.CE_PROJECT_REGION) {
9+
throw new Error(
10+
'You must set the envrionment variables CE_API_KEY, CE_PROJECT_REGION and CE_PROJECT_ID before using the example.'
11+
);
12+
}
13+
14+
// Create an IAM authenticator.
15+
const authenticator = new IamAuthenticator({
16+
apikey: process.env.CE_API_KEY,
17+
clientId: 'bx',
18+
clientSecret: 'bx',
19+
});
20+
21+
// Construct the Code Engine client using the IAM authenticator.
22+
const ceClient = new CodeEngineV1({
23+
authenticator,
24+
serviceUrl: `https://api.${process.env.CE_PROJECT_REGION}.codeengine.cloud.ibm.com/api/v1`,
25+
});
26+
27+
async function main() {
28+
// Get tokens using the Authenticator.
29+
const tokenResponse = await authenticator.tokenManager.requestToken();
30+
31+
// Get Code Engine project config using the Code Engine client.
32+
const configResponse = await ceClient.listKubeconfig({
33+
refreshToken: tokenResponse.result.refresh_token,
34+
id: process.env.CE_PROJECT_ID,
35+
});
36+
37+
// Setup Kubernetes client.
38+
const kubeConfig = new k8s.KubeConfig();
39+
kubeConfig.loadFromString(configResponse.result);
40+
const kubeClient = kubeConfig.makeApiClient(k8s.CoreV1Api);
41+
42+
// Get something from project.
43+
const { namespace } = kubeConfig.getCurrentContextObject();
44+
const configMapList = await kubeClient.listNamespacedConfigMap(namespace);
45+
console.log(
46+
`Project ${process.env.CE_PROJECT_ID} has ${configMapList.body.items.length} configmaps.`
47+
);
48+
}
49+
50+
main();

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"node": ">=14.0.0"
3939
},
4040
"dependencies": {
41-
"@types/node": "^12.0.8",
41+
"@types/node": "^12.20.24",
4242
"extend": "^3.0.2",
4343
"ibm-cloud-sdk-core": "^4.0.3"
4444
},
@@ -56,7 +56,8 @@
5656
"eslint-plugin-jest": "^24.3.6",
5757
"eslint-plugin-jsdoc": "^34.6.3",
5858
"eslint-plugin-node": "^9.0.0",
59-
"eslint-plugin-prettier": "^3.0.1",
59+
"eslint-plugin-prettier": "^3.4.1",
60+
"husky": "^4.3.8",
6061
"installed-check": "^2.2.0",
6162
"jest": "^29.3.1",
6263
"nock": "^13.2.4",

test-integration.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Code Engine Node SDK Integration tests
2+
# Requires the following env. variables (provdied to TravisCI)
3+
# - CE_API_KEY: IBM Cloud API Key
4+
# - CE_PROJECT_ID: GUID of Code Engine project to target
5+
# - CE_PROJECT_REGION: region for API URL
6+
7+
echo "Running integration tests..."
8+
9+
# Setup example package
10+
cd example
11+
npm install
12+
13+
# Run example, get exit code
14+
exampleoutput=$(node ./example.js)
15+
exampleexit=$?
16+
if [ $exampleexit -ne 0 ]; then
17+
echo "Integration tests failed with exit code $exampleexit"
18+
echo $exampleoutput
19+
exit $exampleexit
20+
fi
21+
22+
# Check if output is expected
23+
outputcheck="2 configmaps"
24+
if [[ $exampleoutput != *$outputcheck* ]]; then
25+
echo "Intergration test output is incorrect:"
26+
echo "Expected '$exampleoutput' to contain '$outputcheck'"
27+
exit 1
28+
fi
29+
30+
echo "Success!"

0 commit comments

Comments
 (0)