-
Notifications
You must be signed in to change notification settings - Fork 169
WIP: Fallback to running system's auth.json #1934
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
Draft
ckyrouac
wants to merge
3
commits into
bootc-dev:main
Choose a base branch
from
ckyrouac:lbi-upgrade
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+269
−39
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,3 +23,88 @@ export def have_hostexports [] { | |
| export def parse_cmdline [] { | ||
| open /proc/cmdline | str trim | split row " " | ||
| } | ||
|
|
||
| # cstor-dist configuration for authenticated registry testing | ||
| # cstor-dist serves images from containers-storage via an authenticated OCI registry endpoint | ||
| # https://github.com/ckyrouac/cstor-dist | ||
| const CSTOR_DIST_IMAGE = "ghcr.io/ckyrouac/cstor-dist:latest" | ||
| const CSTOR_DIST_USER = "testuser" | ||
| const CSTOR_DIST_PASS = "testpass" | ||
| const CSTOR_DIST_PORT = 8000 | ||
|
|
||
| # The registry address for cstor-dist | ||
| export const CSTOR_DIST_REGISTRY = $"localhost:($CSTOR_DIST_PORT)" | ||
|
|
||
| # Start cstor-dist with basic auth on localhost | ||
| # Fails if cstor-dist cannot be started | ||
| export def start_cstor_dist [] { | ||
| print "Starting cstor-dist with basic auth..." | ||
|
|
||
| # Pull test images that cstor-dist will serve | ||
| print "Pulling test images for cstor-dist to serve..." | ||
| podman pull docker.io/library/alpine:latest | ||
| podman pull docker.io/library/busybox:latest | ||
|
|
||
| # Run cstor-dist container with auth enabled | ||
| # Mount the local containers storage so cstor-dist can serve images from it | ||
| let storage_path = if ("/var/lib/containers/storage" | path exists) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be done by querying the |
||
| "/var/lib/containers/storage" | ||
| } else { | ||
| $"($env.HOME)/.local/share/containers/storage" | ||
| } | ||
|
|
||
| (podman run --privileged --rm -d --name cstor-dist-auth | ||
| -p $"($CSTOR_DIST_PORT):8000" | ||
| -v $"($storage_path):/var/lib/containers/storage" | ||
| $CSTOR_DIST_IMAGE --username $CSTOR_DIST_USER --password $CSTOR_DIST_PASS) | ||
|
|
||
| # Wait for cstor-dist to be ready by testing HTTP connection | ||
| # Loop for up to 20 seconds | ||
| print "Waiting for cstor-dist to be ready..." | ||
| let auth_header = $"($CSTOR_DIST_USER):($CSTOR_DIST_PASS)" | encode base64 | ||
| mut ready = false | ||
| for i in 1..20 { | ||
| let result = do { curl -sf -H $"Authorization: Basic ($auth_header)" $"http://($CSTOR_DIST_REGISTRY)/v2/" } | complete | ||
| if $result.exit_code == 0 { | ||
| $ready = true | ||
| break | ||
| } | ||
| print $"Attempt ($i)/20: cstor-dist not ready yet..." | ||
| sleep 1sec | ||
| } | ||
|
|
||
| if not $ready { | ||
| # Show container logs for debugging | ||
| print "cstor-dist failed to start. Container logs:" | ||
| podman logs cstor-dist-auth | ||
| error make { msg: "cstor-dist failed to become ready within 20 seconds" } | ||
| } | ||
|
|
||
| print $"cstor-dist running on ($CSTOR_DIST_REGISTRY)" | ||
| } | ||
|
|
||
| # Get cstor-dist auth config | ||
| export def get_cstor_auth [] { | ||
| # Base64 encode the credentials for auth.json | ||
| let auth_b64 = $"($CSTOR_DIST_USER):($CSTOR_DIST_PASS)" | encode base64 | ||
| { | ||
| registry: $CSTOR_DIST_REGISTRY, | ||
| auth_b64: $auth_b64 | ||
| } | ||
| } | ||
|
|
||
| # Configure insecure registry for cstor-dist (no TLS) | ||
| export def setup_insecure_registry [] { | ||
| mkdir /etc/containers/registries.conf.d | ||
| (echo $"[[registry]]\nlocation=\"($CSTOR_DIST_REGISTRY)\"\ninsecure=true" | ||
| | save -f /etc/containers/registries.conf.d/99-cstor-dist.conf) | ||
| } | ||
|
|
||
| # Set up auth.json on the running system with cstor-dist credentials | ||
| export def setup_system_auth [] { | ||
| mkdir /run/ostree | ||
| let cstor = get_cstor_auth | ||
| print $"Setting up system auth for cstor-dist at ($cstor.registry)" | ||
| let auth_json = $'{"auths": {"($cstor.registry)": {"auth": "($cstor.auth_b64)"}}}' | ||
| echo $auth_json | save -f /run/ostree/auth.json | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably be good moving cstor-dist into the bootc-dev org