config_mapping.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. var configs = [
  20. /**********************************************core-site***************************************/
  21. {
  22. "name": "hadoop.proxyuser.<foreignKey[0]>.groups",
  23. "templateName": ["proxyuser_group"],
  24. "foreignKey": ["hive_user"],
  25. "value": "<templateName[0]>",
  26. "filename": "core-site.xml",
  27. "isOverridable": true
  28. },
  29. {
  30. "name": "hadoop.proxyuser.<foreignKey[0]>.hosts",
  31. "templateName": ["hive_master_hosts"],
  32. "foreignKey": ["hive_user"],
  33. "value": "<templateName[0]>",
  34. "filename": "core-site.xml",
  35. "isOverridable": true
  36. },
  37. {
  38. "name": "hadoop.proxyuser.<foreignKey[0]>.groups",
  39. "templateName": [],
  40. "foreignKey": ["oozie_user"],
  41. "value": "*",
  42. "filename": "core-site.xml",
  43. "isOverridable": true
  44. },
  45. {
  46. "name": "hadoop.proxyuser.<foreignKey[0]>.hosts",
  47. "templateName": ["oozieserver_host"],
  48. "foreignKey": ["oozie_user"],
  49. "value": "<templateName[0]>",
  50. "filename": "core-site.xml",
  51. "isOverridable": true
  52. },
  53. {
  54. "name": "hadoop.proxyuser.<foreignKey[0]>.groups",
  55. "templateName": ["proxyuser_group"],
  56. "foreignKey": ["webhcat_user"],
  57. "value": "<templateName[0]>",
  58. "filename": "core-site.xml",
  59. "isOverridable": true
  60. },
  61. {
  62. "name": "hadoop.proxyuser.<foreignKey[0]>.hosts",
  63. "templateName": ["hive_master_hosts"],
  64. "foreignKey": ["webhcat_user"],
  65. "value": "<templateName[0]>",
  66. "filename": "core-site.xml",
  67. "isOverridable": true
  68. },
  69. {
  70. "name": "hadoop.proxyuser.<foreignKey[0]>.groups",
  71. "templateName": ["proxyuser_group"],
  72. "foreignKey": ["falcon_user"],
  73. "value": "<templateName[0]>",
  74. "filename": "core-site.xml",
  75. "isOverridable": true
  76. },
  77. {
  78. "name": "hadoop.proxyuser.<foreignKey[0]>.hosts",
  79. "templateName": [],
  80. "foreignKey": ["falcon_user"],
  81. "value": "*",
  82. "filename": "core-site.xml",
  83. "isOverridable": true
  84. },
  85. /**********************************Oozie******************************/
  86. {
  87. "name": "oozie.service.ProxyUserService.proxyuser.<foreignKey[0]>.groups",
  88. "templateName": [],
  89. "foreignKey": ["falcon_user"],
  90. "value": "*",
  91. "filename": "oozie-site.xml",
  92. "isOverridable": true,
  93. "serviceName": "OOZIE"
  94. },
  95. {
  96. "name": "oozie.service.ProxyUserService.proxyuser.<foreignKey[0]>.hosts",
  97. "templateName": [],
  98. "foreignKey": ["falcon_user"],
  99. "value": "*",
  100. "filename": "oozie-site.xml",
  101. "isOverridable": true,
  102. "serviceName": "OOZIE"
  103. }
  104. ];
  105. /**
  106. * Configs consists of 2 types: Computed values, which cannot be modified by user
  107. * and overridable values, which user can modify. We provide interface how to get all of this
  108. * configs separately
  109. * @type {Object}
  110. */
  111. module.exports = {
  112. checkPrecondition: function () {
  113. return configs.filter(function (config) {
  114. return ((!config.precondition) || (config.precondition()));
  115. });
  116. },
  117. all: function (skipPreconditionCheck) {
  118. if (skipPreconditionCheck) {
  119. return configs.slice(0);
  120. } else {
  121. return this.checkPrecondition().slice(0);
  122. }
  123. },
  124. overridable: function (skipPreconditionCheck) {
  125. if (skipPreconditionCheck) {
  126. return configs.filterProperty('foreignKey');
  127. } else {
  128. return this.checkPrecondition().filterProperty('foreignKey');
  129. }
  130. },
  131. computed: function (skipPreconditionCheck) {
  132. if (skipPreconditionCheck) {
  133. return configs.filterProperty('foreignKey', null);
  134. } else {
  135. return this.checkPrecondition().filterProperty('foreignKey', null);
  136. }
  137. }
  138. };