-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: update docs with new authUrl setting (#169)
- Loading branch information
1 parent
3e9071a
commit 4d36008
Showing
3 changed files
with
63 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const { OpenshiftClient: openshiftRestClient, config } = require('.'); | ||
|
||
// async function genericTryCatch (fn) { | ||
// let result; | ||
// try { | ||
// result = await fn; | ||
// } catch (err) { | ||
// if (err.code === 404) { | ||
// return Promise.reject(err); | ||
// } | ||
// result = err; | ||
// } | ||
|
||
// return result; | ||
// } | ||
|
||
// console.log(config); | ||
|
||
// OpenshiftClient().then(async (client) => { | ||
// // Use the client object to find a list of projects, for example | ||
// let bc = await genericTryCatch(client.apis.build.v1.ns('myproject').buildconfigs('nodejs-rest-http-s2i').delete()); | ||
// console.log(bc); | ||
// }); | ||
|
||
// const openshiftRestClient = require('openshift-rest-client').OpenshiftClient; | ||
|
||
const otherConfig = config.fromKubeconfig(); | ||
|
||
console.log(otherConfig); | ||
|
||
openshiftRestClient().then((client) => { | ||
// Use the client object to find a list of projects, for example | ||
client.apis['project.openshift.io'].v1.project.get().then((response) => { | ||
console.log(response.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
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,26 @@ | ||
let kubeconfig = settings.config; | ||
if (kubeconfig) { | ||
// A config is being passed in. Check if it is an object | ||
if (typeof kubeconfig === 'object' && kubeconfig.auth) { | ||
// Check for the auth username password | ||
if ('user' in kubeconfig.auth || 'username' in kubeconfig.auth) { | ||
// They are trying the basic auth. | ||
// Get the access token using the username and password | ||
const accessToken = await getTokenFromBasicAuth({ insecureSkipTlsVerify: settings.insecureSkipTlsVerify, url: kubeconfig.url, user: kubeconfig.username || kubeconfig.user, password: kubeconfig.password || kubeconfig.pass }); | ||
|
||
kubeconfig = { | ||
url: kubeconfig.url, | ||
auth: { | ||
bearer: accessToken | ||
}, | ||
insecureSkipTlsVerify: 'insecureSkipTlsVerify' in settings ? Boolean(settings.insecureSkipTlsVerify) : false | ||
}; | ||
} | ||
} | ||
} | ||
|
||
console.log(kubeconfig); | ||
|
||
// TODO: need to be able to pass in the config object here | ||
const client = new Client({ config: kubeconfig || config.fromKubeconfig(), spec, getNames: getNames }); | ||
return client; |