-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
86 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
# This job runs after the private registry is up and running, when we know | ||
# address and port provided by the bridge network. It is a sysbatch job | ||
# that writes | ||
# - /usr/local/bin/docker-credential-test.sh | ||
# - /etc/docker-registry-auth.json | ||
|
||
job "registry-configs" { | ||
type = "sysbatch" | ||
|
||
constraint { | ||
attribute { | ||
attribute = "${attr.kernel.name}" | ||
value = "linux" | ||
} | ||
} | ||
|
||
group "group" { | ||
reschedule { | ||
attempts = 0 | ||
unlimited = false | ||
} | ||
} | ||
|
||
task "write-script" { | ||
driver = "pledge" | ||
|
||
template { | ||
destination = "local/docker-credential-test.sh" | ||
data = <<EOH | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
value=$(cat /dev/stdin) | ||
username="auth_helper_user" | ||
password="auth_helper_pass" | ||
case "${value}" in | ||
docker.io/*) | ||
echo "must use local registry" | ||
exit 3 | ||
;; | ||
*) | ||
echo "{\"Username\": \"$username\", \"Secret\": \"$password\"}" | ||
exit 0 | ||
;; | ||
esac | ||
EOH | ||
} | ||
|
||
config { | ||
command = "/usr/bin/mv" | ||
args = [ | ||
"local/docker-crediential-test.sh", | ||
"/usr/local/bin/docker-credential-test.sh", | ||
] | ||
promises = "stdio rpath wpath cpath" | ||
unveil = ["r:local/docker-credential-test.sh", "wc:/usr/local/bin"] | ||
} | ||
|
||
resources { | ||
cpu = 100 | ||
memory = 32 | ||
} | ||
} | ||
} |
This file contains 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