Add flag to disable cross namespace refs to AlertProviders and MetricTemplates

Signed-off-by: Sanskar Jaiswal <sanskar.jaiswal@weave.works>
This commit is contained in:
Sanskar Jaiswal
2022-04-27 17:09:07 +05:30
parent a1e519b352
commit 7df1beef85
14 changed files with 117 additions and 73 deletions
+18 -3
View File
@@ -70,15 +70,15 @@ type CanarySpec struct {
MetricsServer string `json:"metricsServer,omitempty"`
// TargetRef references a target resource
TargetRef CrossNamespaceObjectReference `json:"targetRef"`
TargetRef LocalObjectReference `json:"targetRef"`
// AutoscalerRef references an autoscaling resource
// +optional
AutoscalerRef *CrossNamespaceObjectReference `json:"autoscalerRef,omitempty"`
AutoscalerRef *LocalObjectReference `json:"autoscalerRef,omitempty"`
// Reference to NGINX ingress resource
// +optional
IngressRef *CrossNamespaceObjectReference `json:"ingressRef,omitempty"`
IngressRef *LocalObjectReference `json:"ingressRef,omitempty"`
// Reference to Gloo Upstream resource. Upstream config is copied from
// the referenced upstream to the upstreams generated by flagger.
@@ -393,6 +393,21 @@ type CrossNamespaceObjectReference struct {
Namespace string `json:"namespace,omitempty"`
}
// LocalObjectReference contains enough information to let you locate the typed
// referenced object in the same namespace.
type LocalObjectReference struct {
// API version of the referent
// +optional
APIVersion string `json:"apiVersion,omitempty"`
// Kind of the referent
// +optional
Kind string `json:"kind,omitempty"`
// Name of the referent
Name string `json:"name"`
}
// CustomMetadata holds labels and annotations to set on generated objects.
type CustomMetadata struct {
Labels map[string]string `json:"labels,omitempty"`
@@ -422,12 +422,12 @@ func (in *CanarySpec) DeepCopyInto(out *CanarySpec) {
out.TargetRef = in.TargetRef
if in.AutoscalerRef != nil {
in, out := &in.AutoscalerRef, &out.AutoscalerRef
*out = new(CrossNamespaceObjectReference)
*out = new(LocalObjectReference)
**out = **in
}
if in.IngressRef != nil {
in, out := &in.IngressRef, &out.IngressRef
*out = new(CrossNamespaceObjectReference)
*out = new(LocalObjectReference)
**out = **in
}
if in.UpstreamRef != nil {
@@ -621,6 +621,22 @@ func (in *CustomMetadata) DeepCopy() *CustomMetadata {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *LocalObjectReference) DeepCopyInto(out *LocalObjectReference) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LocalObjectReference.
func (in *LocalObjectReference) DeepCopy() *LocalObjectReference {
if in == nil {
return nil
}
out := new(LocalObjectReference)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MetricTemplate) DeepCopyInto(out *MetricTemplate) {
*out = *in