-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
287 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import baseConfig from "@ctrlplane/eslint-config/base"; | ||
import baseConfig, { requireJsSuffix } from "@ctrlplane/eslint-config/base"; | ||
|
||
/** @type {import('typescript-eslint').Config} */ | ||
export default [ | ||
{ | ||
ignores: ["dist/**"], | ||
}, | ||
...requireJsSuffix, | ||
...baseConfig, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from "./config-file"; | ||
export * from "./config-file.js"; |
20 changes: 0 additions & 20 deletions
20
packages/validators/src/targets/application/v1/instance.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./kubernetes-v1.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { z } from "zod"; | ||
|
||
const clusterConfig = z.object({ | ||
name: z.string(), | ||
server: z.object({ | ||
certificateAuthorityData: z.string(), | ||
endpoint: z.string().url(), | ||
}), | ||
}); | ||
export const kubernetesClusterApiV1 = z.object({ | ||
version: z.literal("kubernetes/v1"), | ||
kind: z.literal("ClusterAPI"), | ||
identifier: z.string(), | ||
name: z.string(), | ||
config: clusterConfig, | ||
labels: z.record(z.string()).and( | ||
z | ||
.object({ | ||
"kubernetes/version": z.string(), | ||
"kubernetes/distribution": z.string(), | ||
"kubernetes/master-version": z.string(), | ||
"kubernetes/master-version-major": z.string(), | ||
"kubernetes/master-version-minor": z.string(), | ||
"kubernetes/master-version-patch": z.string(), | ||
"kubernetes/autoscaling-enabled": z.string().optional(), | ||
}) | ||
.partial(), | ||
), | ||
}); | ||
|
||
export type KubernetesClusterAPIV1 = z.infer<typeof kubernetesClusterApiV1>; | ||
|
||
export const kubernetesNamespaceV1 = z.object({ | ||
version: z.literal("kubernetes/v1"), | ||
kind: z.literal("Namespace"), | ||
identifier: z.string(), | ||
name: z.string(), | ||
config: clusterConfig.and(z.object({ namespace: z.string() })), | ||
labels: z.record(z.string()).and(z.object({}).partial()), | ||
}); | ||
|
||
export type KubernetesNamespaceV1 = z.infer<typeof kubernetesNamespaceV1>; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import type { ClusterManagerClient } from "@google-cloud/container"; | ||
import { KubeConfig } from "@kubernetes/client-node"; | ||
import { GoogleAuth } from "google-auth-library"; | ||
|
||
const sourceCredentials = new GoogleAuth({ | ||
scopes: ["https://www.googleapis.com/auth/cloud-platform"], | ||
}); | ||
|
||
export const connectToCluster = async ( | ||
clusterClient: ClusterManagerClient, | ||
project: string, | ||
clusterName: string, | ||
clusterLocation: string, | ||
) => { | ||
const [credentials] = await clusterClient.getCluster({ | ||
name: `projects/${project}/locations/${clusterLocation}/clusters/${clusterName}`, | ||
}); | ||
const kubeConfig = new KubeConfig(); | ||
kubeConfig.loadFromOptions({ | ||
clusters: [ | ||
{ | ||
name: clusterName, | ||
server: `https://${credentials.endpoint}`, | ||
caData: credentials.masterAuth!.clusterCaCertificate!, | ||
}, | ||
], | ||
users: [ | ||
{ | ||
name: clusterName, | ||
token: (await sourceCredentials.getAccessToken())!, | ||
}, | ||
], | ||
contexts: [ | ||
{ | ||
name: clusterName, | ||
user: clusterName, | ||
cluster: clusterName, | ||
}, | ||
], | ||
currentContext: clusterName, | ||
}); | ||
return kubeConfig; | ||
}; |
Oops, something went wrong.