Skip to content

Commit

Permalink
#73
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaguiar committed Jun 12, 2023
1 parent 53e7806 commit 9e05964
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
Binary file modified Kube/.odoc.db
Binary file not shown.
6 changes: 3 additions & 3 deletions Kube/.package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ name: Kube
main: ''
mainJob: ''
license: https://github.com/OpenAF/openaf-opacks/blob/master/LICENSE
version: '20230608'
version: '20230612'
dependencies:
OpenAF: '>=20220822'
files:
Expand Down Expand Up @@ -61,11 +61,11 @@ files:
- zjsonpatch-0.3.0.jar
filesHash:
.maven.yaml: 3370144c25b04f80c555a737dc8d9c4ae6e00cb5
.odoc.db: 7cb4129d9d62f5858292400b98a5211283caa8a9
.odoc.db: 859c2ecbd1178186ca8c99137e8d6a2257005d7f
.precompile: 8c98d16175a11dcbe315a8e3acf6a40ac70eb365
jackson-dataformat-yaml-2.15.2.jar: 58194ff9f51915ad6bf6b6f24818232d7566418a
jackson-datatype-jsr310-2.15.2.jar: 30d16ec2aef6d8094c5e2dce1d95034ca8b6cb42
kube.js: ffdcba3b611ffacf1fe2d6763e32525ddf23532a
kube.js: 805b1dc4c0f7ed4982e0722a352504ba8a103508
kube.yaml: 460ff6cdd56f7eaec351799d1bf299e363ed1c6b
kubernetes-client-6.7.1.jar: 198903d407baed464727e45ca6690cbb6f77eb1c
kubernetes-client-api-6.7.1.jar: 40406d77a6daad955667e2382eae4959afce4f2b
Expand Down
50 changes: 33 additions & 17 deletions Kube/kube.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ var $kube = function(aMap) {

/**
* <odoc>
* <key>Kube.Kube(aURL, aUser, aPass, aWSTimeout, aToken)</key>
* Creates an instance to access a kubernetes (k8s) cluster on aURL. If defined, using aUser and aPass or aToken.
* <key>Kube.Kube(aURLorFile, aUser, aPass, aWSTimeout, aToken)</key>
* Creates an instance to access a kubernetes (k8s) cluster on aURL or kubectl config file. If defined, using aUser and aPass or aToken.
* </odoc>
*/
var Kube = function (aURL, aUser, aPass, aWSTimeout, aToken) {
var Kube = function (aURLorFile, aUser, aPass, aWSTimeout, aToken) {
plugin("HTTP");
ow.loadFormat();
this.url = aURL;
Expand All @@ -130,21 +130,37 @@ var Kube = function (aURL, aUser, aPass, aWSTimeout, aToken) {
if (isUnDef(aURL)) {
this.config = (new Packages.io.fabric8.kubernetes.client.ConfigBuilder()).build();
} else {
if (isDef(aToken)) {
this.config = (new Packages.io.fabric8.kubernetes.client.ConfigBuilder())
.withMasterUrl(this.url)
.withTrustCerts(true)
.withWebsocketTimeout(aWSTimeout)
.withOauthToken(aToken)
.build();
if (aURL.toLowerCase().startsWith("http")) {
if (isDef(aToken)) {
this.config = (new Packages.io.fabric8.kubernetes.client.ConfigBuilder())
.withMasterUrl(this.url)
.withTrustCerts(true)
.withWebsocketTimeout(aWSTimeout)
.withOauthToken(aToken)
.build();
} else {
this.config = (new Packages.io.fabric8.kubernetes.client.ConfigBuilder())
.withMasterUrl(this.url)
.withUsername(Packages.openaf.AFCmdBase.afc.dIP(this.user))
.withPassword(Packages.openaf.AFCmdBase.afc.dIP(this.pass))
.withTrustCerts(true)
.withWebsocketTimeout(aWSTimeout)
.build();
}
} else {
this.config = (new Packages.io.fabric8.kubernetes.client.ConfigBuilder())
.withMasterUrl(this.url)
.withUsername(Packages.openaf.AFCmdBase.afc.dIP(this.user))
.withPassword(Packages.openaf.AFCmdBase.afc.dIP(this.pass))
.withTrustCerts(true)
.withWebsocketTimeout(aWSTimeout)
.build();
if (io.fileExists(aURL)) {
sync(() => {
var oldValue = java.lang.System.getProperty("kubeconfig")
java.lang.System.setProperty("kubeconfig", aURL)
this.config = (new Packages.io.fabric8.kubernetes.client.ConfigBuilder()).build()
if (oldValue == null)
java.lang.System.clearProperty("kubeconfig")
else
java.lang.System.setProperty("kubeconfig", oldValue)
})
} else {
throw "'" + aURL + "' not found."
}
}
}

Expand Down

0 comments on commit 9e05964

Please sign in to comment.