mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 22:34:56 -04:00
operator: fix gRPC dialing over UDS (#3201)
* operator: add test for gRPC connection over UDS
This commit is contained in:
parent
e0c5acf2f3
commit
3db3db3bf2
3 changed files with 73 additions and 7 deletions
|
@ -21,24 +21,25 @@ import (
|
|||
|
||||
// Client is a client for the upgrade agent.
|
||||
type Client struct {
|
||||
addr string
|
||||
dialer Dialer
|
||||
}
|
||||
|
||||
// NewClient creates a new upgrade agent client.
|
||||
// NewClient creates a new upgrade agent client connecting to the default upgrade-agent Unix socket.
|
||||
func NewClient() *Client {
|
||||
return newClientWithAddress(mainconstants.UpgradeAgentMountPath)
|
||||
}
|
||||
|
||||
func newClientWithAddress(addr string) *Client {
|
||||
return &Client{
|
||||
addr: "unix:" + addr,
|
||||
dialer: &net.Dialer{},
|
||||
}
|
||||
}
|
||||
|
||||
// Upgrade upgrades the Constellation node to the given Kubernetes version.
|
||||
func (c *Client) Upgrade(ctx context.Context, kubernetesComponents components.Components, WantedKubernetesVersion string) error {
|
||||
conn, err := grpc.NewClient(mainconstants.UpgradeAgentMountPath, grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
grpc.WithContextDialer(
|
||||
func(ctx context.Context, addr string) (net.Conn, error) {
|
||||
return c.dialer.DialContext(ctx, "unix", addr)
|
||||
},
|
||||
))
|
||||
conn, err := grpc.NewClient(c.addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to dial: %w", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue