puppet.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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, { begin: IDENT_RE });
  47. const VARIABLE = {
  48. className: 'variable',
  49. begin: '\\$' + IDENT_RE
  50. };
  51. const STRING = {
  52. className: 'string',
  53. contains: [
  54. hljs.BACKSLASH_ESCAPE,
  55. VARIABLE
  56. ],
  57. variants: [
  58. {
  59. begin: /'/,
  60. end: /'/
  61. },
  62. {
  63. begin: /"/,
  64. end: /"/
  65. }
  66. ]
  67. };
  68. return {
  69. name: 'Puppet',
  70. aliases: [ 'pp' ],
  71. contains: [
  72. COMMENT,
  73. VARIABLE,
  74. STRING,
  75. {
  76. beginKeywords: 'class',
  77. end: '\\{|;',
  78. illegal: /=/,
  79. contains: [
  80. TITLE,
  81. COMMENT
  82. ]
  83. },
  84. {
  85. beginKeywords: 'define',
  86. end: /\{/,
  87. contains: [
  88. {
  89. className: 'section',
  90. begin: hljs.IDENT_RE,
  91. endsParent: true
  92. }
  93. ]
  94. },
  95. {
  96. begin: hljs.IDENT_RE + '\\s+\\{',
  97. returnBegin: true,
  98. end: /\S/,
  99. contains: [
  100. {
  101. className: 'keyword',
  102. begin: hljs.IDENT_RE,
  103. relevance: 0.2
  104. },
  105. {
  106. begin: /\{/,
  107. end: /\}/,
  108. keywords: PUPPET_KEYWORDS,
  109. relevance: 0,
  110. contains: [
  111. STRING,
  112. COMMENT,
  113. {
  114. begin: '[a-zA-Z_]+\\s*=>',
  115. returnBegin: true,
  116. end: '=>',
  117. contains: [
  118. {
  119. className: 'attr',
  120. begin: hljs.IDENT_RE
  121. }
  122. ]
  123. },
  124. {
  125. className: 'number',
  126. begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b',
  127. relevance: 0
  128. },
  129. VARIABLE
  130. ]
  131. }
  132. ],
  133. relevance: 0
  134. }
  135. ]
  136. };
  137. }
  138. export { puppet as default };