kit-image-deployer
Advanced tools
Comparing version 3.3.0 to 3.3.2-PRERELEASE-github-abuse-updates.0
{ | ||
"name": "kit-image-deployer", | ||
"version": "3.3.0", | ||
"version": "3.3.2-PRERELEASE-github-abuse-updates.0", | ||
"description": "A service that can be used to update given yaml files within a git repository with a new docker image path.", | ||
@@ -41,3 +41,11 @@ "repository": { | ||
"src" | ||
] | ||
], | ||
"publishConfig": { | ||
"tag": "PRERELEASE-github-abuse-updates" | ||
}, | ||
"release": { | ||
"fallbackTags": { | ||
"PRERELEASE-github-abuse-updates": "latest" | ||
} | ||
} | ||
} |
@@ -8,2 +8,3 @@ "use strict"; | ||
const GitHubApi = require("github"); | ||
const EventEmitter = require("events"); | ||
@@ -23,3 +24,4 @@ class ImageDeployer { | ||
repo: undefined | ||
} | ||
}, | ||
config: undefined | ||
}, | ||
@@ -41,2 +43,4 @@ options | ||
}; | ||
this.emitter = new EventEmitter(); | ||
} | ||
@@ -139,3 +143,14 @@ | ||
.catch(err => { | ||
attempt(err); | ||
let errCode = err && err.code ? err.code : undefined; | ||
if (errCode && errCode >= 500) { | ||
// don't retry 500 errors | ||
reject(err); | ||
} else { | ||
self.emitter( | ||
"error", | ||
`Error updating image file status code ${errCode}, will retry after delay` | ||
); | ||
// try again after a delay | ||
self.retryAfterDelay(tries, err, attempt); | ||
} | ||
}); | ||
@@ -154,3 +169,4 @@ } else { | ||
.catch(err => { | ||
if (err && err.code && err.code === 404) { | ||
let errCode = err && err.code ? err.code : undefined; | ||
if (errCode && errCode === 404) { | ||
// create file if it does not exist yet | ||
@@ -175,2 +191,6 @@ var newFile = {}; | ||
self.emitter( | ||
"info", | ||
`Image file didn't exist creating image file` | ||
); | ||
return self.github | ||
@@ -193,4 +213,13 @@ .createFile({ | ||
} else { | ||
// try again | ||
attempt(err); | ||
if (errCode && errCode >= 500) { | ||
// don't retry 500 errors | ||
reject(err); | ||
} else { | ||
self.emitter( | ||
"error", | ||
`Error creating image file status code ${errCode}, will retry after delay` | ||
); | ||
// try again after a delay | ||
self.retryAfterDelay(tries, err, attempt); | ||
} | ||
} | ||
@@ -208,2 +237,17 @@ }); | ||
return new Promise(function(resolve, reject) { | ||
// if the config was provided via options, skip fetching it | ||
if (this.options.config) { | ||
self | ||
.attemptCommit( | ||
this.options.config, | ||
image, | ||
branch, | ||
committer, | ||
message, | ||
save | ||
) | ||
.then(resolve) | ||
.catch(reject); | ||
} | ||
const configRequest = { | ||
@@ -236,4 +280,18 @@ user: self.options.github.user, | ||
} | ||
/** | ||
* Calls a function with a delay to back off a call due to an error | ||
* @param {number} attempt - number of this attempt | ||
* @param {object} err - the error object returned from our request | ||
* @param {function} func - the function to call after the timeout | ||
* @return {function} - Returns a setTimeout object calling the passed in object | ||
*/ | ||
retryAfterDelay(attempt, err, func) { | ||
let retryDelay = attempt * 15 * 1000; | ||
return setTimeout(() => { | ||
return func(err); | ||
}, retryDelay); | ||
} | ||
} | ||
module.exports = ImageDeployer; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
18884
273
0
2