-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# = Foreman Column View | ||
# | ||
# This class installs the column view plugin and optionally manages the configuration file | ||
# | ||
# === Parameters: | ||
# | ||
# $columns:: an hash of columns to add to the configuration | ||
# | ||
class foreman::plugin::column_view ( | ||
Hash[String, Hash] $columns = {}, | ||
){ | ||
# https://projects.theforeman.org/issues/21398 | ||
assert_type(Hash[String, Foreman::Column_view_column], $columns) | ||
|
||
foreman::plugin { 'column_view': | ||
config => template('foreman/foreman_column_view.yaml.erb'), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
require 'spec_helper' | ||
|
||
describe 'foreman::plugin::column_view' do | ||
include_examples 'basic foreman plugin tests', 'column_view' | ||
|
||
context 'with columns hash architecture' do | ||
let(:params) do | ||
{ | ||
'columns' => { | ||
'architecture' => { | ||
'title' => 'Architecture', | ||
'after' => 'last_report', | ||
'content' => 'facts_hash["architecture"]', | ||
} | ||
} | ||
} | ||
end | ||
|
||
it { is_expected.to contain_file('/etc/foreman/plugins/foreman_column_view.yaml').with_content(/.*:title: Architecture.*/) } | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
end | ||
|
||
context 'with columns hash architecture and console' do | ||
let(:params) do | ||
{ | ||
'columns' => { | ||
'architecture' => { | ||
'title' => 'Architecture', | ||
'after' => 'last_report', | ||
'content' => 'facts_hash["architecture"]', | ||
}, | ||
'console' => { | ||
'title' => 'Console', | ||
'after' => '0', | ||
'content' => 'link_to(_("Console"), "https://#{host.interfaces.first.name}.domainname", { :class => "btn btn-info" } )', | ||
'conditional' => ':bmc_available?', | ||
'eval_content' => 'true', | ||
'view' => ':hosts_properties', | ||
} | ||
} | ||
} | ||
end | ||
|
||
it { is_expected.to contain_file('/etc/foreman/plugins/foreman_column_view.yaml').with_content(/.*:title: Console.*/) } | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
end | ||
|
||
context 'with columns hash broken' do | ||
let(:params) do | ||
{ | ||
'columns' => { | ||
'broken' => { | ||
'title' => 'Broken', | ||
} | ||
} | ||
} | ||
end | ||
|
||
it { is_expected.to_not compile.with_all_deps } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<%= ERB.new(File.read(File.expand_path("_header.erb",File.dirname(file)))).result(binding) -%> | ||
# | ||
# See tfm-rubygem-foreman_column_view-doc and /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_column_view-0.3.0/README.md for more information | ||
:column_view: | ||
<% if @columns -%> | ||
<% @columns.each do |column, hash| -%> | ||
:<%= column %>: | ||
<% hash.each do |key,value| -%> | ||
:<%= key %>: <%= value %> | ||
<% end -%> | ||
<% end -%> | ||
<% end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
type Foreman::Column_view_column = Struct[ | ||
{ | ||
title => String[1], | ||
after => String[1], | ||
content => String[1], | ||
Optional['conditional'] => String[1], | ||
Optional['eval_content'] => String[1], | ||
Optional['view'] => String[1], | ||
Optional['width'] => String[1], | ||
Optional['custom_method'] => String[1], | ||
} | ||
] |