Class: R10K::Environment::SVN

Inherits:
Base
  • Object
show all
Includes:
Util::Setopts
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, Logging::SYSLOG_LEVELS_MAP

Instance Attribute Summary collapse

Attributes inherited from Base

#basedir, #desired_contents, #dirname, #loader, #managed_directories, #name, #path, #puppetfile, #puppetfile_name

Instance Method Summary collapse

Methods included from Logging

add_outputters, debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level

Methods inherited from Base

#accept, #deploy, #determine_purge_exclusions, #generate_types!, #info, #load_puppetfile_modules, #module_conflicts?, #modules, #purge_exclusions, #whitelist

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 Hash (options):

  • :remote (String)

    The URL to the remote SVN branch to check out

  • :username (String)

    The SVN username

  • :password (String)

    The SVN password

Since:

  • 1.3.0



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/r10k/environment/svn.rb', line 43

def initialize(name, basedir, dirname, options = {})
  super
  setopts(options, {
    # Standard option interface
    :source   => :remote,
    :version  => :expected_revision,
    :type     => ::R10K::Util::Setopts::Ignore,

    # Type-specific options
    :remote   => :self,
    :username => :self,
    :password => :self,
  })

  @working_dir = R10K::SVN::WorkingDir.new(Pathname.new(@full_path), :username => @username, :password => @password)
end

Instance Attribute Details

#passwordObject (readonly)

Since:

  • 1.3.0



29
30
31
# File 'lib/r10k/environment/svn.rb', line 29

def password
  @password
end

#remoteObject (readonly)

Since:

  • 1.3.0



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

def remote
  @remote
end

#usernameObject (readonly)

Since:

  • 1.3.0



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

def username
  @username
end

#working_dirObject (readonly)

Since:

  • 1.3.0



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

def working_dir
  @working_dir
end

Instance Method Details

#signatureString

Return a sting which uniquely identifies (per source) the current state of the environment.

Returns:

  • (String)

Since:

  • 1.3.0



81
82
83
# File 'lib/r10k/environment/svn.rb', line 81

def signature
  @working_dir.revision
end

#statusObject

Since:

  • 1.3.0



85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/r10k/environment/svn.rb', line 85

def status
  if !@path.exist?
    :absent
  elsif !@working_dir.is_svn?
    :mismatched
  elsif !(@remote == @working_dir.url)
    :mismatched
  elsif !@synced
    :outdated
  else
    :insync
  end
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



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

def sync
  if @working_dir.is_svn?
    @working_dir.update
  else
    @working_dir.checkout(@remote, @expected_revision)
  end
  @synced = true
end