@catladder/cli
Version:
Panter cli tool for cloud CI/CD and DevOps
47 lines (46 loc) • 2.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.commandOpenLogs = void 0;
const pipeline_1 = require("../../../../pipeline/src/index.js");
const defineCommand_1 = require("../../core/defineCommand");
const getProjectConfig_1 = require("../../config/getProjectConfig");
const openKubernetesDashboards_1 = require("../../kubernetes/openKubernetesDashboards");
const openDashboard_1 = require("../../gcloud/openDashboard");
const autocompletions_1 = require("../../apps/cli/commands/project/utils/autocompletions");
const availability_1 = require("../availability");
exports.commandOpenLogs = (0, defineCommand_1.defineCommand)({
name: "project logs open",
description: "open logs for a component (Google Cloud Logging)",
group: "project",
isAvailable: (0, availability_1.hasDeployType)("kubernetes", "google-cloudrun"),
inputs: {
envComponent: {
type: "string",
message: "environment:component",
positional: true,
choices: async () => (0, autocompletions_1.envAndComponents)()
}
},
execute: async ctx => {
var _a;
const envComponent = await ctx.get("envComponent");
const {
env,
componentName
} = (0, getProjectConfig_1.parseChoice)(envComponent);
const context = await (0, getProjectConfig_1.getPipelineContextByChoice)(env, componentName);
const deployConfig = (_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config;
if ((0, pipeline_1.isOfDeployType)(deployConfig, "kubernetes")) {
await (0, openKubernetesDashboards_1.openGoogleCloudLogs)(ctx, context);
} else if ((0, pipeline_1.isOfDeployType)(deployConfig, "google-cloudrun")) {
const serviceName = context.environment.fullName.toLowerCase();
await (0, openDashboard_1.openGoogleCloudDashboard)(ctx, `run/detail/${deployConfig.region}/${serviceName}/observability/logs`, {
project: deployConfig.projectId
});
} else {
ctx.log(`Unsupported deploy type for open-logs: ${deployConfig === null || deployConfig === void 0 ? void 0 : deployConfig.type}`);
}
}
});