Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kit-image-deployer

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kit-image-deployer - npm Package Compare versions

Comparing version 3.3.0 to 3.3.2-PRERELEASE-github-abuse-retries.0

12

package.json
{
"name": "kit-image-deployer",
"version": "3.3.0",
"version": "3.3.2-PRERELEASE-github-abuse-retries.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-retries"
},
"release": {
"fallbackTags": {
"PRERELEASE-github-abuse-retries": "latest"
}
}
}

@@ -8,2 +8,3 @@ "use strict";

const GitHubApi = require("github");
const EventEmitter = require("events");

@@ -15,2 +16,3 @@ class ImageDeployer {

retries: 10,
retryIncrement: 30,
docker: {

@@ -24,3 +26,4 @@ registry: undefined,

repo: undefined
}
},
config: undefined
},

@@ -42,2 +45,4 @@ options

};
this.emitter = new EventEmitter();
}

@@ -140,3 +145,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.emit(
"error",
`Error updating image file status code ${errCode}, will retry after delay`
);
// try again after a delay
self.retryAfterDelay(tries, err, attempt);
}
});

@@ -155,3 +171,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

@@ -176,2 +193,6 @@ var newFile = {};

self.emitter.emit(
"info",
`Image file didn't exist creating image file`
);
return self.github

@@ -194,4 +215,13 @@ .createFile({

} else {
// try again
attempt(err);
if (errCode && errCode >= 500) {
// don't retry 500 errors
reject(err);
} else {
self.emitter.emit(
"error",
`Error creating image file status code ${errCode}, will retry after delay`
);
// try again after a delay
self.retryAfterDelay(tries, err, attempt);
}
}

@@ -209,2 +239,17 @@ });

return new Promise(function(resolve, reject) {
// if the config was provided via options, skip fetching it
if (self.options.config) {
self
.attemptCommit(
self.options.config,
image,
branch,
committer,
message,
save
)
.then(resolve)
.catch(reject);
}
const configRequest = {

@@ -237,4 +282,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 * this.options.retryIncrement * 1000;
return setTimeout(() => {
return func(err);
}, retryDelay);
}
}
module.exports = ImageDeployer;

Sorry, the diff of this file is not supported yet

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