Skip to content

Commit

Permalink
Making system information payload explicit as map[string]any
Browse files Browse the repository at this point in the history
  • Loading branch information
felixsch committed Jan 15, 2025
1 parent 8568ade commit 242011d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/public-api-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func runDemo(regcode string) error {
waitForUser("Registration complete")

bold("3) System status // Ping\n")
systemInformation := map[string]string{
systemInformation := map[string]any{
"uname": "public api demo - ping",
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/registration/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ const (
)

type statusRequest struct {
Hostname string `json:"hostname"`
SystemInformation any `json:"hwinfo"`
Hostname string `json:"hostname"`
Info SystemInformation `json:"hwinfo"`
}

// Returns the registration status for the system pointed by the authorized
// connection.
func Status(conn connection.Connection, hostname string, systemInformation any) (StatusCode, error) {
func Status(conn connection.Connection, hostname string, info SystemInformation) (StatusCode, error) {
payload := statusRequest{
Hostname: hostname,
SystemInformation: systemInformation,
Hostname: hostname,
Info: info,
}

request, buildErr := conn.BuildRequest("PUT", "/connect/systems", payload)
Expand Down
2 changes: 1 addition & 1 deletion pkg/registration/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestStatusUnregistered(t *testing.T) {
func TestStatusWithSystemInformation(t *testing.T) {
assert := assert.New(t)

payload := map[string]string{
payload := map[string]any{
"key": "value",
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/registration/system_information.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package registration

// SystemInformation encapsulates any data which should be stored as system meta information.
// This can be sockets, vCPUs, memory or any other useful information.
type SystemInformation = map[string]any

0 comments on commit 242011d

Please sign in to comment.