Class: Eien::CLI::Processes

Inherits:
CLI
  • Object
show all
Defined in:
lib/eien/cli/processes.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CLI

exit_on_failure?

Class Method Details

.process_optionsObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/eien/cli/processes.rb', line 9

def self.process_options
  option(:enabled, type: :boolean)
  option(:image)
  option(:config)
  option(:secret)
  option(:command, type: :array)
  option(:replicas, type: :numeric)
  option(:ports, type: :hash)
  option(:"no-ports", type: :boolean)
end

Instance Method Details

#create(name) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/eien/cli/processes.rb', line 80

def create(name)
  rescue_and_exit do
    context = ::Eien.context_or_default(options[:context])
    app = ::Eien.app_or_default(options[:app])

    require_context!(context)
    require_app!(app)

    attributes = require_options(::Eien::Processes::UpdateTask::ALLOWED_ATTRIBUTES, {
      enabled: true,
      config: "default",
      secret: "default",
      ports: {},
    })

    ::Eien::Processes::CreateTask.new(
      context,
      app,
      name,
      **attributes,
    ).run!
  end
end

#delete(name) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/eien/cli/processes.rb', line 130

def delete(name)
  rescue_and_exit do
    context = ::Eien.context_or_default(options[:context])
    app = ::Eien.app_or_default(options[:app])

    require_context!(context)
    require_app!(app)

    ::Eien::Processes::DeleteTask.new(
      context,
      app,
      name,
    ).run!
  end
end

#disable(process) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/eien/cli/processes.rb', line 59

def disable(process)
  rescue_and_exit do
    context = ::Eien.context_or_default(options[:context])
    app = ::Eien.app_or_default(options[:app])

    require_context!(context)
    require_app!(app)

    ::Eien::Processes::UpdateTask.new(
      context,
      app,
      process,
      enabled: false,
    ).run!
  end
end

#enable(process) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/eien/cli/processes.rb', line 40

def enable(process)
  rescue_and_exit do
    context = ::Eien.context_or_default(options[:context])
    app = ::Eien.app_or_default(options[:app])

    require_context!(context)
    require_app!(app)

    ::Eien::Processes::UpdateTask.new(
      context,
      app,
      process,
      enabled: true,
    ).run!
  end
end

#listObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/eien/cli/processes.rb', line 23

def list
  rescue_and_exit do
    context = ::Eien.context_or_default(options[:context])
    app = ::Eien.app_or_default(options[:app])

    require_context!(context)
    require_app!(app)

    ::Eien::Processes::ListTask.new(
      context,
      app,
    ).run!
  end
end

#update(name) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/eien/cli/processes.rb', line 108

def update(name)
  rescue_and_exit do
    context = ::Eien.context_or_default(options[:context])
    app = ::Eien.app_or_default(options[:app])

    require_context!(context)
    require_app!(app)

    attributes = require_options(::Eien::Processes::UpdateTask::ALLOWED_ATTRIBUTES)
    attributes[:ports] = {} if options[:"no-ports"]

    ::Eien::Processes::UpdateTask.new(
      context,
      app,
      name,
      **attributes,
    ).run!
  end
end