@catladder/cli 1.47.0 → 1.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apps/cli/commands/project/commandOpenDashboard.js +19 -20
- package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -1
- package/dist/apps/cli/commands/project/commandOpenLogs.js +7 -20
- package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -1
- package/dist/bundles/catenv/index.js +1 -1
- package/dist/bundles/cli/index.js +2 -2
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js +1 -1
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js.map +1 -1
- package/dist/gcloud/cloudRun/openCloudRunDashboards.d.ts +3 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.js +62 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.js.map +1 -0
- package/dist/gcloud/openDashboard.d.ts +2 -0
- package/dist/{apps/cli/commands/shared/index.js → gcloud/openDashboard.js} +23 -27
- package/dist/gcloud/openDashboard.js.map +1 -0
- package/dist/kubernetes/openKubernetesDashboards.d.ts +4 -0
- package/dist/kubernetes/openKubernetesDashboards.js +94 -0
- package/dist/kubernetes/openKubernetesDashboards.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/apps/cli/commands/project/commandOpenDashboard.ts +11 -31
- package/src/apps/cli/commands/project/commandOpenLogs.ts +3 -34
- package/src/gcloud/cloudRun/getCloudRunDomainSuffix.ts +2 -1
- package/src/gcloud/cloudRun/openCloudRunDashboards.ts +22 -0
- package/src/gcloud/openDashboard.ts +19 -0
- package/src/kubernetes/openKubernetesDashboards.ts +52 -0
- package/dist/apps/cli/commands/shared/index.d.ts +0 -3
- package/dist/apps/cli/commands/shared/index.js.map +0 -1
- package/src/apps/cli/commands/shared/index.ts +0 -32
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"node": ">=12.0.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@catladder/pipeline": "1.
|
|
27
|
+
"@catladder/pipeline": "1.48.0",
|
|
28
28
|
"@kubernetes/client-node": "^0.16.2",
|
|
29
29
|
"@tsconfig/node14": "^1.0.1",
|
|
30
30
|
"@types/common-tags": "^1.8.0",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"update-notifier": "^5",
|
|
59
59
|
"vorpal": "^1.12.0"
|
|
60
60
|
},
|
|
61
|
-
"version": "1.
|
|
61
|
+
"version": "1.48.0"
|
|
62
62
|
}
|
|
@@ -1,48 +1,28 @@
|
|
|
1
|
+
import { isOfDeployType } from "@catladder/pipeline";
|
|
1
2
|
import type Vorpal from "vorpal";
|
|
2
3
|
import {
|
|
3
4
|
getPipelineContextByChoice,
|
|
4
5
|
parseChoice,
|
|
5
6
|
} from "../../../../config/getProjectConfig";
|
|
6
|
-
import {
|
|
7
|
-
import { openGoogleCloudKubernetesDashboard } from "
|
|
7
|
+
import { openGoogleCloudRunDashboard } from "../../../../gcloud/cloudRun/openCloudRunDashboards";
|
|
8
|
+
import { openGoogleCloudKubernetesDashboard } from "../../../../kubernetes/openKubernetesDashboards";
|
|
9
|
+
|
|
8
10
|
import { envAndComponents } from "./utils/autocompletions";
|
|
11
|
+
|
|
9
12
|
export default async (vorpal: Vorpal) =>
|
|
10
13
|
vorpal
|
|
11
14
|
.command(
|
|
12
15
|
"project-open-dashboard <envComponent>",
|
|
13
|
-
"open
|
|
16
|
+
"open an apps dashboard (kubernetes or cloudrun)"
|
|
14
17
|
)
|
|
15
18
|
.autocomplete(await envAndComponents())
|
|
16
19
|
.action(async function ({ envComponent }) {
|
|
17
20
|
const { env, componentName } = parseChoice(envComponent);
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
!componentConfig.deploy ||
|
|
25
|
-
componentConfig.deploy.type !== "kubernetes"
|
|
26
|
-
) {
|
|
27
|
-
throw new Error(
|
|
28
|
-
"only kubernetes deployments are supported at the moment"
|
|
29
|
-
);
|
|
21
|
+
const context = await getPipelineContextByChoice(env, componentName);
|
|
22
|
+
if (isOfDeployType(context.componentConfig.deploy, "kubernetes")) {
|
|
23
|
+
await openGoogleCloudKubernetesDashboard(this, context);
|
|
30
24
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
!componentConfig.deploy.cluster ||
|
|
34
|
-
componentConfig.deploy.cluster.type !== "gcloud"
|
|
35
|
-
) {
|
|
36
|
-
throw new Error("no gcloud custer configured");
|
|
25
|
+
if (isOfDeployType(context.componentConfig.deploy, "google-cloudrun")) {
|
|
26
|
+
await openGoogleCloudRunDashboard(this, context);
|
|
37
27
|
}
|
|
38
|
-
// currently only supports kubernetes
|
|
39
|
-
const namespace = environment.envVars.KUBE_NAMESPACE;
|
|
40
|
-
|
|
41
|
-
const authGoogleNumber = await getGoogleAuthUserNumber.call(this, vorpal);
|
|
42
|
-
|
|
43
|
-
openGoogleCloudKubernetesDashboard(
|
|
44
|
-
componentConfig.deploy.cluster,
|
|
45
|
-
namespace,
|
|
46
|
-
authGoogleNumber
|
|
47
|
-
);
|
|
48
28
|
});
|
|
@@ -3,12 +3,8 @@ import {
|
|
|
3
3
|
getPipelineContextByChoice,
|
|
4
4
|
parseChoice,
|
|
5
5
|
} from "../../../../config/getProjectConfig";
|
|
6
|
-
import {
|
|
7
|
-
import { getProjectNamespace } from "../../../../utils/projects";
|
|
8
|
-
import { getGoogleAuthUserNumber } from "../../utils/getGoogleAuthUserNumber";
|
|
9
|
-
import { openGoogleCloudLogs } from "../shared";
|
|
6
|
+
import { openGoogleCloudLogs } from "../../../../kubernetes/openKubernetesDashboards";
|
|
10
7
|
import { envAndComponents } from "./utils/autocompletions";
|
|
11
|
-
import ensureCluster from "./utils/ensureCluster";
|
|
12
8
|
|
|
13
9
|
export default async (vorpal: Vorpal) =>
|
|
14
10
|
vorpal
|
|
@@ -19,34 +15,7 @@ export default async (vorpal: Vorpal) =>
|
|
|
19
15
|
.autocomplete(await envAndComponents())
|
|
20
16
|
.action(async function ({ envComponent }) {
|
|
21
17
|
const { env, componentName } = parseChoice(envComponent);
|
|
22
|
-
const
|
|
23
|
-
env,
|
|
24
|
-
componentName
|
|
25
|
-
);
|
|
18
|
+
const context = await getPipelineContextByChoice(env, componentName);
|
|
26
19
|
|
|
27
|
-
|
|
28
|
-
!componentConfig.deploy ||
|
|
29
|
-
componentConfig.deploy.type !== "kubernetes"
|
|
30
|
-
) {
|
|
31
|
-
throw new Error(
|
|
32
|
-
"only kubernetes deployments are supported at the moment"
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
!componentConfig.deploy.cluster ||
|
|
38
|
-
componentConfig.deploy.cluster.type !== "gcloud"
|
|
39
|
-
) {
|
|
40
|
-
throw new Error("no gcloud custer configured");
|
|
41
|
-
}
|
|
42
|
-
// currently only supports kubernetes
|
|
43
|
-
const namespace = environment.envVars.KUBE_NAMESPACE;
|
|
44
|
-
|
|
45
|
-
const authGoogleNumber = await getGoogleAuthUserNumber.call(this, vorpal);
|
|
46
|
-
|
|
47
|
-
await openGoogleCloudLogs(
|
|
48
|
-
componentConfig.deploy.cluster,
|
|
49
|
-
namespace,
|
|
50
|
-
authGoogleNumber
|
|
51
|
-
);
|
|
20
|
+
await openGoogleCloudLogs(this, context);
|
|
52
21
|
});
|
|
@@ -17,7 +17,7 @@ export const getCloudRunDomainSuffix = async (config: DeployConfigCloudRun) => {
|
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
const dummyServiceName = "cl-dummy-service";
|
|
20
|
+
const dummyServiceName = "cl-dummy-service-delete-me";
|
|
21
21
|
|
|
22
22
|
const existingServices = await exec(
|
|
23
23
|
`gcloud run services list --format=json --project="${config.projectId}" --region=${config.region} --limit=1`
|
|
@@ -30,5 +30,6 @@ export const getCloudRunDomainSuffix = async (config: DeployConfigCloudRun) => {
|
|
|
30
30
|
const result = await exec(
|
|
31
31
|
`gcloud run deploy ${dummyServiceName} --region=${config.region} --allow-unauthenticated --project ${config.projectId} --image=us-docker.pkg.dev/cloudrun/container/hello --format=json`
|
|
32
32
|
).then((r) => JSON.parse(r.stdout));
|
|
33
|
+
|
|
33
34
|
return await getSuffixFromService(result);
|
|
34
35
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Context } from "@catladder/pipeline";
|
|
2
|
+
import { isOfDeployType } from "@catladder/pipeline";
|
|
3
|
+
import type { CommandInstance } from "vorpal";
|
|
4
|
+
import { openGoogleCloudDashboard } from "../openDashboard";
|
|
5
|
+
|
|
6
|
+
export const openGoogleCloudRunDashboard = async (
|
|
7
|
+
instance: CommandInstance,
|
|
8
|
+
context: Context
|
|
9
|
+
) => {
|
|
10
|
+
if (!isOfDeployType(context.componentConfig.deploy, "google-cloudrun")) {
|
|
11
|
+
throw new Error("deploy type is not google-cloudrun ");
|
|
12
|
+
}
|
|
13
|
+
const { fullName } = context.environment;
|
|
14
|
+
const { region, projectId } = context.componentConfig.deploy;
|
|
15
|
+
await openGoogleCloudDashboard(
|
|
16
|
+
instance,
|
|
17
|
+
`run/detail/${region}/${fullName}/metrics`,
|
|
18
|
+
{
|
|
19
|
+
project: projectId,
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CommandInstance } from "vorpal";
|
|
2
|
+
import { getGoogleAuthUserNumber } from "../apps/cli/utils/getGoogleAuthUserNumber";
|
|
3
|
+
import open from "open";
|
|
4
|
+
export const openGoogleCloudDashboard = async (
|
|
5
|
+
instance: CommandInstance,
|
|
6
|
+
path: string,
|
|
7
|
+
params: Record<string, string>
|
|
8
|
+
) => {
|
|
9
|
+
const url = new URL("https://console.cloud.google.com/");
|
|
10
|
+
url.pathname = path;
|
|
11
|
+
for (const [key, value] of Object.entries(params)) {
|
|
12
|
+
url.searchParams.set(key, value);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const googleAuthUserNumber = await getGoogleAuthUserNumber.call(instance);
|
|
16
|
+
url.searchParams.set("authuser", googleAuthUserNumber);
|
|
17
|
+
|
|
18
|
+
open(url.toString());
|
|
19
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Context } from "@catladder/pipeline";
|
|
2
|
+
import { isOfDeployType } from "@catladder/pipeline";
|
|
3
|
+
import type { CommandInstance } from "vorpal";
|
|
4
|
+
import { openGoogleCloudDashboard } from "../gcloud/openDashboard";
|
|
5
|
+
|
|
6
|
+
export const openGoogleCloudLogs = async (
|
|
7
|
+
instance: CommandInstance,
|
|
8
|
+
context: Context
|
|
9
|
+
) => {
|
|
10
|
+
const deployConfig = context.componentConfig.deploy;
|
|
11
|
+
if (!isOfDeployType(deployConfig, "kubernetes")) {
|
|
12
|
+
throw new Error("context is not of type kubernetes");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (!deployConfig.cluster || deployConfig.cluster.type !== "gcloud") {
|
|
16
|
+
throw new Error("no gcloud custer configured");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const namespace = context.environment.envVars.KUBE_NAMESPACE;
|
|
20
|
+
const cluster = deployConfig.cluster;
|
|
21
|
+
|
|
22
|
+
const resource = `k8s_container/cluster_name/${cluster.name}${
|
|
23
|
+
namespace ? `/namespace_name/${namespace}` : ""
|
|
24
|
+
}`;
|
|
25
|
+
|
|
26
|
+
await openGoogleCloudDashboard(instance, "logs/viewer", {
|
|
27
|
+
project: cluster.projectId,
|
|
28
|
+
resource: resource,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const openGoogleCloudKubernetesDashboard = async (
|
|
33
|
+
instance: CommandInstance,
|
|
34
|
+
context: Context
|
|
35
|
+
) => {
|
|
36
|
+
const deployConfig = context.componentConfig.deploy;
|
|
37
|
+
if (!isOfDeployType(deployConfig, "kubernetes")) {
|
|
38
|
+
throw new Error("context is not of type kubernetes");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!deployConfig.cluster || deployConfig.cluster.type !== "gcloud") {
|
|
42
|
+
throw new Error("no gcloud custer configured");
|
|
43
|
+
}
|
|
44
|
+
const namespace = context.environment.envVars.KUBE_NAMESPACE;
|
|
45
|
+
const cluster = deployConfig.cluster;
|
|
46
|
+
const pageState = `("savedViews":("c":["gke/${cluster.region}/${cluster.name}"],"n":["${namespace}"],"i":"4e42e0b9cd6147f8a4fba7516752ec48"))`;
|
|
47
|
+
|
|
48
|
+
await openGoogleCloudDashboard(instance, "kubernetes/workload", {
|
|
49
|
+
project: cluster.projectId,
|
|
50
|
+
pageState: pageState,
|
|
51
|
+
});
|
|
52
|
+
};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { DeployConfigKubernetesCluster } from "@catladder/pipeline";
|
|
2
|
-
export declare const openGoogleCloudLogs: (cluster?: DeployConfigKubernetesCluster, namespace?: string, googleAuthUserNumber?: number) => Promise<void>;
|
|
3
|
-
export declare const openGoogleCloudKubernetesDashboard: (cluster: DeployConfigKubernetesCluster, namespace: string, googleAuthUserNumber?: number) => Promise<void>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/apps/cli/commands/shared/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,8CAAwB;AAEjB,IAAM,mBAAmB,GAAG,UACjC,OAAuC,EACvC,SAAkB,EAClB,oBAAwB;IAAxB,qCAAA,EAAA,wBAAwB;;;;YAElB,QAAQ,GAAG,qCAA8B,OAAO,CAAC,IAAI,SACzD,SAAS,CAAC,CAAC,CAAC,0BAAmB,SAAS,CAAE,CAAC,CAAC,CAAC,EAAE,CAC/C,CAAC;YAEG,GAAG,GAAG,+DACV,OAAO,CAAC,SAAS,SAEjB,QAAQ,CAAC,CAAC,CAAC,oBAAa,kBAAkB,CAAC,QAAQ,CAAC,CAAE,CAAC,CAAC,CAAC,EAAE,uBAChD,oBAAoB,CAAE,CAAC;YACpC,IAAA,iBAAI,EAAC,GAAG,CAAC,CAAC;;;;CACX,CAAC;AAfW,QAAA,mBAAmB,uBAe9B;AAEK,IAAM,kCAAkC,GAAG,UAChD,OAAsC,EACtC,SAAiB,EACjB,oBAAwB;IAAxB,qCAAA,EAAA,wBAAwB;;;;YAElB,SAAS,GAAG,wCAA4B,OAAO,CAAC,MAAM,cAAI,OAAO,CAAC,IAAI,0BAAY,SAAS,qDAA6C,CAAC;YACzI,GAAG,GAAG,wEAAiE,oBAAoB,sBAC/F,OAAO,CAAC,SAAS,wBACL,kBAAkB,CAAC,SAAS,CAAC,CAAE,CAAC;YAE9C,IAAA,iBAAI,EAAC,GAAG,CAAC,CAAC;;;;CACX,CAAC;AAXW,QAAA,kCAAkC,sCAW7C"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { DeployConfigKubernetesCluster } from "@catladder/pipeline";
|
|
2
|
-
import open from "open";
|
|
3
|
-
|
|
4
|
-
export const openGoogleCloudLogs = async (
|
|
5
|
-
cluster?: DeployConfigKubernetesCluster,
|
|
6
|
-
namespace?: string,
|
|
7
|
-
googleAuthUserNumber = 0
|
|
8
|
-
) => {
|
|
9
|
-
const resource = `k8s_container/cluster_name/${cluster.name}${
|
|
10
|
-
namespace ? `/namespace_name/${namespace}` : ""
|
|
11
|
-
}`;
|
|
12
|
-
|
|
13
|
-
const url = `https://console.cloud.google.com/logs/viewer?project=${
|
|
14
|
-
cluster.projectId
|
|
15
|
-
}${
|
|
16
|
-
resource ? `&resource=${encodeURIComponent(resource)}` : ""
|
|
17
|
-
}&authuser=${googleAuthUserNumber}`;
|
|
18
|
-
open(url);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const openGoogleCloudKubernetesDashboard = async (
|
|
22
|
-
cluster: DeployConfigKubernetesCluster,
|
|
23
|
-
namespace: string,
|
|
24
|
-
googleAuthUserNumber = 0
|
|
25
|
-
) => {
|
|
26
|
-
const pageState = `("savedViews":("c":["gke/${cluster.region}/${cluster.name}"],"n":["${namespace}"],"i":"4e42e0b9cd6147f8a4fba7516752ec48"))`;
|
|
27
|
-
const url = `https://console.cloud.google.com/kubernetes/workload?authuser=${googleAuthUserNumber}&project=${
|
|
28
|
-
cluster.projectId
|
|
29
|
-
}&pageState=${encodeURIComponent(pageState)}`;
|
|
30
|
-
|
|
31
|
-
open(url);
|
|
32
|
-
};
|