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

Make starter Chart.yaml the source of truth for all versions #25

Merged
merged 3 commits into from
Nov 13, 2024

Conversation

miles-w-3
Copy link
Collaborator

No description provided.

Copy link
Contributor

@oraNod oraNod left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this @miles-w-3 it seems like a really good approach. I've got some minor comments for now but will come back to the get_app_version function with a suggestion in a couple of hours. I think I see one or two things that might be an improvement. Cheers.

.helm/starter/Chart.yaml Outdated Show resolved Hide resolved
type: application
# the current version of this helm chart
version: 0.1.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to go ahead and change the chart version to CalVer or should we do that as a follow up?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Feel free to change it, I'm not sure I understand where the current version starts but I think it would make sense to do it in this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

On second thought I'm a little unsure about switching this to CalVer in this PR. It probably feels somewhat arbitrary to change it now so I'm inclined to go with this version until we have some actual helm chart improvements.

Makefile Show resolved Hide resolved
DEFAULT_AWX_OPERATOR_REPO = "https://github.com/ansible/awx-operator"

# get the appVersion configured in Chart.yaml
def get_app_version():
# naive implementation without yaml-parsing package
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't mind adding a dependency and calling yaml.safe_load(). It might be a little more robust.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wasn't sure whether we wanted to open the can of worms from the python standpoint, given all of the options around dependency management (venv, Dockerfile, etc)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm happy to leave it to your preference. Maybe the fewer lines of code isn't worth the overhead of adding requirements files and all that.

Copy link
Contributor

@oraNod oraNod left a comment

Choose a reason for hiding this comment

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

Here's my second round review. Thanks again @miles-w-3

return result[1].rstrip()
except:
raise FileNotFoundError("Failed to open Chart.yaml")
raise KeyError("Could not find appVersion")
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can consider an alternative approach here, if you don't want to go with the yaml parser. I've been playing around with it a little. Here is what I've come up with:

# get the appVersion configured in Chart.yaml
def get_app_version():
    # naive implementation without yaml-parsing package
    try:
        with open("./.helm/starter/Chart.yaml") as chart:
            for line in chart:
                line = line.strip()
                if line.startswith('appVersion:'):
                    result = line.split(":", 1)
                    if len(result) != 2:
                        raise KeyError("Malformed appVersion")

                    version = result[1].rstrip()
                    if not version:
                        raise KeyError("No appVersion value found")

                    return version

        raise KeyError("Could not find appVersion")

    except FileNotFoundError:
        raise FileNotFoundError("Failed to open Chart.yaml")

Here I think using strip() might handle the whitespace better than replacing it. Plus we probably want to split on the first colon : only. Maybe it's a little pedantic though.

I also think it would be ideal to check for empty version values.

clone-awx-operator.py Outdated Show resolved Hide resolved
@miles-w-3 miles-w-3 force-pushed the feature/chart-versioning branch from cbe63a3 to 1f405f5 Compare November 12, 2024 04:19
@miles-w-3
Copy link
Collaborator Author

@oraNod Thanks for the review, updated based on your feedbacl. If you confirm which version would be appropriate I can update that as well

clone-awx-operator.py Outdated Show resolved Hide resolved
@oraNod
Copy link
Contributor

oraNod commented Nov 12, 2024

@oraNod Thanks for the review, updated based on your feedbacl. If you confirm which version would be appropriate I can update that as well

@miles-w-3 Thanks for updating! I think we're almost there. Made a couple of nit changes and left a comment about printing the pre-stripped result. We probably only need the one print call there and could make it a little more informative.

@miles-w-3
Copy link
Collaborator Author

@oraNod I didn't intend to leave either print in, removed both in my latest commit

Copy link
Contributor

@oraNod oraNod left a comment

Choose a reason for hiding this comment

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

This looks good. Thanks for the great work here @miles-w-3 it's much appreciated. Glad to have someone from the community stepping forward as a maintainer on this project. I'll go ahead and merge.

@oraNod oraNod merged commit 3f16dc0 into ansible-community:main Nov 13, 2024
3 checks passed
@oraNod oraNod mentioned this pull request Nov 13, 2024
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.

2 participants