feat: [CDE-142]: provider interface pass pointers. (#2232)

* feat: [CDE-142]: provider interface pass pointers.
* feat: [CDE-142]: provider interface pass pointers.
* feat: [CDE-142]: provider interface pass pointers.
* feat: [CDE-142]: provider interface pass pointers.
* feat: [CDE-142]: provider interface pass pointers.
* feat: [CDE-142]: provider interface pass pointers.
This commit is contained in:
Ansuman Satapathy 2024-07-16 13:06:08 +00:00 committed by Harness
parent b83348c0d7
commit 767bb717d9
11 changed files with 133 additions and 153 deletions

View File

@ -82,7 +82,6 @@ ENV GITNESS_DATABASE_DATASOURCE /data/database.sqlite
ENV GITNESS_METRIC_ENABLED=true ENV GITNESS_METRIC_ENABLED=true
ENV GITNESS_METRIC_ENDPOINT=https://stats.drone.ci/api/v1/gitness ENV GITNESS_METRIC_ENDPOINT=https://stats.drone.ci/api/v1/gitness
ENV GITNESS_TOKEN_COOKIE_NAME=token ENV GITNESS_TOKEN_COOKIE_NAME=token
ENV GITNESS_GITSPACE_ROOT /data
ENV GITNESS_DOCKER_HOST unix:///var/run/docker.sock ENV GITNESS_DOCKER_HOST unix:///var/run/docker.sock
COPY --from=builder /app/gitness /app/gitness COPY --from=builder /app/gitness /app/gitness

View File

@ -93,7 +93,7 @@ func (i infraProvisioner) Provision(
// TODO: Update the infraProvisioned record // TODO: Update the infraProvisioned record
} }
return &provisionedInfra, nil return provisionedInfra, nil
} }
func (i infraProvisioner) Stop( func (i infraProvisioner) Stop(
@ -133,11 +133,11 @@ func (i infraProvisioner) Stop(
return nil, fmt.Errorf("invalid provisioning params %+v: %w", infraProviderResource.Metadata, err) return nil, fmt.Errorf("invalid provisioning params %+v: %w", infraProviderResource.Metadata, err)
} }
var provisionedInfra infraprovider.Infrastructure var provisionedInfra *infraprovider.Infrastructure
if infraProvider.ProvisioningType() == enum.InfraProvisioningTypeNew { //nolint:revive if infraProvider.ProvisioningType() == enum.InfraProvisioningTypeNew { //nolint:revive
// TODO: Fetch and check existing infraProvisioned record // TODO: Fetch and check existing infraProvisioned record
} else { } else {
provisionedInfra = infraprovider.Infrastructure{ provisionedInfra = &infraprovider.Infrastructure{
ResourceKey: gitspaceConfig.Identifier, ResourceKey: gitspaceConfig.Identifier,
ProviderType: infraProviderEntity.Type, ProviderType: infraProviderEntity.Type,
Parameters: allParams, Parameters: allParams,
@ -153,7 +153,7 @@ func (i infraProvisioner) Stop(
// TODO: Update existing infraProvisioned record // TODO: Update existing infraProvisioned record
} }
return &stoppedInfra, err return stoppedInfra, err
} }
func (i infraProvisioner) Deprovision( func (i infraProvisioner) Deprovision(
@ -193,18 +193,16 @@ func (i infraProvisioner) Deprovision(
return nil, fmt.Errorf("invalid provisioning params %+v: %w", infraProviderResource.Metadata, err) return nil, fmt.Errorf("invalid provisioning params %+v: %w", infraProviderResource.Metadata, err)
} }
var provisionedInfra infraprovider.Infrastructure var provisionedInfra *infraprovider.Infrastructure
if infraProvider.ProvisioningType() == enum.InfraProvisioningTypeNew { //nolint:revive if infraProvider.ProvisioningType() == enum.InfraProvisioningTypeNew { //nolint:revive
// TODO: Fetch and check existing infraProvisioned record // TODO: Fetch and check existing infraProvisioned record
} else { } else {
provisionedInfra = infraprovider.Infrastructure{ provisionedInfra, err = infraProvider.Find(ctx, gitspaceConfig.SpacePath, gitspaceConfig.Identifier, allParams)
ResourceKey: gitspaceConfig.Identifier, if err != nil {
SpacePath: gitspaceConfig.SpacePath, return nil, fmt.Errorf("unable to find provisioned infra for gitspace %s: %w",
ProviderType: infraProviderEntity.Type, gitspaceConfig.Identifier, err)
Parameters: allParams,
} }
} }
destroyedInfra, err := infraProvider.Deprovision(ctx, provisionedInfra) destroyedInfra, err := infraProvider.Deprovision(ctx, provisionedInfra)
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to stop provisioned infra %+v: %w", provisionedInfra, err) return nil, fmt.Errorf("unable to stop provisioned infra %+v: %w", provisionedInfra, err)
@ -214,7 +212,7 @@ func (i infraProvisioner) Deprovision(
// TODO: Update existing infraProvisioned record // TODO: Update existing infraProvisioned record
} }
return &destroyedInfra, err return destroyedInfra, err
} }
func (i infraProvisioner) Find( func (i infraProvisioner) Find(

View File

@ -18,7 +18,6 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"path/filepath"
"strings" "strings"
"github.com/harness/gitness/app/gitspace/logutil" "github.com/harness/gitness/app/gitspace/logutil"
@ -46,7 +45,6 @@ const (
containerStateRemoved = "removed" containerStateRemoved = "removed"
templateCloneGit = "clone_git.sh" templateCloneGit = "clone_git.sh"
templateSetupSSHServer = "setup_ssh_server.sh" templateSetupSSHServer = "setup_ssh_server.sh"
gitspacesDir = "gitspaces"
) )
type Config struct { type Config struct {
@ -159,6 +157,7 @@ func (e *EmbeddedDockerOrchestrator) StartGitspace(
dockerClient, dockerClient,
ideService, ideService,
logStreamInstance, logStreamInstance,
infra.Storage,
) )
if startErr != nil { if startErr != nil {
return nil, fmt.Errorf("failed to start gitspace %s: %w", containerName, startErr) return nil, fmt.Errorf("failed to start gitspace %s: %w", containerName, startErr)
@ -194,6 +193,7 @@ func (e *EmbeddedDockerOrchestrator) startGitspace(
dockerClient *client.Client, dockerClient *client.Client,
ideService IDE, ideService IDE,
logStreamInstance *logutil.LogStreamInstance, logStreamInstance *logutil.LogStreamInstance,
volumeName string,
) error { ) error {
var imageName = devcontainerConfig.Image var imageName = devcontainerConfig.Image
if imageName == "" { if imageName == "" {
@ -205,7 +205,15 @@ func (e *EmbeddedDockerOrchestrator) startGitspace(
return err return err
} }
err = e.createContainer(ctx, gitspaceConfig, dockerClient, imageName, containerName, ideService, logStreamInstance) err = e.createContainer(
ctx,
dockerClient,
imageName,
containerName,
ideService,
logStreamInstance,
volumeName,
)
if err != nil { if err != nil {
return err return err
} }
@ -411,12 +419,12 @@ func (e *EmbeddedDockerOrchestrator) executePostCreateCommand(
func (e *EmbeddedDockerOrchestrator) createContainer( func (e *EmbeddedDockerOrchestrator) createContainer(
ctx context.Context, ctx context.Context,
gitspaceConfig *types.GitspaceConfig,
dockerClient *client.Client, dockerClient *client.Client,
imageName string, imageName string,
containerName string, containerName string,
ideService IDE, ideService IDE,
logStreamInstance *logutil.LogStreamInstance, logStreamInstance *logutil.LogStreamInstance,
volumeName string,
) error { ) error {
portUsedByIDE := ideService.PortAndProtocol() portUsedByIDE := ideService.PortAndProtocol()
@ -442,14 +450,6 @@ func (e *EmbeddedDockerOrchestrator) createContainer(
commands := make(strslice.StrSlice, 0) commands := make(strslice.StrSlice, 0)
commands = append(commands, "infinity") commands = append(commands, "infinity")
mountSource :=
filepath.Join(
e.config.RootSource,
gitspacesDir,
gitspaceConfig.SpacePath,
gitspaceConfig.Identifier,
)
loggingErr := logStreamInstance.Write("Creating container: " + containerName) loggingErr := logStreamInstance.Write("Creating container: " + containerName)
if loggingErr != nil { if loggingErr != nil {
return fmt.Errorf("logging error: %w", loggingErr) return fmt.Errorf("logging error: %w", loggingErr)
@ -464,8 +464,8 @@ func (e *EmbeddedDockerOrchestrator) createContainer(
PortBindings: portBindings, PortBindings: portBindings,
Mounts: []mount.Mount{ Mounts: []mount.Mount{
{ {
Type: mount.TypeBind, Type: mount.TypeVolume,
Source: mountSource, Source: volumeName,
Target: e.config.WorkingDirectory, Target: e.config.WorkingDirectory,
}, },
}, },

View File

@ -405,18 +405,10 @@ func ProvideIDEVSCodeWebConfig(config *types.Config) *container.VSCodeWebConfig
} }
// ProvideGitspaceContainerOrchestratorConfig loads the Gitspace container orchestrator config from the main config. // ProvideGitspaceContainerOrchestratorConfig loads the Gitspace container orchestrator config from the main config.
func ProvideGitspaceContainerOrchestratorConfig( func ProvideGitspaceContainerOrchestratorConfig(config *types.Config) *container.Config {
config *types.Config,
dockerProviderConfig *infraprovider.DockerProviderConfig,
) *container.Config {
if config.Gitspace.RootSource == "" {
config.Gitspace.RootSource = dockerProviderConfig.MountSourceBasePath
}
return &container.Config{ return &container.Config{
DefaultBaseImage: config.Gitspace.DefaultBaseImage, DefaultBaseImage: config.Gitspace.DefaultBaseImage,
WorkingDirectory: config.Gitspace.WorkingDirectory, WorkingDirectory: config.Gitspace.WorkingDirectory,
RootSource: config.Gitspace.RootSource,
} }
} }
@ -428,21 +420,3 @@ func ProvideGitspaceEventConfig(config *types.Config) gitspaceevent.Config {
MaxRetries: config.Gitspace.Events.MaxRetries, MaxRetries: config.Gitspace.Events.MaxRetries,
} }
} }
// ProvideDockerProviderConfig loads the Docker provider config from the main config.
func ProvideDockerProviderConfig(config *types.Config) (*infraprovider.DockerProviderConfig, error) {
if config.Gitspace.Root == "" {
var homedir string
homedir, err := os.UserHomeDir()
if err != nil {
return nil, fmt.Errorf("unable to determine home directory: %w", err)
}
config.Gitspace.Root = filepath.Join(homedir, gitnessHomeDir)
}
return &infraprovider.DockerProviderConfig{
MountSourceBasePath: config.Gitspace.Root,
}, nil
}

View File

@ -225,7 +225,6 @@ func initSystem(ctx context.Context, config *types.Config) (*cliserver.System, e
cliserver.ProvideGitspaceContainerOrchestratorConfig, cliserver.ProvideGitspaceContainerOrchestratorConfig,
cliserver.ProvideGitspaceEventConfig, cliserver.ProvideGitspaceEventConfig,
logutil.WireSet, logutil.WireSet,
cliserver.ProvideDockerProviderConfig,
) )
return &cliserver.System{}, nil return &cliserver.System{}, nil
} }

View File

@ -327,11 +327,7 @@ func initSystem(ctx context.Context, config *types.Config) (*server.System, erro
return nil, err return nil, err
} }
dockerClientFactory := infraprovider.ProvideDockerClientFactory(dockerConfig) dockerClientFactory := infraprovider.ProvideDockerClientFactory(dockerConfig)
dockerProviderConfig, err := server.ProvideDockerProviderConfig(config) dockerProvider := infraprovider.ProvideDockerProvider(dockerConfig, dockerClientFactory)
if err != nil {
return nil, err
}
dockerProvider := infraprovider.ProvideDockerProvider(dockerConfig, dockerClientFactory, dockerProviderConfig)
factory := infraprovider.ProvideFactory(dockerProvider) factory := infraprovider.ProvideFactory(dockerProvider)
providerService := infraprovider2.ProvideInfraProvider(infraProviderResourceStore, infraProviderConfigStore, factory, spaceStore, transactor) providerService := infraprovider2.ProvideInfraProvider(infraProviderResourceStore, infraProviderConfigStore, factory, spaceStore, transactor)
infraproviderController := infraprovider3.ProvideController(authorizer, spaceStore, providerService) infraproviderController := infraprovider3.ProvideController(authorizer, spaceStore, providerService)
@ -344,7 +340,7 @@ func initSystem(ctx context.Context, config *types.Config) (*server.System, erro
vsCode := container.ProvideVSCodeService() vsCode := container.ProvideVSCodeService()
vsCodeWebConfig := server.ProvideIDEVSCodeWebConfig(config) vsCodeWebConfig := server.ProvideIDEVSCodeWebConfig(config)
vsCodeWeb := container.ProvideVSCodeWebService(vsCodeWebConfig) vsCodeWeb := container.ProvideVSCodeWebService(vsCodeWebConfig)
containerConfig := server.ProvideGitspaceContainerOrchestratorConfig(config, dockerProviderConfig) containerConfig := server.ProvideGitspaceContainerOrchestratorConfig(config)
statefulLogger := logutil.ProvideStatefulLogger(logStream) statefulLogger := logutil.ProvideStatefulLogger(logStream)
containerOrchestrator := container.ProvideEmbeddedDockerOrchestrator(dockerClientFactory, vsCode, vsCodeWeb, containerConfig, statefulLogger) containerOrchestrator := container.ProvideEmbeddedDockerOrchestrator(dockerClientFactory, vsCode, vsCodeWeb, containerConfig, statefulLogger)
orchestratorOrchestrator := orchestrator.ProvideOrchestrator(scmSCM, infraProviderResourceStore, infraProvisioner, containerOrchestrator, reporter3) orchestratorOrchestrator := orchestrator.ProvideOrchestrator(scmSCM, infraProviderResourceStore, infraProvisioner, containerOrchestrator, reporter3)

View File

@ -18,56 +18,47 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"os" "strings"
"path/filepath"
"github.com/harness/gitness/infraprovider/enum" "github.com/harness/gitness/infraprovider/enum"
"github.com/docker/docker/api/types/volume"
"github.com/docker/docker/client"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
) )
var _ InfraProvider = (*DockerProvider)(nil) var _ InfraProvider = (*DockerProvider)(nil)
const gitspacesDir = "gitspaces"
type DockerProviderConfig struct {
MountSourceBasePath string
}
type DockerProvider struct { type DockerProvider struct {
config *DockerConfig config *DockerConfig
dockerClientFactory *DockerClientFactory dockerClientFactory *DockerClientFactory
dockerProviderConfig *DockerProviderConfig
} }
func NewDockerProvider( func NewDockerProvider(
config *DockerConfig, config *DockerConfig,
dockerClientFactory *DockerClientFactory, dockerClientFactory *DockerClientFactory,
dockerProviderConfig *DockerProviderConfig,
) *DockerProvider { ) *DockerProvider {
return &DockerProvider{ return &DockerProvider{
config: config, config: config,
dockerClientFactory: dockerClientFactory, dockerClientFactory: dockerClientFactory,
dockerProviderConfig: dockerProviderConfig,
} }
} }
// Provision assumes a docker engine is already running on the Gitness host machine and re-uses that as infra. // 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. // It does not start docker engine. It creates a directory in the host machine using the given resource key.
func (d DockerProvider) Provision( func (d DockerProvider) Provision(
ctx context.Context, ctx context.Context,
spacePath string, spacePath string,
resourceKey string, resourceKey string,
params []Parameter, params []Parameter,
) (Infrastructure, error) { ) (*Infrastructure, error) {
dockerClient, err := d.dockerClientFactory.NewDockerClient(ctx, &Infrastructure{ dockerClient, err := d.dockerClientFactory.NewDockerClient(ctx, &Infrastructure{
ProviderType: enum.InfraProviderTypeDocker, ProviderType: enum.InfraProviderTypeDocker,
Parameters: params, Parameters: params,
}) })
if err != nil { if err != nil {
return Infrastructure{}, fmt.Errorf("error getting docker client from docker client factory: %w", err) return nil, fmt.Errorf("error getting docker client from docker client factory: %w", err)
} }
defer func() { defer func() {
closingErr := dockerClient.Close() closingErr := dockerClient.Close()
if closingErr != nil { if closingErr != nil {
@ -75,82 +66,78 @@ func (d DockerProvider) Provision(
} }
}() }()
info, err := dockerClient.Info(ctx) infrastructure, err := d.dockerHostInfo(ctx, dockerClient)
if err != nil { if err != nil {
return Infrastructure{}, fmt.Errorf("unable to connect to docker engine: %w", err) return nil, err
}
volumeName, err := d.createNamedVolume(ctx, spacePath, resourceKey, dockerClient)
infrastructure.Storage = volumeName
if err != nil {
return nil, err
}
return infrastructure, nil
} }
err = d.createMountSourceDirectory(spacePath, resourceKey) // Find fetches the infrastructure with the current state, the method has no side effects on the infra.
if err != nil { func (d DockerProvider) Find(
return Infrastructure{}, err ctx context.Context,
} spacePath string,
resourceKey string,
return Infrastructure{ params []Parameter,
Identifier: info.ID, ) (*Infrastructure, error) {
dockerClient, err := d.dockerClientFactory.NewDockerClient(ctx, &Infrastructure{
ProviderType: enum.InfraProviderTypeDocker, ProviderType: enum.InfraProviderTypeDocker,
Status: enum.InfraStatusProvisioned, Parameters: params,
Host: d.config.DockerMachineHostName, })
}, nil
}
func (d DockerProvider) createMountSourceDirectory(spacePath string, resourceKey string) error {
mountSourcePath := d.getMountSourceDirectoryPath(spacePath, resourceKey)
err := os.MkdirAll(mountSourcePath, os.ModePerm)
if err != nil { if err != nil {
return fmt.Errorf( return nil, fmt.Errorf("error getting docker client from docker client factory: %w", err)
"could not create bind mount source path %s: %w", mountSourcePath, err)
} }
defer func() {
return nil closingErr := dockerClient.Close()
if closingErr != nil {
log.Ctx(ctx).Warn().Err(closingErr).Msg("failed to close docker client")
} }
}()
func (d DockerProvider) deleteMountSourceDirectory(spacePath string, resourceKey string) error { infrastructure, err := d.dockerHostInfo(ctx, dockerClient)
mountSourcePath := d.getMountSourceDirectoryPath(spacePath, resourceKey)
err := os.RemoveAll(mountSourcePath)
if err != nil { if err != nil {
return fmt.Errorf( return nil, err
"could not delete bind mount source path %s: %w", mountSourcePath, err)
} }
name := volumeName(spacePath, resourceKey)
return nil volumeInspect, err := dockerClient.VolumeInspect(ctx, name)
if err != nil {
return nil, fmt.Errorf("couldn't find the volume for %s : %w", name, err)
} }
infrastructure.Storage = volumeInspect.Name
func (d DockerProvider) getMountSourceDirectoryPath(spacePath string, resourceKey string) string { return infrastructure, nil
return filepath.Join(
d.dockerProviderConfig.MountSourceBasePath,
gitspacesDir,
spacePath,
resourceKey,
)
}
func (d DockerProvider) Find(_ context.Context, _ string, _ []Parameter) (Infrastructure, error) {
// TODO implement me
panic("implement me")
} }
// Stop is NOOP as this provider uses already running docker engine. It does not stop the docker engine. // Stop is NOOP as this provider uses already running docker engine. It does not stop the docker engine.
func (d DockerProvider) Stop(_ context.Context, infra Infrastructure) (Infrastructure, error) { func (d DockerProvider) Stop(_ context.Context, infra *Infrastructure) (*Infrastructure, error) {
return infra, nil return infra, nil
} }
// Deprovision deletes the host machine directory created by Provision. It does not stop the docker engine. // Deprovision deletes the host machine directory created by Provision. It does not stop the docker engine.
func (d DockerProvider) Deprovision(_ context.Context, infra Infrastructure) (Infrastructure, error) { func (d DockerProvider) Deprovision(ctx context.Context, infra *Infrastructure) (*Infrastructure, error) {
err := d.deleteMountSourceDirectory(infra.SpacePath, infra.ResourceKey) dockerClient, err := d.dockerClientFactory.NewDockerClient(ctx, &Infrastructure{
ProviderType: enum.InfraProviderTypeDocker,
Parameters: infra.Parameters,
})
if err != nil { if err != nil {
return Infrastructure{}, err return nil, fmt.Errorf("error getting docker client from docker client factory: %w", err)
}
defer func() {
closingErr := dockerClient.Close()
if closingErr != nil {
log.Ctx(ctx).Warn().Err(closingErr).Msg("failed to close docker client")
}
}()
err = dockerClient.VolumeRemove(ctx, infra.Storage, true)
if err != nil {
return nil, fmt.Errorf("couldn't delete volume for %s : %w", infra.Storage, err)
} }
return infra, nil return infra, nil
} }
func (d DockerProvider) Status(_ context.Context, _ Infrastructure) (enum.InfraStatus, error) {
// TODO implement me
panic("implement me")
}
// AvailableParams returns empty slice as no params are defined. // AvailableParams returns empty slice as no params are defined.
func (d DockerProvider) AvailableParams() []ParameterSchema { func (d DockerProvider) AvailableParams() []ParameterSchema {
return []ParameterSchema{} return []ParameterSchema{}
@ -171,7 +158,45 @@ func (d DockerProvider) ProvisioningType() enum.InfraProvisioningType {
return enum.InfraProvisioningTypeExisting return enum.InfraProvisioningTypeExisting
} }
func (d DockerProvider) Exec(_ context.Context, _ Infrastructure, _ []string) (io.Reader, io.Reader, error) { func (d DockerProvider) Exec(_ context.Context, _ *Infrastructure, _ []string) (io.Reader, io.Reader, error) {
// TODO implement me // TODO implement me
panic("implement me") panic("implement me")
} }
func (d DockerProvider) dockerHostInfo(ctx context.Context, dockerClient *client.Client) (*Infrastructure, error) {
info, err := dockerClient.Info(ctx)
if err != nil {
return nil, fmt.Errorf("unable to connect to docker engine: %w", err)
}
return &Infrastructure{
Identifier: info.ID,
ProviderType: enum.InfraProviderTypeDocker,
Status: enum.InfraStatusProvisioned,
Host: d.config.DockerMachineHostName,
}, nil
}
func (d DockerProvider) createNamedVolume(
ctx context.Context,
spacePath string,
resourceKey string,
dockerClient *client.Client,
) (string, error) {
name := volumeName(spacePath, resourceKey)
dockerVolume, err := dockerClient.VolumeCreate(ctx, volume.VolumeCreateBody{
Name: name,
Driver: "local",
Labels: nil,
DriverOpts: nil})
if err != nil {
return "", fmt.Errorf(
"could not create name volume %s: %w", name, err)
}
log.Info().Msgf("created volume %s", dockerVolume.Name)
return dockerVolume.Name, nil
}
func volumeName(spacePath string, resourceKey string) string {
name := "gitspace-" + strings.ReplaceAll(spacePath, "/", "-") + "-" + resourceKey
return name
}

View File

@ -23,15 +23,13 @@ import (
type InfraProvider interface { type InfraProvider interface {
// Provision provisions infrastructure against a resourceKey with the provided parameters. // Provision provisions infrastructure against a resourceKey with the provided parameters.
Provision(ctx context.Context, spacePath string, resourceKey string, parameters []Parameter) (Infrastructure, error) Provision(ctx context.Context, spacePath string, resourceKey string, parameters []Parameter) (*Infrastructure, error)
// Find finds infrastructure provisioned against a resourceKey. // Find finds infrastructure provisioned against a resourceKey.
Find(ctx context.Context, resourceKey string, parameters []Parameter) (Infrastructure, error) 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 frees up the resources allocated against a resourceKey, which can be freed.
Stop(ctx context.Context, infra Infrastructure) (Infrastructure, error) Stop(ctx context.Context, infra *Infrastructure) (*Infrastructure, error)
// Deprovision removes all infrastructure provisioned againest the resourceKey. // Deprovision removes all infrastructure provisioned againest the resourceKey.
Deprovision(ctx context.Context, infra Infrastructure) (Infrastructure, error) Deprovision(ctx context.Context, infra *Infrastructure) (*Infrastructure, error)
// Status checks the infrastructure status provisioned againest the resourceKey.
Status(ctx context.Context, infra Infrastructure) (enum.InfraStatus, error)
// AvailableParams provides a schema to define the infrastructure. // AvailableParams provides a schema to define the infrastructure.
AvailableParams() []ParameterSchema AvailableParams() []ParameterSchema
// ValidateParams validates the supplied params before defining the infrastructure resource . // ValidateParams validates the supplied params before defining the infrastructure resource .
@ -41,5 +39,5 @@ type InfraProvider interface {
// ProvisioningType specifies whether the provider will provision new infra resources or it will reuse existing. // ProvisioningType specifies whether the provider will provision new infra resources or it will reuse existing.
ProvisioningType() enum.InfraProvisioningType ProvisioningType() enum.InfraProvisioningType
// Exec executes a shell command in the infrastructure. // Exec executes a shell command in the infrastructure.
Exec(ctx context.Context, infra Infrastructure, cmd []string) (io.Reader, io.Reader, error) Exec(ctx context.Context, infra *Infrastructure, cmd []string) (io.Reader, io.Reader, error)
} }

View File

@ -39,4 +39,5 @@ type Infrastructure struct {
Status enum.InfraStatus Status enum.InfraStatus
Host string Host string
Port int Port int
Storage string
} }

View File

@ -28,9 +28,8 @@ var WireSet = wire.NewSet(
func ProvideDockerProvider( func ProvideDockerProvider(
config *DockerConfig, config *DockerConfig,
dockerClientFactory *DockerClientFactory, dockerClientFactory *DockerClientFactory,
dockerProviderConfig *DockerProviderConfig,
) *DockerProvider { ) *DockerProvider {
return NewDockerProvider(config, dockerClientFactory, dockerProviderConfig) return NewDockerProvider(config, dockerClientFactory)
} }
func ProvideFactory(dockerProvider *DockerProvider) Factory { func ProvideFactory(dockerProvider *DockerProvider) Factory {

View File

@ -406,15 +406,6 @@ type Config struct {
Enable bool `envconfig:"GITNESS_GITSPACE_ENABLE" default:"false"` Enable bool `envconfig:"GITNESS_GITSPACE_ENABLE" default:"false"`
// Root is the source for bind mount in the Gitspace container.
// Sub-directories will be created from this eg <Root>/gitspace/space1/space2/config1
// If left blank, it will be set to $HOME/.gitness
Root string `envconfig:"GITNESS_GITSPACE_ROOT"`
// RootSource is the source path on which the Root is mounted in Gitness container.
// If left blank, it will be equal to Root.
RootSource string `envconfig:"GITNESS_GITSPACE_ROOT_SOURCE"`
Events struct { Events struct {
Concurrency int `envconfig:"GITNESS_GITSPACE_EVENTS_CONCURRENCY" default:"4"` Concurrency int `envconfig:"GITNESS_GITSPACE_EVENTS_CONCURRENCY" default:"4"`
MaxRetries int `envconfig:"GITNESS_GITSPACE_EVENTS_MAX_RETRIES" default:"3"` MaxRetries int `envconfig:"GITNESS_GITSPACE_EVENTS_MAX_RETRIES" default:"3"`