New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

k8s

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

k8s - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

29

lib/kubectl.js

@@ -168,2 +168,31 @@ var spawn = require('child_process').spawn

Kubectl.prototype.portForward = function(name, portString, done)
{
if( this.type !== 'pods' )
throw new Error('not a function')
var action = new Array('port-forward', name, portString);
return this.spawn(action, function(err, data){
console.log(err);
done(err, data)
})
}
Kubectl.prototype.useContext = function(context, done){
var action = new Array('config', 'use-context', context);
return this.spawn(action, function(err, data){
console.log(err);
done(err, data)
});
}
Kubectl.prototype.viewContext = function(done){
var action = new Array('config', '--output=json', 'view');
return this.spawn(action, function(err, data){
console.log(err);
done(err, !err ? JSON.parse(data) : data)
});
}
// Kubectl.prototype.describe = function()

@@ -170,0 +199,0 @@ // {

42

lib/request.js

@@ -5,12 +5,38 @@ var request = require('request')

function Request(conf){
this.authtype = null;
if (conf.hasOwnProperty("auth") && conf.auth.hasOwnProperty("type")) {
this.authtype = conf.auth.type;
if (this.authtype === 'password') {
this.username = conf.auth.username;
this.password = conf.auth.password;
}
}
this.ignoreCerts = false;
if (conf.hasOwnProperty("strictSSL") && conf.strictSSL === false) {
this.ignoreCerts = true;
}
this.domain = conf.endpoint + '/api/' + conf.version + '/'
}
Request.prototype.getRequestOptions = function(path, opts){
var options = opts || {};
options.url = this.domain + path;
options.headers = {
"Content-Type": "application/json"
};
if (this.ignoreCerts) {
options.strictSSL = false;
}
if (this.authtype === 'password') {
var authstr = new Buffer(this.username + ':' + this.password).toString('base64');
options.headers.Authorization = 'Basic ' + authstr;
}
return options;
}
Request.prototype.get = function(url, done)
{
request.get(this.domain + url, function(err, response, data){
request.get(this.getRequestOptions(url), function(err, response, data){
if( err )
return done(err)
done(null, JSON.parse(data))

@@ -26,3 +52,3 @@ })

request.get(this.domain + url, {timeout: timeout},function(e){ }).on('data', function(data)
request.get(this.getRequestOptions(url), {timeout: timeout},function(e){ }).on('data', function(data)
{

@@ -55,3 +81,3 @@ var json

// console.log(url, body)
request.post({ url: this.domain + url, json: body }, function(err, res, data){
request.post(this.getRequestOptions(url, {json: body}), function(err, res, data){
done(err, data)

@@ -63,3 +89,3 @@ })

// console.log(url, body)
request.put({ url: this.domain + url, json: body }, function(err, res, data){
request.put(this.getRequestOptions(url, {json: body}), function(err, res, data){
done(err, data)

@@ -70,3 +96,3 @@ })

Request.prototype.patch = function(url, body, done){
request.patch({ url: this.domain + url, json: body }, function(err, res, data){
request.patch(this.getRequestOptions(url, {json: body}), function(err, res, data){
done(err, data)

@@ -77,3 +103,3 @@ })

Request.prototype.delete = function(url, done){
request.del(this.domain + url, function(err, res, data){
request.del(this.getRequestOptions(url), function(err, res, data){
done(err, data)

@@ -80,0 +106,0 @@ })

2

package.json
{
"name": "k8s",
"version": "0.2.0",
"version": "0.2.1",
"description": "",

@@ -5,0 +5,0 @@ "repository": {

@@ -38,2 +38,34 @@ # Nodejs Kubernetes client

### Options
endpoint
: URL for API
version
: API Version
binary
: Path to binary file
kubeconfig
: Path to kubeconfig
:auth
Authentication to REST API. Currently supported authentication method type is password
```
{
"auth": {
"type" : "password",
"username": "admin",
"password": "123123"
}
}
```
:strictSSL
If set to false, use of the API will not validate SSL certificate. Defualt is true.
# kubeAPI

@@ -40,0 +72,0 @@

@@ -8,3 +8,3 @@ /// <reference path="../../../typings/mocha/mocha.d.ts"/>

var kubeapi = K8s.api({
endpoint: 'http://192.168.10.10:8080'
endpoint: 'http://172.18.18.101:8080'
, version: 'v1'

@@ -46,3 +46,3 @@ })

data.spec.replicas = 1
kubeapi.put('namespaces/default/replicationcontrollers/nginx', data, function(err, data)

@@ -49,0 +49,0 @@ {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc