Skip to content

Commit

Permalink
feat: create/update/remove a config map if there is one in the .nodes…
Browse files Browse the repository at this point in the history
…hift directory. (#255)

This will not 'enrich' the configMap yaml file, it only will create it if not already created remotely.

fixes #203
  • Loading branch information
lholmquist committed Jul 24, 2018
1 parent f1892b9 commit f6f96c7
Show file tree
Hide file tree
Showing 8 changed files with 304 additions and 172 deletions.
3 changes: 3 additions & 0 deletions lib/apply-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const routes = require('./routes');
const deploymentConfig = require('./deployment-config').deploy;
const secrets = require('./secrets');
const ingress = require('./ingress');
const configMap = require('./config-map');

module.exports = (config, resourceList) => {
const mappedResources = resourceList.map((r) => {
Expand All @@ -37,6 +38,8 @@ module.exports = (config, resourceList) => {
return secrets(config, r);
case 'Ingress':
return ingress(config, r);
case 'ConfigMap':
return configMap(config, r);
default:
return Promise.resolve(r);
}
Expand Down
34 changes: 34 additions & 0 deletions lib/config-map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
*
* Copyright 2016-2017 Red Hat, Inc, and individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

'use strict';

const log = require('./common-log')();

module.exports = async function getConfigMap (config, configMapResource) {
// First check to see if we already have a route created
let configMap = await config.openshiftRestClient.configmaps.find(configMapResource.metadata.name);
if (configMap.code === 404) {
// There isn't a configMap yet, so we need to create one
log.info(`creating new configMap ${configMapResource.metadata.name}`);
configMap = await config.openshiftRestClient.configmaps.create(configMapResource);
} else {
log.info(`using existing configMap ${configMap.metadata.name}`);
}
return configMap;
};
3 changes: 3 additions & 0 deletions lib/goals/undeploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ module.exports = async function (config) {
case 'Ingress':
response.ingress = await config.openshiftRestClient.ingress.remove(item.metadata.name, removeOptions);
break;
case 'ConfigMap':
response.configMap = await config.openshiftRestClient.configmaps.remove(item.metadata.name, removeOptions);
break;
default:
logger.error(`${item.kind} is not recognized`);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/resource-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const kindMappings = {
service: 'Service',
secret: 'Secret',
deployment: 'Deployment',
ingress: 'Ingress'
ingress: 'Ingress',
config: 'ConfigMap'
};

function loadYaml (fileLocation) {
Expand Down

0 comments on commit f6f96c7

Please sign in to comment.