Class: Armature::Repo::Forge
Overview
Get a module from the Forge
Constant Summary
collapse
- CANONICAL_FORGE_URL =
"https://forge.puppet.com"
- FORGE_URLS =
[
"https://forge.puppetlabs.com",
"https://forgeapi.puppetlabs.com",
"https://forgeapi.puppet.com",
"http://forge.puppetlabs.com",
"http://forgeapi.puppetlabs.com",
"http://forge.puppet.com",
"http://forgeapi.puppet.com",
]
Class Method Summary
collapse
Instance Method Summary
collapse
#freshen, from_path, #initialize, #to_s, #type, type
Constructor Details
This class inherits a constructor from Armature::Repo
Class Method Details
.from_url(cache, forge_url, full_name) ⇒ Object
Gets a repo object for a given Forge module. This just contains metadata.
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/armature/repo/forge.rb', line 24
def self.from_url(cache, forge_url, full_name)
forge_url = self.normalize_forge_url(forge_url)
url = "#{forge_url}/#{full_name}"
repo = cache.get_repo("forge", url)
if repo
return repo
end
repo_dir = cache.open_repo("forge", url) do |temp_path|
File.write("#{temp_path}/url", "#{url}\n")
File.write("#{temp_path}/forge_url", "#{forge_url}\n")
File.write("#{temp_path}/full_name", "#{full_name}\n")
Logging.logger[self].debug("Created stub repo for '#{url}'")
end
return self.new(cache, repo_dir)
end
|
.normalize_forge_url(url) ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/armature/repo/forge.rb', line 14
def self.normalize_forge_url(url)
url.chomp!("/")
if FORGE_URLS.include? url
CANONICAL_FORGE_URL
else
url
end
end
|
Instance Method Details
#check_out(ref) ⇒ Object
Ensure we’ve got the correct version and return its path
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/armature/repo/forge.rb', line 57
def check_out(ref)
@cache.open_ref(ref) do |object_path|
@cache.open_temp() do
@logger.debug("Downloading #{ref} from #{url}")
url = forge_url() + release_metadata(ref.identity, "file_uri")
tarball = Armature::Util::http_get(url)
Armature::Run::pipe_command(tarball, "tar", "xzf" , "-")
= Dir["*"].first()
Dir.entries().each do |child|
if ! [".", ".."].include?(child)
File.rename("#{}/#{child}", "#{object_path}/#{child}")
end
end
end
end
end
|
#flush_memory! ⇒ Object
84
85
86
87
|
# File 'lib/armature/repo/forge.rb', line 84
def flush_memory!
@fresh = false
@metadata = nil
end
|
#forge_url ⇒ Object
48
49
50
|
# File 'lib/armature/repo/forge.rb', line 48
def forge_url
@forge_url || File.read("#{@repo_dir}/forge_url").chomp()
end
|
#freshen! ⇒ Object
79
80
81
82
|
# File 'lib/armature/repo/forge.rb', line 79
def freshen!
flush_memory!
download_metadata()
end
|
#full_name ⇒ Object
52
53
54
|
# File 'lib/armature/repo/forge.rb', line 52
def full_name
@full_name || File.read("#{@repo_dir}/full_name").chomp()
end
|
#general_ref(version) ⇒ Object
90
91
92
93
94
95
96
|
# File 'lib/armature/repo/forge.rb', line 90
def general_ref(version)
if version.nil? || version.to_s == "latest"
latest_ref()
else
version_ref(version)
end
end
|
#latest_ref ⇒ Object
102
103
104
105
106
107
|
# File 'lib/armature/repo/forge.rb', line 102
def latest_ref
freshen()
version = metadata("current_release.version")
Armature::Ref::Mutable.new(self, "latest", version, "version", "latest")
end
|
#url ⇒ Object
44
45
46
|
# File 'lib/armature/repo/forge.rb', line 44
def url
@url || File.read("#{@repo_dir}/url").chomp()
end
|
#version_ref(version) ⇒ Object
98
99
100
|
# File 'lib/armature/repo/forge.rb', line 98
def version_ref(version)
Armature::Ref::Immutable.new(self, version, version, "version", version)
end
|