github.com/opentofu/opentofu@v1.7.1/internal/encryption/registry/registry.go (about)

     1  // Copyright (c) The OpenTofu Authors
     2  // SPDX-License-Identifier: MPL-2.0
     3  // Copyright (c) 2023 HashiCorp, Inc.
     4  // SPDX-License-Identifier: MPL-2.0
     5  
     6  package registry
     7  
     8  import (
     9  	"github.com/opentofu/opentofu/internal/encryption/keyprovider"
    10  	"github.com/opentofu/opentofu/internal/encryption/method"
    11  )
    12  
    13  // Registry collects all encryption methods and key providers
    14  type Registry interface {
    15  	// RegisterKeyProvider registers a key provider. Use the keyprovider.Any().
    16  	// This function returns a *KeyProviderAlreadyRegisteredError error if a key provider with the
    17  	// same ID is already registered.
    18  	RegisterKeyProvider(keyProvider keyprovider.Descriptor) error
    19  	// RegisterMethod registers an encryption method. Use the method.Any() function to convert your method into a
    20  	// suitable format. This function returns a *MethodAlreadyRegisteredError error if a key provider with the same ID is
    21  	// already registered.
    22  	RegisterMethod(method method.Descriptor) error
    23  
    24  	// GetKeyProviderDescriptor returns the key provider with the specified ID. If the key provider is not registered,
    25  	// it will return a *KeyProviderNotFoundError error.
    26  	GetKeyProviderDescriptor(id keyprovider.ID) (keyprovider.Descriptor, error)
    27  
    28  	// GetMethodDescriptor returns the method with the specified ID.
    29  	// If the method is not registered, it will return a *MethodNotFoundError.
    30  	GetMethodDescriptor(id method.ID) (method.Descriptor, error)
    31  }