Module: CiCd::Builder::ChefRepoManifest::Repo

Included in:
Runner
Defined in:
lib/cicd/builder/chefrepo-manifest/mixlib/repo.rb,
lib/cicd/builder/chefrepo-manifest/mixlib/repo/S3.rb,
lib/cicd/builder/chefrepo-manifest/mixlib/repo/artifactory.rb

Defined Under Namespace

Classes: Artifactory, S3

Instance Method Summary collapse

Instance Method Details

#getRepoClass(type = nil) ⇒ Object




16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cicd/builder/chefrepo-manifest/mixlib/repo.rb', line 16

def getRepoClass(type = nil)
  @logger.step CLASS+'::'+__method__.to_s
  if type.nil?
    type ||= 'S3'
    if ENV.has_key?('REPO_TYPE')
      type = ENV['REPO_TYPE']
    end
  end

  @logger.info "#{type} repo interface"
  clazz = begin
            Object.const_get("#{self.class.name.gsub(%r'::\w+$', '')}::Repo::#{type}")
          rescue NameError => e
            begin
              # Object.const_get("#{self.class.name.gsub(%r'::\w+$', '')}::Repo::#{type}")
              Object.const_get("CiCd::Builder::Manifest::Repo::#{type}")
            rescue NameError #=> e
              Object.const_get("CiCd::Builder::Repo::#{type}")
            end
          end

  if block_given?
    if clazz.is_a?(Class) and not clazz.nil?
      yield
    end
  end

  clazz
end