Skip to content

ENT-13808: Improve release history generation and download handling#51

Merged
olehermanse merged 2 commits intocfengine:mainfrom
sarakthon:generate-community-checksums
Apr 17, 2026
Merged

ENT-13808: Improve release history generation and download handling#51
olehermanse merged 2 commits intocfengine:mainfrom
sarakthon:generate-community-checksums

Conversation

@sarakthon
Copy link
Copy Markdown
Contributor

No description provided.

@cf-bottom
Copy link
Copy Markdown

Thanks for submitting a PR! Maybe @larsewi can review this?

Comment thread src/cfengine_cli/masterfiles/generate_release_information.py
Comment thread src/cfengine_cli/masterfiles/generate_release_information.py
Comment on lines 99 to 100
def process_release_type(folder, download_func):
# Function for processing either community or enterprise releases
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This function was here already, but looking at it, I wonder if it unnecessarily complex.

Why is it necessary to pass in a download function, instead of just a download URL?

# Downloading releases.json:
try:
releases_data = get_json(ENTERPRISE_RELEASES_URL)
return requests.get(ENTERPRISE_RELEASES_URL)
Copy link
Copy Markdown
Member

@olehermanse olehermanse Apr 10, 2026

Choose a reason for hiding this comment

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

Here you change the return type from json / dict to a requests response object. However, where you use this, you only use response.content, right? Maybe it's cleaner to just return .content? When I write functions that essentially wrap requests in various ways, I usually like to not "leak" the fact that it is requests.

Comment on lines +186 to +203
def save_to_file(path, content):
try:
with open(path, "wb") as f:
f.write(content)
print(f"Saved {path}")

except OSError:
raise CFBSExitError(f"Failed to write file {path}.")


def load_json_from_file(path):
# Open saved file and return as dict
try:
with open(path, "r", encoding="utf-8") as f:
return json.load(f)

except OSError:
raise CFBSExitError(f"Failed to read file {path}.")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was thinking we could make a function which does "everything" you need, without saving the data to file and then reading it from file again;

def json_get_save_return(url: str, path: str) -> dict:
    r = requests.get(url)
    content = r.content
    with open(path, "wb") as f:
        f.write(content)
    # TODO: Add some error handling
    data = json.loads(content)
    return data

@sarakthon sarakthon force-pushed the generate-community-checksums branch from 2c27558 to 1c4ce4c Compare April 15, 2026 11:18
@sarakthon sarakthon force-pushed the generate-community-checksums branch 3 times, most recently from 47efe87 to 6c70444 Compare April 16, 2026 06:44
@sarakthon sarakthon force-pushed the generate-community-checksums branch from 6c70444 to c3df853 Compare April 16, 2026 06:50
@sarakthon sarakthon requested a review from olehermanse April 16, 2026 06:58
Comment thread src/cfengine_cli/masterfiles/generate_release_information.py
@olehermanse olehermanse merged commit 4f8f557 into cfengine:main Apr 17, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants