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

Not generating absolute paths from relative paths #102

Open
cob-web-corner opened this issue Sep 8, 2024 · 4 comments
Open

Not generating absolute paths from relative paths #102

cob-web-corner opened this issue Sep 8, 2024 · 4 comments

Comments

@cob-web-corner
Copy link

cob-web-corner commented Sep 8, 2024

podlet compose --kube docker-compose.yaml

The compose:

  the_service:
    volumes:
      - /run/user/1001/podman/podman.sock:/var/run/docker.sock
      - ./data:/data
      - ./config.yaml:/config.yaml
    container_name: container_name
    image: container/image:latest

Resulting yaml

  - hostPath:
      path: ./data
    name: container_data
  - hostPath:
      path: ./config.yaml
    name: **container_config.yaml**

Obviously not a whole real-example but just to demonstrate. The only way the resulting kube file can be used in a corresponding .kube service is by using absolute paths. During the podlet run it should convert these paths

Version

$ podlet --version
podlet 0.3.0
@cob-web-corner
Copy link
Author

cob-web-corner commented Sep 8, 2024

Just found this:

#55

and tried podlet --absolute-host-paths compose --kube but I'm still getting relative paths in the yaml output

I will note, this is translating from relative to absolute paths when using this /usr/lib/systemd/system-generators/podman-system-generator --user --dryrun

@k9withabone
Copy link
Member

From podlet --help:

  -a, --absolute-host-paths [<RESOLVE_DIR>]
          Convert relative host paths to absolute paths.
          
          Relative host paths in generated Quadlet files are resolved using the given directory or the current working
          directory. For `podlet compose`, the parent directory of the compose file is used as the default if the compose file
          is not read from stdin.
          
          All host paths are also cleaned to remove interior `/../`, `/./`, and `//`.
          
          When using `podlet compose --pod`, modifying paths in generated Kubernetes YAML files is not supported.
          
          Note that only host paths not in the `PodmanArgs=` Quadlet option will be modified.
          
          Podlet will return an error if the current working directory cannot be read, or if the given directory path is not
          absolute.

See that it says "Quadlet files", not Kubernetes YAML. The reason for this is that it would be significantly more complicated to do for Kubernetes YAML files. The types are controlled by the k8s-openapi library, and they are not the correct to work with what I did to get that feature working with Quadlet files (the paths are Strings, not PathBufs). It would also be a lot of additional work to find all the host paths and potentially parse them out from other strings. I would gladly accept a PR that figures out a way around the limitations and does the work, but I don't have the time for it.

Note that Podman does work Kubernetes YAML that has relative paths. The SetWorkingDirectory= option is all about how relative paths should be resolved.

@k9withabone
Copy link
Member

Just noticed in the help that it says in the 4th paragraph podlet compose --pod instead of --kube like it should.

@cob-web-corner
Copy link
Author

cob-web-corner commented Sep 21, 2024

It would also be a lot of additional work to find all the host paths and potentially parse them out from other strings. I would gladly accept a PR that figures out a way around the limitations and does the work, but I don't have the time for it.

I get it, other more important things to work on and this isn't a show stopper and the SetWorkingDirectory option is available

Just noticed in the help that it says in the 4th paragraph podlet compose --pod instead of --kube like it should.

Okay glad I'm not crazy I read that about 20 times before I saw your comment

Thanks for the response!

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

No branches or pull requests

2 participants