mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
scheduler: adds implicit constraint for secrets plugin node attributes (#26303)
This commit is contained in:
@@ -43,6 +43,7 @@ var (
|
||||
"nomad": NewNomadFingerprint,
|
||||
"plugins_cni": NewPluginsCNIFingerprint,
|
||||
"host_volume_plugins": NewPluginsHostVolumeFingerprint,
|
||||
"secrets": NewPluginsSecretsFingerprint,
|
||||
"signal": NewSignalFingerprint,
|
||||
"storage": NewStorageFingerprint,
|
||||
"vault": NewVaultFingerprint,
|
||||
|
||||
33
client/fingerprint/secrets.go
Normal file
33
client/fingerprint/secrets.go
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package fingerprint
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
)
|
||||
|
||||
type SecretsPluginFingerprint struct {
|
||||
logger hclog.Logger
|
||||
}
|
||||
|
||||
func NewPluginsSecretsFingerprint(logger hclog.Logger) Fingerprint {
|
||||
return &SecretsPluginFingerprint{
|
||||
logger: logger.Named("secrets_plugins"),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SecretsPluginFingerprint) Fingerprint(request *FingerprintRequest, response *FingerprintResponse) error {
|
||||
// Add builtin secrets providers
|
||||
response.AddAttribute("plugins.secrets.nomad.version", "1.0.0")
|
||||
response.AddAttribute("plugins.secrets.vault.version", "1.0.0")
|
||||
response.Detected = true
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SecretsPluginFingerprint) Periodic() (bool, time.Duration) {
|
||||
return false, 0
|
||||
}
|
||||
24
client/fingerprint/secrets_test.go
Normal file
24
client/fingerprint/secrets_test.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package fingerprint
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/nomad/helper/testlog"
|
||||
"github.com/shoenig/test/must"
|
||||
)
|
||||
|
||||
func TestPluginsSecretsFingerprint(t *testing.T) {
|
||||
fp := NewPluginsSecretsFingerprint(testlog.HCLogger(t))
|
||||
|
||||
resp := FingerprintResponse{}
|
||||
err := fp.Fingerprint(&FingerprintRequest{}, &resp)
|
||||
must.NoError(t, err)
|
||||
must.True(t, resp.Detected)
|
||||
must.MapContainsKeys(t, resp.Attributes, []string{
|
||||
"plugins.secrets.nomad.version",
|
||||
"plugins.secrets.vault.version",
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user