Skip to content

Instantly share code, notes, and snippets.

@glarizza
Created December 6, 2013 00:22
Show Gist options
  • Save glarizza/7816619 to your computer and use it in GitHub Desktop.
Save glarizza/7816619 to your computer and use it in GitHub Desktop.
require 'uri'
require 'pathname'
Puppet::Type.newtype(:rcsrepo) do
desc "A Puppet type to model a Version Control Repository"
ensurable
newparam(:path, :namevar => true) do
desc "Path to our version control repository"
validate do |value|
path = Pathname.new(value)
unless path.absolute?
raise Puppet::Error, "Path must be an absolute path, not #{value}"
end
end
end
newparam(:source) do
desc "The source URL for the repository"
validate do |value|
unless value =~ URI.regexp
raise Puppet::Error, "Value must be a valid URI, not #{value}"
end
end
end
newproperty(:revision) do
desc "The revision of the repository"
defaultto "HEAD"
newvalues(/^\S+$/)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment