Skip to content

Commit 1442a3b

Browse files
authored
feat:(src!) (#285)
BREAKING_CHANGE: This changes the default value of loadClusterFromSpec to true instead of false. The motivation is that most people will want to just load the API's their cluster has access to. If they can't do that, then it does fallback to load the included spec file. This could be another investigation, to see if we really need this fallback. If not, it would get rid of a somewhat large file.
1 parent da100e7 commit 1442a3b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/openshift-rest-client.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const spec = JSON.parse(zlib.gunzipSync(fs.readFileSync(path.join(__dirname, 'sp
6161
* Builds the rest client based on provided or default kubernetes configuration.
6262
*
6363
* @param {object} [settings] - settings object for the openshiftClient function
64-
* @param {boolean} [settings.loadSpecFromCluster] - load the api spec from a remote cluster. Defaults to false
64+
* @param {boolean} [settings.loadSpecFromCluster] - load the api spec from a remote cluster. Defaults to true
6565
* @param {object|string} [settings.config] - custom config object(KubeConfig or object). String value will assume a config file location.
6666
* @param {string} [settings.config.url] - Openshift cluster url
6767
* @param {object} [settings.config.auth] -
@@ -73,10 +73,12 @@ const spec = JSON.parse(zlib.gunzipSync(fs.readFileSync(path.join(__dirname, 'sp
7373
*/
7474
async function openshiftClient (settings = {}) {
7575
let config = settings.config;
76+
// Default the load spec from cluster to true
77+
const { loadSpecFromCluster = true } = settings;
7678

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

79-
if (!settings.loadSpecFromCluster) {
81+
if (!loadSpecFromCluster) {
8082
clientConfig.spec = spec;
8183
}
8284

@@ -166,7 +168,7 @@ async function openshiftClient (settings = {}) {
166168
}
167169

168170
let client = new Client(clientConfig);
169-
if (settings.loadSpecFromCluster) {
171+
if (loadSpecFromCluster) {
170172
try {
171173
await client.loadSpec();
172174
} catch (err) {

test/binary-build-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const userDefinedConfig = require('./test-config.json');
1212
test('instantiateBinary - buildconfig', async (t) => {
1313
openshiftRestClient.config.loadFromString(JSON.stringify(userDefinedConfig));
1414
const settings = {
15-
config: openshiftRestClient.config
15+
config: openshiftRestClient.config,
16+
loadSpecFromCluster: false
1617
};
1718

1819
const client = await openshiftRestClient.OpenshiftClient(settings);

0 commit comments

Comments
 (0)