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 or set scope limit"
44 "The name of the branch"
47 "The provider understands Perforce Configuration"
50 "The repository contains submodules which can be optionally initialized"
53 "The provider supports automatic conflict resolution"
63 return true unless [:absent, :purged, :held].include?(is)
80 notice "Creating repository from present"
84 newvalue :bare, :required_features => [:bare_repositories] do
90 newvalue :mirror, :required_features => [:bare_repositories] do
100 newvalue :latest, :required_features => [:reference_tracking] do
101 if provider.exists? && !@resource.value(:force)
102 if provider.respond_to?(:update_references)
103 provider.update_references
105 if provider.respond_to?(:latest?)
106 reference = provider.latest || provider.revision
108 reference = resource.value(:revision) || provider.revision
110 notice "Updating to latest '#{reference}' revision"
111 provider.revision = reference
113 notice "Creating repository from latest"
119 prov = @resource.provider
121 if prov.working_copy_exists?
122 (@should.include?(:latest) && prov.latest?) ? :latest : :present
123 elsif prov.class.feature?(:bare_repositories) and prov.bare_exists?
129 raise Puppet::Error, "Could not find provider"
136 desc "Absolute path to repository"
139 path = Pathname.new(value)
140 unless path.absolute?
141 raise ArgumentError, "Path must be absolute: #{path}"
147 desc "The source URI for the repository"
150 newparam :fstype, :required_features => [:filesystem_types] do
151 desc "Filesystem type"
154 newproperty :revision do
155 desc "The revision of the repository"
160 desc "The user/uid that owns the repository files"
164 desc "The group/gid that owns the repository files"
168 desc "The user to run for repository operations"
171 newparam :excludes do
172 desc "Files to be excluded from the repository"
176 desc "Force repository creation, destroying any files on the path in the process."
177 newvalues(:true, :false)
181 newparam :compression, :required_features => [:gzip_compression] do
182 desc "Compression level"
184 unless Integer(amount).between?(0, 6)
185 raise ArgumentError, "Unsupported compression level: #{amount} (expected 0-6)"
190 newparam :basic_auth_username, :required_features => [:basic_auth] do
191 desc "HTTP Basic Auth username"
194 newparam :basic_auth_password, :required_features => [:basic_auth] do
195 desc "HTTP Basic Auth password"
198 newparam :identity, :required_features => [:ssh_identity] do
199 desc "SSH identity file"
202 newparam :module, :required_features => [:modules] do
203 desc "The repository module to manage"
206 newparam :remote, :required_features => [:multiple_remotes] do
207 desc "The remote repository to track"
211 newparam :configuration, :required_features => [:configuration] do
212 desc "The configuration directory to use"
215 newparam :cvs_rsh, :required_features => [:cvs_rsh] do
216 desc "The value to be used for the CVS_RSH environment variable."
219 newparam :depth, :required_features => [:depth] do
220 desc "The value to be used to do a shallow clone."
223 newparam :branch, :required_features => [:branch] do
224 desc "The name of the branch to clone."
227 newparam :p4config, :required_features => [:p4config] do
228 desc "The Perforce P4CONFIG environment."
231 newparam :submodules, :required_features => [:submodules] do
232 desc "Initialize and update each submodule in the repository."
233 newvalues(:true, :false)
237 newparam :conflict do
238 desc "The action to take if conflicts exist between repository and working copy"
241 newparam :trust_server_cert do
242 desc "Trust server certificate"
243 newvalues(:true, :false)
247 autorequire(:package) do
248 ['git', 'git-core', 'mercurial']