Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 159 additions & 1 deletion apis/v1alpha2/validation/util/utils.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 The Kubernetes Authors.
Copyright 2022 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,3 +31,161 @@ func PortNumberPtr(p int) *gatewayv1a2.PortNumber {
result := gatewayv1a2.PortNumber(p)
return &result
}

// PortNumberInt32 translates reference value of ptr to Int32
func PortNumberInt32(name *gatewayv1a2.PortNumber) int32 {
portNum := int32(*name)
return portNum
}

// SectionNamePtr translates an int to a *SectionName
func SectionNamePtr(sectionName string) *gatewayv1a2.SectionName {
gwSectionName := gatewayv1a2.SectionName(sectionName)
return &gwSectionName
}

// SectionNameStr translates reference value of ptr to string
func SectionNameStr(name *gatewayv1a2.SectionName) string {
sectionName := string(*name)
return sectionName
}

func ListenerHostnameToPtr(host string) *gatewayv1a2.Hostname {
h := *gatewayv1a2.Hostname(host)
return &h
}

func ListenerHostnameFromPtr(name *Hostname) string {
hostName := string(*name)
return hostName
}

func PreciseHostnameToPtr(host string) *PreciseHostname {
h := PreciseHostname(host)
return &h
}

func PreciseHostnameFromPtr(name *PreciseHostname) string {
prechostName := string(*name)
return prechostName
}

func GroupToPtr(group string) *Group {
gwGroup := Group(group)
return &gwGroup
}

func GroupFromPtr(name *Group) string {
groupStr := string(*name)
return groupStr
}

func KindToPtr(kind string) *Kind {
gwKind := Kind(kind)
return &gwKind
}

func KindFromPtr(name *Kind) string {
kindStr := string(*name)
return kindStr
}

func NamespaceToPtr(namespace string) *Namespace {
gwNamespace := Namespace(namespace)
return &gwNamespace
}

func NamespaceFromPtr(name *Namespace) string {
namespace := string(*name)
return namespace
}

func ObjectNameToPtr(name string) *ObjectName {
objectName := ObjectName(name)
return &objectName
}

func ObjectNameFromPtr(name *ObjectName) string {
objname := string(*name)
return objname
}

func GatewayControllerToPtr(name string) *GatewayController {
gwCtrl := GatewayController(name)
return &gwCtrl
}

func GatewayControllerFromPtr(name *GatewayController) string {
gw := string(*name)
return gw
}

func AnnotationKeyToPtr(name string) *AnnotationKey {
key := AnnotationKey(name)
return &key
}

func AnnotationKeyFromPtr(name *AnnotationKey) string {
key := string(*name)
return key
}

func AnnotationValueToPtr(name string) *AnnotationValue {
val := AnnotationValue(name)
return &val
}

func AnnotationValueFromPtr(name *AnnotationValue) string {
val := string(*name)
return val
}

func AddressTypeToPtr(name string) *AddressType {
addr := AddressType(name)
return &addr
}

func AddressTypeFromPtr(name *AddressType) string {
val := string(*name)
return val
}

func RouteConditionTypeToPtr(name string) *RouteConditionType {
str := RouteConditionType(name)
return &str
}

func RouteConditionTypeFromPtr(name *RouteConditionType) string {
val := string(*name)
return val
}

func RouteConditionReasonToPtr(name string) *RouteConditionReason {
str := RouteConditionReason(name)
return &str
}

func RouteConditionReasonFromPtr(name *RouteConditionType) string {
val := string(*name)
return val
}

func ProtocolTypeToPtr(name string) *ProtocolType {
proto := ProtocolType(name)
return &proto
}

func ProtocolTypeFromPtr(name *ProtocolType) string {
val := string(*name)
return val
}

func TLSModeTypePtr(name string) *TLSModeType {
tls := TLSModeType(name)
return &tls
}

func TLSModeTypeFromPtr(name *TLSModeType) string {
val := string(*name)
return val
}
186 changes: 186 additions & 0 deletions apis/v1beta1/validation/util/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,189 @@ func PortNumberPtr(p int) *gatewayv1b1.PortNumber {
result := gatewayv1b1.PortNumber(p)
return &result
}

// PortNumberInt32 translates reference value of ptr to Int32
func PortNumberInt32(name *gatewayv1b1.PortNumber) int32 {
portNum := int32(*name)
return portNum
}

// SectionNamePtr translates an int to a *SectionName
func SectionNamePtr(sectionName string) *gatewayv1b1.SectionName {
gwSectionName := gatewayv1b1.SectionName(sectionName)
return &gwSectionName
}

// SectionNameStr translates reference value of ptr to string
func SectionNameStr(name *gatewayv1b1.SectionName) string {
sectionName := string(*name)
return sectionName
}

// HostnamePtr translates an int to a *Hostname
func HostnamePtr(host string) *gatewayv1b1.Hostname {
h := gatewayv1b1.Hostname(host)
return &h
}

// HostnameStr translates reference value of ptr to string
func HostnameStr(name *gatewayv1b1.Hostname) string {
hostName := string(*name)
return hostName
}

// PreciseHostnamePtr translates an int to a *PreciseHostname
func PreciseHostnamePtr(host string) *gatewayv1b1.PreciseHostname {
h := gatewayv1b1.PreciseHostname(host)
return &h
}

// PreciseHostnameStr translates reference value of ptr to string
func PreciseHostnameStr(name *gatewayv1b1.PreciseHostname) string {
prechostName := string(*name)
return prechostName
}

// GroupPtr translates an int to a *Group
func GroupPtr(group string) *gatewayv1b1.Group {
gwGroup := gatewayv1b1.Group(group)
return &gwGroup
}

// GroupStr translates reference value of ptr to string
func GroupStr(name *gatewayv1b1.Group) string {
groupStr := string(*name)
return groupStr
}

// KindPtr translates an int to a *Kind
func KindPtr(kind string) *gatewayv1b1.Kind {
gwKind := gatewayv1b1.Kind(kind)
return &gwKind
}

// KindStr translates reference value of ptr to string
func KindStr(name *gatewayv1b1.Kind) string {
kindStr := string(*name)
return kindStr
}

// NamespacePtr translates an int to a *Namespace
func NamespacePtr(namespace string) *gatewayv1b1.Namespace {
gwNamespace := gatewayv1b1.Namespace(namespace)
return &gwNamespace
}

// NamespaceStr translates reference value of ptr to string
func NamespaceStr(name *gatewayv1b1.Namespace) string {
namespace := string(*name)
return namespace
}

// ObjectNamePtr translates an int to a *ObjectName
func ObjectNamePtr(name string) *gatewayv1b1.ObjectName {
objectName := gatewayv1b1.ObjectName(name)
return &objectName
}

// ObjectNameStr translates reference value of ptr to string
func ObjectNameStr(name *gatewayv1b1.ObjectName) string {
objname := string(*name)
return objname
}

// GatewayControllerPtr translates an int to a *GatewayController
func GatewayControllerPtr(name string) *gatewayv1b1.GatewayController {
gwCtrl := gatewayv1b1.GatewayController(name)
return &gwCtrl
}

// GatewayControllerStr translates reference value of ptr to string
func GatewayControllerStr(name *gatewayv1b1.GatewayController) string {
gw := string(*name)
return gw
}

// AnnotationKeyPtr translates an int to a *AnnotationKey
func AnnotationKeyPtr(name string) *gatewayv1b1.AnnotationKey {
key := gatewayv1b1.AnnotationKey(name)
return &key
}

// AnnotationKeyStr translates reference value of ptr to string
func AnnotationKeyStr(name *gatewayv1b1.AnnotationKey) string {
key := string(*name)
return key
}

// AnnotationValuePtr translates an int to a *AnnotationValue
func AnnotationValuePtr(name string) *gatewayv1b1.AnnotationValue {
val := gatewayv1b1.AnnotationValue(name)
return &val
}

// AnnotationValueStr translates reference value of ptr to string
func AnnotationValueStr(name *gatewayv1b1.AnnotationValue) string {
val := string(*name)
return val
}

// AddressTypePtr translates an int to a *AddressType
func AddressTypePtr(name string) *gatewayv1b1.AddressType {
addr := gatewayv1b1.AddressType(name)
return &addr
}

// AddressTypeStr translates reference value of ptr to string
func AddressTypeStr(name *gatewayv1b1.AddressType) string {
val := string(*name)
return val
}

// RouteConditionTypePtr translates an int to a *RouteConditionType
func RouteConditionTypePtr(name string) *gatewayv1b1.RouteConditionType {
str := gatewayv1b1.RouteConditionType(name)
return &str
}

// RouteConditionTypeStr translates reference value of ptr to string
func RouteConditionTypeStr(name *gatewayv1b1.RouteConditionType) string {
val := string(*name)
return val
}

// RouteConditionReasonPtr translates an int to a *RouteConditionReason
func RouteConditionReasonPtr(name string) *gatewayv1b1.RouteConditionReason {
str := gatewayv1b1.RouteConditionReason(name)
return &str
}

// RouteConditionReasonStr translates reference value of ptr to string
func RouteConditionReasonStr(name *gatewayv1b1.RouteConditionType) string {
val := string(*name)
return val
}

// ProtocolTypePtr translates an int to a *ProtocolType
func ProtocolTypePtr(name string) *gatewayv1b1.ProtocolType {
proto := gatewayv1b1.ProtocolType(name)
return &proto
}

// ProtocolTypeStr translates reference value of ptr to string
func ProtocolTypeStr(name *gatewayv1b1.ProtocolType) string {
val := string(*name)
return val
}

// TLSModeTypePtr translates an int to a *TLSModeType
func TLSModeTypePtr(name string) *gatewayv1b1.TLSModeType {
tls := gatewayv1b1.TLSModeType(name)
return &tls
}

// TLSModeTypeStr translates reference value of ptr to string
func TLSModeTypeStr(name *gatewayv1b1.TLSModeType) string {
val := string(*name)
return val
}