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

Implement override and reset analog to docker-compose #830

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SebTM
Copy link

@SebTM SebTM commented Feb 1, 2024

return service

try:
tagObj.value = serivce
Copy link

Choose a reason for hiding this comment

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

Is this a typo?

Copy link
Author

Choose a reason for hiding this comment

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

No you need to still normalize the values of the Override-tag to be valid in the end (as they are the ones used) but pass the override-tag through to the recursive merge to do the actual override. I used try to determinate if there is a tagObj defiend and if so get the normalized values to the tagObj and return it otherwise return the normalized service-definition.

Copy link
Author

Choose a reason for hiding this comment

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

Also this isn't my most recent version anymore as I'm locally working an a version based on the latest https://github.com/maurerle/podman-compose but for now using docker-compose again.

Copy link

Choose a reason for hiding this comment

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

Thanks for the explanation 😄

Copy link
Collaborator

Choose a reason for hiding this comment

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

serivce seems to be non-existing variable though.

Copy link
Author

Choose a reason for hiding this comment

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

Edit: You are all right - missed the typo but that's not an issue/the latest state and needs a rebase.

How likely are my chances to get this approach merged, if I resubmit it?

Copy link
Collaborator

@p12tic p12tic Mar 8, 2024

Choose a reason for hiding this comment

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

Good question, haven't looked into viability of the PR so far. Could you point me to the part of the compose spec that this implements? I didn't find with couple minutes of googling and better I don't make an error here :) Whoops, it's in PR description

Overall I think podman-compose should support all things possible in non-swarm compose that can be implemented on podman. We may argue about the approach of implementation though.

What I will definitely ask that's not part of the PR right now is unit and integration tests.

class OverrideTag(yaml.YAMLObject):
yaml_dumper = yaml.Dumper
yaml_loader = yaml.SafeLoader
yaml_tag = u'!override'
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I remember correctly, u prefix is from python 2 times. Am I correct that it's not needed here?

for item in value:
values.append(item.value)

self.value = values
Copy link
Collaborator

Choose a reason for hiding this comment

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

self.value = [item.value for item in value]

@@ -1629,7 +1709,7 @@ def _parse_compose_file(self):
compose["services"] = resolved_services
if not getattr(args, "no_normalize", None):
compose = normalize_final(compose, self.dirname)
self.merged_yaml = yaml.safe_dump(compose)
self.merged_yaml = yaml.dump(compose)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this strictly needed?

return service

if isinstance(service, OverrideTag):
tagObj = service
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use tag_obj spelling.

if isinstance(service, OverrideTag):
tagObj = service
service = tagObj.value
print(subdir)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unneeded print.

Copy link
Collaborator

@p12tic p12tic left a comment

Choose a reason for hiding this comment

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

Looks good in principle.

Please add unit and integration tests.

@SebTM
Copy link
Author

SebTM commented Apr 7, 2024

Just to let you all know - I'm still interested in this feature but I have to put the PR from my side on-hold so if someone needs it / want's to take over - feel free 🙏🏻

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.

3 participants