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

[overrideable url] Initial changes to ct scripts to use environment variable #1251

Open
wants to merge 2 commits into
base: dev_overrideable_url
Choose a base branch
from

Conversation

cricalix
Copy link

@cricalix cricalix commented Jan 5, 2025

🛠️ Note:
We are meticulous about merging code into the main branch, so please understand that pull requests not meeting the project's standards may be rejected. It's never personal!
🎮 Note for game-related scripts: These have a lower likelihood of being merged.


✍️ Description

In #1202, I proposed that a new environment variable could be used to change the URL that the scripts fetch data from, enabling easy testing against custom repositories (or even local disk) without having to edit the files every time. In #1230, the request was made to split the PR into smaller PRs.

This PR implements the initial changes to a subset of ct/* app scripts, moving the root of the hard-coded URL to a variable that allows the environment to override it, and then changes the source command to use that variable as the base of the URL to fetch.

This PR is essentially a codemod done with rg -sl 'curl -s' | xargs sed -i -e '/ProxmoxVE/develop/misc/ i: "${CSCRIPTS_BASE_URL:=https://raw.githubusercontent.com/community-scripts/ProxmoxVE/develop}"' -e 's%https://raw.githubusercontent.com/community-scripts/ProxmoxVE/develop/misc/build.func%"${CSCRIPTS_BASE_URL}/misc/build.func"%'

The defaulting of the vault to the existing base URL means that there will be no impact on existing source calls; setting the variable will change where build.func is sourced from, but will not affect where the $var_install.sh script is loaded from.



🛠️ Type of Change

Please check the relevant options:

  • Bug fix (non-breaking change that resolves an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change unexpectedly)
  • New script (a fully functional and thoroughly tested script or set of scripts)

✅ Prerequisites

The following steps must be completed for the pull request to be considered:

  • Self-review performed (I have reviewed my code to ensure it follows established patterns and conventions.)
  • Testing performed (I have thoroughly tested my changes and verified expected functionality.)
  • Documentation updated (I have updated any relevant documentation)

📋 Additional Information (optional)

The second run of the script sets the URL to point to my local checkout on the pve node.

  • git checkout initial-ct-changes
  • bash ct/alpine.sh
  • pct stop 105 && pct destroy 105
  • CSCRIPTS_BASE_URL=file:///root/t/ProxmoxVE bash ct/alpine.sh

In both cases:
image

@se-bastiaan
Copy link
Contributor

Wouldn't it also be nice if the CSCRIPTS_BASE_URL is also be used in all other sub-scripts? Build.func contains 'calls' to the install.func scripts, and the app install script. Those are still bound to the repository url that is hardcoded.

@cricalix
Copy link
Author

cricalix commented Jan 5, 2025

Wouldn't it also be nice if the CSCRIPTS_BASE_URL is also be used in all other sub-scripts? Build.func contains 'calls' to the install.func scripts, and the app install script. Those are still bound to the repository url that is hardcoded.

Yes. That's the 4th PR to come, but there's a bit of discussion needed around making curl a default for all containers, so that the lxc attach bash -c wget can be replaced with a bash -c curl. If that's acceptable, I need to slide a 5th PR in place (or make it part of the 4th) to ensure curl is always installed in all containers.

I interpreted the other request about splitting the PR to mean "make the changes in a way that can be tested step by step"; updating all the other curl calls in build.func is the last change.

@MickLesk MickLesk changed the base branch from develop to dev_overrideable_url January 6, 2025 06:58
@cricalix cricalix force-pushed the initial-ct-changes branch from 3483bea to 4ca6da2 Compare January 6, 2025 20:54
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.

4 participants