Quadlet installation code refactoring#28860
Conversation
3599897 to
5703e04
Compare
|
@simonbrauner @inknos PTAL |
1661876 to
24903e0
Compare
|
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
inknos
left a comment
There was a problem hiding this comment.
2 nits and a clarification, then LGTM
| // First, validate that the source path exists and is a file | ||
| stat, err := os.Stat(path) | ||
| _, err := os.Stat(srcPath) | ||
| if err != nil { | ||
| return "", fmt.Errorf("quadlet to install %q does not exist or cannot be read: %w", path, err) | ||
| } | ||
| if stat.IsDir() { | ||
| dirs, err := os.ReadDir(path) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| for _, d := range dirs { | ||
| nInstallDir := filepath.Join(installDir, destName) | ||
| err := os.MkdirAll(nInstallDir, 0o755) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| _, err = ic.installQuadlet( | ||
| ctx, | ||
| filepath.Join(path, d.Name()), // path | ||
| d.Name(), // destName | ||
| nInstallDir, // installDir | ||
| replace) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| } | ||
| return path, nil | ||
| return "", fmt.Errorf("quadlet to install %q does not exist or cannot be read: %w", srcPath, err) |
There was a problem hiding this comment.
nit. this comment is outdated
Edit: got me confused when I was reading the code, had to go through it twice :)
There was a problem hiding this comment.
Which comment is outdated?
There was a problem hiding this comment.
// First, validate that the source path exists and is a file
code seemed just clear as is
There was a problem hiding this comment.
I'll be off in the next days, so to be clear, this is non blocking and the PR LGTM in the current state. waiting for tests only
- Cleanup the code to install quadlets - Fix `podman quadlet install` output message (see podman-container-tools#28335 (comment)) - Update libpod quadlet endpoint documentation Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
24903e0 to
9890a3b
Compare
simonbrauner
left a comment
There was a problem hiding this comment.
Checked #28335 (comment), it is fixed.
Added 2 comments, otherwise, LGTM
| defer func() { | ||
| if r != nil { | ||
| r.Body.Close() | ||
| } | ||
| if tmpFile != nil { | ||
| tmpFile.Close() |
There was a problem hiding this comment.
This gets called only once at the end of QuadletInstall, right? So if there are multiple URLs in quadletURLs, the r/tmpFile contains values from the last iteration of the foreach cycle that follows, so only those get Closed.
| // If toInstall is a single file with a supported extension, execute the original logic | ||
| installedPath, err := ic.installQuadlet(ctx, toInstall, filepath.Base(toInstall), installDir, options.Replace) | ||
| // Install the quadlet from the temporary file | ||
| destName := quadlet.name + quadlet.extension |
There was a problem hiding this comment.
$ tree postgres-17-test-6
postgres-17-test-6
└── a
├── A.container
└── test.quadlets
2 directories, 2 files
$ podman quadlet install postgres-17-test-6 --application 6
/home/sbrauner/.config/containers/systemd/6/a/A.container
/home/sbrauner/.config/containers/systemd/6/fromquadlets.containerThere is an inconsistency on install destination.
For .quadlet files, the quadlets are installed to the path they were at (a/).
But for .quadlets files, the quadlets are installed to ~/.config/containers/systemd/applicationName, independently on their location within the application file structure.
This is a follow-up of #28335 with some improvements:
--application)podman quadlet installoutput message (see refactor: podman quadlet sub-command #28335 (comment))Checklist
Ensure you have completed the following checklist for your pull request to be reviewed:
commits. (
git commit -s). (If needed, usegit commit -s --amend). The author email must matchthe sign-off email address. See CONTRIBUTING.md
for more information.
Fixes: #00000in commit message (if applicable)make validatepr(format/lint checks)Noneif no user-facing changes)Does this PR introduce a user-facing change?