Class: VMC::App::Env_old

Inherits:
Base
  • Object
show all
Defined in:
lib/appfog-vmc-plugin/deprecated/env.rb

Constant Summary collapse

VALID_ENV_VAR =
/^[a-zA-Za-z_][[:alnum:]_]*$/

Instance Method Summary collapse

Instance Method Details

#env_addObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/appfog-vmc-plugin/deprecated/env.rb', line 17

def env_add
  app = input[:app]
  name = input[:name]

  if value = input[:value]
    name = input[:name]
  elsif name["="]
    name, value = name.split("=")
  end

  unless name =~ VALID_ENV_VAR
    fail "Invalid variable name; must match #{VALID_ENV_VAR.inspect}"
  end

  with_progress("Updating #{c(app.name, :name)}") do
    app.env[name] = value
    app.update!
  end

  if app.started? && input[:restart]
    invoke :restart, :app => app
  end
end

#env_delObject



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/appfog-vmc-plugin/deprecated/env.rb', line 48

def env_del
  app = input[:app]
  name = input[:name]

  with_progress("Updating #{c(app.name, :name)}") do
    app.env.delete(name)
    app.update!
  end

  if app.started? && input[:restart]
    invoke :restart, :app => app
  end
end