Merge branch 'feat/puppet' of https://github.com/kelvix/atom-beautify into kelvix-feat/puppet
This commit is contained in:
commit
30681e9a8a
|
@ -0,0 +1,95 @@
|
||||||
|
# Define quantum::generic_service
|
||||||
|
#
|
||||||
|
# This class implements basic ceilomer services.
|
||||||
|
# It is derived from https://github.com/stackforge/puppet-quantum/blob/master/manifests/generic_service.pp
|
||||||
|
#
|
||||||
|
define quantum::generic_service (
|
||||||
|
|
||||||
|
$package_name = '',
|
||||||
|
$package_ensure = 'present',
|
||||||
|
|
||||||
|
$service_name = '',
|
||||||
|
$service_ensure = 'running',
|
||||||
|
$service_enable = true,
|
||||||
|
|
||||||
|
$config_file_path = undef,
|
||||||
|
$config_file_notify = 'default',
|
||||||
|
$config_file_require = 'default',
|
||||||
|
$config_file_replace = undef,
|
||||||
|
$config_file_source = undef,
|
||||||
|
$config_file_template = undef,
|
||||||
|
$config_file_content = undef,
|
||||||
|
$config_file_options_hash = { },
|
||||||
|
|
||||||
|
$config_dir_path = '/etc/quantum',
|
||||||
|
) {
|
||||||
|
|
||||||
|
$distro_prefix = $::osfamily ? {
|
||||||
|
RedHat => 'openstack-',
|
||||||
|
Debian => '',
|
||||||
|
}
|
||||||
|
|
||||||
|
$manage_package_name = pickx($package_name, "${distro_prefix}${name}")
|
||||||
|
$manage_service_name = pickx($service_name, "${distro_prefix}${name}")
|
||||||
|
$manage_config_file_path = pickx($config_file_path, "${config_dir_path}/${name}.conf")
|
||||||
|
$manage_config_file_content = default_content($config_file_content, $config_file_template)
|
||||||
|
$manage_config_file_notify = $config_file_notify ? {
|
||||||
|
'default' => "Service[${name}]",
|
||||||
|
'' => undef,
|
||||||
|
default => $config_file_notify,
|
||||||
|
}
|
||||||
|
$manage_config_file_require = $config_file_require ? {
|
||||||
|
'default' => "Package[${name}]",
|
||||||
|
default => $config_file_require,
|
||||||
|
}
|
||||||
|
|
||||||
|
if $package_ensure == 'absent' {
|
||||||
|
$manage_service_enable = undef
|
||||||
|
$manage_service_ensure = stopped
|
||||||
|
$config_file_ensure = absent
|
||||||
|
} else {
|
||||||
|
$manage_service_enable = $service_enable ? {
|
||||||
|
'' => undef,
|
||||||
|
'undef' => undef,
|
||||||
|
default => $service_enable,
|
||||||
|
}
|
||||||
|
$manage_service_ensure = $service_ensure ? {
|
||||||
|
'' => undef,
|
||||||
|
'undef' => undef,
|
||||||
|
default => $service_ensure,
|
||||||
|
}
|
||||||
|
$config_file_ensure = present
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($manage_package_name) {
|
||||||
|
package { $name:
|
||||||
|
ensure => $package_ensure,
|
||||||
|
name => $manage_package_name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($manage_service_name) {
|
||||||
|
service { $name:
|
||||||
|
ensure => $manage_service_ensure,
|
||||||
|
name => $manage_service_name,
|
||||||
|
enable => $manage_service_enable,
|
||||||
|
require => Package[$manage_package_name],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if $config_file_source
|
||||||
|
or $manage_config_file_content {
|
||||||
|
file { "${name}.conf":
|
||||||
|
ensure => $config_file_ensure,
|
||||||
|
path => $manage_config_file_path,
|
||||||
|
mode => $config_file_mode,
|
||||||
|
owner => $config_file_owner,
|
||||||
|
group => $config_file_group,
|
||||||
|
source => $config_file_source,
|
||||||
|
content => $manage_config_file_content,
|
||||||
|
notify => $manage_config_file_notify,
|
||||||
|
require => $manage_config_file_require,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
# Define quantum::generic_service
|
||||||
|
#
|
||||||
|
# This class implements basic ceilomer services.
|
||||||
|
# It is derived from https://github.com/stackforge/puppet-quantum/blob/master/manifests/generic_service.pp
|
||||||
|
#
|
||||||
|
define quantum::generic_service (
|
||||||
|
|
||||||
|
$package_name = '',
|
||||||
|
$package_ensure = 'present',
|
||||||
|
|
||||||
|
$service_name = '',
|
||||||
|
$service_ensure = 'running',
|
||||||
|
$service_enable = true,
|
||||||
|
|
||||||
|
$config_file_path = undef,
|
||||||
|
$config_file_notify = 'default',
|
||||||
|
$config_file_require = 'default',
|
||||||
|
$config_file_replace = undef,
|
||||||
|
$config_file_source = undef,
|
||||||
|
$config_file_template = undef,
|
||||||
|
$config_file_content = undef,
|
||||||
|
$config_file_options_hash = { },
|
||||||
|
|
||||||
|
$config_dir_path = '/etc/quantum',
|
||||||
|
) {
|
||||||
|
|
||||||
|
$distro_prefix = $::osfamily ? {
|
||||||
|
RedHat => 'openstack-',
|
||||||
|
Debian => '',
|
||||||
|
}
|
||||||
|
|
||||||
|
$manage_package_name = pickx($package_name, "${distro_prefix}${name}")
|
||||||
|
$manage_service_name = pickx($service_name, "${distro_prefix}${name}")
|
||||||
|
$manage_config_file_path = pickx($config_file_path, "${config_dir_path}/${name}.conf")
|
||||||
|
$manage_config_file_content = default_content($config_file_content, $config_file_template)
|
||||||
|
$manage_config_file_notify = $config_file_notify ? {
|
||||||
|
'default' => "Service[${name}]",
|
||||||
|
'' => undef,
|
||||||
|
default => $config_file_notify,
|
||||||
|
}
|
||||||
|
$manage_config_file_require = $config_file_require ? {
|
||||||
|
'default' => "Package[${name}]",
|
||||||
|
default => $config_file_require,
|
||||||
|
}
|
||||||
|
|
||||||
|
if $package_ensure == 'absent' {
|
||||||
|
$manage_service_enable = undef
|
||||||
|
$manage_service_ensure = stopped
|
||||||
|
$config_file_ensure = absent
|
||||||
|
} else {
|
||||||
|
$manage_service_enable = $service_enable ? {
|
||||||
|
'' => undef,
|
||||||
|
'undef' => undef,
|
||||||
|
default => $service_enable,
|
||||||
|
}
|
||||||
|
$manage_service_ensure = $service_ensure ? {
|
||||||
|
'' => undef,
|
||||||
|
'undef' => undef,
|
||||||
|
default => $service_ensure,
|
||||||
|
}
|
||||||
|
$config_file_ensure = present
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($manage_package_name) {
|
||||||
|
package { $name:
|
||||||
|
ensure => $package_ensure,
|
||||||
|
name => $manage_package_name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($manage_service_name) {
|
||||||
|
service { $name:
|
||||||
|
ensure => $manage_service_ensure,
|
||||||
|
name => $manage_service_name,
|
||||||
|
enable => $manage_service_enable,
|
||||||
|
require => Package[$manage_package_name],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if $config_file_source
|
||||||
|
or $manage_config_file_content {
|
||||||
|
file { "${name}.conf":
|
||||||
|
ensure => $config_file_ensure,
|
||||||
|
path => $manage_config_file_path,
|
||||||
|
mode => $config_file_mode,
|
||||||
|
owner => $config_file_owner,
|
||||||
|
group => $config_file_group,
|
||||||
|
source => $config_file_source,
|
||||||
|
content => $manage_config_file_content,
|
||||||
|
notify => $manage_config_file_notify,
|
||||||
|
require => $manage_config_file_require,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -47,6 +47,7 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
'perltidy'
|
'perltidy'
|
||||||
'php-cs-fixer'
|
'php-cs-fixer'
|
||||||
'prettydiff'
|
'prettydiff'
|
||||||
|
'puppet-fix'
|
||||||
'rubocop'
|
'rubocop'
|
||||||
'ruby-beautify'
|
'ruby-beautify'
|
||||||
'rustfmt'
|
'rustfmt'
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
###
|
||||||
|
Requires [puppet-link](http://puppet-lint.com/)
|
||||||
|
###
|
||||||
|
"use strict"
|
||||||
|
Beautifier = require('./beautifier')
|
||||||
|
|
||||||
|
module.exports = class PuppetFix extends Beautifier
|
||||||
|
# this is what displays as your Default Beautifier in Language Config
|
||||||
|
name: "puppet-lint"
|
||||||
|
|
||||||
|
options: {
|
||||||
|
Puppet: true
|
||||||
|
}
|
||||||
|
|
||||||
|
cli: (options) ->
|
||||||
|
if not options.puppet_path?
|
||||||
|
return new Error("'puppet-lint' path is not set!" +
|
||||||
|
" Please set this in the Atom Beautify package settings.")
|
||||||
|
else
|
||||||
|
return options.puppet_path
|
||||||
|
|
||||||
|
beautify: (text, language, options) ->
|
||||||
|
@run("puppet-lint", [
|
||||||
|
'--fix'
|
||||||
|
tempFile = @tempFile("input", text)
|
||||||
|
], {
|
||||||
|
ignoreReturnCode: true
|
||||||
|
help: {
|
||||||
|
link: "http://puppet-lint.com/"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(=>
|
||||||
|
@readFile(tempFile)
|
||||||
|
)
|
|
@ -39,6 +39,7 @@ module.exports = class Languages
|
||||||
"pawn"
|
"pawn"
|
||||||
"perl"
|
"perl"
|
||||||
"php"
|
"php"
|
||||||
|
"puppet"
|
||||||
"python"
|
"python"
|
||||||
"ruby"
|
"ruby"
|
||||||
"rust"
|
"rust"
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
name: "Puppet"
|
||||||
|
namespace: "puppet"
|
||||||
|
|
||||||
|
###
|
||||||
|
Supported Grammars
|
||||||
|
###
|
||||||
|
grammars: [
|
||||||
|
"Puppet"
|
||||||
|
]
|
||||||
|
|
||||||
|
###
|
||||||
|
Supported extensions
|
||||||
|
###
|
||||||
|
extensions: [
|
||||||
|
"pp"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue