opentofu/internal/encryption/method/id.go
Janos 8c99c75229
[State Encryption] Compliance tests (#1377)
Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com>
2024-03-14 15:53:40 +01:00

25 lines
613 B
Go

// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package method
import (
"fmt"
)
// ID is a type alias to make passing the wrong ID into a method ID harder.
type ID string
// Validate validates the key provider ID for correctness.
func (i ID) Validate() error {
if i == "" {
return fmt.Errorf("empty key provider ID (key provider IDs must match %s)", idRe.String())
}
if !idRe.MatchString(string(i)) {
return fmt.Errorf("invalid key provider ID: %s (must match %s)", i, idRe.String())
}
return nil
}