Get Hub host and port from ProxyConfig struct

This commit is contained in:
M. Mert Yildiran
2022-12-29 04:23:37 +03:00
parent a4f5d832b3
commit 1474a7d687
3 changed files with 6 additions and 8 deletions

View File

@@ -150,14 +150,13 @@ func createAndStartContainers(
}, },
} }
// TODO: Get host and port from ProxyConfig
respFront, err = cli.ContainerCreate(ctx, &container.Config{ respFront, err = cli.ContainerCreate(ctx, &container.Config{
Image: imageFront, Image: imageFront,
Tty: false, Tty: false,
Env: []string{ Env: []string{
"REACT_APP_DEFAULT_FILTER= ", "REACT_APP_DEFAULT_FILTER= ",
"REACT_APP_HUB_HOST=localhost", fmt.Sprintf("REACT_APP_HUB_HOST=%s", config.Config.Tap.Proxy.Host),
"REACT_APP_HUB_PORT=8898", fmt.Sprintf("REACT_APP_HUB_PORT=%d", config.Config.Tap.Proxy.Hub.SrcPort),
}, },
}, hostConfigFront, nil, nil, nameFront) }, hostConfigFront, nil, nil, nameFront)
if err != nil { if err != nil {

View File

@@ -261,7 +261,7 @@ func (provider *Provider) BuildHubPod(opts *PodOptions) (*core.Pod, error) {
return pod, nil return pod, nil
} }
func (provider *Provider) BuildFrontPod(opts *PodOptions) (*core.Pod, error) { func (provider *Provider) BuildFrontPod(opts *PodOptions, hubHost string, hubPort string) (*core.Pod, error) {
configMapVolume := &core.ConfigMapVolumeSource{} configMapVolume := &core.ConfigMapVolumeSource{}
configMapVolume.Name = ConfigMapName configMapVolume.Name = ConfigMapName
@@ -285,7 +285,6 @@ func (provider *Provider) BuildFrontPod(opts *PodOptions) (*core.Pod, error) {
volumeMounts := []core.VolumeMount{} volumeMounts := []core.VolumeMount{}
volumes := []core.Volume{} volumes := []core.Volume{}
// TODO: Get host and port from ProxyConfig
containers := []core.Container{ containers := []core.Container{
{ {
Name: opts.PodName, Name: opts.PodName,
@@ -322,11 +321,11 @@ func (provider *Provider) BuildFrontPod(opts *PodOptions) (*core.Pod, error) {
}, },
{ {
Name: "REACT_APP_HUB_HOST", Name: "REACT_APP_HUB_HOST",
Value: "localhost", Value: hubHost,
}, },
{ {
Name: "REACT_APP_HUB_PORT", Name: "REACT_APP_HUB_PORT",
Value: "8898", Value: hubPort,
}, },
}, },
}, },

View File

@@ -110,7 +110,7 @@ func createSelfHubPod(ctx context.Context, kubernetesProvider *kubernetes.Provid
} }
func createFrontPod(ctx context.Context, kubernetesProvider *kubernetes.Provider, opts *kubernetes.PodOptions) error { func createFrontPod(ctx context.Context, kubernetesProvider *kubernetes.Provider, opts *kubernetes.PodOptions) error {
pod, err := kubernetesProvider.BuildFrontPod(opts) pod, err := kubernetesProvider.BuildFrontPod(opts, config.Config.Tap.Proxy.Host, fmt.Sprintf("%d", config.Config.Tap.Proxy.Hub.SrcPort))
if err != nil { if err != nil {
return err return err
} }