Move the 8899 integer and string literals into a const named DefaultApiServerPort in shared (#367)

This commit is contained in:
M. Mert Yıldıran 2021-10-17 15:28:33 +03:00 committed by GitHub
parent 9d179c7227
commit 167b17dfd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 4 deletions

View File

@ -12,12 +12,14 @@ import (
"strings"
"syscall"
"time"
"github.com/up9inc/mizu/shared"
)
const (
longRetriesCount = 100
shortRetriesCount = 10
defaultApiServerPort = 8899
defaultApiServerPort = shared.DefaultApiServerPort
defaultNamespaceName = "mizu-tests"
defaultServiceName = "httpbin"
defaultEntriesCount = 50

View File

@ -2,6 +2,7 @@ package utils
import (
"context"
"fmt"
"net/http"
"net/url"
"os"
@ -11,6 +12,7 @@ import (
"time"
"github.com/gin-gonic/gin"
"github.com/up9inc/mizu/shared"
"github.com/up9inc/mizu/shared/logger"
)
@ -37,7 +39,7 @@ func StartServer(app *gin.Engine) {
// Run server.
logger.Log.Infof("Starting the server...")
if err := app.Run(":8899"); err != nil {
if err := app.Run(fmt.Sprintf(":%d", shared.DefaultApiServerPort)); err != nil {
logger.Log.Errorf("Server is not running! Reason: %v", err)
}
}

View File

@ -193,7 +193,7 @@ func (provider *Provider) CreateMizuApiServerPod(ctx context.Context, opts *ApiS
command = append(command, "--namespace", opts.Namespace)
}
port := intstr.FromInt(8899)
port := intstr.FromInt(shared.DefaultApiServerPort)
pod := &core.Pod{
ObjectMeta: metav1.ObjectMeta{
@ -281,7 +281,7 @@ func (provider *Provider) CreateService(ctx context.Context, namespace string, s
Namespace: namespace,
},
Spec: core.ServiceSpec{
Ports: []core.ServicePort{{TargetPort: intstr.FromInt(8899), Port: 80}},
Ports: []core.ServicePort{{TargetPort: intstr.FromInt(shared.DefaultApiServerPort), Port: 80}},
Type: core.ServiceTypeClusterIP,
Selector: map[string]string{"app": appLabelValue},
},

View File

@ -10,4 +10,5 @@ const (
RulePolicyPath = "/app/enforce-policy/"
RulePolicyFileName = "enforce-policy.yaml"
GoGCEnvVar = "GOGC"
DefaultApiServerPort = 8899
)