-
Notifications
You must be signed in to change notification settings - Fork 191
kola: add bootc-base tag for kola tests #4469
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
yasminvalim
wants to merge
3
commits into
coreos:main
Choose a base branch
from
yasminvalim:poc-run-tests
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.
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
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
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 |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // Copyright 2026 Red Hat | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package platform | ||
|
|
||
| import ( | ||
| "encoding/base64" | ||
| "fmt" | ||
| "strings" | ||
|
|
||
| "golang.org/x/crypto/ssh/agent" | ||
| ) | ||
|
|
||
| const systemdCredentialPrefix = "io.systemd.credential.binary:" | ||
|
|
||
| // SystemdSMBIOSSSHCredential builds a QEMU -smbios type=11 value that provisions | ||
| // SSH authorized_keys via the systemd tmpfiles.extra system credential. | ||
| // See https://systemd.io/CREDENTIALS/ | ||
| func SystemdSMBIOSSSHCredential(user string, keys []*agent.Key) (string, error) { | ||
| if user == "" { | ||
| return "", fmt.Errorf("SSH user must be set") | ||
| } | ||
| if len(keys) == 0 { | ||
| return "", fmt.Errorf("no SSH keys provided") | ||
| } | ||
|
|
||
| var keyLines []string | ||
| for _, key := range keys { | ||
| keyLines = append(keyLines, key.String()) | ||
| } | ||
| keysContent := strings.Join(keyLines, "\n") + "\n" | ||
| keysB64 := base64.StdEncoding.EncodeToString([]byte(keysContent)) | ||
|
|
||
| homeDir := sshHomeDir(user) | ||
| sshDirMode := "0700" | ||
| if user == "root" { | ||
| sshDirMode = "0750" | ||
| } | ||
|
|
||
| tmpfiles := fmt.Sprintf("d %s/.ssh %s %s %s -\nf~ %s/.ssh/authorized_keys 0600 %s %s - %s", | ||
| homeDir, sshDirMode, user, user, | ||
| homeDir, user, user, | ||
| keysB64) | ||
|
|
||
| tmpfilesB64 := base64.StdEncoding.EncodeToString([]byte(tmpfiles)) | ||
| return fmt.Sprintf("type=11,value=%stmpfiles.extra=%s", systemdCredentialPrefix, tmpfilesB64), nil | ||
| } | ||
|
|
||
| func sshHomeDir(user string) string { | ||
| if user == "root" { | ||
| return "/root" | ||
| } | ||
| return fmt.Sprintf("/var/home/%s", user) | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Copyright 2026 Red Hat | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package platform | ||
|
|
||
| import ( | ||
| "crypto/ed25519" | ||
| "crypto/rand" | ||
| "encoding/base64" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "golang.org/x/crypto/ssh" | ||
| "golang.org/x/crypto/ssh/agent" | ||
| ) | ||
|
|
||
| func TestSystemdSMBIOSSSHCredential(t *testing.T) { | ||
| _, priv, err := ed25519.GenerateKey(rand.Reader) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| signer, err := ssh.NewSignerFromKey(priv) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| pub := signer.PublicKey() | ||
| keys := []*agent.Key{{Format: pub.Type(), Blob: pub.Marshal()}} | ||
|
|
||
| val, err := SystemdSMBIOSSSHCredential("root", keys) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if !strings.HasPrefix(val, "type=11,value=io.systemd.credential.binary:tmpfiles.extra=") { | ||
| t.Fatalf("unexpected smbios value prefix: %q", val) | ||
| } | ||
|
|
||
| payloadB64 := strings.TrimPrefix(val, "type=11,value=io.systemd.credential.binary:tmpfiles.extra=") | ||
| tmpfiles, err := base64.StdEncoding.DecodeString(payloadB64) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if !strings.Contains(string(tmpfiles), "/root/.ssh") { | ||
| t.Fatalf("tmpfiles missing root ssh dir: %q", tmpfiles) | ||
| } | ||
| if !strings.Contains(string(tmpfiles), "authorized_keys") { | ||
| t.Fatalf("tmpfiles missing authorized_keys: %q", tmpfiles) | ||
| } | ||
| } | ||
|
|
||
| func TestSystemdSMBIOSSSHCredentialNoKeys(t *testing.T) { | ||
| _, err := SystemdSMBIOSSSHCredential("root", nil) | ||
| if err == nil { | ||
| t.Fatal("expected error for empty keys") | ||
| } | ||
| } |
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.
createMachine seems to already handle the case where
userdatacould benil. Would it be cleaner to instead keep using createMachine, and conditionalize whatever else is needed there on niluserdata?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.
Not sure I got the point here, but I kept createMachine and moved the Ignition vs SMBIOS split there. For bootc runs we key off
--no-ignitionrather than userdata == nil, since many normal tests pass nil userdata and still expect default Ignition. When the flag isn’t set, nil userdata still goes through RenderUserDataIfNeeded as before. Is that making sense to you? What would be another approach for this?