3 Puppet::Type.newtype(:vcsrepo) do
4 desc "A local version control repository"
6 feature :gzip_compression,
7 "The provider supports explicit GZip compression levels"
9 "The provider supports HTTP Basic Authentication"
10 feature :bare_repositories,
11 "The provider differentiates between bare repositories
12 and those with working copies",
13 :methods => [:bare_exists?, :working_copy_exists?]
15 feature :filesystem_types,
16 "The provider supports different filesystem types"
18 feature :reference_tracking,
19 "The provider supports tracking revision references that can change
20 over time (eg, some VCS tags and branch names)"
22 feature :ssh_identity,
23 "The provider supports a configurable SSH identity file"
26 "The provider can run as a different user"
29 "The repository contains modules that can be chosen of"
31 feature :multiple_remotes,
32 "The repository tracks multiple remote repositories"
34 feature :configuration,
35 "The configuration directory to use"
38 "The provider understands the CVS_RSH environment variable"
41 "The provider can do shallow clones"
44 "The provider understands Perforce Configuration"
47 "The repository contains submodules which can be optionally initialized"
57 return true unless [:absent, :purged, :held].include?(is)
70 notice "Creating repository from present"
74 newvalue :bare, :required_features => [:bare_repositories] do
84 newvalue :latest, :required_features => [:reference_tracking] do
85 if provider.exists? && !@resource.value(:force)
86 if provider.respond_to?(:update_references)
87 provider.update_references
89 if provider.respond_to?(:latest?)
90 reference = provider.latest || provider.revision
92 reference = resource.value(:revision) || provider.revision
94 notice "Updating to latest '#{reference}' revision"
95 provider.revision = reference
97 notice "Creating repository from latest"
103 prov = @resource.provider
105 if prov.working_copy_exists?
106 (@should.include?(:latest) && prov.latest?) ? :latest : :present
107 elsif prov.class.feature?(:bare_repositories) and prov.bare_exists?
113 raise Puppet::Error, "Could not find provider"
120 desc "Absolute path to repository"
123 path = Pathname.new(value)
124 unless path.absolute?
125 raise ArgumentError, "Path must be absolute: #{path}"
131 desc "The source URI for the repository"
134 newparam :fstype, :required_features => [:filesystem_types] do
135 desc "Filesystem type"
138 newproperty :revision do
139 desc "The revision of the repository"
144 desc "The user/uid that owns the repository files"
148 desc "The group/gid that owns the repository files"
152 desc "The user to run for repository operations"
155 newparam :excludes do
156 desc "Files to be excluded from the repository"
160 desc "Force repository creation, destroying any files on the path in the process."
161 newvalues(:true, :false)
165 newparam :compression, :required_features => [:gzip_compression] do
166 desc "Compression level"
168 unless Integer(amount).between?(0, 6)
169 raise ArgumentError, "Unsupported compression level: #{amount} (expected 0-6)"
174 newparam :basic_auth_username, :required_features => [:basic_auth] do
175 desc "HTTP Basic Auth username"
178 newparam :basic_auth_password, :required_features => [:basic_auth] do
179 desc "HTTP Basic Auth password"
182 newparam :identity, :required_features => [:ssh_identity] do
183 desc "SSH identity file"
186 newparam :module, :required_features => [:modules] do
187 desc "The repository module to manage"
190 newparam :remote, :required_features => [:multiple_remotes] do
191 desc "The remote repository to track"
195 newparam :configuration, :required_features => [:configuration] do
196 desc "The configuration directory to use"
199 newparam :cvs_rsh, :required_features => [:cvs_rsh] do
200 desc "The value to be used for the CVS_RSH environment variable."
203 newparam :depth, :required_features => [:depth] do
204 desc "The value to be used to do a shallow clone."
207 newparam :p4config, :required_features => [:p4config] do
208 desc "The Perforce P4CONFIG environment."
211 newparam :submodules, :required_features => [:submodules] do
212 desc "Initialize and update each submodule in the repository."
213 newvalues(:true, :false)
217 autorequire(:package) do