Skip to content

Commit

Permalink
Use attributes map to store os.
Browse files Browse the repository at this point in the history
Signed-off-by: Shishir Mahajan <smahajan@roblox.com>
  • Loading branch information
shishir-a412ed committed Apr 6, 2022
1 parent 9b07048 commit 3785155
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ func (v *StatValue) String() string {
type NodeListStub struct {
Address string
ID string
OS string
Attributes map[string]string
Datacenter string
Name string
NodeClass string
Expand Down
2 changes: 1 addition & 1 deletion command/node_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (c *NodeStatusCommand) Run(args []string) int {
node.Name,
node.NodeClass)
if c.os {
out[i+1] += fmt.Sprintf("|%s", node.OS)
out[i+1] += fmt.Sprintf("|%s", node.Attributes["os.name"])
}
if c.verbose {
out[i+1] += fmt.Sprintf("|%s|%s",
Expand Down
10 changes: 7 additions & 3 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2192,10 +2192,14 @@ func (n *Node) Stub(fields *NodeStubFields) *NodeListStub {

addr, _, _ := net.SplitHostPort(n.HTTPAddr)

s := &NodeListStub{
// Fetch key attributes from the main Attributes map.
s := &NodeListStub{}
s.Attributes = make(map[string]string)
s.Attributes["os.name"] = n.Attributes["os.name"]

s = &NodeListStub{
Address: addr,
ID: n.ID,
OS: n.Attributes["os.name"],
Datacenter: n.Datacenter,
Name: n.Name,
NodeClass: n.NodeClass,
Expand Down Expand Up @@ -2226,7 +2230,7 @@ func (n *Node) Stub(fields *NodeStubFields) *NodeListStub {
type NodeListStub struct {
Address string
ID string
OS string
Attributes map[string]string
Datacenter string
Name string
NodeClass string
Expand Down

0 comments on commit 3785155

Please sign in to comment.