Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
openshift-rest-client
Advanced tools
Readme
Node.js based client for the Openshift REST API, not unlike the Fabric8 Maven Plugin, but for node clients/builds.
npm install --save openshift-rest-client
Code:
const openshiftRestClient = require('openshift-rest-client').OpenshiftClient;
openshiftRestClient().then((client) => {
// Use the client object to find a list of projects, for example
client.apis['project.openshift.io'].v1.projects.get().then((response) => {
console.log(response.body);
});
});
The openshift-rest-client translates Path Item Objects [[1]] (e.g.,
/apis/project.openshift.io/v1/projects
) to object chains ending in HTTP methods (e.g.,
apis['project.openshift.io'].v1.projects.get
).
So, to fetch all Projects:
const projects = await client.apis['project.openshift.io'].v1.projects.get()
If needed, Query Parameters can be used:
const projects = await client.apis['project.openshift.io'].v1.projects.get({qs: {labelSelector: 'someOpenShiftLabel'}})
The openshift-rest-client translates Path Templating [[2]] (e.g.,
/apis/build.openshift.io/v1/namespaces/$NAMESPACE/buildconfigs
) to function calls (e.g.,
apis['build.openshift.io'].v1.namespaces('default').buildconfigs
).
So, to create a new Build Config in the default Namespace:
const buildConfig = require('./build-config.json')
const create = await client.apis['build.openshift.io'].v1.namespaces('default').buildconfigs.post({ body: buildConfig })
and then fetch your newly created Build Config:
const deployment = await client.apis['build.openshift.io'].v1.namespaces('default').buildconfigs(buildConfig.metadata.name).get()
and finally, remove the Build Config:
await client.apis['build.openshift.io'].v1.namespaces('default').buildconfigs(buildConfig.metadata.name).delete()
The openshift-rest-client supports .delete
, .get
, .patch
, .post
, and .put
.
There are also aliases defined, so instead of writing client.apis['build.openshift.io']
, you can just use client.apis.build
for example. The list of aliases can be seen here: https://github.com/nodeshift/openshift-rest-client/blob/master/lib/openshift-rest-client.js
By default, the openshift-rest-client will use the kubernetes-client module to get your configuration.
The openshift-rest-client exposes the config module from the kubernetes client for ease of use.
For example, if you want to provide a different path to your configuration, you can do something like this:
const openshiftRestClient = require('openshift-rest-client').OpenshiftClient;
const config = '~/some/path/config';
openshiftRestClient({ config }).then((client) => {
// Use the client object to find a list of projects, for example
client.apis['project.openshift.io'].v1.project.get().then((response) => {
console.log(response.body);
});
});
If you want to use a username/password combo to authenticate to Openshift, you might do something like this:
const openshiftRestClient = require('openshift-rest-client').OpenshiftClient;
(async function () {
const settings = {
};
settings.config = {
url: process.env.CLUSTER_URL,
auth: {
username: process.env.ADMIN_USERNAME,
password: process.env.ADMIN_PASSWORD
},
insecureSkipTlsVerify: true
};
const client = await openshiftRestClient(settings);
const projects = await client.apis['build.openshift.io'].v1.ns('myproject').builds.get();
console.log(projects);
})();
To see more examples of how to customize your config, check out the kubernetes-client Initializing section
The client has been totally rewritten for the 2.0 release. This includes a new, more fluent, API.
The old API will live in the 1.x branch.
FAQs
Node.js client for developing with OpenShift
The npm package openshift-rest-client receives a total of 15,838 weekly downloads. As such, openshift-rest-client popularity was classified as popular.
We found that openshift-rest-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.