MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / GetVariable

Method GetVariable

datasource/etcd_machine.go:207–232  ·  view source on GitHub ↗

GetVariable Gets a machine's variable, or the global if it was not set for the machine

(key string)

Source from the content-addressed store, hash-verified

205// GetVariable Gets a machine's variable, or the global if it was not
206// set for the machine
207func (m *etcdMachineInterface) GetVariable(key string) (string, error) {
208 value, err := m.selfGet(key)
209
210 if err != nil {
211 if !etcd.IsKeyNotFound(err) {
212 return "", fmt.Errorf(
213 "error while getting variable key=%s for machine=%s: %s",
214 key, m.mac, err)
215 }
216
217 // Key was not found for the machine
218 value, err := m.etcdDS.GetClusterVariable(key)
219 if err != nil {
220 if !etcd.IsKeyNotFound(err) {
221 return "", fmt.Errorf(
222 "error while getting variable key=%s for machine=%s (global check): %s",
223 key, m.mac, err)
224
225 }
226 return "", nil // Not set, not for machine, nor globally
227 }
228 return value, nil
229 }
230
231 return value, nil
232}
233
234// SetVariable sets the value of the specified key
235func (m *etcdMachineInterface) SetVariable(key, value string) error {

Callers

nothing calls this directly

Calls 2

selfGetMethod · 0.95
GetClusterVariableMethod · 0.65

Tested by

no test coverage detected