istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/test/framework/components/echo/common/ports/ports.go (about)

     1  // Copyright Istio Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package ports
    16  
    17  import (
    18  	"istio.io/istio/pkg/config/protocol"
    19  	"istio.io/istio/pkg/test/framework/components/echo"
    20  )
    21  
    22  // Port names.
    23  var (
    24  	HTTP             = echo.Port{Name: "http", Protocol: protocol.HTTP, ServicePort: 80, WorkloadPort: 18080}
    25  	GRPC             = echo.Port{Name: "grpc", Protocol: protocol.GRPC, ServicePort: 7070, WorkloadPort: 17070}
    26  	HTTP2            = echo.Port{Name: "http2", Protocol: protocol.HTTP, ServicePort: 85, WorkloadPort: 18085}
    27  	TCP              = echo.Port{Name: "tcp", Protocol: protocol.TCP, ServicePort: 9090, WorkloadPort: 19090}
    28  	HTTPS            = echo.Port{Name: "https", Protocol: protocol.HTTPS, ServicePort: 443, WorkloadPort: 18443, TLS: true}
    29  	TCPServer        = echo.Port{Name: "tcp-server", Protocol: protocol.TCP, ServicePort: 9091, WorkloadPort: 16060, ServerFirst: true}
    30  	AutoTCP          = echo.Port{Name: "auto-tcp", Protocol: protocol.TCP, ServicePort: 9092, WorkloadPort: 19091}
    31  	AutoTCPServer    = echo.Port{Name: "auto-tcp-server", Protocol: protocol.TCP, ServicePort: 9093, WorkloadPort: 16061, ServerFirst: true}
    32  	AutoHTTP         = echo.Port{Name: "auto-http", Protocol: protocol.HTTP, ServicePort: 81, WorkloadPort: 18081}
    33  	AutoGRPC         = echo.Port{Name: "auto-grpc", Protocol: protocol.GRPC, ServicePort: 7071, WorkloadPort: 17071}
    34  	AutoHTTPS        = echo.Port{Name: "auto-https", Protocol: protocol.HTTPS, ServicePort: 9443, WorkloadPort: 19443, TLS: true}
    35  	HTTPInstance     = echo.Port{Name: "http-instance", Protocol: protocol.HTTP, ServicePort: 82, WorkloadPort: 18082, InstanceIP: true}
    36  	HTTPLocalHost    = echo.Port{Name: "http-localhost", Protocol: protocol.HTTP, ServicePort: 84, WorkloadPort: 18084, LocalhostIP: true}
    37  	TCPWorkloadOnly  = echo.Port{Name: "tcp-wl-only", Protocol: protocol.TCP, ServicePort: echo.NoServicePort, WorkloadPort: 19092}
    38  	HTTPWorkloadOnly = echo.Port{Name: "http-wl-only", Protocol: protocol.HTTP, ServicePort: echo.NoServicePort, WorkloadPort: 18083}
    39  	TCPForHTTP       = echo.Port{Name: "tcp-for-http", Protocol: protocol.HTTP, ServicePort: 86, WorkloadPort: 18086}
    40  )
    41  
    42  // All the common ports.
    43  func All() echo.Ports {
    44  	return echo.Ports{
    45  		HTTP,
    46  		GRPC,
    47  		HTTP2,
    48  		TCP,
    49  		HTTPS,
    50  		TCPServer,
    51  		AutoTCP,
    52  		AutoTCPServer,
    53  		AutoHTTP,
    54  		AutoGRPC,
    55  		AutoHTTPS,
    56  		HTTPInstance,
    57  		HTTPLocalHost,
    58  		TCPWorkloadOnly,
    59  		HTTPWorkloadOnly,
    60  		TCPForHTTP,
    61  	}
    62  }
    63  
    64  // Headless returns a modified version of All for use with headless services.
    65  func Headless() echo.Ports {
    66  	all := All()
    67  	headlessPorts := make([]echo.Port, len(all))
    68  	for i, p := range all {
    69  		if !p.IsWorkloadOnly() {
    70  			p.ServicePort = p.WorkloadPort
    71  		}
    72  		headlessPorts[i] = p
    73  	}
    74  	return headlessPorts
    75  }