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-updates.0

12

package.json
{
"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;
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