Updates linting rules
New linting rule to disable spaces after functions, before parens Fixed all new linting errors I suppose I'd like this to eventually get landed in official `eslint-config-openstack` project, but for now it is here Change-Id: I6c77524c5679117ce3b211db0bd9943c5ad5e646
This commit is contained in:
parent
3221a3513d
commit
7c544e1460
@ -1 +1,6 @@
|
|||||||
extends: openstack/es2015
|
extends: openstack/es2015
|
||||||
|
|
||||||
|
rules:
|
||||||
|
space-before-function-paren:
|
||||||
|
- 2
|
||||||
|
- never
|
||||||
|
@ -42,7 +42,7 @@ export default class Glance extends AbstractService {
|
|||||||
* }
|
* }
|
||||||
* @param {{}} endpointConfig The configuration element for a specific glance endpoint.
|
* @param {{}} endpointConfig The configuration element for a specific glance endpoint.
|
||||||
*/
|
*/
|
||||||
constructor (endpointConfig) {
|
constructor(endpointConfig) {
|
||||||
// Sanity checks.
|
// Sanity checks.
|
||||||
if (!endpointConfig || !endpointConfig.url) {
|
if (!endpointConfig || !endpointConfig.url) {
|
||||||
throw new Error('An endpoint configuration is required.');
|
throw new Error('An endpoint configuration is required.');
|
||||||
@ -61,7 +61,7 @@ export default class Glance extends AbstractService {
|
|||||||
* @param {String} token An authorization token, or a promise which will resolve into one.
|
* @param {String} token An authorization token, or a promise which will resolve into one.
|
||||||
* @returns {Promise.<T>} A promise which will resolve with the list of images.
|
* @returns {Promise.<T>} A promise which will resolve with the list of images.
|
||||||
*/
|
*/
|
||||||
imageList (token = null) {
|
imageList(token = null) {
|
||||||
return this
|
return this
|
||||||
._requestComponents(token)
|
._requestComponents(token)
|
||||||
.then(([url, headers]) => this.http.httpRequest('GET', `${url}images`, headers))
|
.then(([url, headers]) => this.http.httpRequest('GET', `${url}images`, headers))
|
||||||
|
@ -22,7 +22,7 @@ export default class Keystone extends AbstractService {
|
|||||||
* @param {{}} cloudConfig The configuration object for a specific cloud.
|
* @param {{}} cloudConfig The configuration object for a specific cloud.
|
||||||
* @see http://docs.openstack.org/developer/os-client-config/#site-specific-file-locations
|
* @see http://docs.openstack.org/developer/os-client-config/#site-specific-file-locations
|
||||||
*/
|
*/
|
||||||
constructor (cloudConfig) {
|
constructor(cloudConfig) {
|
||||||
// Sanity checks.
|
// Sanity checks.
|
||||||
if (!cloudConfig) {
|
if (!cloudConfig) {
|
||||||
throw new Error('A configuration is required.');
|
throw new Error('A configuration is required.');
|
||||||
@ -44,7 +44,7 @@ export default class Keystone extends AbstractService {
|
|||||||
* @returns {String} The value found in the config, or null.
|
* @returns {String} The value found in the config, or null.
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
_safeConfigGet (path) {
|
_safeConfigGet(path) {
|
||||||
let segments = path.split('.');
|
let segments = path.split('.');
|
||||||
let pointer = this.cloudConfig;
|
let pointer = this.cloudConfig;
|
||||||
while (segments.length > 0) {
|
while (segments.length > 0) {
|
||||||
@ -63,7 +63,7 @@ export default class Keystone extends AbstractService {
|
|||||||
*
|
*
|
||||||
* @returns {Promise.<T>} A promise that will resolve with the list of API versions.
|
* @returns {Promise.<T>} A promise that will resolve with the list of API versions.
|
||||||
*/
|
*/
|
||||||
versions () {
|
versions() {
|
||||||
return super.versions()
|
return super.versions()
|
||||||
.then((versions) => versions.values);
|
.then((versions) => versions.values);
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ export default class Keystone extends AbstractService {
|
|||||||
* @param {String} projectDomainName Domain name for the project, not required with project ID.
|
* @param {String} projectDomainName Domain name for the project, not required with project ID.
|
||||||
* @returns {Promise.<T>} A promise which will resolve with a valid token.
|
* @returns {Promise.<T>} A promise which will resolve with a valid token.
|
||||||
*/
|
*/
|
||||||
tokenIssue (username = this._safeConfigGet('auth.username'),
|
tokenIssue(username = this._safeConfigGet('auth.username'),
|
||||||
password = this._safeConfigGet('auth.password'),
|
password = this._safeConfigGet('auth.password'),
|
||||||
projectName = this._safeConfigGet('auth.project_name'),
|
projectName = this._safeConfigGet('auth.project_name'),
|
||||||
userDomainName = this._safeConfigGet('auth.user_domain_id'),
|
userDomainName = this._safeConfigGet('auth.user_domain_id'),
|
||||||
@ -141,7 +141,7 @@ export default class Keystone extends AbstractService {
|
|||||||
* @param {String} adminToken An optional admin token.
|
* @param {String} adminToken An optional admin token.
|
||||||
* @returns {Promise.<T>} A promise which will resolve if the token has been successfully revoked.
|
* @returns {Promise.<T>} A promise which will resolve if the token has been successfully revoked.
|
||||||
*/
|
*/
|
||||||
tokenRevoke (token, adminToken = null) {
|
tokenRevoke(token, adminToken = null) {
|
||||||
return Promise
|
return Promise
|
||||||
.all([this.serviceEndpoint(), token, adminToken])
|
.all([this.serviceEndpoint(), token, adminToken])
|
||||||
.then(([url, token, adminToken]) => {
|
.then(([url, token, adminToken]) => {
|
||||||
@ -159,7 +159,7 @@ export default class Keystone extends AbstractService {
|
|||||||
* @param {String} token The authorization token.
|
* @param {String} token The authorization token.
|
||||||
* @returns {Promise.<T>} A promise which will resolve with the service catalog.
|
* @returns {Promise.<T>} A promise which will resolve with the service catalog.
|
||||||
*/
|
*/
|
||||||
catalogList (token = null) {
|
catalogList(token = null) {
|
||||||
return this
|
return this
|
||||||
._requestComponents(token)
|
._requestComponents(token)
|
||||||
.then(([url, headers]) => this.http.httpRequest('GET', `${url}auth/catalog`, headers))
|
.then(([url, headers]) => this.http.httpRequest('GET', `${url}auth/catalog`, headers))
|
||||||
|
@ -26,7 +26,7 @@ export default class AbstractService {
|
|||||||
* @param {string} endpointUrl The endpoint URL.
|
* @param {string} endpointUrl The endpoint URL.
|
||||||
* @param {Array} supportedVersions The list of all supported versions.
|
* @param {Array} supportedVersions The list of all supported versions.
|
||||||
*/
|
*/
|
||||||
constructor (endpointUrl, supportedVersions) {
|
constructor(endpointUrl, supportedVersions) {
|
||||||
this._endpointUrl = endpointUrl;
|
this._endpointUrl = endpointUrl;
|
||||||
this._supportedVersions = supportedVersions;
|
this._supportedVersions = supportedVersions;
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ export default class AbstractService {
|
|||||||
*
|
*
|
||||||
* @returns {Http} Our HTTP service instance.
|
* @returns {Http} Our HTTP service instance.
|
||||||
*/
|
*/
|
||||||
get http () {
|
get http() {
|
||||||
if (!this._http) {
|
if (!this._http) {
|
||||||
this._http = new Http();
|
this._http = new Http();
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ export default class AbstractService {
|
|||||||
*
|
*
|
||||||
* @returns {Array} The list of all supported versions, or empty array.
|
* @returns {Array} The list of all supported versions, or empty array.
|
||||||
*/
|
*/
|
||||||
get supportedVersions () {
|
get supportedVersions() {
|
||||||
return this._supportedVersions || [];
|
return this._supportedVersions || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ export default class AbstractService {
|
|||||||
*
|
*
|
||||||
* @returns {Promise.<T>} A promise that will resolve with the list of API versions.
|
* @returns {Promise.<T>} A promise that will resolve with the list of API versions.
|
||||||
*/
|
*/
|
||||||
versions () {
|
versions() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let promise = this.http
|
let promise = this.http
|
||||||
.httpGet(this._endpointUrl)
|
.httpGet(this._endpointUrl)
|
||||||
@ -85,7 +85,7 @@ export default class AbstractService {
|
|||||||
*
|
*
|
||||||
* @returns {Promise.<T>} A promise that will resolve with the specific API version.
|
* @returns {Promise.<T>} A promise that will resolve with the specific API version.
|
||||||
*/
|
*/
|
||||||
version () {
|
version() {
|
||||||
return this
|
return this
|
||||||
.versions()
|
.versions()
|
||||||
.then((versions) => {
|
.then((versions) => {
|
||||||
@ -103,7 +103,7 @@ export default class AbstractService {
|
|||||||
*
|
*
|
||||||
* @returns {Promise.<T>|*} A promise which will resolve with the endpoint URL string.
|
* @returns {Promise.<T>|*} A promise which will resolve with the endpoint URL string.
|
||||||
*/
|
*/
|
||||||
serviceEndpoint () {
|
serviceEndpoint() {
|
||||||
if (!this._endpointPromise) {
|
if (!this._endpointPromise) {
|
||||||
this._endpointPromise = this.version()
|
this._endpointPromise = this.version()
|
||||||
.then((version) => {
|
.then((version) => {
|
||||||
@ -130,7 +130,7 @@ export default class AbstractService {
|
|||||||
* @returns {Promise} A promise which resolves with [url, token].
|
* @returns {Promise} A promise which resolves with [url, token].
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_requestComponents (token = null) {
|
_requestComponents(token = null) {
|
||||||
// Make sure the token is a promise.
|
// Make sure the token is a promise.
|
||||||
let headerPromise = Promise
|
let headerPromise = Promise
|
||||||
.resolve(token)
|
.resolve(token)
|
||||||
|
@ -41,14 +41,14 @@ export default class Http {
|
|||||||
*
|
*
|
||||||
* @returns {{string: string}} A mapping of 'headerName': 'headerValue'
|
* @returns {{string: string}} A mapping of 'headerName': 'headerValue'
|
||||||
*/
|
*/
|
||||||
get defaultHeaders () {
|
get defaultHeaders() {
|
||||||
return this._defaultHeaders;
|
return this._defaultHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new HTTP handler.
|
* Create a new HTTP handler.
|
||||||
*/
|
*/
|
||||||
constructor () {
|
constructor() {
|
||||||
// Add default response interceptors.
|
// Add default response interceptors.
|
||||||
this._defaultHeaders = {
|
this._defaultHeaders = {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
@ -64,7 +64,7 @@ export default class Http {
|
|||||||
* @param {{}} body The body. It will be JSON-Encoded by the handler.
|
* @param {{}} body The body. It will be JSON-Encoded by the handler.
|
||||||
* @returns {Promise} A promise which will resolve with the processed request response.
|
* @returns {Promise} A promise which will resolve with the processed request response.
|
||||||
*/
|
*/
|
||||||
httpRequest (method, url, headers = {}, body) {
|
httpRequest(method, url, headers = {}, body) {
|
||||||
|
|
||||||
// Sanitize the headers...
|
// Sanitize the headers...
|
||||||
headers = Object.assign({}, headers, this.defaultHeaders);
|
headers = Object.assign({}, headers, this.defaultHeaders);
|
||||||
@ -106,7 +106,7 @@ export default class Http {
|
|||||||
* @param {String} url The request URL.
|
* @param {String} url The request URL.
|
||||||
* @returns {Promise} A promise which will resolve with the processed request response.
|
* @returns {Promise} A promise which will resolve with the processed request response.
|
||||||
*/
|
*/
|
||||||
httpGet (url) {
|
httpGet(url) {
|
||||||
return this.httpRequest('GET', url, {}, null);
|
return this.httpRequest('GET', url, {}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ export default class Http {
|
|||||||
* @param {{}} body The body. It will be JSON-Encoded by the handler.
|
* @param {{}} body The body. It will be JSON-Encoded by the handler.
|
||||||
* @returns {Promise} A promise which will resolve with the processed request response.
|
* @returns {Promise} A promise which will resolve with the processed request response.
|
||||||
*/
|
*/
|
||||||
httpPut (url, body) {
|
httpPut(url, body) {
|
||||||
return this.httpRequest('PUT', url, {}, body);
|
return this.httpRequest('PUT', url, {}, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ export default class Http {
|
|||||||
* @param {{}} body The body. It will be JSON-Encoded by the handler.
|
* @param {{}} body The body. It will be JSON-Encoded by the handler.
|
||||||
* @returns {Promise} A promise which will resolve with the processed request response.
|
* @returns {Promise} A promise which will resolve with the processed request response.
|
||||||
*/
|
*/
|
||||||
httpPost (url, body) {
|
httpPost(url, body) {
|
||||||
return this.httpRequest('POST', url, {}, body);
|
return this.httpRequest('POST', url, {}, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ export default class Http {
|
|||||||
* @param {String} url The request URL.
|
* @param {String} url The request URL.
|
||||||
* @returns {Promise} A promise which will resolve with the processed request response.
|
* @returns {Promise} A promise which will resolve with the processed request response.
|
||||||
*/
|
*/
|
||||||
httpDelete (url) {
|
httpDelete(url) {
|
||||||
return this.httpRequest('DELETE', url, {}, null);
|
return this.httpRequest('DELETE', url, {}, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ export default class Version {
|
|||||||
*
|
*
|
||||||
* @returns {String|*|null} The name of the service, or null.
|
* @returns {String|*|null} The name of the service, or null.
|
||||||
*/
|
*/
|
||||||
get service () {
|
get service() {
|
||||||
return this._service || null;
|
return this._service || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ export default class Version {
|
|||||||
*
|
*
|
||||||
* @returns {Number} The major version number
|
* @returns {Number} The major version number
|
||||||
*/
|
*/
|
||||||
get major () {
|
get major() {
|
||||||
return this._major || 0;
|
return this._major || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ export default class Version {
|
|||||||
*
|
*
|
||||||
* @returns {Number} The minor version number
|
* @returns {Number} The minor version number
|
||||||
*/
|
*/
|
||||||
get minor () {
|
get minor() {
|
||||||
return this._minor || 0;
|
return this._minor || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ export default class Version {
|
|||||||
*
|
*
|
||||||
* @returns {Number} The patch version number.
|
* @returns {Number} The patch version number.
|
||||||
*/
|
*/
|
||||||
get patch () {
|
get patch() {
|
||||||
return this._patch || 0;
|
return this._patch || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ export default class Version {
|
|||||||
* @param {String} service The name of the service.
|
* @param {String} service The name of the service.
|
||||||
* @param {String} versionString The version string for this service.
|
* @param {String} versionString The version string for this service.
|
||||||
*/
|
*/
|
||||||
constructor (service, versionString) {
|
constructor(service, versionString) {
|
||||||
// Sanitize input
|
// Sanitize input
|
||||||
if (typeof service !== 'string') {
|
if (typeof service !== 'string') {
|
||||||
service = undefined;
|
service = undefined;
|
||||||
@ -97,7 +97,7 @@ export default class Version {
|
|||||||
* @param {String|Version} version The version to compare to.
|
* @param {String|Version} version The version to compare to.
|
||||||
* @returns {boolean} True if they are exactly the same, otherwise false.
|
* @returns {boolean} True if they are exactly the same, otherwise false.
|
||||||
*/
|
*/
|
||||||
equals (version) {
|
equals(version) {
|
||||||
if (!(version instanceof Version)) {
|
if (!(version instanceof Version)) {
|
||||||
// is it a parseable string?
|
// is it a parseable string?
|
||||||
if (typeof version === 'string') {
|
if (typeof version === 'string') {
|
||||||
|
@ -37,7 +37,7 @@ const glanceConfig = {
|
|||||||
*
|
*
|
||||||
* @returns {{}} A full FetchMock configuration for Glance's Root Resource.
|
* @returns {{}} A full FetchMock configuration for Glance's Root Resource.
|
||||||
*/
|
*/
|
||||||
function rootResponse () {
|
function rootResponse() {
|
||||||
return {
|
return {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
matcher: 'http://192.168.99.99:9292/',
|
matcher: 'http://192.168.99.99:9292/',
|
||||||
@ -108,7 +108,7 @@ function rootResponse () {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function imageList (token) {
|
function imageList(token) {
|
||||||
return {
|
return {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
matcher: 'http://192.168.99.99:9292/v2/images',
|
matcher: 'http://192.168.99.99:9292/v2/images',
|
||||||
|
@ -39,7 +39,7 @@ const cloudConfig = {
|
|||||||
*
|
*
|
||||||
* @returns {{}} A full FetchMock configuration for Keystone's Root Resource.
|
* @returns {{}} A full FetchMock configuration for Keystone's Root Resource.
|
||||||
*/
|
*/
|
||||||
function rootResponse () {
|
function rootResponse() {
|
||||||
return {
|
return {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
matcher: 'http://192.168.99.99/',
|
matcher: 'http://192.168.99.99/',
|
||||||
@ -96,7 +96,7 @@ function rootResponse () {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function tokenIssue () {
|
function tokenIssue() {
|
||||||
return {
|
return {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
matcher: 'http://192.168.99.99/identity_v2_admin/v3/auth/tokens',
|
matcher: 'http://192.168.99.99/identity_v2_admin/v3/auth/tokens',
|
||||||
@ -375,7 +375,7 @@ function tokenIssue () {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function tokenRevoke (token, adminToken = null) {
|
function tokenRevoke(token, adminToken = null) {
|
||||||
return {
|
return {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
matcher: 'http://192.168.99.99/identity_v2_admin/v3/auth/tokens',
|
matcher: 'http://192.168.99.99/identity_v2_admin/v3/auth/tokens',
|
||||||
@ -389,7 +389,7 @@ function tokenRevoke (token, adminToken = null) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function catalogList (token) {
|
function catalogList(token) {
|
||||||
return {
|
return {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
matcher: 'http://192.168.99.99/identity_v2_admin/v3/auth/catalog',
|
matcher: 'http://192.168.99.99/identity_v2_admin/v3/auth/catalog',
|
||||||
|
@ -20,7 +20,7 @@ describe('Version', () => {
|
|||||||
|
|
||||||
it("should parse various header versions", () => {
|
it("should parse various header versions", () => {
|
||||||
|
|
||||||
const testVersion = function (args, results) {
|
const testVersion = function(args, results) {
|
||||||
const v = new Version(...args);
|
const v = new Version(...args);
|
||||||
expect(v.service).toBe(results[0]);
|
expect(v.service).toBe(results[0]);
|
||||||
expect(v.major).toBe(results[1]);
|
expect(v.major).toBe(results[1]);
|
||||||
|
Loading…
Reference in New Issue
Block a user