Skip to content

Commit

Permalink
refactor: inventory API
Browse files Browse the repository at this point in the history
add service to query cluster

Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Jan 7, 2024
1 parent ff552b7 commit bafffd5
Show file tree
Hide file tree
Showing 27 changed files with 745 additions and 406 deletions.
2 changes: 1 addition & 1 deletion buf.work.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ version: v1
directories:
- proto/node
- proto/provider
- .cache/include
- vendor/github.com/cosmos/cosmos-sdk/proto
- vendor/github.com/cosmos/cosmos-sdk/third_party/proto
- vendor/k8s.io/apimachinery/pkg/api/resource
10 changes: 10 additions & 0 deletions go/inventory/v1/cluster.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package v1

func (cl *Cluster) Dup() *Cluster {
res := &Cluster{
Nodes: cl.Nodes.Dup(),
Storage: cl.Storage.Dup(),
}

return res
}
34 changes: 17 additions & 17 deletions go/inventory/v1/cluster.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions go/inventory/v1/cpu.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package v1

func (r *CPU) Dup() CPU {
res := CPU{
Quantity: r.Quantity.Dup(),
Info: r.Info.Dup(),
}

return res
}

func (s CPUInfoS) Dup() CPUInfoS {
if len(s) == 0 {
return nil
}

res := make(CPUInfoS, 0, len(s))

for _, n := range s {
res = append(res, CPUInfo{
ID: n.ID,
Vendor: n.Vendor,
Model: n.Model,
Vcores: n.Vcores,
})
}

return res
}
66 changes: 34 additions & 32 deletions go/inventory/v1/cpu.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions go/inventory/v1/gpu.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package v1

func (s GPUs) Dup() GPUs {
if len(s) == 0 {
return nil
}

res := make(GPUs, 0, len(s))

for _, g := range s {
res = append(res, g.Dup())
}

return res
}

func (r *GPU) Dup() GPU {
res := GPU{
Quantity: r.Quantity.Dup(),
Info: r.Info.Dup(),
}

return res
}

func (s *GPUInfo) Dup() GPUInfo {
res := GPUInfo{
Vendor: s.Vendor,
Name: s.Name,
ModelID: s.ModelID,
Interface: s.Interface,
MemorySize: s.MemorySize,
}

return res
}

func (s GPUInfoS) Dup() GPUInfoS {
if len(s) == 0 {
return nil
}

res := make(GPUInfoS, 0, len(s))

for _, n := range s {
res = append(res, GPUInfo{
Vendor: n.Vendor,
Name: n.Name,
ModelID: n.ModelID,
Interface: n.Interface,
MemorySize: n.MemorySize,
})
}

return res
}
Loading

0 comments on commit bafffd5

Please sign in to comment.