diff --git a/artifacts/flagger/crd.yaml b/artifacts/flagger/crd.yaml index 0989e403..c8092d8c 100644 --- a/artifacts/flagger/crd.yaml +++ b/artifacts/flagger/crd.yaml @@ -215,18 +215,29 @@ spec: required: ["name", "threshold"] properties: name: - description: Name of the Prometheus metric + description: Name of the metric type: string interval: - description: Interval of the promql query + description: Interval of the query type: string pattern: "^[0-9]+(m|s)" threshold: - description: Max scalar value accepted for this metric + description: Max value accepted for this metric type: number query: description: Prometheus query type: string + templateRef: + description: Metric template reference + type: object + required: ["name"] + properties: + name: + description: Name of this metric template + type: string + namespace: + description: Namespace of this metric template + type: string webhooks: description: Webhook list for this canary type: array @@ -322,3 +333,62 @@ spec: type: description: Type of this condition type: string +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: metrictemplates.flagger.app + annotations: + helm.sh/resource-policy: keep +spec: + group: flagger.app + version: v1alpha1 + versions: + - name: v1alpha1 + served: true + storage: true + names: + plural: metrictemplates + singular: metrictemplate + kind: MetricTemplate + categories: + - all + scope: Namespaced + subresources: + status: {} + validation: + openAPIV3Schema: + properties: + spec: + required: + - provider + - query + properties: + provider: + description: Provider of this metric template + type: object + required: + - type + - address + properties: + type: + description: Type of this provider + type: string + enum: + - prometheus + - influxdb + address: + description: API address of this provider + type: string + secretRef: + description: Kubernetes secret reference containing the provider credentials + type: object + required: + - name + properties: + name: + description: Name of the Kubernetes secret + type: string + query: + description: Query of this metric template + type: string diff --git a/charts/flagger/templates/crd.yaml b/charts/flagger/templates/crd.yaml index 48575fef..3bfc48bd 100644 --- a/charts/flagger/templates/crd.yaml +++ b/charts/flagger/templates/crd.yaml @@ -78,7 +78,7 @@ spec: targetRef: description: Deployment selector type: object - required: ['apiVersion', 'kind', 'name'] + required: ["apiVersion", "kind", "name"] properties: apiVersion: type: string @@ -91,7 +91,7 @@ spec: anyOf: - type: string - type: object - required: ['apiVersion', 'kind', 'name'] + required: ["apiVersion", "kind", "name"] properties: apiVersion: type: string @@ -104,7 +104,7 @@ spec: anyOf: - type: string - type: object - required: ['apiVersion', 'kind', 'name'] + required: ["apiVersion", "kind", "name"] properties: apiVersion: type: string @@ -114,7 +114,7 @@ spec: type: string service: type: object - required: ['port'] + required: ["port"] properties: name: description: Kubernetes service name @@ -213,21 +213,32 @@ spec: properties: items: type: object - required: ['name', 'threshold'] + required: ["name", "threshold"] properties: name: - description: Name of the Prometheus metric + description: Name of the metric type: string interval: - description: Interval of the promql query + description: Interval of the query type: string pattern: "^[0-9]+(m|s)" threshold: - description: Max scalar value accepted for this metric + description: Max value accepted for this metric type: number query: description: Prometheus query type: string + templateRef: + description: Metric template reference + type: object + required: ["name"] + properties: + name: + description: Name of this metric template + type: string + namespace: + description: Namespace of this metric template + type: string webhooks: description: Webhook list for this canary type: array @@ -301,7 +312,7 @@ spec: properties: items: type: object - required: ['type', 'status', 'reason'] + required: ["type", "status", "reason"] properties: lastTransitionTime: description: LastTransitionTime of this condition @@ -323,4 +334,63 @@ spec: type: description: Type of this condition type: string +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: metrictemplates.flagger.app + annotations: + helm.sh/resource-policy: keep +spec: + group: flagger.app + version: v1alpha1 + versions: + - name: v1alpha1 + served: true + storage: true + names: + plural: metrictemplates + singular: metrictemplate + kind: MetricTemplate + categories: + - all + scope: Namespaced + subresources: + status: {} + validation: + openAPIV3Schema: + properties: + spec: + required: + - provider + - query + properties: + provider: + description: Provider of this metric template + type: object + required: + - type + - address + properties: + type: + description: Type of this provider + type: string + enum: + - prometheus + - influxdb + address: + description: API address of this provider + type: string + secretRef: + description: Kubernetes secret reference containing the provider credentials + type: object + required: + - name + properties: + name: + description: Name of the Kubernetes secret + type: string + query: + description: Query of this metric template + type: string {{- end }} diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 12351485..d9f7d575 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -30,7 +30,7 @@ chmod +x ${CODEGEN_PKG}/generate-groups.sh ${CODEGEN_PKG}/generate-groups.sh all \ github.com/weaveworks/flagger/pkg/client github.com/weaveworks/flagger/pkg/apis \ - "flagger:v1alpha3 appmesh:v1beta1 istio:v1alpha3 smi:v1alpha1 gloo:v1 projectcontour:v1" \ + "flagger:v1alpha3 flagger:v1alpha1 appmesh:v1beta1 istio:v1alpha3 smi:v1alpha1 gloo:v1 projectcontour:v1" \ --output-base "${TEMP_DIR}" \ --go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt diff --git a/kustomize/base/flagger/crd.yaml b/kustomize/base/flagger/crd.yaml index 0989e403..c8092d8c 100644 --- a/kustomize/base/flagger/crd.yaml +++ b/kustomize/base/flagger/crd.yaml @@ -215,18 +215,29 @@ spec: required: ["name", "threshold"] properties: name: - description: Name of the Prometheus metric + description: Name of the metric type: string interval: - description: Interval of the promql query + description: Interval of the query type: string pattern: "^[0-9]+(m|s)" threshold: - description: Max scalar value accepted for this metric + description: Max value accepted for this metric type: number query: description: Prometheus query type: string + templateRef: + description: Metric template reference + type: object + required: ["name"] + properties: + name: + description: Name of this metric template + type: string + namespace: + description: Namespace of this metric template + type: string webhooks: description: Webhook list for this canary type: array @@ -322,3 +333,62 @@ spec: type: description: Type of this condition type: string +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: metrictemplates.flagger.app + annotations: + helm.sh/resource-policy: keep +spec: + group: flagger.app + version: v1alpha1 + versions: + - name: v1alpha1 + served: true + storage: true + names: + plural: metrictemplates + singular: metrictemplate + kind: MetricTemplate + categories: + - all + scope: Namespaced + subresources: + status: {} + validation: + openAPIV3Schema: + properties: + spec: + required: + - provider + - query + properties: + provider: + description: Provider of this metric template + type: object + required: + - type + - address + properties: + type: + description: Type of this provider + type: string + enum: + - prometheus + - influxdb + address: + description: API address of this provider + type: string + secretRef: + description: Kubernetes secret reference containing the provider credentials + type: object + required: + - name + properties: + name: + description: Name of the Kubernetes secret + type: string + query: + description: Query of this metric template + type: string diff --git a/pkg/apis/flagger/v1alpha1/doc.go b/pkg/apis/flagger/v1alpha1/doc.go new file mode 100755 index 00000000..c019ac47 --- /dev/null +++ b/pkg/apis/flagger/v1alpha1/doc.go @@ -0,0 +1,21 @@ +/* +Copyright The Flagger Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:deepcopy-gen=package + +// Package v1alpha1 is the v1alpha1 version of the API. +// +groupName=flagger.app +package v1alpha1 diff --git a/pkg/apis/flagger/v1alpha1/metric.go b/pkg/apis/flagger/v1alpha1/metric.go new file mode 100644 index 00000000..657f997d --- /dev/null +++ b/pkg/apis/flagger/v1alpha1/metric.go @@ -0,0 +1,120 @@ +/* +Copyright The Flagger Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "text/template" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + MetricTemplateKind = "MetricTemplate" + MetricInterval = "1m" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// MetricTemplate is a specification for a canary analysis metric +type MetricTemplate struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec MetricTemplateSpec `json:"spec"` + Status MetricTemplateStatus `json:"status"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// MetricTemplateList is a list of metric template resources +type MetricTemplateList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []MetricTemplate `json:"items"` +} + +// MetricTemplateSpec is the spec for a metric template resource +type MetricTemplateSpec struct { + // Provider of this metric + Provider MetricTemplateProvider `json:"provider,omitempty"` + + // Query template for this metric + Query string `json:"query,omitempty"` +} + +// MetricProvider is the spec for a MetricProvider resource +type MetricTemplateProvider struct { + // Type of provider + Type string `json:"type,omitempty"` + + // HTTP(S) address of this provider + Address string `json:"address,omitempty"` + + // Secret reference containing the provider credentials + // +optional + SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty"` +} + +// MetricTemplateModel is the query template model +type MetricTemplateModel struct { + Name string `json:"name"` + Namespace string `json:"namespace"` + Target string `json:"target"` + Service string `json:"service"` + Ingress string `json:"ingress"` + Interval string `json:"interval"` +} + +// TemplateFunctions returns a map of functions, one for each model field +func (mtm *MetricTemplateModel) TemplateFunctions() template.FuncMap { + return template.FuncMap{ + "name": func() string { return mtm.Name }, + "namespace": func() string { return mtm.Namespace }, + "target": func() string { return mtm.Target }, + "service": func() string { return mtm.Service }, + "ingress": func() string { return mtm.Ingress }, + "interval": func() string { return mtm.Interval }, + } +} + +type MetricTemplateStatus struct { + // Conditions of this status + Conditions []MetricTemplateCondition `json:"conditions,omitempty"` +} + +type MetricTemplateCondition struct { + // Type of this condition + Type string `json:"type"` + + // Status of this condition + Status corev1.ConditionStatus `json:"status"` + + // LastUpdateTime of this condition + LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"` + + // LastTransitionTime of this condition + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` + + // Reason for the current status of this condition + Reason string `json:"reason,omitempty"` + + // Message associated with this condition + Message string `json:"message,omitempty"` +} diff --git a/pkg/apis/flagger/v1alpha1/register.go b/pkg/apis/flagger/v1alpha1/register.go new file mode 100755 index 00000000..c400a280 --- /dev/null +++ b/pkg/apis/flagger/v1alpha1/register.go @@ -0,0 +1,53 @@ +/* +Copyright The Flagger Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + + "github.com/weaveworks/flagger/pkg/apis/flagger" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: flagger.GroupName, Version: "v1alpha1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &MetricTemplate{}, + &MetricTemplateList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/flagger/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/flagger/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000..f114c902 --- /dev/null +++ b/pkg/apis/flagger/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,182 @@ +// +build !ignore_autogenerated + +/* +Copyright The Flagger Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// 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 + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricTemplate. +func (in *MetricTemplate) DeepCopy() *MetricTemplate { + if in == nil { + return nil + } + out := new(MetricTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MetricTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricTemplateCondition) DeepCopyInto(out *MetricTemplateCondition) { + *out = *in + in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricTemplateCondition. +func (in *MetricTemplateCondition) DeepCopy() *MetricTemplateCondition { + if in == nil { + return nil + } + out := new(MetricTemplateCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricTemplateList) DeepCopyInto(out *MetricTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]MetricTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricTemplateList. +func (in *MetricTemplateList) DeepCopy() *MetricTemplateList { + if in == nil { + return nil + } + out := new(MetricTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MetricTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricTemplateModel) DeepCopyInto(out *MetricTemplateModel) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricTemplateModel. +func (in *MetricTemplateModel) DeepCopy() *MetricTemplateModel { + if in == nil { + return nil + } + out := new(MetricTemplateModel) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricTemplateProvider) DeepCopyInto(out *MetricTemplateProvider) { + *out = *in + if in.SecretRef != nil { + in, out := &in.SecretRef, &out.SecretRef + *out = new(v1.LocalObjectReference) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricTemplateProvider. +func (in *MetricTemplateProvider) DeepCopy() *MetricTemplateProvider { + if in == nil { + return nil + } + out := new(MetricTemplateProvider) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricTemplateSpec) DeepCopyInto(out *MetricTemplateSpec) { + *out = *in + in.Provider.DeepCopyInto(&out.Provider) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricTemplateSpec. +func (in *MetricTemplateSpec) DeepCopy() *MetricTemplateSpec { + if in == nil { + return nil + } + out := new(MetricTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricTemplateStatus) DeepCopyInto(out *MetricTemplateStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]MetricTemplateCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricTemplateStatus. +func (in *MetricTemplateStatus) DeepCopy() *MetricTemplateStatus { + if in == nil { + return nil + } + out := new(MetricTemplateStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/flagger/v1alpha3/types.go b/pkg/apis/flagger/v1alpha3/types.go index 96e7f935..f281240c 100644 --- a/pkg/apis/flagger/v1alpha3/types.go +++ b/pkg/apis/flagger/v1alpha3/types.go @@ -135,6 +135,14 @@ type CanaryMetric struct { Threshold float64 `json:"threshold"` // +optional Query string `json:"query,omitempty"` + // +optional + TemplateRef *MetricTemplateRef `json:"templateRef,omitempty"` +} + +type MetricTemplateRef struct { + Name string `json:"name"` + // +optional + Namespace string `json:"namespace,omitempty"` } // HookType can be pre, post or during rollout diff --git a/pkg/apis/flagger/v1alpha3/zz_generated.deepcopy.go b/pkg/apis/flagger/v1alpha3/zz_generated.deepcopy.go index 55f12a94..e6fa5689 100644 --- a/pkg/apis/flagger/v1alpha3/zz_generated.deepcopy.go +++ b/pkg/apis/flagger/v1alpha3/zz_generated.deepcopy.go @@ -60,7 +60,9 @@ func (in *CanaryAnalysis) DeepCopyInto(out *CanaryAnalysis) { if in.Metrics != nil { in, out := &in.Metrics, &out.Metrics *out = make([]CanaryMetric, len(*in)) - copy(*out, *in) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } if in.Webhooks != nil { in, out := &in.Webhooks, &out.Webhooks @@ -143,6 +145,11 @@ func (in *CanaryList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CanaryMetric) DeepCopyInto(out *CanaryMetric) { *out = *in + if in.TemplateRef != nil { + in, out := &in.TemplateRef, &out.TemplateRef + *out = new(MetricTemplateRef) + **out = **in + } return } @@ -338,3 +345,19 @@ func (in *CanaryWebhookPayload) DeepCopy() *CanaryWebhookPayload { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricTemplateRef) DeepCopyInto(out *MetricTemplateRef) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricTemplateRef. +func (in *MetricTemplateRef) DeepCopy() *MetricTemplateRef { + if in == nil { + return nil + } + out := new(MetricTemplateRef) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 9a41c4c4..c31899f2 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -22,6 +22,7 @@ import ( "fmt" appmeshv1beta1 "github.com/weaveworks/flagger/pkg/client/clientset/versioned/typed/appmesh/v1beta1" + flaggerv1alpha1 "github.com/weaveworks/flagger/pkg/client/clientset/versioned/typed/flagger/v1alpha1" flaggerv1alpha3 "github.com/weaveworks/flagger/pkg/client/clientset/versioned/typed/flagger/v1alpha3" gloov1 "github.com/weaveworks/flagger/pkg/client/clientset/versioned/typed/gloo/v1" networkingv1alpha3 "github.com/weaveworks/flagger/pkg/client/clientset/versioned/typed/istio/v1alpha3" @@ -36,6 +37,7 @@ type Interface interface { Discovery() discovery.DiscoveryInterface AppmeshV1beta1() appmeshv1beta1.AppmeshV1beta1Interface FlaggerV1alpha3() flaggerv1alpha3.FlaggerV1alpha3Interface + FlaggerV1alpha1() flaggerv1alpha1.FlaggerV1alpha1Interface GlooV1() gloov1.GlooV1Interface NetworkingV1alpha3() networkingv1alpha3.NetworkingV1alpha3Interface ProjectcontourV1() projectcontourv1.ProjectcontourV1Interface @@ -48,6 +50,7 @@ type Clientset struct { *discovery.DiscoveryClient appmeshV1beta1 *appmeshv1beta1.AppmeshV1beta1Client flaggerV1alpha3 *flaggerv1alpha3.FlaggerV1alpha3Client + flaggerV1alpha1 *flaggerv1alpha1.FlaggerV1alpha1Client glooV1 *gloov1.GlooV1Client networkingV1alpha3 *networkingv1alpha3.NetworkingV1alpha3Client projectcontourV1 *projectcontourv1.ProjectcontourV1Client @@ -64,6 +67,11 @@ func (c *Clientset) FlaggerV1alpha3() flaggerv1alpha3.FlaggerV1alpha3Interface { return c.flaggerV1alpha3 } +// FlaggerV1alpha1 retrieves the FlaggerV1alpha1Client +func (c *Clientset) FlaggerV1alpha1() flaggerv1alpha1.FlaggerV1alpha1Interface { + return c.flaggerV1alpha1 +} + // GlooV1 retrieves the GlooV1Client func (c *Clientset) GlooV1() gloov1.GlooV1Interface { return c.glooV1 @@ -113,6 +121,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + cs.flaggerV1alpha1, err = flaggerv1alpha1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.glooV1, err = gloov1.NewForConfig(&configShallowCopy) if err != nil { return nil, err @@ -143,6 +155,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset cs.appmeshV1beta1 = appmeshv1beta1.NewForConfigOrDie(c) cs.flaggerV1alpha3 = flaggerv1alpha3.NewForConfigOrDie(c) + cs.flaggerV1alpha1 = flaggerv1alpha1.NewForConfigOrDie(c) cs.glooV1 = gloov1.NewForConfigOrDie(c) cs.networkingV1alpha3 = networkingv1alpha3.NewForConfigOrDie(c) cs.projectcontourV1 = projectcontourv1.NewForConfigOrDie(c) @@ -157,6 +170,7 @@ func New(c rest.Interface) *Clientset { var cs Clientset cs.appmeshV1beta1 = appmeshv1beta1.New(c) cs.flaggerV1alpha3 = flaggerv1alpha3.New(c) + cs.flaggerV1alpha1 = flaggerv1alpha1.New(c) cs.glooV1 = gloov1.New(c) cs.networkingV1alpha3 = networkingv1alpha3.New(c) cs.projectcontourV1 = projectcontourv1.New(c) diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index f7f67683..ffc967ea 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -22,6 +22,8 @@ import ( clientset "github.com/weaveworks/flagger/pkg/client/clientset/versioned" appmeshv1beta1 "github.com/weaveworks/flagger/pkg/client/clientset/versioned/typed/appmesh/v1beta1" fakeappmeshv1beta1 "github.com/weaveworks/flagger/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake" + flaggerv1alpha1 "github.com/weaveworks/flagger/pkg/client/clientset/versioned/typed/flagger/v1alpha1" + fakeflaggerv1alpha1 "github.com/weaveworks/flagger/pkg/client/clientset/versioned/typed/flagger/v1alpha1/fake" flaggerv1alpha3 "github.com/weaveworks/flagger/pkg/client/clientset/versioned/typed/flagger/v1alpha3" fakeflaggerv1alpha3 "github.com/weaveworks/flagger/pkg/client/clientset/versioned/typed/flagger/v1alpha3/fake" gloov1 "github.com/weaveworks/flagger/pkg/client/clientset/versioned/typed/gloo/v1" @@ -96,6 +98,11 @@ func (c *Clientset) FlaggerV1alpha3() flaggerv1alpha3.FlaggerV1alpha3Interface { return &fakeflaggerv1alpha3.FakeFlaggerV1alpha3{Fake: &c.Fake} } +// FlaggerV1alpha1 retrieves the FlaggerV1alpha1Client +func (c *Clientset) FlaggerV1alpha1() flaggerv1alpha1.FlaggerV1alpha1Interface { + return &fakeflaggerv1alpha1.FakeFlaggerV1alpha1{Fake: &c.Fake} +} + // GlooV1 retrieves the GlooV1Client func (c *Clientset) GlooV1() gloov1.GlooV1Interface { return &fakegloov1.FakeGlooV1{Fake: &c.Fake} diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 0c4fc3ff..a43d9d4f 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -20,6 +20,7 @@ package fake import ( appmeshv1beta1 "github.com/weaveworks/flagger/pkg/apis/appmesh/v1beta1" + flaggerv1alpha1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1alpha1" flaggerv1alpha3 "github.com/weaveworks/flagger/pkg/apis/flagger/v1alpha3" gloov1 "github.com/weaveworks/flagger/pkg/apis/gloo/v1" networkingv1alpha3 "github.com/weaveworks/flagger/pkg/apis/istio/v1alpha3" @@ -38,6 +39,7 @@ var parameterCodec = runtime.NewParameterCodec(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ appmeshv1beta1.AddToScheme, flaggerv1alpha3.AddToScheme, + flaggerv1alpha1.AddToScheme, gloov1.AddToScheme, networkingv1alpha3.AddToScheme, projectcontourv1.AddToScheme, diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index a3169314..fb03079e 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -20,6 +20,7 @@ package scheme import ( appmeshv1beta1 "github.com/weaveworks/flagger/pkg/apis/appmesh/v1beta1" + flaggerv1alpha1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1alpha1" flaggerv1alpha3 "github.com/weaveworks/flagger/pkg/apis/flagger/v1alpha3" gloov1 "github.com/weaveworks/flagger/pkg/apis/gloo/v1" networkingv1alpha3 "github.com/weaveworks/flagger/pkg/apis/istio/v1alpha3" @@ -38,6 +39,7 @@ var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ appmeshv1beta1.AddToScheme, flaggerv1alpha3.AddToScheme, + flaggerv1alpha1.AddToScheme, gloov1.AddToScheme, networkingv1alpha3.AddToScheme, projectcontourv1.AddToScheme, diff --git a/pkg/client/clientset/versioned/typed/flagger/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/flagger/v1alpha1/doc.go new file mode 100644 index 00000000..20b3d7fd --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flagger/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Flagger Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/flagger/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/flagger/v1alpha1/fake/doc.go new file mode 100644 index 00000000..7a3b19cb --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flagger/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Flagger Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/client/clientset/versioned/typed/flagger/v1alpha1/fake/fake_flagger_client.go b/pkg/client/clientset/versioned/typed/flagger/v1alpha1/fake/fake_flagger_client.go new file mode 100644 index 00000000..c2e07626 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flagger/v1alpha1/fake/fake_flagger_client.go @@ -0,0 +1,40 @@ +/* +Copyright The Flagger Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/weaveworks/flagger/pkg/client/clientset/versioned/typed/flagger/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeFlaggerV1alpha1 struct { + *testing.Fake +} + +func (c *FakeFlaggerV1alpha1) MetricTemplates(namespace string) v1alpha1.MetricTemplateInterface { + return &FakeMetricTemplates{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeFlaggerV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/flagger/v1alpha1/fake/fake_metrictemplate.go b/pkg/client/clientset/versioned/typed/flagger/v1alpha1/fake/fake_metrictemplate.go new file mode 100644 index 00000000..452becbd --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flagger/v1alpha1/fake/fake_metrictemplate.go @@ -0,0 +1,140 @@ +/* +Copyright The Flagger Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeMetricTemplates implements MetricTemplateInterface +type FakeMetricTemplates struct { + Fake *FakeFlaggerV1alpha1 + ns string +} + +var metrictemplatesResource = schema.GroupVersionResource{Group: "flagger.app", Version: "v1alpha1", Resource: "metrictemplates"} + +var metrictemplatesKind = schema.GroupVersionKind{Group: "flagger.app", Version: "v1alpha1", Kind: "MetricTemplate"} + +// Get takes name of the metricTemplate, and returns the corresponding metricTemplate object, and an error if there is any. +func (c *FakeMetricTemplates) Get(name string, options v1.GetOptions) (result *v1alpha1.MetricTemplate, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(metrictemplatesResource, c.ns, name), &v1alpha1.MetricTemplate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.MetricTemplate), err +} + +// List takes label and field selectors, and returns the list of MetricTemplates that match those selectors. +func (c *FakeMetricTemplates) List(opts v1.ListOptions) (result *v1alpha1.MetricTemplateList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(metrictemplatesResource, metrictemplatesKind, c.ns, opts), &v1alpha1.MetricTemplateList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.MetricTemplateList{ListMeta: obj.(*v1alpha1.MetricTemplateList).ListMeta} + for _, item := range obj.(*v1alpha1.MetricTemplateList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested metricTemplates. +func (c *FakeMetricTemplates) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(metrictemplatesResource, c.ns, opts)) + +} + +// Create takes the representation of a metricTemplate and creates it. Returns the server's representation of the metricTemplate, and an error, if there is any. +func (c *FakeMetricTemplates) Create(metricTemplate *v1alpha1.MetricTemplate) (result *v1alpha1.MetricTemplate, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(metrictemplatesResource, c.ns, metricTemplate), &v1alpha1.MetricTemplate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.MetricTemplate), err +} + +// Update takes the representation of a metricTemplate and updates it. Returns the server's representation of the metricTemplate, and an error, if there is any. +func (c *FakeMetricTemplates) Update(metricTemplate *v1alpha1.MetricTemplate) (result *v1alpha1.MetricTemplate, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(metrictemplatesResource, c.ns, metricTemplate), &v1alpha1.MetricTemplate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.MetricTemplate), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeMetricTemplates) UpdateStatus(metricTemplate *v1alpha1.MetricTemplate) (*v1alpha1.MetricTemplate, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(metrictemplatesResource, "status", c.ns, metricTemplate), &v1alpha1.MetricTemplate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.MetricTemplate), err +} + +// Delete takes name of the metricTemplate and deletes it. Returns an error if one occurs. +func (c *FakeMetricTemplates) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(metrictemplatesResource, c.ns, name), &v1alpha1.MetricTemplate{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeMetricTemplates) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(metrictemplatesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.MetricTemplateList{}) + return err +} + +// Patch applies the patch and returns the patched metricTemplate. +func (c *FakeMetricTemplates) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MetricTemplate, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(metrictemplatesResource, c.ns, name, pt, data, subresources...), &v1alpha1.MetricTemplate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.MetricTemplate), err +} diff --git a/pkg/client/clientset/versioned/typed/flagger/v1alpha1/flagger_client.go b/pkg/client/clientset/versioned/typed/flagger/v1alpha1/flagger_client.go new file mode 100644 index 00000000..fc8a6062 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flagger/v1alpha1/flagger_client.go @@ -0,0 +1,89 @@ +/* +Copyright The Flagger Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1alpha1" + "github.com/weaveworks/flagger/pkg/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type FlaggerV1alpha1Interface interface { + RESTClient() rest.Interface + MetricTemplatesGetter +} + +// FlaggerV1alpha1Client is used to interact with features provided by the flagger.app group. +type FlaggerV1alpha1Client struct { + restClient rest.Interface +} + +func (c *FlaggerV1alpha1Client) MetricTemplates(namespace string) MetricTemplateInterface { + return newMetricTemplates(c, namespace) +} + +// NewForConfig creates a new FlaggerV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*FlaggerV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &FlaggerV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new FlaggerV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *FlaggerV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new FlaggerV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *FlaggerV1alpha1Client { + return &FlaggerV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FlaggerV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/clientset/versioned/typed/flagger/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/flagger/v1alpha1/generated_expansion.go new file mode 100644 index 00000000..15b3fbce --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flagger/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright The Flagger Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type MetricTemplateExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/flagger/v1alpha1/metrictemplate.go b/pkg/client/clientset/versioned/typed/flagger/v1alpha1/metrictemplate.go new file mode 100644 index 00000000..1d2f8731 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flagger/v1alpha1/metrictemplate.go @@ -0,0 +1,191 @@ +/* +Copyright The Flagger Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "time" + + v1alpha1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1alpha1" + scheme "github.com/weaveworks/flagger/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// MetricTemplatesGetter has a method to return a MetricTemplateInterface. +// A group's client should implement this interface. +type MetricTemplatesGetter interface { + MetricTemplates(namespace string) MetricTemplateInterface +} + +// MetricTemplateInterface has methods to work with MetricTemplate resources. +type MetricTemplateInterface interface { + Create(*v1alpha1.MetricTemplate) (*v1alpha1.MetricTemplate, error) + Update(*v1alpha1.MetricTemplate) (*v1alpha1.MetricTemplate, error) + UpdateStatus(*v1alpha1.MetricTemplate) (*v1alpha1.MetricTemplate, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.MetricTemplate, error) + List(opts v1.ListOptions) (*v1alpha1.MetricTemplateList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MetricTemplate, err error) + MetricTemplateExpansion +} + +// metricTemplates implements MetricTemplateInterface +type metricTemplates struct { + client rest.Interface + ns string +} + +// newMetricTemplates returns a MetricTemplates +func newMetricTemplates(c *FlaggerV1alpha1Client, namespace string) *metricTemplates { + return &metricTemplates{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the metricTemplate, and returns the corresponding metricTemplate object, and an error if there is any. +func (c *metricTemplates) Get(name string, options v1.GetOptions) (result *v1alpha1.MetricTemplate, err error) { + result = &v1alpha1.MetricTemplate{} + err = c.client.Get(). + Namespace(c.ns). + Resource("metrictemplates"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of MetricTemplates that match those selectors. +func (c *metricTemplates) List(opts v1.ListOptions) (result *v1alpha1.MetricTemplateList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.MetricTemplateList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("metrictemplates"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested metricTemplates. +func (c *metricTemplates) Watch(opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("metrictemplates"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a metricTemplate and creates it. Returns the server's representation of the metricTemplate, and an error, if there is any. +func (c *metricTemplates) Create(metricTemplate *v1alpha1.MetricTemplate) (result *v1alpha1.MetricTemplate, err error) { + result = &v1alpha1.MetricTemplate{} + err = c.client.Post(). + Namespace(c.ns). + Resource("metrictemplates"). + Body(metricTemplate). + Do(). + Into(result) + return +} + +// Update takes the representation of a metricTemplate and updates it. Returns the server's representation of the metricTemplate, and an error, if there is any. +func (c *metricTemplates) Update(metricTemplate *v1alpha1.MetricTemplate) (result *v1alpha1.MetricTemplate, err error) { + result = &v1alpha1.MetricTemplate{} + err = c.client.Put(). + Namespace(c.ns). + Resource("metrictemplates"). + Name(metricTemplate.Name). + Body(metricTemplate). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *metricTemplates) UpdateStatus(metricTemplate *v1alpha1.MetricTemplate) (result *v1alpha1.MetricTemplate, err error) { + result = &v1alpha1.MetricTemplate{} + err = c.client.Put(). + Namespace(c.ns). + Resource("metrictemplates"). + Name(metricTemplate.Name). + SubResource("status"). + Body(metricTemplate). + Do(). + Into(result) + return +} + +// Delete takes name of the metricTemplate and deletes it. Returns an error if one occurs. +func (c *metricTemplates) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("metrictemplates"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *metricTemplates) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("metrictemplates"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched metricTemplate. +func (c *metricTemplates) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.MetricTemplate, err error) { + result = &v1alpha1.MetricTemplate{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("metrictemplates"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/client/informers/externalversions/flagger/interface.go b/pkg/client/informers/externalversions/flagger/interface.go index 1e03780e..b2e39442 100644 --- a/pkg/client/informers/externalversions/flagger/interface.go +++ b/pkg/client/informers/externalversions/flagger/interface.go @@ -19,6 +19,7 @@ limitations under the License. package flagger import ( + v1alpha1 "github.com/weaveworks/flagger/pkg/client/informers/externalversions/flagger/v1alpha1" v1alpha3 "github.com/weaveworks/flagger/pkg/client/informers/externalversions/flagger/v1alpha3" internalinterfaces "github.com/weaveworks/flagger/pkg/client/informers/externalversions/internalinterfaces" ) @@ -27,6 +28,8 @@ import ( type Interface interface { // V1alpha3 provides access to shared informers for resources in V1alpha3. V1alpha3() v1alpha3.Interface + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface } type group struct { @@ -44,3 +47,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList func (g *group) V1alpha3() v1alpha3.Interface { return v1alpha3.New(g.factory, g.namespace, g.tweakListOptions) } + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/flagger/v1alpha1/interface.go b/pkg/client/informers/externalversions/flagger/v1alpha1/interface.go new file mode 100644 index 00000000..0340df59 --- /dev/null +++ b/pkg/client/informers/externalversions/flagger/v1alpha1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright The Flagger Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "github.com/weaveworks/flagger/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // MetricTemplates returns a MetricTemplateInformer. + MetricTemplates() MetricTemplateInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// MetricTemplates returns a MetricTemplateInformer. +func (v *version) MetricTemplates() MetricTemplateInformer { + return &metricTemplateInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/flagger/v1alpha1/metrictemplate.go b/pkg/client/informers/externalversions/flagger/v1alpha1/metrictemplate.go new file mode 100644 index 00000000..6d11021b --- /dev/null +++ b/pkg/client/informers/externalversions/flagger/v1alpha1/metrictemplate.go @@ -0,0 +1,89 @@ +/* +Copyright The Flagger Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + flaggerv1alpha1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1alpha1" + versioned "github.com/weaveworks/flagger/pkg/client/clientset/versioned" + internalinterfaces "github.com/weaveworks/flagger/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/weaveworks/flagger/pkg/client/listers/flagger/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// MetricTemplateInformer provides access to a shared informer and lister for +// MetricTemplates. +type MetricTemplateInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.MetricTemplateLister +} + +type metricTemplateInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewMetricTemplateInformer constructs a new informer for MetricTemplate type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewMetricTemplateInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredMetricTemplateInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredMetricTemplateInformer constructs a new informer for MetricTemplate type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredMetricTemplateInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.FlaggerV1alpha1().MetricTemplates(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.FlaggerV1alpha1().MetricTemplates(namespace).Watch(options) + }, + }, + &flaggerv1alpha1.MetricTemplate{}, + resyncPeriod, + indexers, + ) +} + +func (f *metricTemplateInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredMetricTemplateInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *metricTemplateInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&flaggerv1alpha1.MetricTemplate{}, f.defaultInformer) +} + +func (f *metricTemplateInformer) Lister() v1alpha1.MetricTemplateLister { + return v1alpha1.NewMetricTemplateLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 7b18bd19..38c6dad1 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -22,11 +22,12 @@ import ( "fmt" v1beta1 "github.com/weaveworks/flagger/pkg/apis/appmesh/v1beta1" + v1alpha1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1alpha1" v1alpha3 "github.com/weaveworks/flagger/pkg/apis/flagger/v1alpha3" v1 "github.com/weaveworks/flagger/pkg/apis/gloo/v1" istiov1alpha3 "github.com/weaveworks/flagger/pkg/apis/istio/v1alpha3" projectcontourv1 "github.com/weaveworks/flagger/pkg/apis/projectcontour/v1" - v1alpha1 "github.com/weaveworks/flagger/pkg/apis/smi/v1alpha1" + smiv1alpha1 "github.com/weaveworks/flagger/pkg/apis/smi/v1alpha1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -65,6 +66,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1beta1.SchemeGroupVersion.WithResource("virtualservices"): return &genericInformer{resource: resource.GroupResource(), informer: f.Appmesh().V1beta1().VirtualServices().Informer()}, nil + // Group=flagger.app, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("metrictemplates"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Flagger().V1alpha1().MetricTemplates().Informer()}, nil + // Group=flagger.app, Version=v1alpha3 case v1alpha3.SchemeGroupVersion.WithResource("canaries"): return &genericInformer{resource: resource.GroupResource(), informer: f.Flagger().V1alpha3().Canaries().Informer()}, nil @@ -84,7 +89,7 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Projectcontour().V1().HTTPProxies().Informer()}, nil // Group=split.smi-spec.io, Version=v1alpha1 - case v1alpha1.SchemeGroupVersion.WithResource("trafficsplits"): + case smiv1alpha1.SchemeGroupVersion.WithResource("trafficsplits"): return &genericInformer{resource: resource.GroupResource(), informer: f.Split().V1alpha1().TrafficSplits().Informer()}, nil } diff --git a/pkg/client/listers/flagger/v1alpha1/expansion_generated.go b/pkg/client/listers/flagger/v1alpha1/expansion_generated.go new file mode 100644 index 00000000..8a9bb44d --- /dev/null +++ b/pkg/client/listers/flagger/v1alpha1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright The Flagger Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +// MetricTemplateListerExpansion allows custom methods to be added to +// MetricTemplateLister. +type MetricTemplateListerExpansion interface{} + +// MetricTemplateNamespaceListerExpansion allows custom methods to be added to +// MetricTemplateNamespaceLister. +type MetricTemplateNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/flagger/v1alpha1/metrictemplate.go b/pkg/client/listers/flagger/v1alpha1/metrictemplate.go new file mode 100644 index 00000000..35766ae0 --- /dev/null +++ b/pkg/client/listers/flagger/v1alpha1/metrictemplate.go @@ -0,0 +1,94 @@ +/* +Copyright The Flagger Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// MetricTemplateLister helps list MetricTemplates. +type MetricTemplateLister interface { + // List lists all MetricTemplates in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.MetricTemplate, err error) + // MetricTemplates returns an object that can list and get MetricTemplates. + MetricTemplates(namespace string) MetricTemplateNamespaceLister + MetricTemplateListerExpansion +} + +// metricTemplateLister implements the MetricTemplateLister interface. +type metricTemplateLister struct { + indexer cache.Indexer +} + +// NewMetricTemplateLister returns a new MetricTemplateLister. +func NewMetricTemplateLister(indexer cache.Indexer) MetricTemplateLister { + return &metricTemplateLister{indexer: indexer} +} + +// List lists all MetricTemplates in the indexer. +func (s *metricTemplateLister) List(selector labels.Selector) (ret []*v1alpha1.MetricTemplate, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.MetricTemplate)) + }) + return ret, err +} + +// MetricTemplates returns an object that can list and get MetricTemplates. +func (s *metricTemplateLister) MetricTemplates(namespace string) MetricTemplateNamespaceLister { + return metricTemplateNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// MetricTemplateNamespaceLister helps list and get MetricTemplates. +type MetricTemplateNamespaceLister interface { + // List lists all MetricTemplates in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.MetricTemplate, err error) + // Get retrieves the MetricTemplate from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.MetricTemplate, error) + MetricTemplateNamespaceListerExpansion +} + +// metricTemplateNamespaceLister implements the MetricTemplateNamespaceLister +// interface. +type metricTemplateNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all MetricTemplates in the indexer for a given namespace. +func (s metricTemplateNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.MetricTemplate, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.MetricTemplate)) + }) + return ret, err +} + +// Get retrieves the MetricTemplate from the indexer for a given namespace and name. +func (s metricTemplateNamespaceLister) Get(name string) (*v1alpha1.MetricTemplate, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("metrictemplate"), name) + } + return obj.(*v1alpha1.MetricTemplate), nil +}