moduleregistry

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MPL-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package moduleregistry package

Index

Constants

View Source
const (
	// IntotoPayloadType is the type identifier for the in-toto format
	IntotoPayloadType = "application/vnd.in-toto+json"
	// MaxModuleAttestationSize is the max size in bytes for a module attestation
	MaxModuleAttestationSize = 1024 * 10
)

Variables

View Source
var (
	// SupportedIntotoStatementTypes contains a list of in-toto statement types that are
	// supported for module attestations
	SupportedIntotoStatementTypes = []string{"https://in-toto.io/Statement/v0.1"}
)

Functions

This section is empty.

Types

type CreateModuleAttestationInput

type CreateModuleAttestationInput struct {
	ModuleID        string
	Description     string
	AttestationData string
}

CreateModuleAttestationInput is the input for creating a terraform module attestation

type CreateModuleInput

type CreateModuleInput struct {
	Name          string
	System        string
	GroupID       string
	RepositoryURL string
	Private       bool
}

CreateModuleInput is the input for creating a terraform module

type CreateModuleVersionInput

type CreateModuleVersionInput struct {
	SemanticVersion string
	ModuleID        string
	SHASum          []byte
}

CreateModuleVersionInput is the input for creating a terraform module version

type GetModuleAttestationsInput

type GetModuleAttestationsInput struct {
	Sort              *db.TerraformModuleAttestationSortableField
	PaginationOptions *pagination.Options
	Digest            *string
	ModuleID          string
}

GetModuleAttestationsInput is the input for getting a list of module attestations

type GetModuleVersionsInput

type GetModuleVersionsInput struct {
	Sort              *db.TerraformModuleVersionSortableField
	PaginationOptions *pagination.Options
	Status            *models.TerraformModuleVersionStatus
	SemanticVersion   *string
	Latest            *bool
	ModuleID          string
}

GetModuleVersionsInput is the input for getting a list of module versions

type GetModulesInput

type GetModulesInput struct {
	// Sort specifies the field to sort on and direction
	Sort *db.TerraformModuleSortableField
	// PaginationOptions supports cursor based pagination
	PaginationOptions *pagination.Options
	// Group filters modules be the specified group
	Group *models.Group
	// Search filters module list by modules with a name that contains the search query
	Search *string
}

GetModulesInput is the input for getting a list of terraform modules

type MockRegistryStore

type MockRegistryStore struct {
	mock.Mock
}

MockRegistryStore is an autogenerated mock type for the RegistryStore type

func NewMockRegistryStore

func NewMockRegistryStore(t mockConstructorTestingTNewMockRegistryStore) *MockRegistryStore

NewMockRegistryStore creates a new instance of MockRegistryStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockRegistryStore) DownloadModulePackage

func (_m *MockRegistryStore) DownloadModulePackage(ctx context.Context, moduleVersion *models.TerraformModuleVersion, module *models.TerraformModule, writer io.WriterAt) error

DownloadModulePackage provides a mock function with given fields: ctx, moduleVersion, module, writer

func (*MockRegistryStore) GetModuleConfigurationDetails

func (_m *MockRegistryStore) GetModuleConfigurationDetails(ctx context.Context, moduleVersion *models.TerraformModuleVersion, module *models.TerraformModule, path string) (io.ReadCloser, error)

GetModuleConfigurationDetails provides a mock function with given fields: ctx, moduleVersion, module, path

func (*MockRegistryStore) GetModulePackagePresignedURL

func (_m *MockRegistryStore) GetModulePackagePresignedURL(ctx context.Context, moduleVersion *models.TerraformModuleVersion, module *models.TerraformModule) (string, error)

GetModulePackagePresignedURL provides a mock function with given fields: ctx, moduleVersion, module

func (*MockRegistryStore) UploadModuleConfigurationDetails

func (_m *MockRegistryStore) UploadModuleConfigurationDetails(ctx context.Context, metadata *ModuleConfigurationDetails, moduleVersion *models.TerraformModuleVersion, module *models.TerraformModule) error

UploadModuleConfigurationDetails provides a mock function with given fields: ctx, metadata, moduleVersion, module

func (*MockRegistryStore) UploadModulePackage

func (_m *MockRegistryStore) UploadModulePackage(ctx context.Context, moduleVersion *models.TerraformModuleVersion, module *models.TerraformModule, body io.Reader) error

UploadModulePackage provides a mock function with given fields: ctx, moduleVersion, module, body

type MockService

type MockService struct {
	mock.Mock
}

MockService is an autogenerated mock type for the Service type

func NewMockService

func NewMockService(t mockConstructorTestingTNewMockService) *MockService

NewMockService creates a new instance of MockService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockService) CreateModule

func (_m *MockService) CreateModule(ctx context.Context, input *CreateModuleInput) (*models.TerraformModule, error)

CreateModule provides a mock function with given fields: ctx, input

func (*MockService) CreateModuleAttestation

func (_m *MockService) CreateModuleAttestation(ctx context.Context, input *CreateModuleAttestationInput) (*models.TerraformModuleAttestation, error)

CreateModuleAttestation provides a mock function with given fields: ctx, input

func (*MockService) CreateModuleVersion

func (_m *MockService) CreateModuleVersion(ctx context.Context, input *CreateModuleVersionInput) (*models.TerraformModuleVersion, error)

CreateModuleVersion provides a mock function with given fields: ctx, input

func (*MockService) DeleteModule

func (_m *MockService) DeleteModule(ctx context.Context, module *models.TerraformModule) error

DeleteModule provides a mock function with given fields: ctx, module

func (*MockService) DeleteModuleAttestation

func (_m *MockService) DeleteModuleAttestation(ctx context.Context, attestation *models.TerraformModuleAttestation) error

DeleteModuleAttestation provides a mock function with given fields: ctx, attestation

func (*MockService) DeleteModuleVersion

func (_m *MockService) DeleteModuleVersion(ctx context.Context, moduleVersion *models.TerraformModuleVersion) error

DeleteModuleVersion provides a mock function with given fields: ctx, moduleVersion

func (*MockService) GetModuleAttestationByID

func (_m *MockService) GetModuleAttestationByID(ctx context.Context, id string) (*models.TerraformModuleAttestation, error)

GetModuleAttestationByID provides a mock function with given fields: ctx, id

func (*MockService) GetModuleAttestations

func (_m *MockService) GetModuleAttestations(ctx context.Context, input *GetModuleAttestationsInput) (*db.ModuleAttestationsResult, error)

GetModuleAttestations provides a mock function with given fields: ctx, input

func (*MockService) GetModuleByAddress

func (_m *MockService) GetModuleByAddress(ctx context.Context, namespace string, name string, system string) (*models.TerraformModule, error)

GetModuleByAddress provides a mock function with given fields: ctx, namespace, name, system

func (*MockService) GetModuleByID

func (_m *MockService) GetModuleByID(ctx context.Context, id string) (*models.TerraformModule, error)

GetModuleByID provides a mock function with given fields: ctx, id

func (*MockService) GetModuleByPath

func (_m *MockService) GetModuleByPath(ctx context.Context, path string) (*models.TerraformModule, error)

GetModuleByPath provides a mock function with given fields: ctx, path

func (*MockService) GetModuleConfigurationDetails

func (_m *MockService) GetModuleConfigurationDetails(ctx context.Context, moduleVersion *models.TerraformModuleVersion, path string) (*ModuleConfigurationDetails, error)

GetModuleConfigurationDetails provides a mock function with given fields: ctx, moduleVersion, path

func (*MockService) GetModuleVersionByID

func (_m *MockService) GetModuleVersionByID(ctx context.Context, id string) (*models.TerraformModuleVersion, error)

GetModuleVersionByID provides a mock function with given fields: ctx, id

func (*MockService) GetModuleVersionPackageDownloadURL

func (_m *MockService) GetModuleVersionPackageDownloadURL(ctx context.Context, moduleVersion *models.TerraformModuleVersion) (string, error)

GetModuleVersionPackageDownloadURL provides a mock function with given fields: ctx, moduleVersion

func (*MockService) GetModuleVersions

func (_m *MockService) GetModuleVersions(ctx context.Context, input *GetModuleVersionsInput) (*db.ModuleVersionsResult, error)

GetModuleVersions provides a mock function with given fields: ctx, input

func (*MockService) GetModuleVersionsByIDs

func (_m *MockService) GetModuleVersionsByIDs(ctx context.Context, ids []string) ([]models.TerraformModuleVersion, error)

GetModuleVersionsByIDs provides a mock function with given fields: ctx, ids

func (*MockService) GetModules

func (_m *MockService) GetModules(ctx context.Context, input *GetModulesInput) (*db.ModulesResult, error)

GetModules provides a mock function with given fields: ctx, input

func (*MockService) GetModulesByIDs

func (_m *MockService) GetModulesByIDs(ctx context.Context, ids []string) ([]models.TerraformModule, error)

GetModulesByIDs provides a mock function with given fields: ctx, ids

func (*MockService) UpdateModule

func (_m *MockService) UpdateModule(ctx context.Context, module *models.TerraformModule) (*models.TerraformModule, error)

UpdateModule provides a mock function with given fields: ctx, module

func (*MockService) UpdateModuleAttestation

func (_m *MockService) UpdateModuleAttestation(ctx context.Context, attestation *models.TerraformModuleAttestation) (*models.TerraformModuleAttestation, error)

UpdateModuleAttestation provides a mock function with given fields: ctx, attestation

func (*MockService) UploadModuleVersionPackage

func (_m *MockService) UploadModuleVersionPackage(ctx context.Context, moduleVersion *models.TerraformModuleVersion, reader io.Reader) error

UploadModuleVersionPackage provides a mock function with given fields: ctx, moduleVersion, reader

type ModuleCall

type ModuleCall struct {
	Name    string `json:"name"`
	Source  string `json:"source"`
	Version string `json:"version,omitempty"`
}

ModuleCall represents a call to another module

type ModuleConfigurationDetails

type ModuleConfigurationDetails struct {
	RequiredProviders []*ProviderRequirement `json:"required_providers"`
	ProviderConfigs   []*ProviderRef         `json:"provider_configs,omitempty"`
	ManagedResources  []*Resource            `json:"managed_resources"`
	Variables         []*Variable            `json:"variables"`
	Outputs           []*Output              `json:"outputs"`
	DataResources     []*Resource            `json:"data_resources"`
	ModuleCalls       []*ModuleCall          `json:"module_calls"`
	Readme            string                 `json:"readme"`
	Path              string                 `json:"path"`
	RequiredCore      []string               `json:"required_core,omitempty"`
}

ModuleConfigurationDetails includes the metadata for a parsed module configuration

type Output

type Output struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Sensitive   bool   `json:"sensitive,omitempty"`
}

Output represents a Terraform configuration output

type ParseModuleResponse

type ParseModuleResponse struct {
	Root        *ModuleConfigurationDetails
	Submodules  []ModuleConfigurationDetails
	Examples    []ModuleConfigurationDetails
	Diagnostics tfconfig.Diagnostics
}

ParseModuleResponse contains the configuration details for the root module, submodules, and example modules

type ProviderRef

type ProviderRef struct {
	Name  string `json:"name"`
	Alias string `json:"alias,omitempty"`
}

ProviderRef identifies a provider by name and an optional alias

type ProviderRequirement

type ProviderRequirement struct {
	Source               string        `json:"source,omitempty"`
	VersionConstraints   []string      `json:"version_constraints,omitempty"`
	ConfigurationAliases []ProviderRef `json:"aliases,omitempty"`
}

ProviderRequirement represents a provider that is required by a configuration

type RegistryStore

type RegistryStore interface {
	UploadModulePackage(
		ctx context.Context,
		moduleVersion *models.TerraformModuleVersion,
		module *models.TerraformModule,
		body io.Reader,
	) error
	UploadModuleConfigurationDetails(
		ctx context.Context,
		metadata *ModuleConfigurationDetails,
		moduleVersion *models.TerraformModuleVersion,
		module *models.TerraformModule,
	) error
	GetModuleConfigurationDetails(
		ctx context.Context,
		moduleVersion *models.TerraformModuleVersion,
		module *models.TerraformModule,
		path string,
	) (io.ReadCloser, error)
	DownloadModulePackage(
		ctx context.Context,
		moduleVersion *models.TerraformModuleVersion,
		module *models.TerraformModule,
		writer io.WriterAt,
	) error
	GetModulePackagePresignedURL(
		ctx context.Context,
		moduleVersion *models.TerraformModuleVersion,
		module *models.TerraformModule,
	) (string, error)
}

RegistryStore interface encapsulates the logic for saving workspace registrys

func NewRegistryStore

func NewRegistryStore(objectStore objectstore.ObjectStore) RegistryStore

NewRegistryStore creates an instance of the RegistryStore interface

type Resource

type Resource struct {
	Mode string `json:"mode"`
	Type string `json:"type"`
	Name string `json:"name"`

	Provider ProviderRef `json:"provider"`
}

Resource represents a resource created by a configuration

type Service

type Service interface {
	GetModuleByID(ctx context.Context, id string) (*models.TerraformModule, error)
	GetModuleByPath(ctx context.Context, path string) (*models.TerraformModule, error)
	GetModuleByAddress(ctx context.Context, namespace string, name string, system string) (*models.TerraformModule, error)
	GetModulesByIDs(ctx context.Context, ids []string) ([]models.TerraformModule, error)
	GetModules(ctx context.Context, input *GetModulesInput) (*db.ModulesResult, error)
	CreateModule(ctx context.Context, input *CreateModuleInput) (*models.TerraformModule, error)
	UpdateModule(ctx context.Context, module *models.TerraformModule) (*models.TerraformModule, error)
	DeleteModule(ctx context.Context, module *models.TerraformModule) error
	GetModuleAttestationByID(ctx context.Context, id string) (*models.TerraformModuleAttestation, error)
	GetModuleAttestations(ctx context.Context, input *GetModuleAttestationsInput) (*db.ModuleAttestationsResult, error)
	CreateModuleAttestation(ctx context.Context, input *CreateModuleAttestationInput) (*models.TerraformModuleAttestation, error)
	UpdateModuleAttestation(ctx context.Context, attestation *models.TerraformModuleAttestation) (*models.TerraformModuleAttestation, error)
	DeleteModuleAttestation(ctx context.Context, attestation *models.TerraformModuleAttestation) error
	GetModuleVersionByID(ctx context.Context, id string) (*models.TerraformModuleVersion, error)
	GetModuleVersions(ctx context.Context, input *GetModuleVersionsInput) (*db.ModuleVersionsResult, error)
	GetModuleVersionsByIDs(ctx context.Context, ids []string) ([]models.TerraformModuleVersion, error)
	CreateModuleVersion(ctx context.Context, input *CreateModuleVersionInput) (*models.TerraformModuleVersion, error)
	DeleteModuleVersion(ctx context.Context, moduleVersion *models.TerraformModuleVersion) error
	GetModuleConfigurationDetails(ctx context.Context, moduleVersion *models.TerraformModuleVersion, path string) (*ModuleConfigurationDetails, error)
	UploadModuleVersionPackage(ctx context.Context, moduleVersion *models.TerraformModuleVersion, reader io.Reader) error
	GetModuleVersionPackageDownloadURL(ctx context.Context, moduleVersion *models.TerraformModuleVersion) (string, error)
}

Service implements all module registry functionality

func NewService

func NewService(
	logger logger.Logger,
	dbClient *db.Client,
	limitChecker limits.LimitChecker,
	registryStore RegistryStore,
	activityService activityevent.Service,
	taskManager asynctask.Manager,
) Service

NewService creates an instance of Service

type Variable

type Variable struct {
	Default     *string `json:"default"`
	Name        string  `json:"name"`
	Type        string  `json:"type,omitempty"`
	Description string  `json:"description,omitempty"`
	Required    bool    `json:"required"`
	Sensitive   bool    `json:"sensitive,omitempty"`
}

Variable represents a Terraform conifguration input variable

Jump to

Keyboard shortcuts

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