Skip to content

Add MachineID and SystemTime to remotefs.OS interface - #306

Merged
kke merged 2 commits into
mainfrom
machine-id-system-time
Apr 21, 2026
Merged

kke merged 2 commits into
mainfrom
machine-id-system-time

Conversation

@kke

@kke kke commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Moving some stuff that is generic from k0sctl to rig

Breaking rig's v2 api here is not a problem as it's not released and not in use anywhere yet.

MachineID: PosixFS reads /etc/machine-id, WinFS queries the registry
MachineGuid via Get-ItemProperty.

SystemTime: PosixFS runs date -u +%s, WinFS uses
[DateTimeOffset]::UtcNow.ToUnixTimeSeconds(). Both parse the result as
a Unix timestamp and return time.Time.

Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds host identity and clock introspection to the remotefs.OS abstraction so callers can retrieve a stable machine identifier and the remote host’s current UTC time via a common interface (Posix/Windows).

Changes:

  • Extend remotefs.OS with MachineID() and SystemTime().
  • Implement the new methods in PosixFS and WinFS using platform-appropriate commands.
  • Add unit tests covering normal and error/parse-failure cases for both platforms.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
remotefs/types.go Adds ErrEmptyMachineID and extends OS interface with MachineID + SystemTime.
remotefs/posixfs.go Implements MachineID via /etc/machine-id and SystemTime via date -u +%s.
remotefs/winfs.go Implements MachineID via registry MachineGuid and SystemTime via UtcNow.ToUnixTimeSeconds().
remotefs/hostinfo_test.go Adds tests for the new methods on both Posix and Windows mock runners.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread remotefs/posixfs.go Resolved
Comment thread remotefs/winfs.go Resolved
Comment thread remotefs/hostinfo_test.go Resolved
Comment thread remotefs/hostinfo_test.go Resolved
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kke
kke marked this pull request as ready for review April 21, 2026 08:46
@kke
kke merged commit af384a9 into main Apr 21, 2026
15 checks passed
@kke
kke deleted the machine-id-system-time branch April 21, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants