vault/command/server/config_util.go

56 lines
1,001 B
Go
Raw Normal View History

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
//go:build !enterprise
2020-02-14 19:39:13 -05:00
package server
import (
"errors"
"fmt"
"github.com/hashicorp/hcl/hcl/ast"
)
type entConfig struct{}
2020-02-14 19:39:13 -05:00
func (ec *entConfig) parseConfig(list *ast.ObjectList, source string) error {
2020-02-14 19:39:13 -05:00
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
}