Class: Strobe::Resources::Application
Defined Under Namespace
Classes: PackFile
Instance Attribute Summary
#response
Instance Method Summary
collapse
#retry_on_error
#key, #reload, #reload!
#[], #[]=, #destroy, #initialize, #key?, #merge!, #params, #params=, #persisted?, #save, #save!
#read_attribute_for_validation, #valid_attribute?, #valid_for_given_attributes?
Instance Method Details
#deploy!(opts = {}) ⇒ Object
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/strobe/resources/application.rb', line 89
def deploy!(opts = {})
self['path'] = opts[:path] if opts[:path]
if opts[:pre_deploy]
unless Kernel.system(opts[:pre_deploy])
raise Strobe::DeployInterrupted, "pre deploy hook returned non-zero status, deploy was stopped"
end
end
environment = (opts[:environment] == "production" ? nil : opts[:environment])
callback = opts[:callback]
message = opts[:message]
github_url = opts[:github_url]
scm_version = opts[:scm_version]
validate_for_deploy or return
request do
qs = []
qs << "environment=#{environment}" if environment
qs << "message=#{message}" if message
qs << "github_url=#{URI.escape(github_url)}" if github_url
qs << "scm_version=#{scm_version}" if scm_version
uri = "#{http_uri}/deploy"
uri = "#{uri}?#{qs.join('&')}" unless qs.blank?
uri = URI.escape(uri)
packfile = build_packfile(opts)
response = connection.put(uri, packfile, packfile.)
callback.deploy_complete if callback
Kernel.system(opts[:post_deploy]) if opts[:post_deploy]
response
end
environment_url(environment)
end
|
#environment_url(environment) ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/strobe/resources/application.rb', line 45
def environment_url(environment)
if environment.blank? || environment == "production"
web_url
else
uri = web_install['environment_uri']
"#{environment}.#{uri}"
end
end
|
#id ⇒ Object
24
25
26
|
# File 'lib/strobe/resources/application.rb', line 24
def id
self[:id]
end
|
#rollback!(sha, opts = {}) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/strobe/resources/application.rb', line 61
def rollback!(sha, opts = {})
environment = opts[:environment]
message = opts[:message]
id = self[:id]
request do
qs = []
qs << "message=#{message}" if message
qs << "application_id=#{id}"
uri = URI.escape("/deploys?#{qs.join('&')}")
body = { :deploy => sha }
body[:environment] = environment if environment
= {
"Content-Type" => "application/json",
"Accept" => "application/json"
}
response = connection.post(uri, body, )
response
end
environment_url(environment)
end
|
#set_web_url!(url) ⇒ Object
54
55
56
57
58
59
|
# File 'lib/strobe/resources/application.rb', line 54
def set_web_url!(url)
return if url.blank?
install = web_install
install['url'] = install['install_uri'] = url
install.save!
end
|
#web_install ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/strobe/resources/application.rb', line 28
def web_install
@web_install ||= begin
install = nil
retry_on_error([IOError, Timeout::Error]) do
install = self.platform_installs.detect { |p| p.web? }
end
raise "Application does not have web platform" unless install
install
end
end
|
#web_url ⇒ Object
41
42
43
|
# File 'lib/strobe/resources/application.rb', line 41
def web_url
web_install['install_uri']
end
|