-
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.
feature(Kubernetes) : Cleaned Shulker_utils.ts & making all post requ…
…est endpoint
- Loading branch information
1 parent
952a61b
commit 9774144
Showing
6 changed files
with
144 additions
and
64 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
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,53 @@ | ||
import k8s from "@kubernetes/client-node"; | ||
import * as shulker from "~/server/utils/Shulker_utils"; | ||
|
||
const kc = new k8s.KubeConfig(); | ||
kc.loadFromDefault(); | ||
const k8sCRDApi = kc.makeApiClient(k8s.CustomObjectsApi); | ||
export default defineEventHandler(async (event) => { | ||
const body = await readBody(event); | ||
if (!body) { | ||
throw createError({ | ||
statusCode: 400, | ||
statusMessage: "Bad request", | ||
message: "Missing body", | ||
}); | ||
} | ||
if (!body.name || !body.clusterRef) { | ||
throw createError({ | ||
statusCode: 400, | ||
statusMessage: "Bad request", | ||
message: "Missing ProxyFleet parameters", | ||
}); | ||
} | ||
|
||
const clusterRef = new shulker.ClusterRef(body.clusterRef); | ||
const metadata = new shulker.ShulkerMetadata(body.name); | ||
|
||
const service: shulker.ProxyFleetSpecService = | ||
body.services || new shulker.ProxyFleetSpecService(); | ||
const templateSpec: shulker.ProxyFleetSpecTemplateSpec = | ||
new shulker.ProxyFleetSpecTemplateSpec(body.version); | ||
const template: shulker.ProxyFleetSpecTemplate = | ||
new shulker.ProxyFleetSpecTemplate(templateSpec); | ||
|
||
const spec: shulker.ProxyFleetSpec = new shulker.ProxyFleetSpec( | ||
clusterRef, | ||
service, | ||
template, | ||
); | ||
|
||
const Deploy_ProxyFleet = new shulker.ProxyFleet(metadata, spec); | ||
//console.log(JSON.stringify(body, null, 4)); | ||
//console.log(JSON.stringify(Deploy_ProxyFleet, null, 4)); | ||
const Deployments_Result = await k8sCRDApi.createNamespacedCustomObject( | ||
"shulkermc.io", | ||
"v1alpha1", | ||
Deploy_ProxyFleet.metadata.namespace, | ||
"proxyfleets", | ||
Deploy_ProxyFleet, | ||
); | ||
return { | ||
deploy: Deployments_Result, | ||
}; | ||
}); |
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,5 @@ | ||
export default defineEventHandler(async (event) => { | ||
const body = await readBody(event); | ||
console.log(body); | ||
return { body }; | ||
}); |
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