podman-compose icon indicating copy to clipboard operation
podman-compose copied to clipboard

podman-compose extension for --pod-args

Open TheMDev opened this issue 1 year ago • 0 comments

The recent PR https://github.com/containers/podman-compose/pull/964 implemented the ability to set --in-pod in the compose file. However, there still does not appear to be a way to set --pod-args in the compose file. This would be pretty useful as it would allow for options such as --infra, --infra-command, --infra-image, --infra-name, --share and more to be set in the compose file instead of needing to pass them in with --pod-args.

Compose example:

x-podman:
    in_pod: true
    pod_args: '--infra=true --infra-name=pod_unipi_infra --share=""'

Possible partial implementation:

index 6b974f5..43305fb 100755
--- a/podman_compose.py
+++ b/podman_compose.py
@@ -1762,6 +1762,12 @@ class PodmanCompose:
         # otherwise use `in_pod` value provided by command line
         return self.global_args.in_pod_bool
 
+    def resolve_pod_args(self):
+        if self.global_args.pod_args == "--infra=false --share=":
+            self.global_args.pod_args = self.x_podman.get("pod_args", True)
+        # otherwise use `pod_args` value provided by command line
+        return self.global_args.pod_args
+
     def _parse_compose_file(self):
         args = self.global_args
         # cmd = args.command
@@ -2008,6 +2014,7 @@ class PodmanCompose:
         self.x_podman = compose.get("x-podman", {})
 
         args.in_pod_bool = self.resolve_in_pod()
+        args.pod_args = self.resolve_pod_args()
         pods, containers = transform(args, project_name, given_containers)
         self.pods = pods
         self.containers = containers

TheMDev avatar Oct 12 '24 03:10 TheMDev