Skip to content

Commit

Permalink
command: Remove redundant -cap suffixes from options
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Nov 17, 2020
1 parent 9a13c58 commit 787123d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/fluent/command/cap_ctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ def prepare_option_parser
@opts[:clear_capabilities] = true
}

@op.on('--add-cap', '--add-capabilities [CAPABILITITY1, CAPABILITY2, ...]', "Add capabilities into Fluentd Ruby") {|s|
@op.on('--add [CAPABILITITY1,CAPABILITY2, ...]', "Add capabilities into Fluentd Ruby") {|s|
@opts[:add_capabilities] = s
}

@op.on('--drop-cap', '--drop-capabilities [CAPABILITITY1, CAPABILITY2, ...]', "Drop capabilities into Fluentd Ruby") {|s|
@op.on('--drop [CAPABILITITY1,CAPABILITY2, ...]', "Drop capabilities into Fluentd Ruby") {|s|
@opts[:drop_capabilities] = s
}

@op.on('--get-cap', '--get-capabilities', "Get capabilities for Fluentd") {|s|
@op.on('--get', "Get capabilities for Fluentd Ruby") {|s|
@opts[:get_capabilities] = true
}

Expand Down
16 changes: 8 additions & 8 deletions test/command/test_cap_ctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ class TestFluentCapCtl < Test::Unit::TestCase

test "add capability" do
logs = capture_stdout do
Fluent::CapCtl.new(["--add-cap", "dac_override"]).call
Fluent::CapCtl.new(["--add", "dac_override"]).call
end
expression = /\AUpdating .* done.\nAdding .*\n/m
assert_match expression, logs
end

test "drop capability" do
logs = capture_stdout do
Fluent::CapCtl.new(["--drop-cap", "chown"]).call
Fluent::CapCtl.new(["--drop", "chown"]).call
end
expression = /\AUpdating .* done.\nDropping .*\n/m
assert_match expression, logs
end

test "get capability" do
logs = capture_stdout do
Fluent::CapCtl.new(["--get-cap"]).call
Fluent::CapCtl.new(["--get"]).call
end
expression = /\ACapabilities in .*,\nEffective: .*\nInheritable: .*\nPermitted: .*/m
assert_match expression, logs
Expand All @@ -56,7 +56,7 @@ class TestFluentCapCtl < Test::Unit::TestCase
test "add capability" do
logs = capture_stdout do
Tempfile.create("fluent-cap-") do |tempfile|
Fluent::CapCtl.new(["--add-cap", "dac_override", "-f", tempfile.path]).call
Fluent::CapCtl.new(["--add", "dac_override", "-f", tempfile.path]).call
end
end
expression = /\AUpdating .* done.\nAdding .*\n/m
Expand All @@ -66,7 +66,7 @@ class TestFluentCapCtl < Test::Unit::TestCase
test "drop capability" do
logs = capture_stdout do
Tempfile.create("fluent-cap-") do |tempfile|
Fluent::CapCtl.new(["--drop-cap", "chown", "-f", tempfile.path]).call
Fluent::CapCtl.new(["--drop", "chown", "-f", tempfile.path]).call
end
end
expression = /\AUpdating .* done.\nDropping .*\n/m
Expand All @@ -76,7 +76,7 @@ class TestFluentCapCtl < Test::Unit::TestCase
test "get capability" do
logs = capture_stdout do
Tempfile.create("fluent-cap-") do |tempfile|
Fluent::CapCtl.new(["--get-cap", "-f", tempfile.path]).call
Fluent::CapCtl.new(["--get", "-f", tempfile.path]).call
end
end
expression = /\ACapabilities in .*,\nEffective: .*\nInheritable: .*\nPermitted: .*/m
Expand All @@ -87,13 +87,13 @@ class TestFluentCapCtl < Test::Unit::TestCase
sub_test_case "invalid" do
test "add capability" do
assert_raise(ArgumentError) do
Fluent::CapCtl.new(["--add-cap", "nonexitent"]).call
Fluent::CapCtl.new(["--add", "nonexitent"]).call
end
end

test "drop capability" do
assert_raise(ArgumentError) do
Fluent::CapCtl.new(["--drop-cap", "invalid"]).call
Fluent::CapCtl.new(["--drop", "invalid"]).call
end
end
end
Expand Down

0 comments on commit 787123d

Please sign in to comment.