Class: R10K::Environment::SVN

Inherits:
Base
  • Object
show all
Includes:
Logging
Defined in:
lib/r10k/environment/svn.rb

Overview

This class implements an environment based on an SVN branch.

Since:

  • 1.3.0

Constant Summary

Constants included from Logging

Logging::LOG_LEVELS

Instance Attribute Summary collapse

Attributes inherited from Base

#basedir, #dirname, #name

Instance Method Summary collapse

Methods included from Logging

formatter, included, level, level=, levels, #logger, #logger_name, outputter, parse_level

Constructor Details

#initialize(name, basedir, dirname, options = {}) ⇒ SVN

Initialize the given SVN environment.

Parameters:

  • name (String)

    The unique name describing this environment.

  • basedir (String)

    The base directory where this environment will be created.

  • dirname (String)

    The directory name for this environment.

  • options (Hash) (defaults to: {})

    An additional set of options for this environment.

  • options (String) (defaults to: {})

    :remote The URL to the remote SVN branch to check out

Since:

  • 1.3.0



33
34
35
36
37
38
39
40
# File 'lib/r10k/environment/svn.rb', line 33

def initialize(name, basedir, dirname, options = {})
  super

  @remote = options[:remote]

  @working_dir = R10K::SVN::WorkingDir.new(Pathname.new(@full_path))
  @puppetfile  = R10K::Puppetfile.new(@full_path)
end

Instance Attribute Details

#puppetfileObject (readonly)

Since:

  • 1.3.0



23
24
25
# File 'lib/r10k/environment/svn.rb', line 23

def puppetfile
  @puppetfile
end

#remoteObject (readonly)

Since:

  • 1.3.0



13
14
15
# File 'lib/r10k/environment/svn.rb', line 13

def remote
  @remote
end

#working_dirObject (readonly)

Since:

  • 1.3.0



18
19
20
# File 'lib/r10k/environment/svn.rb', line 18

def working_dir
  @working_dir
end

Instance Method Details

#modulesArray<R10K::Module::Base>

Returns All modules defined in the Puppetfile associated with this environment.

Returns:

  • (Array<R10K::Module::Base>)

    All modules defined in the Puppetfile associated with this environment.

Since:

  • 1.3.0



61
62
63
64
# File 'lib/r10k/environment/svn.rb', line 61

def modules
  @puppetfile.load
  @puppetfile.modules
end

#syncvoid

This method returns an undefined value.

Perform an initial checkout of the SVN repository or update the repository.

If the environment is being created for the first time, it will automatically update all modules to ensure that the environment is complete.

Since:

  • 1.3.0



49
50
51
52
53
54
55
56
57
# File 'lib/r10k/environment/svn.rb', line 49

def sync
  if @working_dir.is_svn?
    @working_dir.update
  else
    @working_dir.checkout(@remote)
    logger.debug "Environment #{@full_path} is a fresh clone; automatically updating modules."
    sync_modules
  end
end

#sync_modulesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.3.0



67
68
69
70
71
72
# File 'lib/r10k/environment/svn.rb', line 67

def sync_modules
  modules.each do |mod|
    logger.debug "Deploying module #{mod.name}"
    mod.sync
  end
end