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)
76 notice "Creating repository from present"
80 newvalue :bare, :required_features => [:bare_repositories] do
90 newvalue :latest, :required_features => [:reference_tracking] do
91 if provider.exists? && !@resource.value(:force)
92 if provider.respond_to?(:update_references)
93 provider.update_references
95 if provider.respond_to?(:latest?)
96 reference = provider.latest || provider.revision
98 reference = resource.value(:revision) || provider.revision
100 notice "Updating to latest '#{reference}' revision"
101 provider.revision = reference
103 notice "Creating repository from latest"
109 prov = @resource.provider
111 if prov.working_copy_exists?
112 (@should.include?(:latest) && prov.latest?) ? :latest : :present
113 elsif prov.class.feature?(:bare_repositories) and prov.bare_exists?
119 raise Puppet::Error, "Could not find provider"
126 desc "Absolute path to repository"
129 path = Pathname.new(value)
130 unless path.absolute?
131 raise ArgumentError, "Path must be absolute: #{path}"
137 desc "The source URI for the repository"
140 newparam :fstype, :required_features => [:filesystem_types] do
141 desc "Filesystem type"
144 newproperty :revision do
145 desc "The revision of the repository"
150 desc "The user/uid that owns the repository files"
154 desc "The group/gid that owns the repository files"
158 desc "The user to run for repository operations"
161 newparam :excludes do
162 desc "Files to be excluded from the repository"
166 desc "Force repository creation, destroying any files on the path in the process."
167 newvalues(:true, :false)
171 newparam :compression, :required_features => [:gzip_compression] do
172 desc "Compression level"
174 unless Integer(amount).between?(0, 6)
175 raise ArgumentError, "Unsupported compression level: #{amount} (expected 0-6)"
180 newparam :basic_auth_username, :required_features => [:basic_auth] do
181 desc "HTTP Basic Auth username"
184 newparam :basic_auth_password, :required_features => [:basic_auth] do
185 desc "HTTP Basic Auth password"
188 newparam :identity, :required_features => [:ssh_identity] do
189 desc "SSH identity file"
192 newparam :module, :required_features => [:modules] do
193 desc "The repository module to manage"
196 newparam :remote, :required_features => [:multiple_remotes] do
197 desc "The remote repository to track"
201 newparam :configuration, :required_features => [:configuration] do
202 desc "The configuration directory to use"
205 newparam :cvs_rsh, :required_features => [:cvs_rsh] do
206 desc "The value to be used for the CVS_RSH environment variable."
209 newparam :depth, :required_features => [:depth] do
210 desc "The value to be used to do a shallow clone."
213 newparam :branch, :required_features => [:branch] do
214 desc "The name of the branch to clone."
217 newparam :p4config, :required_features => [:p4config] do
218 desc "The Perforce P4CONFIG environment."
221 newparam :submodules, :required_features => [:submodules] do
222 desc "Initialize and update each submodule in the repository."
223 newvalues(:true, :false)
227 newparam :conflict do
228 desc "The action to take if conflicts exist between repository and working copy"
231 newparam :trust_server_cert do
232 desc "Trust server certificate"
233 newvalues(:true, :false)
237 autorequire(:package) do
238 ['git', 'git-core', 'mercurial']