puppet.js 5.4 KB

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