Skip to content

Commit

Permalink
trial
Browse files Browse the repository at this point in the history
  • Loading branch information
uriziv1 committed Aug 25, 2024
1 parent e98d8ec commit 102febc
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"strings"
"math"
stdErrors "errors"

consolev1alpha1 "github.com/openshift/api/console/v1alpha1"
operatorv1 "github.com/openshift/api/operator/v1"
Expand All @@ -36,11 +35,11 @@ import (
const MainBasePath = "/"
const CompatibilityBasePath = "/compatibility/"

func safeIntToUint32(val int) (uint32, error) {
if val < 0 || val > math.MaxUint32 {
return 0, stdErrors.New("integer overflow")
func safeIntToInt32(val int) int32 {
if val < math.MinInt32 || val > math.MaxInt32 {
panic("integer overflow")
}
return uint32(val), nil
return int32(val)
}

func GetDeployment(namespace string) *appsv1.Deployment {
Expand All @@ -67,8 +66,8 @@ func GetService(port int, namespace string) *apiv1.Service {
Spec: apiv1.ServiceSpec{
Ports: []apiv1.ServicePort{
{Protocol: "TCP",
TargetPort: intstr.IntOrString{IntVal: safeIntToUint32(port)},
Port: safeIntToUint32(port),
TargetPort: intstr.IntOrString{IntVal: safeIntToInt32(port)},
Port: safeIntToInt32(port),
Name: "console-port",
},
},
Expand All @@ -90,7 +89,7 @@ func GetConsolePluginCR(consolePort int, basePath string, serviceNamespace strin
Service: consolev1alpha1.ConsolePluginService{
Name: "ibm-odf-console-service",
Namespace: serviceNamespace,
Port: safeIntToUint32(consolePort),
Port: safeIntToInt32(consolePort),
BasePath: basePath,
},
},
Expand Down

0 comments on commit 102febc

Please sign in to comment.