feat: [CDE-192]: make hosts and ports in gitspace infrastructure more verbose (#2496)

* feat: [CDE-192]: make hosts and ports in gitspace infrastructure more verbose
pull/3545/head
Ansuman Satapathy 2024-08-13 11:42:01 +00:00 committed by Harness
parent be471c2151
commit 99d8d2d6a3
5 changed files with 31 additions and 18 deletions

View File

@ -209,10 +209,10 @@ func (i infraProvisioner) resumeProvisionForNewProvisioning(
}
infraProvisionedLatest.InfraStatus = provisionedInfra.Status
infraProvisionedLatest.ServerHostIP = provisionedInfra.Host
infraProvisionedLatest.ServerHostIP = provisionedInfra.AgentHost
infraProvisionedLatest.ServerHostPort = strconv.Itoa(provisionedInfra.AgentPort)
infraProvisionedLatest.ProxyHost = provisionedInfra.ProxyHost
infraProvisionedLatest.ProxyPort = int32(provisionedInfra.ProxyPort)
infraProvisionedLatest.ProxyHost = provisionedInfra.ProxyAgentHost
infraProvisionedLatest.ProxyPort = int32(provisionedInfra.ProxyAgentPort)
infraProvisionedLatest.ResponseMetadata = &responseMetadata
infraProvisionedLatest.Updated = time.Now().UnixMilli()

View File

@ -204,10 +204,10 @@ func (i infraProvisioner) updateInfraProvisionedRecord(
}
infraProvisionedLatest.InfraStatus = deprovisionedInfra.Status
infraProvisionedLatest.ServerHostIP = deprovisionedInfra.Host
infraProvisionedLatest.ServerHostIP = deprovisionedInfra.AgentHost
infraProvisionedLatest.ServerHostPort = strconv.Itoa(deprovisionedInfra.AgentPort)
infraProvisionedLatest.ProxyHost = deprovisionedInfra.ProxyHost
infraProvisionedLatest.ProxyPort = int32(deprovisionedInfra.ProxyPort)
infraProvisionedLatest.ProxyHost = deprovisionedInfra.ProxyAgentHost
infraProvisionedLatest.ProxyPort = int32(deprovisionedInfra.ProxyAgentPort)
infraProvisionedLatest.ResponseMetadata = &responseMetadata
infraProvisionedLatest.Updated = time.Now().UnixMilli()

View File

@ -374,16 +374,17 @@ func (o orchestrator) ResumeStartGitspace(
forwardedPort = strconv.Itoa(provisionedInfra.GitspacePortMappings[idePort].ForwardedPort)
}
host := provisionedInfra.Host
if provisionedInfra.ProxyHost != "" {
host = provisionedInfra.ProxyHost
scheme := provisionedInfra.GitspaceScheme
host := provisionedInfra.GitspaceHost
if provisionedInfra.ProxyGitspaceHost != "" {
host = provisionedInfra.ProxyGitspaceHost
}
relativeRepoPath := strings.TrimPrefix(startResponse.AbsoluteRepoPath, "/")
if gitspaceConfig.IDE == enum.IDETypeVSCodeWeb {
ideURL = url.URL{
Scheme: "http",
Scheme: scheme,
Host: host + ":" + forwardedPort,
RawQuery: filepath.Join("folder=", relativeRepoPath),
}

View File

@ -239,10 +239,11 @@ func (d DockerProvider) dockerHostInfo(
return nil, fmt.Errorf("unable to connect to docker engine: %w", err)
}
return &types.Infrastructure{
Identifier: info.ID,
ProviderType: enum.InfraProviderTypeDocker,
Status: enum.InfraStatusProvisioned,
Host: d.config.DockerMachineHostName,
Identifier: info.ID,
ProviderType: enum.InfraProviderTypeDocker,
Status: enum.InfraStatusProvisioned,
GitspaceHost: d.config.DockerMachineHostName,
GitspaceScheme: "http",
}, nil
}

View File

@ -54,12 +54,23 @@ type Infrastructure struct {
InputParameters []InfraProviderParameter
// Status of the infra.
Status enum.InfraStatus
// Host through which the infra can be accessed.
Host string
ProxyHost string
// AgentHost through which the infra can be accessed.
AgentHost string
// AgentPort on which the agent can be accessed to orchestrate containers.
AgentPort int
ProxyPort int
// ProxyAgentHost on which to connect to agent incase a proxy is used.
ProxyAgentHost string
ProxyAgentPort int
// HostScheme is scheme to connect to the host e.g. https
HostScheme string
// GitspaceHost on which gitspace is accessible directly, without proxy being configured.
GitspaceHost string
// ProxyGitspaceHost on which gitspace is accessible through a proxy.
ProxyGitspaceHost string
GitspaceScheme string
// Storage is the name of the volume or disk created for the resource.
Storage string
// GitspacePortMappings contains the ports assigned for every requested port.