Skip to content

Commit

Permalink
refactor(linter): Upgrade godaddy-style
Browse files Browse the repository at this point in the history
* Do a lint pass; and
* add lint checks to the test script.
  • Loading branch information
Silas Boyd-Wickizer committed May 14, 2017
1 parent 087fe38 commit ef8cfcb
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 47 deletions.
4 changes: 1 addition & 3 deletions .eslintrc
@@ -1,7 +1,5 @@
{
"extends": [
"./node_modules/godaddy-style/dist/.eslintrc"
],
"extends": "godaddy",
"rules": {
"strict": 0
}
Expand Down
6 changes: 3 additions & 3 deletions lib/api.js
Expand Up @@ -7,9 +7,9 @@ const Batch = require('./batch');
const Rbac = require('./rbac');

const groups = {
extensions: Extensions,
apps: Apps,
batch: Batch,
'extensions': Extensions,
'apps': Apps,
'batch': Batch,
'rbac.authorization.k8s.io': Rbac
};

Expand Down
2 changes: 1 addition & 1 deletion lib/config.js
Expand Up @@ -22,7 +22,7 @@ function getInCluster() {
const port = process.env.KUBERNETES_SERVICE_PORT;

if (!host || !port) {
throw TypeError(
throw new TypeError(
'Unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST' +
' and KUBERNETES_SERVICE_PORT must be defined');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/replicationcontrollers.js
Expand Up @@ -90,7 +90,7 @@ class ReplicationControllers extends BaseObject {
return;
}

const patch = { spec: { replicas: 0 } };
const patch = { spec: { replicas: 0 }};
this.api.patch({
path: [this.path, options.name],
body: patch
Expand Down
11 changes: 6 additions & 5 deletions package.json
Expand Up @@ -6,12 +6,10 @@
"scripts": {
"check-coverage": "istanbul check-coverage",
"coverage": "istanbul cover ./node_modules/.bin/_mocha && istanbul report cobertura",
"eslint": "godaddy-js-style-eslint -c .eslintrc lib/ test/",
"jsdoc": "jsdoc -d doc lib",
"jscs": "godaddy-js-style-jscs lib/ test/",
"lint": "godaddy-js-style-lint lib/ test/",
"lint": "eslint-godaddy lib/ test/",
"release": "standard-version --tag-prefix=''",
"test": "mocha",
"test": "npm run lint && mocha",
"test-integration": "TESTING=int mocha -t ${TIMEOUT:-30000} test"
},
"repository": "godaddy/kubernetes-client",
Expand All @@ -35,7 +33,10 @@
},
"devDependencies": {
"assume": "^1.4.1",
"godaddy-style": "^3.1.5",
"eslint": "^3.19.0",
"eslint-config-godaddy": "^1.1.0",
"eslint-plugin-json": "^1.2.0",
"eslint-plugin-mocha": "^4.9.0",
"istanbul": "^0.4.3",
"jsdoc": "^3.4.0",
"mocha": "^2.5.3",
Expand Down
18 changes: 10 additions & 8 deletions test/common.js
Expand Up @@ -67,17 +67,19 @@ function newName() {

function injectApis(options) {
const apis = {
api: { cls: Core },
apiGroup: { cls: Api },
apps: { cls: Apps },
batch: { cls: Batch },
extensions: { cls: Extensions },
rbac: { cls: Rbac },
thirdPartyResources: { cls: ThirdPartyResources, options: { group: 'kubernetes-client.com' } }
api: { Constructor: Core },
apiGroup: { Constructor: Api },
apps: { Constructor: Apps },
batch: { Constructor: Batch },
extensions: { Constructor: Extensions },
rbac: { Constructor: Rbac },
thirdPartyResources: {
Constructor: ThirdPartyResources, options: { group: 'kubernetes-client.com' }
}
};
Object.keys(apis).forEach(apiName => {
const api = apis[apiName];
module.exports[apiName] = new (api.cls)(Object.assign({}, options, api.options));
module.exports[apiName] = new (api.Constructor)(Object.assign({}, options, api.options));
});
}

Expand Down
50 changes: 25 additions & 25 deletions test/config.test.js
Expand Up @@ -54,11 +54,11 @@ describe('Config', () => {
describe('.fromKubeconfig', () => {
it('handles username and password', () => {
const kubeconfig = {
apiVersion: 'v1',
kind: 'Config',
preferences: {},
'apiVersion': 'v1',
'kind': 'Config',
'preferences': {},
'current-context': 'foo-context',
contexts: [
'contexts': [
{
name: 'foo-context',
context: {
Expand All @@ -67,15 +67,15 @@ describe('Config', () => {
}
}
],
clusters: [
'clusters': [
{
name: 'foo-cluster',
cluster: {
server: 'https://192.168.42.121:8443'
}
}
],
users: [
'users': [
{
name: 'foo-user',
user: {
Expand All @@ -92,11 +92,11 @@ describe('Config', () => {

it('handles base64 encoded certs and keys', () => {
const kubeconfig = {
apiVersion: 'v1',
kind: 'Config',
preferences: {},
'apiVersion': 'v1',
'kind': 'Config',
'preferences': {},
'current-context': 'foo-context',
contexts: [
'contexts': [
{
name: 'foo-context',
context: {
Expand All @@ -105,16 +105,16 @@ describe('Config', () => {
}
}
],
clusters: [
'clusters': [
{
name: 'foo-cluster',
cluster: {
'certificate-authority-data': new Buffer('certificate-authority-data').toString('base64'),
server: 'https://192.168.42.121:8443'
'server': 'https://192.168.42.121:8443'
}
}
],
users: [
'users': [
{
name: 'foo-user',
user: {
Expand All @@ -132,11 +132,11 @@ describe('Config', () => {

it('handles token', () => {
const kubeconfig = {
apiVersion: 'v1',
kind: 'Config',
preferences: {},
'apiVersion': 'v1',
'kind': 'Config',
'preferences': {},
'current-context': 'foo-context',
contexts: [
'contexts': [
{
name: 'foo-context',
context: {
Expand All @@ -145,15 +145,15 @@ describe('Config', () => {
}
}
],
clusters: [
'clusters': [
{
name: 'foo-cluster',
cluster: {
server: 'https://192.168.42.121:8443'
}
}
],
users: [
'users': [
{
name: 'foo-user',
user: {
Expand All @@ -168,11 +168,11 @@ describe('Config', () => {

it('handles manually specified current-context', () => {
const kubeconfig = {
apiVersion: 'v1',
kind: 'Config',
preferences: {},
'apiVersion': 'v1',
'kind': 'Config',
'preferences': {},
'current-context': 'foo-context-1',
contexts: [
'contexts': [
{
name: 'foo-context-1',
context: {
Expand All @@ -188,7 +188,7 @@ describe('Config', () => {
}
}
],
clusters: [
'clusters': [
{
name: 'foo-cluster-1',
cluster: {
Expand All @@ -202,7 +202,7 @@ describe('Config', () => {
}
}
],
users: [
'users': [
{
name: 'foo-user',
user: {
Expand Down
2 changes: 1 addition & 1 deletion test/third-party-resources.test.js
Expand Up @@ -90,7 +90,7 @@ describe('lib.ThirdPartyResource', () => {
.post(`/apis/${ common.thirdPartyDomain }/v1/namespaces/${ common.currentName }/newresources`)
.reply(200, {})
.get(`/apis/${ common.thirdPartyDomain }/v1/namespaces/${ common.currentName }/newresources/test`)
.reply(200, { metadata: { name: 'test' } });
.reply(200, { metadata: { name: 'test' }});
});

it('creates a resources', done => {
Expand Down

0 comments on commit ef8cfcb

Please sign in to comment.