Skip to content

Commit db8003e

Browse files
committed
Merge main
2 parents 25b351c + d0a2fcb commit db8003e

File tree

22 files changed

+775
-622
lines changed

22 files changed

+775
-622
lines changed

doc/index.html

Lines changed: 76 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,10 @@ <h2>Table of Contents</h2>
14721472
<a href="#metalstack.api.v2.SwitchQuery"><span class="badge">M</span>SwitchQuery</a>
14731473
</li>
14741474

1475+
<li>
1476+
<a href="#metalstack.api.v2.SwitchSync"><span class="badge">M</span>SwitchSync</a>
1477+
</li>
1478+
14751479

14761480
<li>
14771481
<a href="#metalstack.api.v2.BGPState"><span class="badge">E</span>BGPState</a>
@@ -2077,11 +2081,11 @@ <h2>Table of Contents</h2>
20772081
</li>
20782082

20792083
<li>
2080-
<a href="#metalstack.infra.v2.WaitForMachineEventRequest"><span class="badge">M</span>WaitForMachineEventRequest</a>
2084+
<a href="#metalstack.infra.v2.WaitForBMCCommandRequest"><span class="badge">M</span>WaitForBMCCommandRequest</a>
20812085
</li>
20822086

20832087
<li>
2084-
<a href="#metalstack.infra.v2.WaitForMachineEventResponse"><span class="badge">M</span>WaitForMachineEventResponse</a>
2088+
<a href="#metalstack.infra.v2.WaitForBMCCommandResponse"><span class="badge">M</span>WaitForBMCCommandResponse</a>
20852089
</li>
20862090

20872091

@@ -2229,10 +2233,6 @@ <h2>Table of Contents</h2>
22292233
<a href="#metalstack.infra.v2.SwitchServiceRegisterResponse"><span class="badge">M</span>SwitchServiceRegisterResponse</a>
22302234
</li>
22312235

2232-
<li>
2233-
<a href="#metalstack.infra.v2.SwitchSync"><span class="badge">M</span>SwitchSync</a>
2234-
</li>
2235-
22362236

22372237

22382238

@@ -12498,6 +12498,20 @@ <h3 id="metalstack.api.v2.Switch">Switch</h3>
1249812498
<td><p>MachineConnections map machines to the nics they are connected to. </p></td>
1249912499
</tr>
1250012500

12501+
<tr>
12502+
<td>last_sync</td>
12503+
<td><a href="#metalstack.api.v2.SwitchSync">SwitchSync</a></td>
12504+
<td></td>
12505+
<td><p>LastSync contains information about the last heartbeat of the switch. </p></td>
12506+
</tr>
12507+
12508+
<tr>
12509+
<td>last_sync_error</td>
12510+
<td><a href="#metalstack.api.v2.SwitchSync">SwitchSync</a></td>
12511+
<td></td>
12512+
<td><p>LastSyncError contains information about the last unsuccessful heartbeat of the switch. </p></td>
12513+
</tr>
12514+
1250112515
</tbody>
1250212516
</table>
1250312517

@@ -12751,6 +12765,44 @@ <h3 id="metalstack.api.v2.SwitchQuery">SwitchQuery</h3>
1275112765

1275212766

1275312767

12768+
<h3 id="metalstack.api.v2.SwitchSync">SwitchSync</h3>
12769+
<p>SwitchSync summarizes information about a switch sync.</p>
12770+
12771+
12772+
<table class="field-table">
12773+
<thead>
12774+
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
12775+
</thead>
12776+
<tbody>
12777+
12778+
<tr>
12779+
<td>time</td>
12780+
<td><a href="#google.protobuf.Timestamp">google.protobuf.Timestamp</a></td>
12781+
<td></td>
12782+
<td><p>Time of the sync. </p></td>
12783+
</tr>
12784+
12785+
<tr>
12786+
<td>duration</td>
12787+
<td><a href="#google.protobuf.Duration">google.protobuf.Duration</a></td>
12788+
<td></td>
12789+
<td><p>Duration of the sync. </p></td>
12790+
</tr>
12791+
12792+
<tr>
12793+
<td>error</td>
12794+
<td><a href="#string">string</a></td>
12795+
<td>optional</td>
12796+
<td><p>Error if any occurred. </p></td>
12797+
</tr>
12798+
12799+
</tbody>
12800+
</table>
12801+
12802+
12803+
12804+
12805+
1275412806

1275512807

1275612808
<h3 id="metalstack.api.v2.BGPState">BGPState</h3>
@@ -16731,8 +16783,8 @@ <h3 id="metalstack.infra.v2.UpdateBMCInfoResponse">UpdateBMCInfoResponse</h3>
1673116783

1673216784

1673316785

16734-
<h3 id="metalstack.infra.v2.WaitForMachineEventRequest">WaitForMachineEventRequest</h3>
16735-
<p>WaitForMachineEventRequest</p>
16786+
<h3 id="metalstack.infra.v2.WaitForBMCCommandRequest">WaitForBMCCommandRequest</h3>
16787+
<p>WaitForBMCCommandRequest</p>
1673616788

1673716789

1673816790
<table class="field-table">
@@ -16745,14 +16797,7 @@ <h3 id="metalstack.infra.v2.WaitForMachineEventRequest">WaitForMachineEventReque
1674516797
<td>partition</td>
1674616798
<td><a href="#string">string</a></td>
1674716799
<td></td>
16748-
<td><p>Partition the partition id where metal-bmc wants to receive events </p></td>
16749-
</tr>
16750-
16751-
<tr>
16752-
<td>hostname</td>
16753-
<td><a href="#string">string</a></td>
16754-
<td></td>
16755-
<td><p>Hostname should be set to the senders hostname, e.g. from the server metal-bmc is running on. </p></td>
16800+
<td><p>Partition the partition id where metal-bmc wants to receive bmc commands </p></td>
1675616801
</tr>
1675716802

1675816803
</tbody>
@@ -16762,8 +16807,8 @@ <h3 id="metalstack.infra.v2.WaitForMachineEventRequest">WaitForMachineEventReque
1676216807

1676316808

1676416809

16765-
<h3 id="metalstack.infra.v2.WaitForMachineEventResponse">WaitForMachineEventResponse</h3>
16766-
<p>WaitForMachineEventResponse</p>
16810+
<h3 id="metalstack.infra.v2.WaitForBMCCommandResponse">WaitForBMCCommandResponse</h3>
16811+
<p>WaitForBMCCommandResponse</p>
1676716812

1676816813

1676916814
<table class="field-table">
@@ -16772,6 +16817,13 @@ <h3 id="metalstack.infra.v2.WaitForMachineEventResponse">WaitForMachineEventResp
1677216817
</thead>
1677316818
<tbody>
1677416819

16820+
<tr>
16821+
<td>uuid</td>
16822+
<td><a href="#string">string</a></td>
16823+
<td></td>
16824+
<td><p>UUID of the machine to send the command to </p></td>
16825+
</tr>
16826+
1677516827
<tr>
1677616828
<td>bmc_command</td>
1677716829
<td><a href="#metalstack.api.v2.MachineBMCCommand">metalstack.api.v2.MachineBMCCommand</a></td>
@@ -16815,10 +16867,10 @@ <h3 id="metalstack.infra.v2.BMCService">BMCService</h3>
1681516867
</tr>
1681616868

1681716869
<tr>
16818-
<td>WaitForMachineEvent</td>
16819-
<td><a href="#metalstack.infra.v2.WaitForMachineEventRequest">WaitForMachineEventRequest</a></td>
16820-
<td><a href="#metalstack.infra.v2.WaitForMachineEventResponse">WaitForMachineEventResponse</a> stream</td>
16821-
<td><p>WaitForMachineEvent is called by the metal-bmc and is returned with a bmc command to execute.</p></td>
16870+
<td>WaitForBMCCommand</td>
16871+
<td><a href="#metalstack.infra.v2.WaitForBMCCommandRequest">WaitForBMCCommandRequest</a></td>
16872+
<td><a href="#metalstack.infra.v2.WaitForBMCCommandResponse">WaitForBMCCommandResponse</a> stream</td>
16873+
<td><p>WaitForBMCCommand is called by the metal-bmc and is returned with a bmc command to execute.</p></td>
1682216874
</tr>
1682316875

1682416876
</tbody>
@@ -17695,14 +17747,14 @@ <h3 id="metalstack.infra.v2.SwitchServiceHeartbeatResponse">SwitchServiceHeartbe
1769517747

1769617748
<tr>
1769717749
<td>last_sync</td>
17698-
<td><a href="#metalstack.infra.v2.SwitchSync">SwitchSync</a></td>
17750+
<td><a href="#metalstack.api.v2.SwitchSync">metalstack.api.v2.SwitchSync</a></td>
1769917751
<td></td>
1770017752
<td><p>LastSync holds information about the last sync. </p></td>
1770117753
</tr>
1770217754

1770317755
<tr>
1770417756
<td>last_sync_error</td>
17705-
<td><a href="#metalstack.infra.v2.SwitchSync">SwitchSync</a></td>
17757+
<td><a href="#metalstack.api.v2.SwitchSync">metalstack.api.v2.SwitchSync</a></td>
1770617758
<td></td>
1770717759
<td><p>LastSyncError holds information about the last erroneous sync. </p></td>
1770817760
</tr>
@@ -17762,44 +17814,6 @@ <h3 id="metalstack.infra.v2.SwitchServiceRegisterResponse">SwitchServiceRegister
1776217814

1776317815

1776417816

17765-
<h3 id="metalstack.infra.v2.SwitchSync">SwitchSync</h3>
17766-
<p>SwitchSync summarizes information about a switch sync.</p>
17767-
17768-
17769-
<table class="field-table">
17770-
<thead>
17771-
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
17772-
</thead>
17773-
<tbody>
17774-
17775-
<tr>
17776-
<td>time</td>
17777-
<td><a href="#google.protobuf.Timestamp">google.protobuf.Timestamp</a></td>
17778-
<td></td>
17779-
<td><p>Time of the sync. </p></td>
17780-
</tr>
17781-
17782-
<tr>
17783-
<td>duration</td>
17784-
<td><a href="#google.protobuf.Duration">google.protobuf.Duration</a></td>
17785-
<td></td>
17786-
<td><p>Duration of the sync. </p></td>
17787-
</tr>
17788-
17789-
<tr>
17790-
<td>error</td>
17791-
<td><a href="#string">string</a></td>
17792-
<td>optional</td>
17793-
<td><p>Error if any occurred. </p></td>
17794-
</tr>
17795-
17796-
</tbody>
17797-
</table>
17798-
17799-
17800-
17801-
17802-
1780317817

1780417818

1780517819

generate/go_client.tpl

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
package client
33

44
import (
5-
"context"
65
"sync"
76

87
"connectrpc.com/connect"
@@ -53,33 +52,17 @@ func New(config *DialConfig) (Client, error) {
5352
interceptors: []connect.Interceptor{},
5453
}
5554

56-
authInterceptor := connect.UnaryInterceptorFunc(func(next connect.UnaryFunc) connect.UnaryFunc {
57-
return connect.UnaryFunc(func(ctx context.Context, request connect.AnyRequest) (connect.AnyResponse, error) {
58-
request.Header().Add("Authorization", "Bearer "+config.Token)
59-
return next(ctx, request)
60-
})
61-
})
62-
63-
loggingInterceptor := connect.UnaryInterceptorFunc(func(next connect.UnaryFunc) connect.UnaryFunc {
64-
return connect.UnaryFunc(func(ctx context.Context, request connect.AnyRequest) (connect.AnyResponse, error) {
65-
config.Log.Debug("intercept", "request procedure", request.Spec().Procedure, "body", request.Any())
66-
response, err := next(ctx, request)
67-
if err != nil {
68-
return nil, err
69-
}
70-
config.Log.Debug("intercept", "request procedure", request.Spec().Procedure, "response", response.Any())
71-
return response, err
72-
})
73-
})
74-
7555
if config.Token != "" {
56+
authInterceptor := &authInterceptor{config: config}
7657
c.interceptors = append(c.interceptors, authInterceptor)
7758
}
7859
if config.Log != nil {
60+
loggingInterceptor := &loggingInterceptor{config: config}
7961
c.interceptors = append(c.interceptors, loggingInterceptor)
8062
}
8163
c.interceptors = append(c.interceptors, config.Interceptors...)
8264

65+
// TODO convert to interceptor
8366
go c.startTokenRenewal()
8467

8568
return c, nil

go/client/client-interceptors.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package client
2+
3+
import (
4+
"context"
5+
6+
"connectrpc.com/connect"
7+
)
8+
9+
// authinterceptor adds the required auth headers
10+
type authInterceptor struct {
11+
config *DialConfig
12+
}
13+
14+
func (i *authInterceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc {
15+
return connect.UnaryFunc(func(ctx context.Context, request connect.AnyRequest) (connect.AnyResponse, error) {
16+
request.Header().Add("Authorization", "Bearer "+i.config.Token)
17+
return next(ctx, request)
18+
})
19+
}
20+
21+
func (i *authInterceptor) WrapStreamingClient(next connect.StreamingClientFunc) connect.StreamingClientFunc {
22+
return func(ctx context.Context, spec connect.Spec) connect.StreamingClientConn {
23+
return &streamingInterceptorConn{
24+
StreamingClientConn: next(ctx, spec),
25+
token: i.config.Token,
26+
}
27+
}
28+
}
29+
30+
func (i *authInterceptor) WrapStreamingHandler(next connect.StreamingHandlerFunc) connect.StreamingHandlerFunc {
31+
return next
32+
}
33+
34+
type streamingInterceptorConn struct {
35+
connect.StreamingClientConn
36+
token string
37+
}
38+
39+
func (conn *streamingInterceptorConn) Send(m any) error {
40+
conn.RequestHeader().Add("Authorization", "Bearer "+conn.token)
41+
return conn.StreamingClientConn.Send(m)
42+
}
43+
44+
type loggingInterceptor struct {
45+
config *DialConfig
46+
}
47+
48+
func (i *loggingInterceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc {
49+
return connect.UnaryFunc(func(ctx context.Context, request connect.AnyRequest) (connect.AnyResponse, error) {
50+
i.config.Log.Debug("intercept", "request procedure", request.Spec().Procedure, "body", request.Any())
51+
response, err := next(ctx, request)
52+
if err != nil {
53+
return nil, err
54+
}
55+
i.config.Log.Debug("intercept", "request procedure", request.Spec().Procedure, "response", response.Any())
56+
return response, err
57+
})
58+
}
59+
60+
func (i *loggingInterceptor) WrapStreamingClient(next connect.StreamingClientFunc) connect.StreamingClientFunc {
61+
// TODO also log here
62+
return next
63+
}
64+
65+
func (i *loggingInterceptor) WrapStreamingHandler(next connect.StreamingHandlerFunc) connect.StreamingHandlerFunc {
66+
return next
67+
}

go/client/client.go

Lines changed: 3 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)