mirror of
https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git
synced 2025-12-14 19:02:45 +03:00
Get ssh key from user-data with incus
incus has no way to set ssh key in meta-data, instead we can set it in user-data. This means that we cannot set ssh key if user-data is a shell script.
This commit is contained in:
parent
3197427cb3
commit
966f0bb2a4
@ -19,3 +19,9 @@ _imds_userdata() {
|
||||
printf "GET /1.0/config/user.user-data HTTP/1.0\n\n" \
|
||||
| nc "$IMDS_ENDPOINT" | sed '1,/^\r$/d'
|
||||
}
|
||||
|
||||
_imds_ssh_keys() {
|
||||
# extract ssh_authorized_keys from user-data
|
||||
_imds_userdata \
|
||||
| awk '/^ssh_authorized_keys:/ {flag=1; next} /^[a-z]/ {flag=0} flag && /^ *- / {sub(/^ *- /, ""); print}'
|
||||
}
|
||||
|
||||
@ -14,28 +14,29 @@ init_tests \
|
||||
imds_hostname_aws \
|
||||
imds_hostname_azure \
|
||||
imds_hostname_gcp \
|
||||
imds_hostname_hetzner \
|
||||
imds_hostname_incus \
|
||||
imds_hostname_nocloud \
|
||||
imds_hostname_oci \
|
||||
imds_hostname_scaleway \
|
||||
imds_hostname_hetzner \
|
||||
imds_hostname_incus \
|
||||
\
|
||||
imds_local_hostname_aws \
|
||||
imds_local_hostname_azure \
|
||||
imds_local_hostname_gcp \
|
||||
imds_local_hostname_hetzner \
|
||||
imds_local_hostname_incus \
|
||||
imds_local_hostname_nocloud \
|
||||
imds_local_hostname_oci \
|
||||
imds_local_hostname_scaleway \
|
||||
imds_local_hostname_hetzner \
|
||||
imds_local_hostname_incus \
|
||||
\
|
||||
imds_ssh_keys_aws \
|
||||
imds_ssh_keys_azure \
|
||||
imds_ssh_keys_gcp \
|
||||
imds_ssh_keys_hetzner \
|
||||
imds_ssh_keys_incus \
|
||||
imds_ssh_keys_nocloud \
|
||||
imds_ssh_keys_oci \
|
||||
imds_ssh_keys_scaleway \
|
||||
imds_ssh_keys_hetzner \
|
||||
\
|
||||
imds_nocloud_cmdline_local_hostname \
|
||||
imds_nocloud_smbios_local_hostname \
|
||||
@ -171,6 +172,21 @@ imds_ssh_keys_hetzner_body() {
|
||||
CLOUD="hetzner" atf_check -o match:"$key" imds @ssh-keys
|
||||
}
|
||||
|
||||
imds_ssh_keys_incus_body() {
|
||||
local key="ssh-ed25519 keydata"
|
||||
fake_userdata_incus <<-EOF
|
||||
ssh_authorized_keys:
|
||||
- asdasdf
|
||||
# other key
|
||||
- $key
|
||||
foo: bar
|
||||
EOF
|
||||
CLOUD="incus" atf_check \
|
||||
-o match:"$key" \
|
||||
-o not-match:"other key" \
|
||||
imds @ssh-keys
|
||||
}
|
||||
|
||||
imds_nocloud_cmdline_local_hostname_body() {
|
||||
atf_require_prog yx
|
||||
mkdir proc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user