Skip to content

Commit 06a3a62

Browse files
authored
refactor: inventory API (#101)
add service to query cluster Signed-off-by: Artur Troian <[email protected]>
1 parent ff552b7 commit 06a3a62

28 files changed

+746
-407
lines changed

buf.work.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ version: v1
22
directories:
33
- proto/node
44
- proto/provider
5+
- .cache/include
56
- vendor/github.com/cosmos/cosmos-sdk/proto
67
- vendor/github.com/cosmos/cosmos-sdk/third_party/proto
7-
- vendor/k8s.io/apimachinery/pkg/api/resource

go/inventory/v1/cluster.go

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package v1
2+
3+
func (cl *Cluster) Dup() *Cluster {
4+
res := &Cluster{
5+
Nodes: cl.Nodes.Dup(),
6+
Storage: cl.Storage.Dup(),
7+
}
8+
9+
return res
10+
}

go/inventory/v1/cluster.pb.go

+17-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/inventory/v1/cpu.go

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package v1
2+
3+
func (r *CPU) Dup() CPU {
4+
res := CPU{
5+
Quantity: r.Quantity.Dup(),
6+
Info: r.Info.Dup(),
7+
}
8+
9+
return res
10+
}
11+
12+
func (s CPUInfoS) Dup() CPUInfoS {
13+
if len(s) == 0 {
14+
return nil
15+
}
16+
17+
res := make(CPUInfoS, 0, len(s))
18+
19+
for _, n := range s {
20+
res = append(res, CPUInfo{
21+
ID: n.ID,
22+
Vendor: n.Vendor,
23+
Model: n.Model,
24+
Vcores: n.Vcores,
25+
})
26+
}
27+
28+
return res
29+
}

go/inventory/v1/cpu.pb.go

+34-32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/inventory/v1/gpu.go

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package v1
2+
3+
func (s GPUs) Dup() GPUs {
4+
if len(s) == 0 {
5+
return nil
6+
}
7+
8+
res := make(GPUs, 0, len(s))
9+
10+
for _, g := range s {
11+
res = append(res, g.Dup())
12+
}
13+
14+
return res
15+
}
16+
17+
func (r *GPU) Dup() GPU {
18+
res := GPU{
19+
Quantity: r.Quantity.Dup(),
20+
Info: r.Info.Dup(),
21+
}
22+
23+
return res
24+
}
25+
26+
func (s *GPUInfo) Dup() GPUInfo {
27+
res := GPUInfo{
28+
Vendor: s.Vendor,
29+
Name: s.Name,
30+
ModelID: s.ModelID,
31+
Interface: s.Interface,
32+
MemorySize: s.MemorySize,
33+
}
34+
35+
return res
36+
}
37+
38+
func (s GPUInfoS) Dup() GPUInfoS {
39+
if len(s) == 0 {
40+
return nil
41+
}
42+
43+
res := make(GPUInfoS, 0, len(s))
44+
45+
for _, n := range s {
46+
res = append(res, GPUInfo{
47+
Vendor: n.Vendor,
48+
Name: n.Name,
49+
ModelID: n.ModelID,
50+
Interface: n.Interface,
51+
MemorySize: n.MemorySize,
52+
})
53+
}
54+
55+
return res
56+
}

0 commit comments

Comments
 (0)