1 /* 2 Copyright 2021 The Flux 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 v1beta2 18 19 import "fmt" 20 21 // CrossNamespaceSourceReference contains enough information to let you locate the 22 // typed Kubernetes resource object at cluster level. 23 type CrossNamespaceSourceReference struct { 24 // API version of the referent. 25 // +optional 26 APIVersion string `json:"apiVersion,omitempty"` 27 28 // Kind of the referent. 29 // +kubebuilder:validation:Enum=OCIRepository;GitRepository;Bucket 30 // +required 31 Kind string `json:"kind"` 32 33 // Name of the referent. 34 // +required 35 Name string `json:"name"` 36 37 // Namespace of the referent, defaults to the namespace of the Kubernetes resource object that contains the reference. 38 // +optional 39 Namespace string `json:"namespace,omitempty"` 40 } 41 42 func (s *CrossNamespaceSourceReference) String() string { 43 if s.Namespace != "" { 44 return fmt.Sprintf("%s/%s/%s", s.Kind, s.Namespace, s.Name) 45 } 46 return fmt.Sprintf("%s/%s", s.Kind, s.Name) 47 } 48