k8s.io/kubernetes@v1.29.3/test/e2e/framework/namespacedname.go (about)

     1  /*
     2  Copyright 2023 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package framework
    18  
    19  // NamespacedName comprises a resource name, with a mandatory namespace,
    20  // rendered as "<namespace>/<name>". It implements NamedObject and thus can be
    21  // used as function parameter instead of a full API object.
    22  type NamespacedName struct {
    23  	Namespace string
    24  	Name      string
    25  }
    26  
    27  var _ NamedObject = NamespacedName{}
    28  
    29  // NamedObject is a subset of metav1.Object which provides read-only access
    30  // to name and namespace of an object.
    31  type NamedObject interface {
    32  	GetNamespace() string
    33  	GetName() string
    34  }
    35  
    36  // GetNamespace implements NamedObject.
    37  func (n NamespacedName) GetNamespace() string {
    38  	return n.Namespace
    39  }
    40  
    41  // GetName implements NamedObject.
    42  func (n NamespacedName) GetName() string {
    43  	return n.Name
    44  }
    45  
    46  // String returns the general purpose string representation
    47  func (n NamespacedName) String() string {
    48  	return n.Namespace + "/" + n.Name
    49  }