MCPcopy Create free account
hub / github.com/devfile/api / CreateEndpoints

Method CreateEndpoints

test/v200/utils/common/endpoint_test_utils.go:56–101  ·  view source on GitHub ↗

CreateEndpoints creates and returns a randon number of endpoints in a schema structure

()

Source from the content-addressed store, hash-verified

54
55// CreateEndpoints creates and returns a randon number of endpoints in a schema structure
56func (devfile *TestDevfile) CreateEndpoints() []schema.Endpoint {
57
58 numEndpoints := GetRandomNumber(1, 5)
59 endpoints := make([]schema.Endpoint, numEndpoints)
60
61 commonPort := devfile.getUniquePort()
62
63 for i := 0; i < numEndpoints; i++ {
64
65 endpoint := schema.Endpoint{}
66
67 endpoint.Name = GetRandomUniqueString(GetRandomNumber(5, 10), true)
68 LogInfoMessage(fmt.Sprintf(" ....... add endpoint %d name : %s", i, endpoint.Name))
69
70 if GetBinaryDecision() {
71 endpoint.TargetPort = devfile.getUniquePort()
72 } else {
73 endpoint.TargetPort = commonPort
74 }
75 LogInfoMessage(fmt.Sprintf(" ....... add endpoint %d targetPort: %d", i, endpoint.TargetPort))
76
77 if GetBinaryDecision() {
78 endpoint.Exposure = getRandomExposure()
79 LogInfoMessage(fmt.Sprintf(" ....... add endpoint %d exposure: %s", i, endpoint.Exposure))
80 }
81
82 if GetBinaryDecision() {
83 endpoint.Protocol = getRandomProtocol()
84 LogInfoMessage(fmt.Sprintf(" ....... add endpoint %d protocol: %s", i, endpoint.Protocol))
85 }
86
87 value := GetBinaryDecision()
88 endpoint.Secure = &value
89 LogInfoMessage(fmt.Sprintf(" ....... add endpoint %d secure: %t", i, *endpoint.Secure))
90
91 if GetBinaryDecision() {
92 endpoint.Path = "/Path_" + GetRandomString(GetRandomNumber(3, 15), false)
93 LogInfoMessage(fmt.Sprintf(" ....... add endpoint %d path: %s", i, endpoint.Path))
94 }
95
96 endpoints[i] = endpoint
97
98 }
99
100 return endpoints
101}

Callers 2

SetK8sComponentValuesMethod · 0.95

Calls 8

getUniquePortMethod · 0.95
GetRandomNumberFunction · 0.85
GetRandomUniqueStringFunction · 0.85
LogInfoMessageFunction · 0.85
GetBinaryDecisionFunction · 0.85
getRandomExposureFunction · 0.85
getRandomProtocolFunction · 0.85
GetRandomStringFunction · 0.85

Tested by

no test coverage detected