Files
nomad/client/identity.go
James Rasell 8096ea4129 client: Handle identities from servers and use for RPC auth. (#26218)
Nomad servers, if upgraded, can return node identities as part of
the register and update/heartbeat response objects. The Nomad
client will now handle this and store it as appropriate within its
memory and statedb.

The client will now use any stored identity for RPC authentication
with a fallback to the secretID. This supports upgrades paths where
the Nomad clients are updated before the Nomad servers.
2025-07-14 14:24:43 +01:00

22 lines
770 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package client
// NodeIdentityHandler is an interface that allows setting a node identity
// token. The client uses this to inform its subsystems about a new node
// identity that it should use for RPC calls.
type NodeIdentityHandler interface {
SetNodeIdentityToken(token string)
}
// assertAndSetNodeIdentityToken expects the passed interface implements
// NodeIdentityHandler and calls SetNodeIdentityToken. It is a programming error
// if the interface does not implement NodeIdentityHandler and will panic. The
// test file performs test assertions.
func assertAndSetNodeIdentityToken(impl any, token string) {
if impl != nil {
impl.(NodeIdentityHandler).SetNodeIdentityToken(token)
}
}