istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/test/framework/components/echo/config/param/wellknown.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 param
    16  
    17  // WellKnown defines a well-known template parameter injected automatically by the echo testing framework.
    18  type WellKnown string
    19  
    20  const (
    21  	// From is the template parameter used for injecting the source of a call. It will be of type echo.Caller,
    22  	// which is generally either of type echo.Instance or istio.Ingress (for ingress-based tests).
    23  	From WellKnown = "From"
    24  
    25  	// To is the template parameter used for injecting the echo.Target of a call.
    26  	To WellKnown = "To"
    27  
    28  	// Namespace is the template parameter used for injecting the target namespace.Instance of the applied config.
    29  	Namespace WellKnown = "Namespace"
    30  
    31  	// SystemNamespace is the template parameter used for injecting the namespace.Instance of the Istio system.
    32  	SystemNamespace WellKnown = "SystemNamespace"
    33  )
    34  
    35  func (p WellKnown) String() string {
    36  	return string(p)
    37  }
    38  
    39  type WellKnownList []WellKnown
    40  
    41  func (w WellKnownList) ToStringArray() []string {
    42  	out := make([]string, 0, len(w))
    43  	for _, item := range w {
    44  		out = append(out, item.String())
    45  	}
    46  	return out
    47  }
    48  
    49  func AllWellKnown() WellKnownList {
    50  	return []WellKnown{From, To, Namespace, SystemNamespace}
    51  }