interfaces

package
v0.0.0-...-7e26ddd Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

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

type CostEstimationMock struct {
	mock.Mock
}

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

type IdentifyCloudActorsMock struct {
	mock.Mock
}

IdentifyCloudActorsMock implements the IdentifyCloudActors interface for testing purposes.

func (*IdentifyCloudActorsMock) Execute

func (m *IdentifyCloudActorsMock) Execute(ctx context.Context) error

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.

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

type NLPEngineMock struct {
	mock.Mock
}

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

type ResourcesCalculatorMock struct {
	mock.Mock
}

ResourcesCalculatorMock implements the ResourcesCalculator interface for testing purposes.

func (*ResourcesCalculatorMock) Execute

Execute calculates the association between resources and a state file.

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

type ResourcesWriterMock struct {
	mock.Mock
}

ResourcesWriterMock implements the ResourcesWriter interface for testing purposes.

func (*ResourcesWriterMock) Execute

func (m *ResourcesWriterMock) Execute(_ context.Context, _ bool, _ map[string]string) (string, error)

Execute writes new resources to the relevant version control system, and returns a pull request url corresponding to the new changes.

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

type TerraformImportMigrationGeneratorMock struct {
	mock.Mock
}

TerraformImportMigrationGeneratorMock implements the TerraformImportMigrationGenerator interface for unit testing purposes.

func (*TerraformImportMigrationGeneratorMock) Execute

Execute generates terraform state migration statements for identified resources.

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

type TerraformManagedResourcesDriftDetectorMock struct {
	mock.Mock
}

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

type TerraformSecurity interface {
	ExecuteScan(ctx context.Context) error
}

TerraformSecurity is an interface to execute a scanning with tfsec or mocking the files

type TerraformSecurityMock

type TerraformSecurityMock struct {
	mock.Mock
}

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

type TerraformWorkspaceMock struct {
	mock.Mock
}

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

type TerraformerExecutorMock struct {
	mock.Mock
}

TerraformerExecutorMock is a struct that implements the TerraformerExecutor interface for unit testing purposes.

func (*TerraformerExecutorMock) Execute

Execute runs the workflow needed to capture the current state of an external cloud environment via the terraformer package.

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

type VCSMock struct {
	mock.Mock
}

VCSMock implements the VCS interface solely for testing purposes.

func (*VCSMock) AddChanges

func (m *VCSMock) AddChanges() error

AddChanges adds all code changes to be included in the next commit.

func (*VCSMock) Checkout

func (m *VCSMock) Checkout(_ string) error

Checkout creates a new branch within the remote repository.

func (*VCSMock) Clone

func (m *VCSMock) Clone() error

Clone pulls a remote repository's contents into local memory.

func (*VCSMock) Commit

func (m *VCSMock) Commit() error

Commit commits code changes to the current branch of the remote repository.

func (*VCSMock) GetID

func (m *VCSMock) GetID() (string, error)

GetID returns a string which is a random, 10 character unique identifier for a dragondrop built commit/pull request

func (*VCSMock) OpenPullRequest

func (m *VCSMock) OpenPullRequest(_ string) (string, error)

OpenPullRequest opens a new pull request of committed changes to the remote repository, and returns the url of this pull request

func (*VCSMock) Push

func (m *VCSMock) Push() error

Push pushes current branch to remote repository.

func (*VCSMock) SetToken

func (m *VCSMock) SetToken()

SetToken sets the token for the VCS

Jump to

Keyboard shortcuts

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