Class: Kube::Station::ListController

Inherits:
ApplicationController show all
Defined in:
app/controllers/kube/station/list_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#default_url_options

Instance Method Details

#createObject



28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/kube/station/list_controller.rb', line 28

def create
  resource_hash = build_resource_hash(params[:resource])
  resource = ::Kube::Schema[@kind_name].new(resource_hash)
  @cluster.apply_resource(resource.to_h)
  redirect_to cluster_group_version_kind_list_index_path(@cluster, params[:group_id], params[:version_id], @kind_name)
rescue => e
  @error = e.message
  @data = resource_hash || {}
  @fields = SchemaFields.call(resolve_schema(@kind_name), @data)
  render :new, status: :unprocessable_entity
end

#editObject



24
25
26
# File 'app/controllers/kube/station/list_controller.rb', line 24

def edit
  @fields = SchemaFields.call(resolve_schema(@kind_name), @data)
end

#indexObject



9
10
11
12
13
14
# File 'app/controllers/kube/station/list_controller.rb', line 9

def index
  @items = list_items
rescue => e
  @error = e.message
  @items = []
end

#newObject



19
20
21
22
# File 'app/controllers/kube/station/list_controller.rb', line 19

def new
  @data = ::Kube::Schema[@kind_name].defaults.merge({})
  @fields = SchemaFields.call(resolve_schema(@kind_name), @data)
end

#showObject



16
17
# File 'app/controllers/kube/station/list_controller.rb', line 16

def show
end

#updateObject



40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/kube/station/list_controller.rb', line 40

def update
  resource_hash = build_resource_hash(params[:resource])
  resource = ::Kube::Schema[@kind_name].new(resource_hash)
  @cluster.apply_resource(resource.to_h)
  redirect_to cluster_group_version_kind_list_path(@cluster, params[:group_id], params[:version_id], @kind_name, resource.to_h[:metadata][:name])
rescue => e
  @error = e.message
  @data = resource_hash || @data
  @fields = SchemaFields.call(resolve_schema(@kind_name), @data)
  render :edit, status: :unprocessable_entity
end