vault/command/server/config_util.go
Rachel Culpepper 254d8f8356
Vault-11623: OSS changes for seal config and env vars (#21116)
* add config changes for name and priority fields in seal stanza

* change env vars and fix tests

* add header and fix func call

* tweak limits on seals

* fix missing import

* add docstrings
2023-06-21 16:30:59 -05:00

56 lines
985 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
//go:build !enterprise
package server
import (
"errors"
"fmt"
"github.com/hashicorp/hcl/hcl/ast"
)
type entConfig struct{}
func (ec *entConfig) parseConfig(list *ast.ObjectList) error {
return nil
}
func (ec entConfig) Merge(ec2 entConfig) entConfig {
result := entConfig{}
return result
}
func (ec entConfig) Sanitized() map[string]interface{} {
return nil
}
func (c *Config) checkSealConfig() error {
if len(c.Seals) == 0 {
return nil
}
if len(c.Seals) > 2 {
return fmt.Errorf("seals: at most 2 seals can be provided: received %d", len(c.Seals))
}
disabledSeals := 0
for _, seal := range c.Seals {
if seal.Disabled {
disabledSeals++
}
}
if len(c.Seals) > 1 && disabledSeals == len(c.Seals) {
return errors.New("seals: seals provided but all are disabled")
}
if disabledSeals < len(c.Seals)-1 {
return errors.New("seals: only one seal can be enabled")
}
return nil
}