Migrate to V2 and reuse provided token - #66
Merged
Conversation
majst01
marked this pull request as ready for review
September 3, 2026 10:42
This was referenced Sep 4, 2026
Gerrit91
reviewed
Sep 9, 2026
Gerrit91
left a comment
Contributor
There was a problem hiding this comment.
Really good. Nice to see that this seems to work!
| cs.log.Info("checking if machine is still owned by the same user", "machineID", machineID) | ||
|
|
||
| m, err := cs.client.Machine().FindMachine(machine.NewFindMachineParams().WithID(machineID), nil) | ||
| // we must use adminv2 because otherwise project must be passed which is not known here |
Contributor
There was a problem hiding this comment.
Comment is misleading because adminv2 is not always used? The project was passed and is stored in the metalv2 struct.
| Uuid: machineID, | ||
| }) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to fetch requested machine %s %w", machineID, err) |
Contributor
There was a problem hiding this comment.
Suggested change
| return nil, fmt.Errorf("failed to fetch requested machine %s %w", machineID, err) | |
| return nil, fmt.Errorf("failed to fetch requested machine %s: %w", machineID, err) |
| Project: m.project, | ||
| }) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to fetch requested machine %s %w", machineID, err) |
Contributor
There was a problem hiding this comment.
Suggested change
| return nil, fmt.Errorf("failed to fetch requested machine %s %w", machineID, err) | |
| return nil, fmt.Errorf("failed to fetch requested machine %s: %w", machineID, err) |
| func (m *metalv1) getMachine(ctx context.Context, machineID string) (*machine, error) { | ||
| resp, err := m.client.Machine().FindMachine(metalmachine.NewFindMachineParams().WithID(machineID).WithContext(ctx), nil) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to fetch requested machine %s %w", machineID, err) |
Contributor
There was a problem hiding this comment.
Suggested change
| return nil, fmt.Errorf("failed to fetch requested machine %s %w", machineID, err) | |
| return nil, fmt.Errorf("failed to fetch requested machine %s: %w", machineID, err) |
|
|
||
| func (cs *consoleServer) connectSSH(tcpConn *tls.Conn, mgmtServiceAddress, machineID string) (gossh.Conn, *gossh.Client, *gossh.Session, error) { | ||
| pubHostKey, err := loadPublicHostKey() | ||
| bb, err := os.ReadFile(cs.spec.PublicKeyFile) |
Contributor
There was a problem hiding this comment.
We should read all these files on program init in the constructor. Same for loading the certs for the metal-bmc connection.
Contributor
Author
There was a problem hiding this comment.
Yes ! done for all key files on startup
majst01
force-pushed
the
reuse-provided-token
branch
from
September 9, 2026 09:59
75ec3d1 to
27c10a2
Compare
Gerrit91
approved these changes
Sep 9, 2026
Closed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This is a major refactoring of #61 to reuse the provided token instead of using a admin token to fetch machines
Depends on:
replaces #61
Noteworthy
Used AI-Tools ✨