Skip to content
This repository was archived by the owner on Jun 11, 2019. It is now read-only.

added new define git::config to setup github configurations #10

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# = Define a git config
#
# This sets configuration paramenters for github
# It can be used to set system wide configs or user specific configs
#
# == Parameters:
#
# [*section*]
# The section of the config
# [*key*]
# The name of the config
# [*value*]
# The value for the config
# [*user*]
# The user to save the config (defaults to system config)
#
# == Examples:
#
# - Minimal setup for system config
# github::config { 'color.status' :
# value => 'auto'
# }
#
# - Full setup for user specific config
# github::config { 'color-status' :
# section => 'color',
# key => 'status',
# value => 'auto',
# user => $::id
# }

define git::config(
$section = '',
$key = '',
$value,
$user = ''
) {

include git

if empty($user) {
$real_command = "git config --system"
}
else {
validate_string($user)
$real_command = "sudo -u ${user} git config --global"
}

if empty($section) and empty($key) {
validate_re($name, '^\w+\.\w+$')
$real_section_key = $name
}
else {
$real_section_key = "${section}.${key}"
}

exec { $real_section_key:
command => "${real_command} ${real_section_key} \"${value}\"",
unless => "${real_command} ${real_section_key} | grep -c '${value}'",
require => Package['git'],
}
}