Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:(src!): Make the loadSpecFromCluster setting true by default #285

Merged
merged 1 commit into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/openshift-rest-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const spec = JSON.parse(zlib.gunzipSync(fs.readFileSync(path.join(__dirname, 'sp
* Builds the rest client based on provided or default kubernetes configuration.
*
* @param {object} [settings] - settings object for the openshiftClient function
* @param {boolean} [settings.loadSpecFromCluster] - load the api spec from a remote cluster. Defaults to false
* @param {boolean} [settings.loadSpecFromCluster] - load the api spec from a remote cluster. Defaults to true
* @param {object|string} [settings.config] - custom config object(KubeConfig or object). String value will assume a config file location.
* @param {string} [settings.config.url] - Openshift cluster url
* @param {object} [settings.config.auth] -
Expand All @@ -73,10 +73,12 @@ const spec = JSON.parse(zlib.gunzipSync(fs.readFileSync(path.join(__dirname, 'sp
*/
async function openshiftClient (settings = {}) {
let config = settings.config;
// Default the load spec from cluster to true
const { loadSpecFromCluster = true } = settings;

const clientConfig = { backend: null, /* spec, */ getNames };

if (!settings.loadSpecFromCluster) {
if (!loadSpecFromCluster) {
clientConfig.spec = spec;
}

Expand Down Expand Up @@ -166,7 +168,7 @@ async function openshiftClient (settings = {}) {
}

let client = new Client(clientConfig);
if (settings.loadSpecFromCluster) {
if (loadSpecFromCluster) {
try {
await client.loadSpec();
} catch (err) {
Expand Down
3 changes: 2 additions & 1 deletion test/binary-build-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const userDefinedConfig = require('./test-config.json');
test('instantiateBinary - buildconfig', async (t) => {
openshiftRestClient.config.loadFromString(JSON.stringify(userDefinedConfig));
const settings = {
config: openshiftRestClient.config
config: openshiftRestClient.config,
loadSpecFromCluster: false
};

const client = await openshiftRestClient.OpenshiftClient(settings);
Expand Down