feat: [CDE-576]: add port for JetBrains IDEs (#3243)

* feat: [CDE-576]: fix func name
* feat: [CDE-576]: fix lint
* feat: [CDE-576]: add port for JetBrains IDEs
BT-10437
Deepak Bhatt 2025-01-10 03:22:32 +00:00 committed by Harness
parent d88c742d3c
commit 816feec222
5 changed files with 87 additions and 10 deletions

View File

@ -38,7 +38,14 @@ const (
)
type JetBrainsIDEConfig struct {
Port int
IntelliJPort int
GolandPort int
PyCharmPort int
WebStormPort int
CLionPort int
PHPStormPort int
RubyMinePort int
RiderPort int
}
type JetBrainsIDE struct {
@ -53,6 +60,35 @@ func NewJetBrainsIDEService(config *JetBrainsIDEConfig, ideType enum.IDEType) *J
}
}
func (jb *JetBrainsIDE) port() int {
switch jb.ideType {
case enum.IDETypeIntelliJ:
return jb.config.IntelliJPort
case enum.IDETypeGoland:
return jb.config.GolandPort
case enum.IDETypePyCharm:
return jb.config.PyCharmPort
case enum.IDETypeWebStorm:
return jb.config.WebStormPort
case enum.IDETypeCLion:
return jb.config.CLionPort
case enum.IDETypePHPStorm:
return jb.config.PHPStormPort
case enum.IDETypeRubyMine:
return jb.config.RubyMinePort
case enum.IDETypeRider:
return jb.config.RiderPort
case enum.IDETypeVSCode:
// IDETypeVSCode is not JetBrainsIDE
return 0
case enum.IDETypeVSCodeWeb:
// IDETypeVSCodeWeb is not JetBrainsIDE
return 0
default:
return 0
}
}
// Setup installs the SSH server inside the container.
func (jb *JetBrainsIDE) Setup(
ctx context.Context,
@ -178,7 +214,7 @@ func (jb *JetBrainsIDE) runSSHServer(
gitspaceLogger gitspaceTypes.GitspaceLogger,
) error {
payload := gitspaceTypes.RunSSHServerPayload{
Port: strconv.Itoa(jb.config.Port),
Port: strconv.Itoa(jb.port()),
}
runSSHScript, err := utils.GenerateScriptFromTemplate(
templateRunSSHServer, &payload)
@ -237,7 +273,7 @@ func (jb *JetBrainsIDE) runRemoteIDE(
// Port returns the port on which the ssh-server is listening.
func (jb *JetBrainsIDE) Port() *types.GitspacePort {
return &types.GitspacePort{
Port: jb.config.Port,
Port: jb.port(),
Protocol: enum.CommunicationProtocolSSH,
}
}

View File

@ -442,10 +442,16 @@ func ProvideIDEVSCodeConfig(config *types.Config) *ide.VSCodeConfig {
}
}
// ProvideIDEIntellijConfig loads the IdeType IDE config from the main config.
func ProvideIDEIntellijConfig(config *types.Config) *ide.JetBrainsIDEConfig {
// ProvideIDEJetBrainsConfig loads the IdeType IDE config from the main config.
func ProvideIDEJetBrainsConfig(config *types.Config) *ide.JetBrainsIDEConfig {
return &ide.JetBrainsIDEConfig{
Port: config.IDE.Intellij.Port,
IntelliJPort: config.IDE.Intellij.Port,
GolandPort: config.IDE.Goland.Port,
PyCharmPort: config.IDE.PyCharm.Port,
WebStormPort: config.IDE.WebStorm.Port,
PHPStormPort: config.IDE.PHPStorm.Port,
CLionPort: config.IDE.CLion.Port,
RubyMinePort: config.IDE.RubyMine.Port,
}
}

View File

@ -273,7 +273,7 @@ func initSystem(ctx context.Context, config *types.Config) (*cliserver.System, e
gitspaceservice.WireSet,
cliserver.ProvideGitspaceInfraProvisionerConfig,
cliserver.ProvideIDEVSCodeConfig,
cliserver.ProvideIDEIntellijConfig,
cliserver.ProvideIDEJetBrainsConfig,
instrument.WireSet,
aiagentservice.WireSet,
aiagent.WireSet,

View File

@ -333,7 +333,7 @@ func initSystem(ctx context.Context, config *types.Config) (*server.System, erro
vsCode := ide.ProvideVSCodeService(vsCodeConfig)
vsCodeWebConfig := server.ProvideIDEVSCodeWebConfig(config)
vsCodeWeb := ide.ProvideVSCodeWebService(vsCodeWebConfig)
jetBrainsIDEConfig := server.ProvideIDEIntellijConfig(config)
jetBrainsIDEConfig := server.ProvideIDEJetBrainsConfig(config)
v := ide.ProvideJetBrainsIDEsService(jetBrainsIDEConfig)
ideFactory := ide.ProvideIDEFactory(vsCode, vsCodeWeb, v)
passwordResolver := secret.ProvidePasswordResolver()

View File

@ -413,8 +413,43 @@ type Config struct {
}
Intellij struct {
// Port is the port on which the SSH server for Intellij will be accessible.
Port int `envconfig:"GITNESS_IDE_INTELLIJ_PORT" default:"8090"`
// Port is the port on which the SSH server for IntelliJ will be accessible
Port int `envconfig:"CDE_MANAGER_GITSPACE_IDE_INTELLIJ_PORT" default:"8090"`
}
Goland struct {
// Port is the port on which the SSH server for Goland will be accessible
Port int `envconfig:"CDE_MANAGER_GITSPACE_IDE_GOLAND_PORT" default:"8091"`
}
PyCharm struct {
// Port is the port on which the SSH server for PyCharm will be accessible
Port int `envconfig:"CDE_MANAGER_GITSPACE_IDE_PYCHARM_PORT" default:"8092"`
}
WebStorm struct {
// Port is the port on which the SSH server for WebStorm will be accessible
Port int `envconfig:"CDE_MANAGER_GITSPACE_IDE_WEBSTORM_PORT" default:"8093"`
}
CLion struct {
// Port is the port on which the SSH server for CLion will be accessible
Port int `envconfig:"CDE_MANAGER_GITSPACE_IDE_CLION_PORT" default:"8094"`
}
PHPStorm struct {
// Port is the port on which the SSH server for PHPStorm will be accessible
Port int `envconfig:"CDE_MANAGER_GITSPACE_IDE_PHPSTORM_PORT" default:"8095"`
}
RubyMine struct {
// Port is the port on which the SSH server for RubyMine will be accessible
Port int `envconfig:"CDE_MANAGER_GITSPACE_IDE_RUBYMINE_PORT" default:"8096"`
}
Rider struct {
// Port is the port on which the SSH server for Rider will be accessible
Port int `envconfig:"CDE_MANAGER_GITSPACE_IDE_RIDER_PORT" default:"8097"`
}
}