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 name of the branch"
47 "The provider understands Perforce Configuration"
50 "The repository contains submodules which can be optionally initialized"
60 return true unless [:absent, :purged, :held].include?(is)
73 notice "Creating repository from present"
77 newvalue :bare, :required_features => [:bare_repositories] do
87 newvalue :latest, :required_features => [:reference_tracking] do
88 if provider.exists? && !@resource.value(:force)
89 if provider.respond_to?(:update_references)
90 provider.update_references
92 if provider.respond_to?(:latest?)
93 reference = provider.latest || provider.revision
95 reference = resource.value(:revision) || provider.revision
97 notice "Updating to latest '#{reference}' revision"
98 provider.revision = reference
100 notice "Creating repository from latest"
106 prov = @resource.provider
108 if prov.working_copy_exists?
109 (@should.include?(:latest) && prov.latest?) ? :latest : :present
110 elsif prov.class.feature?(:bare_repositories) and prov.bare_exists?
116 raise Puppet::Error, "Could not find provider"
123 desc "Absolute path to repository"
126 path = Pathname.new(value)
127 unless path.absolute?
128 raise ArgumentError, "Path must be absolute: #{path}"
134 desc "The source URI for the repository"
137 newparam :fstype, :required_features => [:filesystem_types] do
138 desc "Filesystem type"
141 newproperty :revision do
142 desc "The revision of the repository"
147 desc "The user/uid that owns the repository files"
151 desc "The group/gid that owns the repository files"
155 desc "The user to run for repository operations"
158 newparam :excludes do
159 desc "Files to be excluded from the repository"
163 desc "Force repository creation, destroying any files on the path in the process."
164 newvalues(:true, :false)
168 newparam :compression, :required_features => [:gzip_compression] do
169 desc "Compression level"
171 unless Integer(amount).between?(0, 6)
172 raise ArgumentError, "Unsupported compression level: #{amount} (expected 0-6)"
177 newparam :basic_auth_username, :required_features => [:basic_auth] do
178 desc "HTTP Basic Auth username"
181 newparam :basic_auth_password, :required_features => [:basic_auth] do
182 desc "HTTP Basic Auth password"
185 newparam :identity, :required_features => [:ssh_identity] do
186 desc "SSH identity file"
189 newparam :module, :required_features => [:modules] do
190 desc "The repository module to manage"
193 newparam :remote, :required_features => [:multiple_remotes] do
194 desc "The remote repository to track"
198 newparam :configuration, :required_features => [:configuration] do
199 desc "The configuration directory to use"
202 newparam :cvs_rsh, :required_features => [:cvs_rsh] do
203 desc "The value to be used for the CVS_RSH environment variable."
206 newparam :depth, :required_features => [:depth] do
207 desc "The value to be used to do a shallow clone."
210 newparam :branch, :required_features => [:branch] do
211 desc "The name of the branch to clone."
214 newparam :p4config, :required_features => [:p4config] do
215 desc "The Perforce P4CONFIG environment."
218 newparam :submodules, :required_features => [:submodules] do
219 desc "Initialize and update each submodule in the repository."
220 newvalues(:true, :false)
224 autorequire(:package) do