github.com/opentofu/opentofu@v1.7.1/internal/moduledeps/dependencies.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 moduledeps
     7  
     8  import (
     9  	"github.com/opentofu/opentofu/internal/addrs"
    10  	"github.com/opentofu/opentofu/internal/plugin/discovery"
    11  )
    12  
    13  // Providers describes a set of provider dependencies for a given module.
    14  //
    15  // Each named provider instance can have one version constraint.
    16  type Providers map[addrs.Provider]ProviderDependency
    17  
    18  // ProviderDependency describes the dependency for a particular provider
    19  // instance, including both the set of allowed versions and the reason for
    20  // the dependency.
    21  type ProviderDependency struct {
    22  	Constraints discovery.Constraints
    23  	Reason      ProviderDependencyReason
    24  }
    25  
    26  // ProviderDependencyReason is an enumeration of reasons why a dependency might be
    27  // present.
    28  type ProviderDependencyReason int
    29  
    30  const (
    31  	// ProviderDependencyExplicit means that there is an explicit "provider"
    32  	// block in the configuration for this module.
    33  	ProviderDependencyExplicit ProviderDependencyReason = iota
    34  
    35  	// ProviderDependencyImplicit means that there is no explicit "provider"
    36  	// block but there is at least one resource that uses this provider.
    37  	ProviderDependencyImplicit
    38  
    39  	// ProviderDependencyInherited is a special case of
    40  	// ProviderDependencyImplicit where a parent module has defined a
    41  	// configuration for the provider that has been inherited by at least one
    42  	// resource in this module.
    43  	ProviderDependencyInherited
    44  
    45  	// ProviderDependencyFromState means that this provider is not currently
    46  	// referenced by configuration at all, but some existing instances in
    47  	// the state still depend on it.
    48  	ProviderDependencyFromState
    49  )