infraprovider

package
v1.0.2-gitspaces-beta Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

WireSet provides a wire set for this package.

Functions

This section is empty.

Types

type DockerClientFactory

type DockerClientFactory struct {
	// contains filtered or unexported fields
}

func NewDockerClientFactory

func NewDockerClientFactory(config *DockerConfig) *DockerClientFactory

func ProvideDockerClientFactory

func ProvideDockerClientFactory(config *DockerConfig) *DockerClientFactory

func (*DockerClientFactory) NewDockerClient

func (d *DockerClientFactory) NewDockerClient(
	_ context.Context,
	infra *Infrastructure,
) (*client.Client, error)

NewDockerClient returns a new docker client created using the docker config and infra.

type DockerConfig

type DockerConfig struct {
	DockerHost            string
	DockerAPIVersion      string
	DockerCertPath        string
	DockerTLSVerify       string
	DockerMachineHostName string
}

type DockerProvider

type DockerProvider struct {
	// contains filtered or unexported fields
}

func NewDockerProvider

func NewDockerProvider(
	config *DockerConfig,
	dockerClientFactory *DockerClientFactory,
) *DockerProvider

func ProvideDockerProvider

func ProvideDockerProvider(
	config *DockerConfig,
	dockerClientFactory *DockerClientFactory,
) *DockerProvider

func (DockerProvider) AvailableParams

func (d DockerProvider) AvailableParams() []ParameterSchema

AvailableParams returns empty slice as no params are defined.

func (DockerProvider) Deprovision

func (d DockerProvider) Deprovision(ctx context.Context, infra *Infrastructure) (*Infrastructure, error)

Deprovision deletes the host machine directory created by Provision. It does not stop the docker engine.

func (DockerProvider) Exec

func (DockerProvider) Find

func (d DockerProvider) Find(
	ctx context.Context,
	spacePath string,
	resourceKey string,
	params []Parameter,
) (*Infrastructure, error)

Find fetches the infrastructure with the current state, the method has no side effects on the infra.

func (DockerProvider) Provision

func (d DockerProvider) Provision(
	ctx context.Context,
	spacePath string,
	resourceKey string,
	params []Parameter,
) (*Infrastructure, error)

Provision assumes a docker engine is already running on the gitness host machine and re-uses that as infra. It does not start docker engine. It creates a directory in the host machine using the given resource key.

func (DockerProvider) ProvisioningType

func (d DockerProvider) ProvisioningType() enum.InfraProvisioningType

ProvisioningType returns existing as docker provider doesn't create new resources.

func (DockerProvider) Stop

Stop is NOOP as this provider uses already running docker engine. It does not stop the docker engine.

func (DockerProvider) TemplateParams

func (d DockerProvider) TemplateParams() []ParameterSchema

TemplateParams returns nil as no template params are used.

func (DockerProvider) ValidateParams

func (d DockerProvider) ValidateParams(_ []Parameter) error

ValidateParams returns nil as no params are defined.

type Factory

type Factory struct {
	// contains filtered or unexported fields
}

func NewFactory

func NewFactory(dockerProvider *DockerProvider) Factory

func ProvideFactory

func ProvideFactory(dockerProvider *DockerProvider) Factory

func (*Factory) GetInfraProvider

func (f *Factory) GetInfraProvider(providerType enum.InfraProviderType) (InfraProvider, error)

type InfraProvider

type InfraProvider interface {
	// Provision provisions infrastructure against a resourceKey with the provided parameters.
	Provision(ctx context.Context, spacePath string, resourceKey string, parameters []Parameter) (*Infrastructure, error)
	// Find finds infrastructure provisioned against a resourceKey.
	Find(ctx context.Context, spacePath string, resourceKey string, parameters []Parameter) (*Infrastructure, error)
	// Stop frees up the resources allocated against a resourceKey, which can be freed.
	Stop(ctx context.Context, infra *Infrastructure) (*Infrastructure, error)
	// Deprovision removes all infrastructure provisioned againest the resourceKey.
	Deprovision(ctx context.Context, infra *Infrastructure) (*Infrastructure, error)
	// AvailableParams provides a schema to define the infrastructure.
	AvailableParams() []ParameterSchema
	// ValidateParams validates the supplied params before defining the infrastructure resource .
	ValidateParams(parameters []Parameter) error
	// TemplateParams provides a list of params which are of type template.
	TemplateParams() []ParameterSchema
	// ProvisioningType specifies whether the provider will provision new infra resources or it will reuse existing.
	ProvisioningType() enum.InfraProvisioningType
	// Exec executes a shell command in the infrastructure.
	Exec(ctx context.Context, infra *Infrastructure, cmd []string) (io.Reader, io.Reader, error)
}

type Infrastructure

type Infrastructure struct {
	Identifier   string
	ResourceKey  string
	SpacePath    string
	ProviderType enum.InfraProviderType
	Parameters   []Parameter
	Status       enum.InfraStatus
	Host         string
	Port         int
	Storage      string
}

type Parameter

type Parameter struct {
	Name  string
	Value string
}

type ParameterSchema

type ParameterSchema struct {
	Name         string
	Description  string
	DefaultValue string
	Required     bool
	Secret       bool
	Editable     bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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