docs: Add tedge-write documentation page#3116
Conversation
Robot Results
|
Codecov ReportAll modified and coverable lines are covered by tests ✅ Additional details and impacted files📢 Thoughts on this report? Let us know! |
7b863cc to
b3da147
Compare
b3da147 to
687cc6e
Compare
rina23q
left a comment
There was a problem hiding this comment.
Left small improvement suggestions
albinsuresh
left a comment
There was a problem hiding this comment.
The content looks fine. Just a few suggestions.
crates/core/tedge_write/src/bin.rs
Outdated
| /// A binary used for writing standard input to files which `tedge` user does not have write | ||
| /// permissions for, using sudo. |
There was a problem hiding this comment.
| /// A binary used for writing standard input to files which `tedge` user does not have write | |
| /// permissions for, using sudo. | |
| /// A binary used for writing to files which `tedge` user does not have write | |
| /// permissions for, using sudo. | |
| /// File content to be passed via standard input. |
Just focussing on the primary purpose first, and the details later.
There was a problem hiding this comment.
My proposal:
| /// A binary used for writing standard input to files which `tedge` user does not have write | |
| /// permissions for, using sudo. | |
| /// A binary used for writing to files which `tedge` user does not have write permissions for. | |
| /// | |
| /// To be used in combination with sudo, passing the file content via standard input. |
There was a problem hiding this comment.
Decided to go with 2nd proposal keeping first sentence short, also referenced tee which is very similar and users should be familiar with.
docs/src/references/tedge-write.md
Outdated
| **tedge-write** is a helper thin-edge component used by tedge-agent for privilege elevation. | ||
| tedge-agent spawns a `tedge-write` process when it needs to write to files that `tedge` user/group | ||
| has no write permissions to (e.g. system files or files owned by other packages), for example when |
There was a problem hiding this comment.
| **tedge-write** is a helper thin-edge component used by tedge-agent for privilege elevation. | |
| tedge-agent spawns a `tedge-write` process when it needs to write to files that `tedge` user/group | |
| has no write permissions to (e.g. system files or files owned by other packages), for example when | |
| **tedge-write** is a helper thin-edge component used by tedge-agent for privilege elevation, | |
| when it needs to write to files that `tedge` user/group | |
| has no write permissions to (e.g. system files or files owned by other packages), for example when |
There was a problem hiding this comment.
I'd rather keep first sentence as a short summary and explain more in detail in the second sentence.
docs/src/references/tedge-write.md
Outdated
| writing an updated configuration file as part of [`config_update` operation][1]. `tedge-agent` will | ||
| first try to write to a file directly and only retry using `tedge-write` if direct write fails due | ||
| to `tedge` user/group not having write permissions to either the file itself or its parent | ||
| directory. Write permission to the parent directory is required to guarantee config updates are |
There was a problem hiding this comment.
| directory. Write permission to the parent directory is required to guarantee config updates are | |
| directory. | |
| Write permission to the parent directory is required to guarantee config updates are |
In docs, we try to follow a convention where new sentences are always started on a new line, to have smaller diffs when changes are made in future. A single line which is too long can be broken into smaller ones across multiple lines (I usually break where there's a punctuation). Would be nice if you could do that for the remaining sentences as well.
There was a problem hiding this comment.
I will follow this style more closely.
Usually I use rewrap extension in Vscode which automatically wraps text to a defined number of columns, but it reflows whole paragraphs, so it tends to merge back two sentences when separated by only a single newline, which is a bit unfortunate.
docs/src/references/tedge-write.md
Outdated
| `tedge-write` will perform an atomic write, i.e. it will write to a temporary file, set file | ||
| ownership and mode, and finally rename the temporary into the final file. If the target file already | ||
| exists, its original ownership/mode will be preserved and optionally provided new values will be | ||
| ignored. |
There was a problem hiding this comment.
| `tedge-write` will perform an atomic write, i.e. it will write to a temporary file, set file | |
| ownership and mode, and finally rename the temporary into the final file. If the target file already | |
| exists, its original ownership/mode will be preserved and optionally provided new values will be | |
| ignored. | |
| While updating a file, `tedge-write` performs an atomic write, i.e. it first writes to a temporary file, set file ownership and mode, and finally moves it to the target location. | |
| If the target file already exists, its original ownership/mode is preserved and the optionally provided new values are ignored. |
docs/src/references/tedge-write.md
Outdated
| exists, its original ownership/mode will be preserved and optionally provided new values will be | ||
| ignored. | ||
|
|
||
| For `tedge-write` to work, it needs to be able to write to and set ownership and mode of all files. |
There was a problem hiding this comment.
| For `tedge-write` to work, it needs to be able to write to and set ownership and mode of all files. | |
| For `tedge-write` to work, it needs to be able to write to and set ownership and mode of the target files. |
docs/src/references/tedge-write.md
Outdated
| To achieve this we can use `sudo` with a `sudoers` configuration that allows `tedge` user to run | ||
| `tedge-write` as root without password if the destination file is inside `/etc`: |
There was a problem hiding this comment.
| To achieve this we can use `sudo` with a `sudoers` configuration that allows `tedge` user to run | |
| `tedge-write` as root without password if the destination file is inside `/etc`: | |
| To achieve this we can use `sudo` with a `sudoers` configuration that allows `tedge` user to run | |
| `tedge-write` as root without password. | |
| For example, the following setting allows `tedge-write` to update any file inside `/etc` with elevated privileges: |
docs/src/references/tedge-write.md
Outdated
| The sudoers entry will be created by thin-edge.io automatically under `/etc/sudoers.d/tedge`, but in | ||
| non-standard setups the default configuration may need to be changed. It's necessary to provide a | ||
| full path to `tedge-write` in the `sudoers` entry. See [`sudoers(5)`][2] for additional details. |
There was a problem hiding this comment.
| The sudoers entry will be created by thin-edge.io automatically under `/etc/sudoers.d/tedge`, but in | |
| non-standard setups the default configuration may need to be changed. It's necessary to provide a | |
| full path to `tedge-write` in the `sudoers` entry. See [`sudoers(5)`][2] for additional details. | |
| When %%te%% is installed using any one of the standard installation methods, the sudoers entry is automatically created under `/etc/sudoers.d/tedge`, | |
| but in non-standard setups the sudoers configuration may need to be updated manually. | |
| It's necessary to provide a full path to `tedge-write` in the `sudoers` entry. See [`sudoers(5)`][2] for additional details. |
docs/src/references/tedge-write.md
Outdated
| ## Command help | ||
|
|
||
| ```sh title="tedge-write" | ||
| A binary used for writing to files which `tedge` user does not have write permissions for, using sudo |
There was a problem hiding this comment.
Nitpick: This message got updated in this PR.
There was a problem hiding this comment.
Indeed manually generating command help is quite a churn and easy to forget to update, it would be good to generate automatically in the future so we could easily see help for all commands in the documentation.
pros:
- command help always in sync
- would be easier to verify that flags and options for commands are consistent between different commands
cons:
- more build scripts for the CI pipeline
There was a problem hiding this comment.
it would be good to generate it automatically
We already have that: Command block
Instead of sh title="tedge-write" use:
text command="tedge-write --help" title="tedge-write"
There was a problem hiding this comment.
Replaced with a call to command block, but I'll need to verify when it's deployed to gh-pages that the output is present as when the command could not be started (e.g. because it wasn't found) the build doesn't fail but the text is left empty.
0799957 to
06a566e
Compare
gligorisaev
left a comment
There was a problem hiding this comment.
Documentation describes the feature correctly
Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
6ed9c1c to
8adcbc7
Compare
Proposed changes
Adds a documentation page for
tedge-writecomponent, which should contain information about the component relevant to users and references relevant tedge-write information inconfig_updateoperation reference.Types of changes
Paste Link to the issue
Checklist
cargo fmtas mentioned in CODING_GUIDELINEScargo clippyas mentioned in CODING_GUIDELINESFurther comments