Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service cap-add/cap-drop: add special "RESET" value #2709

Merged
merged 1 commit into from
Sep 10, 2020

Conversation

thaJeztah
Copy link
Member

follow-up to #2687

This implements a special "RESET" value that can be used to reset the
list of capabilities to add/drop when updating a service.

Given the following service;

CapDrop CapAdd
CAP_SOME_CAP

When updating the service, and applying --cap-drop RESET, the "drop" list
is reset to its default:

CapDrop CapAdd

When updating the service, and applying --cap-drop RESET, combined with
--cap-add CAP_SOME_CAP and --cap-drop CAP_SOME_OTHER_CAP:

CapDrop CapAdd
CAP_FOO_CAP CAP_SOME_CAP

@codecov-commenter
Copy link

codecov-commenter commented Sep 8, 2020

Codecov Report

Merging #2709 into master will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2709      +/-   ##
==========================================
+ Coverage   58.54%   58.56%   +0.01%     
==========================================
  Files         296      296              
  Lines       21286    21294       +8     
==========================================
+ Hits        12462    12470       +8     
  Misses       7915     7915              
  Partials      909      909              

Copy link
Collaborator

@albers albers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bash completion LGTM.

@thaJeztah thaJeztah marked this pull request as ready for review September 9, 2020 11:00
@thaJeztah
Copy link
Member Author

Rebased, and moved out of draft

@cpuguy83 @silvin-lubecki @tiborvass PTAL

@@ -1522,6 +1522,28 @@ func TestUpdateCaps(t *testing.T) {
expectedAdd: []string{"CAP_AAA", "CAP_BBB", "CAP_CCC", "CAP_DDD"},
expectedDrop: []string{"CAP_WWW", "CAP_XXX", "CAP_YYY", "CAP_ZZZ"},
},
{
name: "Reset capabilities",
flagAdd: []string{"RESET"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add also a test with ALL, RESET ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added two tests that combine ALL and RESET

This implements a special "RESET" value that can be used to reset the
list of capabilities to add/drop when updating a service.

Given the following service;

| CapDrop        | CapAdd        |
| -------------- | ------------- |
| CAP_SOME_CAP   |               |

When updating the service, and applying `--cap-drop RESET`, the "drop" list
is reset to its default:

| CapDrop        | CapAdd        |
| -------------- | ------------- |
|                |               |

When updating the service, and applying `--cap-drop RESET`, combined with
`--cap-add CAP_SOME_CAP` and `--cap-drop CAP_SOME_OTHER_CAP`:

| CapDrop        | CapAdd        |
| -------------- | ------------- |
| CAP_FOO_CAP    | CAP_SOME_CAP  |

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants