Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hari/beautify logs #2

Merged
merged 2 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 34 additions & 27 deletions src/actions/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { DeploymentStrategy } from "../types/deploymentStrategy";
import { parseTrafficSplitMethod } from "../types/trafficSplitMethod";
import { parseRouteStrategy } from "../types/routeStrategy";
import { boldText } from "../utilities/loggerUtils";

export async function deploy(
kubectl: Kubectl,
Expand All @@ -24,9 +25,10 @@ export async function deploy(
// update manifests
const inputManifestFiles: string[] = updateManifestFiles(manifestFilePaths);
core.debug("Input manifest files: " + inputManifestFiles);

// deploy manifests
core.info("Deploying manifests");
core.startGroup("Deploying manifests");
core.info(boldText("Deploying manifests"));
const trafficSplitMethod = parseTrafficSplitMethod(
core.getInput("traffic-split-method", { required: true })
);
Expand All @@ -36,26 +38,30 @@ export async function deploy(
kubectl,
trafficSplitMethod
);
core.endGroup();
core.debug("Deployed manifest files: " + deployedManifestFiles);

// check manifest stability
core.info("Checking manifest stability");
core.startGroup("Checking manifest stability");
core.info(boldText("Checking manifest stability"));
const resourceTypes: Resource[] = getResources(
deployedManifestFiles,
models.DEPLOYMENT_TYPES.concat([
KubernetesConstants.DiscoveryAndLoadBalancerResource.SERVICE,
])
);
await checkManifestStability(kubectl, resourceTypes);

if (deploymentStrategy == DeploymentStrategy.BLUE_GREEN) {
core.info("Routing blue green");
const routeStrategy = parseRouteStrategy(
core.getInput("route-method", { required: true })
);
await routeBlueGreen(kubectl, inputManifestFiles, routeStrategy);
core.endGroup();

if (deploymentStrategy == DeploymentStrategy.BLUE_GREEN) {
core.group("Routing Blue/Green", async () => {
core.info(boldText("Routing blue green"));
const routeStrategy = parseRouteStrategy(
core.getInput("route-method", { required: true })
);
await routeBlueGreen(kubectl, inputManifestFiles, routeStrategy);
});
}

// print ingresses
core.info("Printing ingresses");
const ingressResources: Resource[] = getResources(deployedManifestFiles, [
Expand All @@ -67,19 +73,20 @@ export async function deploy(
ingressResource.name
);
}

// annotate resources
core.info("Annotating resources");
// annotate resources
let allPods;
try {
allPods = JSON.parse((await kubectl.getAllPods()).stdout);
} catch (e) {
core.debug("Unable to parse pods: " + e);
}
await annotateAndLabelResources(
deployedManifestFiles,
kubectl,
resourceTypes,
allPods
);
}
core.group("Annotating resources", async () => {
core.info(boldText("Annotating resources"));
try {
allPods = JSON.parse((await kubectl.getAllPods()).stdout);
} catch (e) {
core.debug("Unable to parse pods: " + e);
}
await annotateAndLabelResources(
deployedManifestFiles,
kubectl,
resourceTypes,
allPods
);
});
}
3 changes: 3 additions & 0 deletions src/utilities/loggerUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function boldText(text: string) {
return `\u001b[1mBold ${text}`;
}