-
Notifications
You must be signed in to change notification settings - Fork 594
feat(cli): add policy import/export commands to im-/export policies from/to json #4020
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
Conversation
|
Bump @jkowalski @julio-lopez 🙂 I (and it seems a bunch of other people), are eagerly looking forward to this functionality in order to make process on automated configuration. If you could find the time to take a look at this work, that would be brilliant and much appreciated. (BTW, I think this PR also closes #4114) |
|
This functionality looks great, can you add a quick e2e test and address the comments I've put in, then we can merge. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4020 +/- ##
==========================================
+ Coverage 75.86% 76.04% +0.17%
==========================================
Files 470 503 +33
Lines 37301 38709 +1408
==========================================
+ Hits 28299 29435 +1136
- Misses 7071 7312 +241
- Partials 1931 1962 +31 ☔ View full report in Codecov by Sentry. |
|
addressed most of your comments, gonna add tests and a remove/replace flag tomorrow |
|
added tests and (hopefully) addressed all the comments |
|
this is looking great, still have some linter errors, you can run |
|
should be fixed now I used |
|
it fails on windows only I assume it's due to the policy test target being specified as |
|
gonna try to address the code coverage as well |
|
should be good now (hopefully) afaict more test coverage requires triggering internal kopia errors |
jkowalski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the contribution!
|
The windows test still seem to be failing, seems to be related to the paths Gonna try to spin up a VM to debug |
|
policies in Windows use backslashes for path names |
|
it failed without |
|
I have a Windows dev box, let me try it... |
|
removing ToSlash fixed the issue on Windows. |
|
Interesting that the two ToSlash calls in the import tests don't break anything |
|
i think slash-separated policies will be imported/exported just fine, but will not really take effect on Windows boxes (since it uses backslashes). We should fix that perhaps at some point. |
|
It's brilliant to see this happen, thanks for getting this done blenderfreaky and Jarek! |
…rom/to json (kopia#4020) * feat(cli): add policy export command * feat(cli): add policy import command * chore(cli): remove unused policyTargetFlags in commandPolicyImport * feat(cli): allow limiting which policies to import * docs(cli): document policy import and export commands * feat(cli): add policy import/export commands * fix(cli): apply suggestions * fix(general): unintentional commit * feat(cli: add policy export tests * feat(cli): add policy import tests * feat(cli): add deleteOtherPolicies option for policy import * docs(cli): stdin/stdout in policy import/export and --delete-other-policies flag * chore(cli): fix linter issues * fix(cli): fix newly introduced errors * fix(cli): fix failing windows tests * chore(cli): more test coverage for policy import/export * fixed windows test --------- Co-authored-by: Jarek Kowalski <[email protected]>
…rom/to json (kopia#4020) * feat(cli): add policy export command * feat(cli): add policy import command * chore(cli): remove unused policyTargetFlags in commandPolicyImport * feat(cli): allow limiting which policies to import * docs(cli): document policy import and export commands * feat(cli): add policy import/export commands * fix(cli): apply suggestions * fix(general): unintentional commit * feat(cli: add policy export tests * feat(cli): add policy import tests * feat(cli): add deleteOtherPolicies option for policy import * docs(cli): stdin/stdout in policy import/export and --delete-other-policies flag * chore(cli): fix linter issues * fix(cli): fix newly introduced errors * fix(cli): fix failing windows tests * chore(cli): more test coverage for policy import/export * fixed windows test --------- Co-authored-by: Jarek Kowalski <[email protected]>
This PR adds a
policy importandpolicy exportcommand to the cli.The commands import and export policies from and to json files.
Syntax
Exports policies as json, optionally pretty-printed.
Prints to stdout if no file is specified.
Outputs all policies if
--globaland[<target>]are unspecified.Imports policies from json, reads from stdin if no file is specified.
In-/Output is in the format
{ "(global)": { "retention": { "keepLatest": 10, "keepHourly": 48, ... } }, "foo@bar:/home/foobar": { ... } }Would close #2432 and #2785