Skip to content

Commit

Permalink
Add node modules and new code for release (#168)
Browse files Browse the repository at this point in the history
Co-authored-by: OliverMKing <[email protected]>
  • Loading branch information
github-actions[bot] and OliverMKing authored Feb 2, 2022
1 parent ca8d260 commit a0f00e5
Show file tree
Hide file tree
Showing 8,092 changed files with 1,732,166 additions and 149 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules

.DS_Store
.idea
18 changes: 9 additions & 9 deletions lib/actions/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@ const routeStrategy_1 = require("../types/routeStrategy");
function deploy(kubectl, manifestFilePaths, deploymentStrategy) {
return __awaiter(this, void 0, void 0, function* () {
// update manifests
const inputManifestFiles = manifestUpdateUtils_1.updateManifestFiles(manifestFilePaths);
const inputManifestFiles = (0, manifestUpdateUtils_1.updateManifestFiles)(manifestFilePaths);
core.debug("Input manifest files: " + inputManifestFiles);
// deploy manifests
core.info("Deploying manifests");
const trafficSplitMethod = trafficSplitMethod_1.parseTrafficSplitMethod(core.getInput("traffic-split-method", { required: true }));
const deployedManifestFiles = yield deploymentHelper_1.deployManifests(inputManifestFiles, deploymentStrategy, kubectl, trafficSplitMethod);
const trafficSplitMethod = (0, trafficSplitMethod_1.parseTrafficSplitMethod)(core.getInput("traffic-split-method", { required: true }));
const deployedManifestFiles = yield (0, deploymentHelper_1.deployManifests)(inputManifestFiles, deploymentStrategy, kubectl, trafficSplitMethod);
core.debug("Deployed manifest files: " + deployedManifestFiles);
// check manifest stability
core.info("Checking manifest stability");
const resourceTypes = manifestUpdateUtils_1.getResources(deployedManifestFiles, models.DEPLOYMENT_TYPES.concat([
const resourceTypes = (0, manifestUpdateUtils_1.getResources)(deployedManifestFiles, models.DEPLOYMENT_TYPES.concat([
KubernetesConstants.DiscoveryAndLoadBalancerResource.SERVICE,
]));
yield deploymentHelper_1.checkManifestStability(kubectl, resourceTypes);
yield (0, deploymentHelper_1.checkManifestStability)(kubectl, resourceTypes);
if (deploymentStrategy == deploymentStrategy_1.DeploymentStrategy.BLUE_GREEN) {
core.info("Routing blue green");
const routeStrategy = routeStrategy_1.parseRouteStrategy(core.getInput("route-method", { required: true }));
yield blueGreenHelper_1.routeBlueGreen(kubectl, inputManifestFiles, routeStrategy);
const routeStrategy = (0, routeStrategy_1.parseRouteStrategy)(core.getInput("route-method", { required: true }));
yield (0, blueGreenHelper_1.routeBlueGreen)(kubectl, inputManifestFiles, routeStrategy);
}
// print ingresses
core.info("Printing ingresses");
const ingressResources = manifestUpdateUtils_1.getResources(deployedManifestFiles, [
const ingressResources = (0, manifestUpdateUtils_1.getResources)(deployedManifestFiles, [
KubernetesConstants.DiscoveryAndLoadBalancerResource.INGRESS,
]);
for (const ingressResource of ingressResources) {
Expand All @@ -57,7 +57,7 @@ function deploy(kubectl, manifestFilePaths, deploymentStrategy) {
catch (e) {
core.debug("Unable to parse pods: " + e);
}
yield deploymentHelper_1.annotateAndLabelResources(deployedManifestFiles, kubectl, resourceTypes, allPods);
yield (0, deploymentHelper_1.annotateAndLabelResources)(deployedManifestFiles, kubectl, resourceTypes, allPods);
});
}
exports.deploy = deploy;
30 changes: 15 additions & 15 deletions lib/actions/promote.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ exports.promote = promote;
function promoteCanary(kubectl, manifests) {
return __awaiter(this, void 0, void 0, function* () {
let includeServices = false;
const trafficSplitMethod = trafficSplitMethod_1.parseTrafficSplitMethod(core.getInput("traffic-split-method", { required: true }));
const trafficSplitMethod = (0, trafficSplitMethod_1.parseTrafficSplitMethod)(core.getInput("traffic-split-method", { required: true }));
if (trafficSplitMethod == trafficSplitMethod_1.TrafficSplitMethod.SMI) {
includeServices = true;
// In case of SMI traffic split strategy when deployment is promoted, first we will redirect traffic to
Expand Down Expand Up @@ -70,40 +70,40 @@ function promoteCanary(kubectl, manifests) {
function promoteBlueGreen(kubectl, manifests) {
return __awaiter(this, void 0, void 0, function* () {
// update container images and pull secrets
const inputManifestFiles = manifestUpdateUtils_1.updateManifestFiles(manifests);
const manifestObjects = blueGreenHelper_1.getManifestObjects(inputManifestFiles);
const routeStrategy = routeStrategy_1.parseRouteStrategy(core.getInput("route-method", { required: true }));
const inputManifestFiles = (0, manifestUpdateUtils_1.updateManifestFiles)(manifests);
const manifestObjects = (0, blueGreenHelper_1.getManifestObjects)(inputManifestFiles);
const routeStrategy = (0, routeStrategy_1.parseRouteStrategy)(core.getInput("route-method", { required: true }));
core.info("Deleting old deployment and making new one");
let result;
if (routeStrategy == routeStrategy_1.RouteStrategy.INGRESS) {
result = yield ingressBlueGreenHelper_1.promoteBlueGreenIngress(kubectl, manifestObjects);
result = yield (0, ingressBlueGreenHelper_1.promoteBlueGreenIngress)(kubectl, manifestObjects);
}
else if (routeStrategy == routeStrategy_1.RouteStrategy.SMI) {
result = yield smiBlueGreenHelper_1.promoteBlueGreenSMI(kubectl, manifestObjects);
result = yield (0, smiBlueGreenHelper_1.promoteBlueGreenSMI)(kubectl, manifestObjects);
}
else {
result = yield serviceBlueGreenHelper_1.promoteBlueGreenService(kubectl, manifestObjects);
result = yield (0, serviceBlueGreenHelper_1.promoteBlueGreenService)(kubectl, manifestObjects);
}
// checking stability of newly created deployments
core.info("Checking manifest stability");
const deployedManifestFiles = result.newFilePaths;
const resources = manifestUpdateUtils_1.getResources(deployedManifestFiles, models.DEPLOYMENT_TYPES.concat([
const resources = (0, manifestUpdateUtils_1.getResources)(deployedManifestFiles, models.DEPLOYMENT_TYPES.concat([
models.DiscoveryAndLoadBalancerResource.SERVICE,
]));
yield KubernetesManifestUtility.checkManifestStability(kubectl, resources);
core.info("Routing to new deployments and deleting old workloads and services");
if (routeStrategy == routeStrategy_1.RouteStrategy.INGRESS) {
yield ingressBlueGreenHelper_1.routeBlueGreenIngress(kubectl, null, manifestObjects.serviceNameMap, manifestObjects.ingressEntityList);
yield blueGreenHelper_1.deleteWorkloadsAndServicesWithLabel(kubectl, blueGreenHelper_1.GREEN_LABEL_VALUE, manifestObjects.deploymentEntityList, manifestObjects.serviceEntityList);
yield (0, ingressBlueGreenHelper_1.routeBlueGreenIngress)(kubectl, null, manifestObjects.serviceNameMap, manifestObjects.ingressEntityList);
yield (0, blueGreenHelper_1.deleteWorkloadsAndServicesWithLabel)(kubectl, blueGreenHelper_1.GREEN_LABEL_VALUE, manifestObjects.deploymentEntityList, manifestObjects.serviceEntityList);
}
else if (routeStrategy == routeStrategy_1.RouteStrategy.SMI) {
yield smiBlueGreenHelper_1.routeBlueGreenSMI(kubectl, blueGreenHelper_1.NONE_LABEL_VALUE, manifestObjects.serviceEntityList);
yield blueGreenHelper_1.deleteWorkloadsWithLabel(kubectl, blueGreenHelper_1.GREEN_LABEL_VALUE, manifestObjects.deploymentEntityList);
yield smiBlueGreenHelper_1.cleanupSMI(kubectl, manifestObjects.serviceEntityList);
yield (0, smiBlueGreenHelper_1.routeBlueGreenSMI)(kubectl, blueGreenHelper_1.NONE_LABEL_VALUE, manifestObjects.serviceEntityList);
yield (0, blueGreenHelper_1.deleteWorkloadsWithLabel)(kubectl, blueGreenHelper_1.GREEN_LABEL_VALUE, manifestObjects.deploymentEntityList);
yield (0, smiBlueGreenHelper_1.cleanupSMI)(kubectl, manifestObjects.serviceEntityList);
}
else {
yield serviceBlueGreenHelper_1.routeBlueGreenService(kubectl, blueGreenHelper_1.NONE_LABEL_VALUE, manifestObjects.serviceEntityList);
yield blueGreenHelper_1.deleteWorkloadsWithLabel(kubectl, blueGreenHelper_1.GREEN_LABEL_VALUE, manifestObjects.deploymentEntityList);
yield (0, serviceBlueGreenHelper_1.routeBlueGreenService)(kubectl, blueGreenHelper_1.NONE_LABEL_VALUE, manifestObjects.serviceEntityList);
yield (0, blueGreenHelper_1.deleteWorkloadsWithLabel)(kubectl, blueGreenHelper_1.GREEN_LABEL_VALUE, manifestObjects.deploymentEntityList);
}
});
}
10 changes: 5 additions & 5 deletions lib/actions/reject.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exports.reject = reject;
function rejectCanary(kubectl, manifests) {
return __awaiter(this, void 0, void 0, function* () {
let includeServices = false;
const trafficSplitMethod = trafficSplitMethod_1.parseTrafficSplitMethod(core.getInput("traffic-split-method", { required: true }));
const trafficSplitMethod = (0, trafficSplitMethod_1.parseTrafficSplitMethod)(core.getInput("traffic-split-method", { required: true }));
if (trafficSplitMethod == trafficSplitMethod_1.TrafficSplitMethod.SMI) {
core.info("Rejecting deployment with SMI canary strategy");
includeServices = true;
Expand All @@ -50,15 +50,15 @@ function rejectCanary(kubectl, manifests) {
function rejectBlueGreen(kubectl, manifests) {
return __awaiter(this, void 0, void 0, function* () {
core.info("Rejecting deployment with blue green strategy");
const routeStrategy = routeStrategy_1.parseRouteStrategy(core.getInput("route-method", { required: true }));
const routeStrategy = (0, routeStrategy_1.parseRouteStrategy)(core.getInput("route-method", { required: true }));
if (routeStrategy == routeStrategy_1.RouteStrategy.INGRESS) {
yield ingressBlueGreenHelper_1.rejectBlueGreenIngress(kubectl, manifests);
yield (0, ingressBlueGreenHelper_1.rejectBlueGreenIngress)(kubectl, manifests);
}
else if (routeStrategy == routeStrategy_1.RouteStrategy.SMI) {
yield smiBlueGreenHelper_1.rejectBlueGreenSMI(kubectl, manifests);
yield (0, smiBlueGreenHelper_1.rejectBlueGreenSMI)(kubectl, manifests);
}
else {
yield serviceBlueGreenHelper_1.rejectBlueGreenService(kubectl, manifests);
yield (0, serviceBlueGreenHelper_1.rejectBlueGreenService)(kubectl, manifests);
}
});
}
12 changes: 6 additions & 6 deletions lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ function run() {
if (!process.env["KUBECONFIG"])
core.warning("KUBECONFIG env is not explicitly set. Ensure cluster context is set by using k8s-set-context action.");
// get inputs
const action = action_1.parseAction(core.getInput("action", { required: true }));
const strategy = deploymentStrategy_1.parseDeploymentStrategy(core.getInput("strategy"));
const action = (0, action_1.parseAction)(core.getInput("action", { required: true }));
const strategy = (0, deploymentStrategy_1.parseDeploymentStrategy)(core.getInput("strategy"));
const manifestsInput = core.getInput("manifests", { required: true });
const manifestFilePaths = manifestsInput
.split(/[\n,;]+/) // split into each individual manifest
.map((manifest) => manifest.trim()) // remove surrounding whitespace
.filter((manifest) => manifest.length > 0); // remove any blanks
// create kubectl
const kubectlPath = yield kubectl_1.getKubectlPath();
const kubectlPath = yield (0, kubectl_1.getKubectlPath)();
const namespace = core.getInput("namespace") || "default";
const kubectl = new kubectl_1.Kubectl(kubectlPath, namespace, true);
// run action
switch (action) {
case action_1.Action.DEPLOY: {
yield deploy_1.deploy(kubectl, manifestFilePaths, strategy);
yield (0, deploy_1.deploy)(kubectl, manifestFilePaths, strategy);
break;
}
case action_1.Action.PROMOTE: {
yield promote_1.promote(kubectl, manifestFilePaths, strategy);
yield (0, promote_1.promote)(kubectl, manifestFilePaths, strategy);
break;
}
case action_1.Action.REJECT: {
yield reject_1.reject(kubectl, manifestFilePaths, strategy);
yield (0, reject_1.reject)(kubectl, manifestFilePaths, strategy);
break;
}
default: {
Expand Down
29 changes: 15 additions & 14 deletions lib/strategyHelpers/blueGreen/blueGreenHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ function routeBlueGreen(kubectl, inputManifestFiles, routeStrategy) {
throw Error("Version switch buffer must be between 0 and 300 (inclusive)");
const startSleepDate = new Date();
core.info(`Starting buffer time of ${bufferTime} minute(s) at ${startSleepDate.toISOString()}`);
yield timeUtils_1.sleep(bufferTime * 1000 * 60);
yield (0, timeUtils_1.sleep)(bufferTime * 1000 * 60);
const endSleepDate = new Date();
core.info(`Stopping buffer time of ${bufferTime} minute(s) at ${endSleepDate.toISOString()}`);
const manifestObjects = getManifestObjects(inputManifestFiles);
core.debug("Manifest objects: " + JSON.stringify(manifestObjects));
// route to new deployments
if (routeStrategy == routeStrategy_1.RouteStrategy.INGRESS) {
yield ingressBlueGreenHelper_1.routeBlueGreenIngress(kubectl, exports.GREEN_LABEL_VALUE, manifestObjects.serviceNameMap, manifestObjects.ingressEntityList);
yield (0, ingressBlueGreenHelper_1.routeBlueGreenIngress)(kubectl, exports.GREEN_LABEL_VALUE, manifestObjects.serviceNameMap, manifestObjects.ingressEntityList);
}
else if (routeStrategy == routeStrategy_1.RouteStrategy.SMI) {
yield smiBlueGreenHelper_1.routeBlueGreenSMI(kubectl, exports.GREEN_LABEL_VALUE, manifestObjects.serviceEntityList);
yield (0, smiBlueGreenHelper_1.routeBlueGreenSMI)(kubectl, exports.GREEN_LABEL_VALUE, manifestObjects.serviceEntityList);
}
else {
yield serviceBlueGreenHelper_1.routeBlueGreenService(kubectl, exports.GREEN_LABEL_VALUE, manifestObjects.serviceEntityList);
yield (0, serviceBlueGreenHelper_1.routeBlueGreenService)(kubectl, exports.GREEN_LABEL_VALUE, manifestObjects.serviceEntityList);
}
});
}
Expand Down Expand Up @@ -110,7 +110,7 @@ function deleteObjects(kubectl, deleteList) {
for (const delObject of deleteList) {
try {
const result = yield kubectl.delete([delObject.kind, delObject.name]);
kubectlUtils_1.checkForErrors([result]);
(0, kubectlUtils_1.checkForErrors)([result]);
}
catch (ex) {
// Ignore failures of delete if it doesn't exist
Expand All @@ -133,10 +133,10 @@ function getManifestObjects(filePaths) {
if (!!inputObject) {
const kind = inputObject.kind;
const name = inputObject.metadata.name;
if (kubernetesTypes_1.isDeploymentEntity(kind)) {
if ((0, kubernetesTypes_1.isDeploymentEntity)(kind)) {
deploymentEntityList.push(inputObject);
}
else if (kubernetesTypes_1.isServiceEntity(kind)) {
else if ((0, kubernetesTypes_1.isServiceEntity)(kind)) {
if (isServiceRouted(inputObject, deploymentEntityList)) {
routedServiceEntityList.push(inputObject);
serviceNameMap.set(name, getBlueGreenResourceName(name, exports.GREEN_SUFFIX));
Expand All @@ -145,7 +145,7 @@ function getManifestObjects(filePaths) {
unroutedServiceEntityList.push(inputObject);
}
}
else if (kubernetesTypes_1.isIngressEntity(kind)) {
else if ((0, kubernetesTypes_1.isIngressEntity)(kind)) {
ingressEntityList.push(inputObject);
}
else {
Expand Down Expand Up @@ -211,11 +211,11 @@ function addBlueGreenLabelsAndAnnotations(inputObject, labelValue) {
const newLabels = new Map();
newLabels[exports.BLUE_GREEN_VERSION_LABEL] = labelValue;
// updating object labels and selector labels
manifestUpdateUtils_1.updateObjectLabels(inputObject, newLabels, false);
manifestUpdateUtils_1.updateSelectorLabels(inputObject, newLabels, false);
(0, manifestUpdateUtils_1.updateObjectLabels)(inputObject, newLabels, false);
(0, manifestUpdateUtils_1.updateSelectorLabels)(inputObject, newLabels, false);
// updating spec labels if it is a service
if (!kubernetesTypes_1.isServiceEntity(inputObject.kind)) {
manifestSpecLabelUtils_1.updateSpecLabels(inputObject, newLabels, false);
if (!(0, kubernetesTypes_1.isServiceEntity)(inputObject.kind)) {
(0, manifestSpecLabelUtils_1.updateSpecLabels)(inputObject, newLabels, false);
}
}
exports.addBlueGreenLabelsAndAnnotations = addBlueGreenLabelsAndAnnotations;
Expand All @@ -226,7 +226,8 @@ exports.getBlueGreenResourceName = getBlueGreenResourceName;
function getDeploymentMatchLabels(deploymentObject) {
var _a, _b, _c, _d;
if (((_a = deploymentObject === null || deploymentObject === void 0 ? void 0 : deploymentObject.kind) === null || _a === void 0 ? void 0 : _a.toUpperCase()) ==
kubernetesTypes_1.KubernetesWorkload.POD.toUpperCase() && ((_b = deploymentObject === null || deploymentObject === void 0 ? void 0 : deploymentObject.metadata) === null || _b === void 0 ? void 0 : _b.labels)) {
kubernetesTypes_1.KubernetesWorkload.POD.toUpperCase() &&
((_b = deploymentObject === null || deploymentObject === void 0 ? void 0 : deploymentObject.metadata) === null || _b === void 0 ? void 0 : _b.labels)) {
return deploymentObject.metadata.labels;
}
else if ((_d = (_c = deploymentObject === null || deploymentObject === void 0 ? void 0 : deploymentObject.spec) === null || _c === void 0 ? void 0 : _c.selector) === null || _d === void 0 ? void 0 : _d.matchLabels) {
Expand Down Expand Up @@ -267,7 +268,7 @@ function fetchResource(kubectl, kind, name) {
if (!!result.stdout) {
const resource = JSON.parse(result.stdout);
try {
manifestUpdateUtils_1.UnsetClusterSpecificDetails(resource);
(0, manifestUpdateUtils_1.UnsetClusterSpecificDetails)(resource);
return resource;
}
catch (ex) {
Expand Down
Loading

0 comments on commit a0f00e5

Please sign in to comment.