puppet.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. Language: Puppet
  3. Author: Jose Molina Colmenero <gaudy41@gmail.com>
  4. Website: https://puppet.com/docs
  5. Category: config
  6. */
  7. function puppet(hljs) {
  8. const PUPPET_KEYWORDS = {
  9. keyword:
  10. /* language keywords */
  11. 'and case default else elsif false if in import enherits node or true undef unless main settings $string ',
  12. literal:
  13. /* metaparameters */
  14. 'alias audit before loglevel noop require subscribe tag ' +
  15. /* normal attributes */
  16. 'owner ensure group mode name|0 changes context force incl lens load_path onlyif provider returns root show_diff type_check ' +
  17. 'en_address ip_address realname command environment hour monute month monthday special target weekday ' +
  18. 'creates cwd ogoutput refresh refreshonly tries try_sleep umask backup checksum content ctime force ignore ' +
  19. 'links mtime purge recurse recurselimit replace selinux_ignore_defaults selrange selrole seltype seluser source ' +
  20. 'souirce_permissions sourceselect validate_cmd validate_replacement allowdupe attribute_membership auth_membership forcelocal gid ' +
  21. 'ia_load_module members system host_aliases ip allowed_trunk_vlans description device_url duplex encapsulation etherchannel ' +
  22. 'native_vlan speed principals allow_root auth_class auth_type authenticate_user k_of_n mechanisms rule session_owner shared options ' +
  23. 'device fstype enable hasrestart directory present absent link atboot blockdevice device dump pass remounts poller_tag use ' +
  24. 'message withpath adminfile allow_virtual allowcdrom category configfiles flavor install_options instance package_settings platform ' +
  25. 'responsefile status uninstall_options vendor unless_system_user unless_uid binary control flags hasstatus manifest pattern restart running ' +
  26. 'start stop allowdupe auths expiry gid groups home iterations key_membership keys managehome membership password password_max_age ' +
  27. 'password_min_age profile_membership profiles project purge_ssh_keys role_membership roles salt shell uid baseurl cost descr enabled ' +
  28. 'enablegroups exclude failovermethod gpgcheck gpgkey http_caching include includepkgs keepalive metadata_expire metalink mirrorlist ' +
  29. 'priority protect proxy proxy_password proxy_username repo_gpgcheck s3_enabled skip_if_unavailable sslcacert sslclientcert sslclientkey ' +
  30. 'sslverify mounted',
  31. built_in:
  32. /* core facts */
  33. 'architecture augeasversion blockdevices boardmanufacturer boardproductname boardserialnumber cfkey dhcp_servers ' +
  34. 'domain ec2_ ec2_userdata facterversion filesystems ldom fqdn gid hardwareisa hardwaremodel hostname id|0 interfaces ' +
  35. 'ipaddress ipaddress_ ipaddress6 ipaddress6_ iphostnumber is_virtual kernel kernelmajversion kernelrelease kernelversion ' +
  36. 'kernelrelease kernelversion lsbdistcodename lsbdistdescription lsbdistid lsbdistrelease lsbmajdistrelease lsbminordistrelease ' +
  37. 'lsbrelease macaddress macaddress_ macosx_buildversion macosx_productname macosx_productversion macosx_productverson_major ' +
  38. 'macosx_productversion_minor manufacturer memoryfree memorysize netmask metmask_ network_ operatingsystem operatingsystemmajrelease ' +
  39. 'operatingsystemrelease osfamily partitions path physicalprocessorcount processor processorcount productname ps puppetversion ' +
  40. 'rubysitedir rubyversion selinux selinux_config_mode selinux_config_policy selinux_current_mode selinux_current_mode selinux_enforced ' +
  41. 'selinux_policyversion serialnumber sp_ sshdsakey sshecdsakey sshrsakey swapencrypted swapfree swapsize timezone type uniqueid uptime ' +
  42. 'uptime_days uptime_hours uptime_seconds uuid virtual vlans xendomains zfs_version zonenae zones zpool_version'
  43. };
  44. const COMMENT = hljs.COMMENT('#', '$');
  45. const IDENT_RE = '([A-Za-z_]|::)(\\w|::)*';
  46. const TITLE = hljs.inherit(hljs.TITLE_MODE, {
  47. begin: IDENT_RE
  48. });
  49. const VARIABLE = {
  50. className: 'variable',
  51. begin: '\\$' + IDENT_RE
  52. };
  53. const STRING = {
  54. className: 'string',
  55. contains: [
  56. hljs.BACKSLASH_ESCAPE,
  57. VARIABLE
  58. ],
  59. variants: [
  60. {
  61. begin: /'/,
  62. end: /'/
  63. },
  64. {
  65. begin: /"/,
  66. end: /"/
  67. }
  68. ]
  69. };
  70. return {
  71. name: 'Puppet',
  72. aliases: [ 'pp' ],
  73. contains: [
  74. COMMENT,
  75. VARIABLE,
  76. STRING,
  77. {
  78. beginKeywords: 'class',
  79. end: '\\{|;',
  80. illegal: /=/,
  81. contains: [
  82. TITLE,
  83. COMMENT
  84. ]
  85. },
  86. {
  87. beginKeywords: 'define',
  88. end: /\{/,
  89. contains: [
  90. {
  91. className: 'section',
  92. begin: hljs.IDENT_RE,
  93. endsParent: true
  94. }
  95. ]
  96. },
  97. {
  98. begin: hljs.IDENT_RE + '\\s+\\{',
  99. returnBegin: true,
  100. end: /\S/,
  101. contains: [
  102. {
  103. className: 'keyword',
  104. begin: hljs.IDENT_RE
  105. },
  106. {
  107. begin: /\{/,
  108. end: /\}/,
  109. keywords: PUPPET_KEYWORDS,
  110. relevance: 0,
  111. contains: [
  112. STRING,
  113. COMMENT,
  114. {
  115. begin: '[a-zA-Z_]+\\s*=>',
  116. returnBegin: true,
  117. end: '=>',
  118. contains: [
  119. {
  120. className: 'attr',
  121. begin: hljs.IDENT_RE
  122. }
  123. ]
  124. },
  125. {
  126. className: 'number',
  127. begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b',
  128. relevance: 0
  129. },
  130. VARIABLE
  131. ]
  132. }
  133. ],
  134. relevance: 0
  135. }
  136. ]
  137. };
  138. }
  139. module.exports = puppet;