1 /* 2 Copyright 2022 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 v2beta2 18 19 // CrossNamespaceObjectReference contains enough information to let you locate 20 // the typed referenced object at cluster level. 21 type CrossNamespaceObjectReference struct { 22 // APIVersion of the referent. 23 // +optional 24 APIVersion string `json:"apiVersion,omitempty"` 25 26 // Kind of the referent. 27 // +kubebuilder:validation:Enum=HelmRepository;GitRepository;Bucket 28 // +required 29 Kind string `json:"kind,omitempty"` 30 31 // Name of the referent. 32 // +kubebuilder:validation:MinLength=1 33 // +kubebuilder:validation:MaxLength=253 34 // +required 35 Name string `json:"name"` 36 37 // Namespace of the referent. 38 // +kubebuilder:validation:MinLength=1 39 // +kubebuilder:validation:MaxLength=63 40 // +kubebuilder:validation:Optional 41 // +optional 42 Namespace string `json:"namespace,omitempty"` 43 } 44 45 // CrossNamespaceSourceReference contains enough information to let you locate 46 // the typed referenced object at cluster level. 47 type CrossNamespaceSourceReference struct { 48 // APIVersion of the referent. 49 // +optional 50 APIVersion string `json:"apiVersion,omitempty"` 51 52 // Kind of the referent. 53 // +kubebuilder:validation:Enum=OCIRepository;HelmChart 54 // +required 55 Kind string `json:"kind"` 56 57 // Name of the referent. 58 // +kubebuilder:validation:MinLength=1 59 // +kubebuilder:validation:MaxLength=253 60 // +required 61 Name string `json:"name"` 62 63 // Namespace of the referent, defaults to the namespace of the Kubernetes 64 // resource object that contains the reference. 65 // +kubebuilder:validation:MinLength=1 66 // +kubebuilder:validation:MaxLength=63 67 // +kubebuilder:validation:Optional 68 // +optional 69 Namespace string `json:"namespace,omitempty"` 70 } 71 72 // ValuesReference contains a reference to a resource containing Helm values, 73 // and optionally the key they can be found at. 74 type ValuesReference struct { 75 // Kind of the values referent, valid values are ('Secret', 'ConfigMap'). 76 // +kubebuilder:validation:Enum=Secret;ConfigMap 77 // +required 78 Kind string `json:"kind"` 79 80 // Name of the values referent. Should reside in the same namespace as the 81 // referring resource. 82 // +kubebuilder:validation:MinLength=1 83 // +kubebuilder:validation:MaxLength=253 84 // +required 85 Name string `json:"name"` 86 87 // ValuesKey is the data key where the values.yaml or a specific value can be 88 // found at. Defaults to 'values.yaml'. 89 // +kubebuilder:validation:MaxLength=253 90 // +kubebuilder:validation:Pattern=`^[\-._a-zA-Z0-9]+$` 91 // +optional 92 ValuesKey string `json:"valuesKey,omitempty"` 93 94 // TargetPath is the YAML dot notation path the value should be merged at. When 95 // set, the ValuesKey is expected to be a single flat value. Defaults to 'None', 96 // which results in the values getting merged at the root. 97 // +kubebuilder:validation:MaxLength=250 98 // +kubebuilder:validation:Pattern=`^([a-zA-Z0-9_\-.\\\/]|\[[0-9]{1,5}\])+$` 99 // +optional 100 TargetPath string `json:"targetPath,omitempty"` 101 102 // Optional marks this ValuesReference as optional. When set, a not found error 103 // for the values reference is ignored, but any ValuesKey, TargetPath or 104 // transient error will still result in a reconciliation failure. 105 // +optional 106 Optional bool `json:"optional,omitempty"` 107 } 108 109 // GetValuesKey returns the defined ValuesKey, or the default ('values.yaml'). 110 func (in ValuesReference) GetValuesKey() string { 111 if in.ValuesKey == "" { 112 return "values.yaml" 113 } 114 return in.ValuesKey 115 } 116