func()

in pkg/service/platform/openshift/openshift.go [132:161]


func (s *OpenshiftService) GetDeploymentSSHPort(instance *gerritApi.Gerrit) (int32, error) {
	ctx := context.Background()

	if os.Getenv(deploymentTypeEnvName) == deploymentConfigsDeploymentType {
		dc, err := s.appClient.DeploymentConfigs(instance.Namespace).Get(ctx, instance.Name, metaV1.GetOptions{})
		if err != nil {
			return 0, fmt.Errorf("failed to GET OpenShift Deployment %q: %w", instance.Name, err)
		}

		for _, env := range dc.Spec.Template.Spec.Containers[0].Env {
			if env.Name == spec.SSHListnerEnvName {
				p, err := getPort(env.Value)
				if err != nil {
					return 0, err
				}

				return p, nil
			}
		}

		return 0, nil
	}

	p, err := s.K8SService.GetDeploymentSSHPort(instance)
	if err != nil {
		return 0, fmt.Errorf("failed to Get gerrit ssh port in k8s deployment: %w", err)
	}

	return p, nil
}