Documentation ¶
Index ¶
- type CostEstimation
- type CostEstimationMock
- type IdentifyCloudActors
- type IdentifyCloudActorsMock
- type NLPEngine
- type NLPEngineMock
- type ResourcesCalculator
- type ResourcesCalculatorMock
- type ResourcesWriter
- type ResourcesWriterMock
- type TerraformImportMigrationGenerator
- type TerraformImportMigrationGeneratorMock
- type TerraformManagedResourcesDriftDetector
- type TerraformManagedResourcesDriftDetectorMock
- type TerraformSecurity
- type TerraformSecurityMock
- type TerraformWorkspace
- type TerraformWorkspaceMock
- type TerraformerExecutor
- type TerraformerExecutorMock
- type VCS
- type VCSMock
- func (m *VCSMock) AddChanges() error
- func (m *VCSMock) Checkout(_ string) error
- func (m *VCSMock) Clone() error
- func (m *VCSMock) Commit() error
- func (m *VCSMock) GetID() (string, error)
- func (m *VCSMock) OpenPullRequest(_ string) (string, error)
- func (m *VCSMock) Push() error
- func (m *VCSMock) SetToken()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CostEstimation ¶
type CostEstimation interface { // Execute creates structured cost estimation data for the current identified/scanned // cloud resources. Execute() error // SetInfracostAPIToken sets the Infracost API token. SetInfracostAPIToken(token string) }
CostEstimation is an interface for estimating the cost of Terraform resources.
type CostEstimationMock ¶
CostEstimationMock implements the CostEstimation interface for testing purposes.
func (*CostEstimationMock) Execute ¶
func (m *CostEstimationMock) Execute() error
Execute creates structured cost estimation data for the current identified/scanned cloud resources.
func (*CostEstimationMock) SetInfracostAPIToken ¶
func (m *CostEstimationMock) SetInfracostAPIToken(token string)
SetInfracostAPIToken sets the Infracost API token.
type IdentifyCloudActors ¶
type IdentifyCloudActors interface { // Execute creates structured query_param_data mapping new or drifted resources to the cloud actor (service principal or user) // responsible for the latest changes for that resource. Execute(ctx context.Context) error }
IdentifyCloudActors is an interface for identifying the cloud actors that have made changes to identified drifted resources.
type IdentifyCloudActorsMock ¶
IdentifyCloudActorsMock implements the IdentifyCloudActors interface for testing purposes.
type NLPEngine ¶
type NLPEngine interface { // PostNLPEngine sends a request to the NLPEngine endpoint // and saves results into local container memory. PostNLPEngine(ctx context.Context) error }
NLPEngine is the interface for communicating with the external NLPEngine API
type NLPEngineMock ¶
NLPEngineMock is a struct that implements the NLPEngine interface solely for the purpose of testing with the testify library.
type ResourcesCalculator ¶
type ResourcesCalculator interface { // Execute calculates the association between resources and a state file. Execute(ctx context.Context, workspaceToDirectory map[string]string) error }
ResourcesCalculator is the interface for determining the workspace/state file where different cloud resources should live.
type ResourcesCalculatorMock ¶
ResourcesCalculatorMock implements the ResourcesCalculator interface for testing purposes.
type ResourcesWriter ¶
type ResourcesWriter interface { // Execute writes new resources to the relevant version control system, // and returns a pull request url corresponding to the new changes. Execute(ctx context.Context, createDummyFile bool, workspaceToDirectory map[string]string) (string, error) }
ResourcesWriter is an interface for writing Terraform resource information to a version control system.
type ResourcesWriterMock ¶
ResourcesWriterMock implements the ResourcesWriter interface for testing purposes.
type TerraformImportMigrationGenerator ¶
type TerraformImportMigrationGenerator interface { // Execute generates terraform state migration statements for identified resources. Execute(ctx context.Context) error }
TerraformImportMigrationGenerator is an interface for generating terraform state migration import statements.
type TerraformImportMigrationGeneratorMock ¶
TerraformImportMigrationGeneratorMock implements the TerraformImportMigrationGenerator interface for unit testing purposes.
type TerraformManagedResourcesDriftDetector ¶
type TerraformManagedResourcesDriftDetector interface {
Execute(ctx context.Context, workspaceToDirectory map[string]string) (bool, error)
}
TerraformManagedResourcesDriftDetector is an interface that represents the methods required to detect drift in resources managed by Terraform.
type TerraformManagedResourcesDriftDetectorMock ¶
TerraformManagedResourcesDriftDetectorMock is a mock implementation of the TerraformManagedResourcesDriftDetector interface, suitable for use in unit testing.
func (*TerraformManagedResourcesDriftDetectorMock) Execute ¶
func (m *TerraformManagedResourcesDriftDetectorMock) Execute(ctx context.Context, workspaceToDirectory map[string]string) (bool, error)
Execute is a mock implementation of the Execute method in the TerraformManagedResourcesDriftDetector interface. It simulates the detection of drift in managed resources by returning an error if specified in testing time.
type TerraformSecurity ¶
TerraformSecurity is an interface to execute a scanning with tfsec or mocking the files
type TerraformSecurityMock ¶
TerraformSecurityMock is a mock for testing purposes that implements the TerraformSecurity interface
func (*TerraformSecurityMock) ExecuteScan ¶
func (m *TerraformSecurityMock) ExecuteScan(ctx context.Context) error
ExecuteScan is called from the main job flow to execute the tfsec command and save the output to show to the user in the PR
type TerraformWorkspace ¶
type TerraformWorkspace interface { FindTerraformWorkspaces(ctx context.Context) (map[string]string, error) // DownloadWorkspaceState downloads from the remote Terraform backend the latest state file // for each "workspace". DownloadWorkspaceState(ctx context.Context, WorkspaceToDirectory map[string]string) error }
TerraformWorkspace is an interface for pulling in data from remote Terraform state files.
type TerraformWorkspaceMock ¶
TerraformWorkspaceMock implements the TerraformWorkspace interface for unit testing purposes.
func (*TerraformWorkspaceMock) DownloadWorkspaceState ¶
func (m *TerraformWorkspaceMock) DownloadWorkspaceState(_ context.Context, _ map[string]string) error
DownloadWorkspaceState downloads from the remote Terraform backend the latest state file for each "workspace".
func (*TerraformWorkspaceMock) FindTerraformWorkspaces ¶
func (m *TerraformWorkspaceMock) FindTerraformWorkspaces(ctx context.Context) (map[string]string, error)
FindTerraformWorkspaces returns a map of Terraform workspace names to their respective directories.
type TerraformerExecutor ¶
type TerraformerExecutor interface { // Execute runs the workflow needed to capture the current state of an // external cloud environment via the terraformer package. Execute(ctx context.Context) error }
TerraformerExecutor is an interface for getting the current state of an external cloud by programmatically running terraformer commands.
type TerraformerExecutorMock ¶
TerraformerExecutorMock is a struct that implements the TerraformerExecutor interface for unit testing purposes.
type VCS ¶
type VCS interface { // Clone pulls a remote repository's contents into local memory. Clone() error // AddChanges adds all code changes to be included in the next commit. AddChanges() error // Checkout creates a new branch within the remote repository. Checkout(jobName string) error // Commit commits code changes to the current branch of the remote repository. Commit() error // Push pushes current branch to remote repository. Push() error // OpenPullRequest opens a new pull request of committed changes to the remote repository, // and returns the url of this pull request OpenPullRequest(jobName string) (string, error) // GetID returns a string which is a random, 10 character unique identifier // for a dragondrop built commit/pull request GetID() (string, error) SetToken() }
VCS interface for interacting with version control systems. Since all major VCS systems are git-based (GitHub, GitLab, BitBucket, etc.), they can share the same interface.
type VCSMock ¶
VCSMock implements the VCS interface solely for testing purposes.
func (*VCSMock) AddChanges ¶
AddChanges adds all code changes to be included in the next commit.
func (*VCSMock) Commit ¶
Commit commits code changes to the current branch of the remote repository.
func (*VCSMock) GetID ¶
GetID returns a string which is a random, 10 character unique identifier for a dragondrop built commit/pull request
func (*VCSMock) OpenPullRequest ¶
OpenPullRequest opens a new pull request of committed changes to the remote repository, and returns the url of this pull request