testhelpers

package module
v0.0.0-...-fcf4a08 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CloudflareZoneID string = "8a48b990c00669d41f08e99c184f43dc"
)
View Source
const (
	SSMParameterCloudflareAuthToken string = "TF_CLOUDFLARE_API_TOKEN"
)

Variables

This section is empty.

Functions

func AwsProviderVersionsTest

func AwsProviderVersionsTest(t *testing.T, srcDir string, variables map[string]interface{}, environment_variables map[string]string)

func CloudflareProviderVersionsTest

func CloudflareProviderVersionsTest(t *testing.T, srcDir string, variables map[string]interface{}, environment_variables map[string]string)

func DownloadProviderVersion

func DownloadProviderVersion(t *testing.T, version string, sourceAddress string, providerName string) string

DownloadProviderVersion will download the specified version of provider into the ~/.terraform.d/plugin-cache directory.

Usage: * version is the version of provider to download. * sourceAddress is the sourceAddress of provider to download. * providerName is the name of provider to download.

func DownloadProviderVersionE

func DownloadProviderVersionE(version string, sourceAddress string, providerName string) (binaryPath string, err error)

DownloadProviderVersionE will download the specified version of the provider into the ~/.terraform.d/plugin-cache directory Usage: * version is the version of provider to download. * sourceAddress is the sourceAddress of provider to download. * providerName is the name of provider to download.

func DownloadRequiredProviders

func DownloadRequiredProviders(t *testing.T, srcDir string, provider string)

DownloadRequiredProviders will download the specified version of provider into the ~/.terraform.d/plugin-cache directory.

Usage: * provider is the name of provider to download.

func DownloadTerraformVersion

func DownloadTerraformVersion(t *testing.T, version string) string

DownloadTerraformVersion will download the specified version of Terraform into the ~/.terraform.versions directory.

Usage: * version is the version of Terraform to download.

func DownloadTerraformVersionE

func DownloadTerraformVersionE(version string) (binaryPath string, err error)

DownloadTerraformVersionE will download the specified version of Terraform into the ~/.terraform.versions directory

Usage: * version is the version of Terraform to download.

func GetAvailableVersions

func GetAvailableVersions(t *testing.T, release string) []string

GetAvailableVersions returns all the released versions of a provider or the Terraform binary or fails the test if something goes wrong

func GetAvailableVersionsE

func GetAvailableVersionsE(release string) ([]string, error)

GetAvailableVersionsE returns all of the versions available for the given provider or the Terraform binary, or returns an error if something goes wrong

func GetBinaryPath

func GetBinaryPath() (cachePath string)

GetBinaryPath will return the cache path required to store the provider cache

Usage: * cachePath is the path required to store the provider cache

func GetBinaryUrl

func GetBinaryUrl(version string, providerName string) (string, error)

GetBinaryUrlE will return the correct download URL for the provider binary version requested based on the operating system and architecture by fetching it from the Hashicorp releases API

Usage: * version is the version of provider to download.

func GetEcrRepository

func GetEcrRepository(t *testing.T, name string) ecrTypes.Repository

GetEcrRepository returns the given ECR repository

func GetMatchingVersions

func GetMatchingVersions(t *testing.T, constraint string, versions []string) []string

GetMatchingVersions returns a slice of all the given versions that meet the given constraint or fails the test if something goes wrong

func GetMatchingVersionsE

func GetMatchingVersionsE(constraint string, versions []string) ([]string, error)

GetMatchingVersionsE returns a slice of the matching version strings that meet the constraint criteria given, or an error if something goes wrong

func GetProviderConstraint

func GetProviderConstraint(t *testing.T, srcDir, provider string) string

GetProviderConstraint returns the version string for the given provider or fails the test if the provider is not found

func GetProviderConstraintE

func GetProviderConstraintE(srcDir, provider string) (string, error)

GetProviderConstraintE returns the version string for the given provider or an error if the provider cannot be found

func GetSourceAddress

func GetSourceAddress(t *testing.T, srcDir, provider string) string

GetSourceAddress returns the source string for the given provider or fails the test if the provider is not found Usage: * provider is the name of provider to download.

func GetSourceAddressE

func GetSourceAddressE(srcDir, provider string, attrribute string) (string, error)

GetSourceAddressE returns the source string for the given provider or an error if the provider cannot be found Usage: * attrribute is the name of attrribute to return.

func GetSsmParameter

func GetSsmParameter(t *testing.T, name string) string

GetSsmParameter returns the value of the given parameter as stored in SSM Parameter Store. It will fail the test if a parameter is not found.

func GetTerraformBinaryUrlE

func GetTerraformBinaryUrlE(version string) (string, error)

GetTerraformBinaryUrlE will return the correct download URL for the terraform binary version requested based on the operating system and architecture by fetching it from the Hashicorp releases API

Usage: * version is the version of Terraform to download.

func GetTerraformVersionConstraint

func GetTerraformVersionConstraint(t *testing.T, srcDir string) string

GetTerraformVersionConstraint returns the Terraform version string for the given module or fails the test if the version is not found

func GetTerraformVersionConstraintE

func GetTerraformVersionConstraintE(srcDir string) (string, error)

GetTerraformVersionConstraintE returns the Terraform version string for the given module or an error if the provider cannot be found

func IterateTerraformInDirectory

func IterateTerraformInDirectory(dir string, fn func(filename string, f *hclwrite.File) error) error

IterateTerraformInDirectory will iterate over the files in a directory, running the callback function for every Terraform file found.

func TerraformVersionsTest

func TerraformVersionsTest(t *testing.T, srcDir string, variables map[string]interface{}, environment_variables map[string]string)

func UpdateModuleSourceAndVersion

func UpdateModuleSourceAndVersion(t *testing.T, srcDir, module, src, ver string)

UpdateModuleSourceAndVersion will update the specified modules source and version with the given values.

Usage:

  • t is the test runner instance.
  • srcDir is the directory that contains the Terraform source files to update.
  • module is the name of the module block to update. Use "*" as a wildcard to update all modules
  • src is the new source to update the module to
  • ver is the new version to update the module to. Use "" to remove the version string.

func UpdateModuleSourceAndVersionE

func UpdateModuleSourceAndVersionE(srcDir, module, src, ver string) error

UpdateModuleSourceAndVersionE will update the specified modules source and version with the given values.

Usage:

  • srcDir is the directory that contains the Terraform source files to update.
  • module is the name of the module block to update. Use "*" as a wildcard to update all modules
  • src is the new source to update the module to
  • ver is the new version to update the module to. Use "" to remove the version string.

func UpdateModuleSourceToAbsolutePath

func UpdateModuleSourceToAbsolutePath(t *testing.T, srcDir, module, path string)

UpdateModuleSourceToAbsolutePath will update the specified modules source to the given path by turning it into an absolute path to enable testing examples by changing the repository location from the remote source to the given local one with changes.

Usage:

  • t is the test runner instance.
  • srcDir is the directory that contains the Terraform source files to update.
  • module is the name of the module block to update. Use "*" as a wildcard to update all modules
  • path is the relative path to update the module source argument to

func UpdateModuleSourceToPath

func UpdateModuleSourceToPath(t *testing.T, srcDir, module, path string)

UpdateModuleSourceToPath will update the specified modules source to the given path to enable testing examples by changing the repository location from the remote source to the given local one with changes.

Usage:

  • t is the test runner instance.
  • srcDir is the directory that contains the Terraform source files to update.
  • module is the name of the module block to update. Use "*" as a wildcard to update all modules
  • path is the relative path to update the module source argument to

func UpdateModuleSourceToPathE

func UpdateModuleSourceToPathE(srcDir, module, path string) error

UpdateModuleSourceToPathE will update the specified modules source to the given path to enable testing examples by changing the repository location from the remote source to the given local one with changes. It will return an error if unable to do so.

Usage:

  • srcDir is the directory that contains the Terraform source files to update.
  • module is the name of the module block to update. Use "*" as a wildcard to update all modules
  • path is the relative path to update the module source argument to

func UpdateModuleSourcesToLocalPaths

func UpdateModuleSourcesToLocalPaths(t *testing.T, dst string)

func UpdateProviderVersion

func UpdateProviderVersion(t *testing.T, dir, provider, version string, providerSource string)

UpdateProviderVersion will update the specified provider's version with the given value.

Usage: * dir is the directory that contains the Terraform source files to update. * provider is the name of the provider to update. * version is the new version to update the provider to. * providerSource is the source of the provider being tested.

func UpdateProviderVersionE

func UpdateProviderVersionE(dir, provider, version string, providerSource string) error

UpdateProviderVersionE will update the specified provider's version with the given value.

Usage: * dir is the directory that contains the Terraform source files to update. * provider is the name of the provider to update. * version is the new version to update the provider to. * providerSource is the source of the provider being tested.

Types

type ModuleMetadata

type ModuleMetadata struct {
	Organisation string
	Name         string
	Provider     string
	LocalPath    string
}

type ModuleMetadataCatalog

type ModuleMetadataCatalog struct {
	Meta []ModuleMetadata
	// contains filtered or unexported fields
}

func GetModuleMetadataCatalog

func GetModuleMetadataCatalog() (*ModuleMetadataCatalog, error)

func (*ModuleMetadataCatalog) Init

func (mmc *ModuleMetadataCatalog) Init() error

func (*ModuleMetadataCatalog) Resolve

func (mmc *ModuleMetadataCatalog) Resolve(src string) (string, bool)

func (*ModuleMetadataCatalog) SetRoot

func (mmc *ModuleMetadataCatalog) SetRoot(root string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL