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

Create sm-plugins and operations/c8y directories by tedge init #2469

Conversation

rina23q
Copy link
Member

@rina23q rina23q commented Nov 20, 2023

Proposed changes

This PR changes tedge init to create:

  • <config_dir>/sm-plugins directory with root:root and 755
  • <config_dir>/operations/c8y directory with tedge:tedge and 755

The directory sm-plugins gets created by the tedge-apt-plugin package installation, therefore, keeping the same permission as it is now.
The directory operations is already created by tedge init, however, operations/c8y gets created on the start-up of tedge-mapper-c8y. From the description of #2452, the user may create the directory before they run tedge-mapper-c8y, so this PR changes it to create by tedge init.

Current permission

root@2749a49fbbcc:/etc/tedge/operations# ls -ltr
total 4
drwxr-xr-x 2 tedge tedge 4096 Nov 21 13:44 c8y
root@2749a49fbbcc:/etc/tedge# ls -ltr
total 32
-rw-r--r-- 1 root  root   386 Feb 25  2023 system.toml
drwxrwxr-x 2 tedge tedge 4096 Nov 21 13:44 mosquitto-conf
drwxr-xr-x 3 root  root  4096 Nov 21 13:44 contrib
drwxrwxr-x 1 tedge tedge 4096 Nov 21 13:44 plugins
drwxrwxr-x 3 tedge tedge 4096 Nov 21 13:44 operations
-rw-r--r-- 1 root  root   305 Nov 21 13:44 tedge.toml
drwxrwxr-x 2 root  root  4096 Nov 21 13:44 device-certs
drwxr-xr-x 2 root  root  4096 Nov 21 13:44 sm-plugins

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue

#2444 and #2452

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s)
  • I ran cargo fmt as mentioned in CODING_GUIDELINES
  • I used cargo clippy as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Copy link

codecov bot commented Nov 20, 2023

Codecov Report

Merging #2469 (92c2ddf) into main (a67dba6) will decrease coverage by 0.1%.
Report is 1 commits behind head on main.
The diff coverage is 0.0%.

Additional details and impacted files
Files Coverage Δ
crates/core/tedge/src/cli/init.rs 0.0% <0.0%> (ø)

... and 2 files with indirect coverage changes

Copy link
Contributor

github-actions bot commented Nov 20, 2023

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
376 0 3 376 100 55m9.047s

@@ -127,6 +127,14 @@ impl TEdgeInitCmd {
Some(0o775),
),
)?;
create_directory(
config_dir.join("operations").join("c8y"),
Copy link
Contributor

Choose a reason for hiding this comment

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

We may have to undo this in future as the desire is to make tedge and other mappers as independent as possible. The right thing to do would have been to make the tedge-mapper-c8y create this directory as part of its installation as well, in addition to runtime, so that plugins like c8y-remote-access plugin, can be sure that this directory is present, before it adds its own operation file. For that to work, such plugins should have a Dependends relationship defined on the tedge-mapper-c8y package, but that's not an unreasonable requirement.

But, for the current state of things, this quick fix is seems sufficient.

@rina23q rina23q force-pushed the improve/2444-2552/create-sm-plugins-and-c8y-dir-by-tedge-init branch from 4d1a549 to 6826dd4 Compare November 21, 2023 14:53
Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
@rina23q rina23q force-pushed the improve/2444-2552/create-sm-plugins-and-c8y-dir-by-tedge-init branch from 6826dd4 to 92c2ddf Compare November 21, 2023 15:17
@rina23q rina23q merged commit c2cc3a9 into thin-edge:main Nov 22, 2023
18 checks passed
@rina23q rina23q deleted the improve/2444-2552/create-sm-plugins-and-c8y-dir-by-tedge-init branch November 22, 2023 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants