Class: Biosphere::TerraformProxy
Instance Attribute Summary collapse
Instance Method Summary
collapse
#from_file
Methods included from Kube
find_manifest_files, #kube_create_resource, #kube_get_client, #kube_test, load_resources
Constructor Details
#initialize(script_name, suite) ⇒ TerraformProxy
Returns a new instance of TerraformProxy.
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/biosphere/terraformproxy.rb', line 113
def initialize(script_name, suite)
@script_name = script_name
@src_path = [File.dirname(script_name)]
@export = {
"provider" => {},
"resource" => {},
"variable" => {},
"output" => {}
}
@suite = suite
@actions = {}
@deployments = []
end
|
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
107
108
109
|
# File 'lib/biosphere/terraformproxy.rb', line 107
def actions
@actions
end
|
#export ⇒ Object
Returns the value of attribute export.
105
106
107
|
# File 'lib/biosphere/terraformproxy.rb', line 105
def export
@export
end
|
#resources ⇒ Object
Returns the value of attribute resources.
106
107
108
|
# File 'lib/biosphere/terraformproxy.rb', line 106
def resources
@resources
end
|
#src_path ⇒ Object
Returns the value of attribute src_path.
108
109
110
|
# File 'lib/biosphere/terraformproxy.rb', line 108
def src_path
@src_path
end
|
Instance Method Details
#action(name, description, &block) ⇒ Object
172
173
174
175
176
177
178
179
180
|
# File 'lib/biosphere/terraformproxy.rb', line 172
def action(name, description, &block)
@actions[name] = {
:name => name,
:description => description,
:block => block,
:location => caller[0],
:src_path => @src_path.clone
}
end
|
#call_action(name, context) ⇒ Object
182
183
184
185
186
187
|
# File 'lib/biosphere/terraformproxy.rb', line 182
def call_action(name, context)
context.caller = self
context.src_path = @actions[name][:src_path]
context.instance_eval(&@actions[name][:block])
end
|
#find_dir(dirname) ⇒ Object
146
147
148
|
# File 'lib/biosphere/terraformproxy.rb', line 146
def find_dir(dirname)
return Pathname.new(@src_path.last).cleanpath.to_s
end
|
#find_file(filename) ⇒ Object
141
142
143
144
|
# File 'lib/biosphere/terraformproxy.rb', line 141
def find_file(filename)
src_path = Pathname.new(@src_path.last + "/" + File.dirname(filename)).cleanpath.to_s
return src_path + "/" + File.basename(filename)
end
|
#id_of(type, name) ⇒ Object
189
190
191
|
# File 'lib/biosphere/terraformproxy.rb', line 189
def id_of(type,name)
"${#{type}.#{name}.id}"
end
|
#load(filename) ⇒ Object
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
# File 'lib/biosphere/terraformproxy.rb', line 150
def load(filename)
src_path = Pathname.new(@src_path.last + "/" + File.dirname(filename)).cleanpath.to_s
@src_path << src_path
$current_biosphere_path_stack = src_path
if File.exists?(src_path + "/" + File.basename(filename))
self.from_file(src_path + "/" + File.basename(filename))
elsif File.exists?(src_path + "/" + File.basename(filename) + ".rb")
self.from_file(src_path + "/" + File.basename(filename) + ".rb")
else
raise "Can't find #{filename}"
end
@src_path.pop
$current_biosphere_path_stack = @src_path.last
end
|
#load_from_block(&block) ⇒ Object
137
138
139
|
# File 'lib/biosphere/terraformproxy.rb', line 137
def load_from_block(&block)
self.instance_eval(&block)
end
|
#load_from_file ⇒ Object
133
134
135
|
# File 'lib/biosphere/terraformproxy.rb', line 133
def load_from_file()
self.from_file(@script_name)
end
|
#output_of(type, name, *values) ⇒ Object
193
194
195
|
# File 'lib/biosphere/terraformproxy.rb', line 193
def output_of(type, name, *values)
"${#{type}.#{name}.#{values.join(".")}}"
end
|
#register(deployment) ⇒ Object
129
130
131
|
# File 'lib/biosphere/terraformproxy.rb', line 129
def register(deployment)
@suite.register(deployment)
end
|
#state ⇒ Object
197
198
199
|
# File 'lib/biosphere/terraformproxy.rb', line 197
def state
return @suite.state
end
|
#suite ⇒ Object
201
202
203
|
# File 'lib/biosphere/terraformproxy.rb', line 201
def suite
return @suite
end
|