diff --git a/config/domain.yaml b/config/domain.yaml deleted file mode 100644 index eac4000b4..000000000 --- a/config/domain.yaml +++ /dev/null @@ -1,194 +0,0 @@ -# Copyright 2020 The Knative 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 -# -# https://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. - -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: domains.networking.internal.knative.dev - labels: - app.kubernetes.io/name: knative-serving - app.kubernetes.io/version: devel - app.kubernetes.io/component: networking - knative.dev/crd-install: "true" -spec: - group: networking.internal.knative.dev - versions: - - name: v1alpha1 - served: true - storage: true - subresources: - status: {} - schema: - openAPIV3Schema: - description: Domain is a cluster-scoped resource to configure a proxy pool for a given Route. - type: object - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: |- - Spec is the desired state of the Domain. - More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - type: object - required: - - ingressClass - - loadBalancers - properties: - configs: - description: Configs contains additional pieces of information to configure ingress proxies. - type: array - items: - description: |- - IngressConfig allows KIngress implementations to add additional information needed - for configuring the proxies associated with this Domain. - For examples, in our Istio-based Ingress this will contains all references of - Istio Gateways associated with this Domain. This could be a reference of a ConfigMap - owned by the implementation as well. - type: object - properties: - name: - description: Name of the Kingress implementation resource - type: string - namespace: - description: Namespace of the Kingress implementation resource - type: string - type: - description: Type of the Kingress implementation resource - type: string - ingressClass: - description: |- - IngressClass tells what Ingress class annotation to use for Routes associated - with this Realm. - type: string - loadBalancers: - description: |- - LoadBalancers provide addresses (IP addresses, domains) of the load balancers - associated with this Domain. This is used in automatic DNS provisioning like - configuration of magic DNS or creating ExternalName services for cluster-local - access. - type: array - items: - description: |- - LoadBalancerIngressSpec represents the spec of a load-balancer ingress point: - traffic intended for the service should be sent to an ingress point. - type: object - properties: - domain: - description: |- - Domain is set for load-balancer ingress points that are DNS based - (typically AWS load-balancers) - type: string - domainInternal: - description: |- - DomainInternal is set if there is a cluster-local DNS name to access the Ingress. - - - NOTE: This differs from K8s Ingress, since we also desire to have a cluster-local - DNS name to allow routing in case of not having a mesh. - type: string - ip: - description: |- - IP is set for load-balancer ingress points that are IP based - (typically GCE or OpenStack load-balancers) - type: string - meshOnly: - description: MeshOnly is set if the Ingress is only load-balanced through a Service mesh. - type: boolean - suffix: - description: |- - Suffix specifies the domain suffix to be used. This field replaces the - existing config-domain ConfigMap. Internal Domains can omit this, in - which case we will default to the cluster suffix. - type: string - status: - description: |- - Status is the current state of the Domain. - More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - type: object - properties: - annotations: - description: |- - Annotations is additional Status fields for the Resource to save some - additional State as well as convey more information to the user. This is - roughly akin to Annotations on any k8s resource, just the reconciler conveying - richer information outwards. - type: object - additionalProperties: - type: string - conditions: - description: Conditions the latest available observations of a resource's current state. - type: array - items: - description: |- - Condition defines a readiness condition for a Knative resource. - See: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties - type: object - required: - - status - - type - properties: - lastTransitionTime: - description: |- - LastTransitionTime is the last time the condition transitioned from one status to another. - We use VolatileTime in place of metav1.Time to exclude this from creating equality.Semantic - differences (all other things held constant). - type: string - message: - description: A human readable message indicating details about the transition. - type: string - reason: - description: The reason for the condition's last transition. - type: string - severity: - description: |- - Severity with which to treat failures of this type of condition. - When this is not specified, it defaults to Error. - type: string - status: - description: Status of the condition, one of True, False, Unknown. - type: string - type: - description: Type of condition. - type: string - observedGeneration: - description: |- - ObservedGeneration is the 'Generation' of the Service that - was last processed by the controller. - type: integer - format: int64 - names: - kind: Domain - plural: domains - singular: domain - categories: - - knative-internal - - networking - shortNames: - - dom - scope: Cluster diff --git a/config/realm.yaml b/config/realm.yaml deleted file mode 100644 index cb76ca14c..000000000 --- a/config/realm.yaml +++ /dev/null @@ -1,142 +0,0 @@ -# Copyright 2020 The Knative 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 -# -# https://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. - -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: realms.networking.internal.knative.dev - labels: - app.kubernetes.io/name: knative-serving - app.kubernetes.io/component: networking - app.kubernetes.io/version: devel - knative.dev/crd-install: "true" -spec: - group: networking.internal.knative.dev - versions: - - name: v1alpha1 - served: true - storage: true - subresources: - status: {} - schema: - openAPIV3Schema: - description: Realm is a cluster-scoped resource that specifies a Route visibility. - type: object - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: |- - Spec is the desired state of the Realm. - More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - type: object - properties: - external: - description: |- - External contains the name of the Domain resource corresponding with traffic - originating from outside of the cluster. Could be omitted for a Realm without - external access. - type: string - internal: - description: |- - Internal contains the name of the Domain resource corresponding with traffic - originating from inside of the cluster. Could be omitted for a Realm without - internal access. - type: string - status: - description: |- - Status is the current state of the Realm. - More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - type: object - properties: - annotations: - description: |- - Annotations is additional Status fields for the Resource to save some - additional State as well as convey more information to the user. This is - roughly akin to Annotations on any k8s resource, just the reconciler conveying - richer information outwards. - type: object - additionalProperties: - type: string - conditions: - description: Conditions the latest available observations of a resource's current state. - type: array - items: - description: |- - Condition defines a readiness condition for a Knative resource. - See: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties - type: object - required: - - status - - type - properties: - lastTransitionTime: - description: |- - LastTransitionTime is the last time the condition transitioned from one status to another. - We use VolatileTime in place of metav1.Time to exclude this from creating equality.Semantic - differences (all other things held constant). - type: string - message: - description: A human readable message indicating details about the transition. - type: string - reason: - description: The reason for the condition's last transition. - type: string - severity: - description: |- - Severity with which to treat failures of this type of condition. - When this is not specified, it defaults to Error. - type: string - status: - description: Status of the condition, one of True, False, Unknown. - type: string - type: - description: Type of condition. - type: string - observedGeneration: - description: |- - ObservedGeneration is the 'Generation' of the Service that - was last processed by the controller. - type: integer - format: int64 - additionalPrinterColumns: - - name: Ready - type: string - jsonPath: ".status.conditions[?(@.type=='Ready')].status" - - name: Reason - type: string - jsonPath: ".status.conditions[?(@.type=='Ready')].reason" - names: - kind: Realm - plural: realms - singular: realm - categories: - - knative-internal - - networking - scope: Cluster diff --git a/pkg/apis/networking/v1alpha1/domain_defaults.go b/pkg/apis/networking/v1alpha1/domain_defaults.go deleted file mode 100644 index 1d3ff93c8..000000000 --- a/pkg/apis/networking/v1alpha1/domain_defaults.go +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright 2020 The Knative 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 - - https://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 ( - "context" - - "knative.dev/pkg/apis" -) - -// SetDefaults populates default values in Domain -func (d *Domain) SetDefaults(ctx context.Context) { - d.Spec.SetDefaults(apis.WithinSpec(ctx)) -} - -// SetDefaults populates default values in DomainSpec -func (*DomainSpec) SetDefaults(_ context.Context) { -} diff --git a/pkg/apis/networking/v1alpha1/domain_defaults_test.go b/pkg/apis/networking/v1alpha1/domain_defaults_test.go deleted file mode 100644 index e86b70206..000000000 --- a/pkg/apis/networking/v1alpha1/domain_defaults_test.go +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright 2020 The Knative 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 - - https://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 ( - "context" - "testing" - - "github.com/google/go-cmp/cmp" -) - -func TestDomainDefaults(t *testing.T) { - d := Domain{} - d.SetDefaults(context.Background()) - - if !cmp.Equal(Domain{}, d) { - t.Errorf("SetDefaults (-want, +got) = \n%s", cmp.Diff(Domain{}, d)) - } -} diff --git a/pkg/apis/networking/v1alpha1/domain_lifecycle.go b/pkg/apis/networking/v1alpha1/domain_lifecycle.go deleted file mode 100644 index 95d16c141..000000000 --- a/pkg/apis/networking/v1alpha1/domain_lifecycle.go +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright 2020 The Knative 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 - - https://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 ( - "k8s.io/apimachinery/pkg/runtime/schema" - "knative.dev/pkg/apis" -) - -var domainCondSet = apis.NewLivingConditionSet() - -// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface. -func (*Domain) GetConditionSet() apis.ConditionSet { - return domainCondSet -} - -// GetGroupVersionKind returns SchemeGroupVersion of an Domain -func (*Domain) GetGroupVersionKind() schema.GroupVersionKind { - return SchemeGroupVersion.WithKind("Domain") -} diff --git a/pkg/apis/networking/v1alpha1/domain_lifecycle_test.go b/pkg/apis/networking/v1alpha1/domain_lifecycle_test.go deleted file mode 100644 index 5b7cae907..000000000 --- a/pkg/apis/networking/v1alpha1/domain_lifecycle_test.go +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright 2020 The Knative 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 - - https://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 ( - "testing" - - "github.com/google/go-cmp/cmp" - "knative.dev/pkg/apis" -) - -func TestDomainGetConditionSet(t *testing.T) { - d := Domain{} - - if got, want := d.GetConditionSet().GetTopLevelConditionType(), apis.ConditionReady; got != want { - t.Errorf("GetConditionSet=%v, want=%v", got, want) - } -} - -func TestDomainGetGroupVersionKind(t *testing.T) { - d := Domain{} - expected := SchemeGroupVersion.WithKind("Domain") - if !cmp.Equal(expected, d.GetGroupVersionKind()) { - t.Error("Unexpected diff (-want, +got) =", cmp.Diff(expected, d.GetGroupVersionKind())) - } -} diff --git a/pkg/apis/networking/v1alpha1/domain_types.go b/pkg/apis/networking/v1alpha1/domain_types.go deleted file mode 100644 index 3296c12ab..000000000 --- a/pkg/apis/networking/v1alpha1/domain_types.go +++ /dev/null @@ -1,160 +0,0 @@ -/* -Copyright 2020 The Knative 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 - - https://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" - "knative.dev/pkg/apis" - duckv1 "knative.dev/pkg/apis/duck/v1" - "knative.dev/pkg/kmeta" -) - -// +genclient -// +genclient:nonNamespaced -// +genreconciler:krshapedlogic=true -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// Domain is a cluster-scoped resource to configure a proxy pool for a given Route. -type Domain struct { - metav1.TypeMeta `json:",inline"` - // Standard object's metadata. - // More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata - // +optional - metav1.ObjectMeta `json:"metadata,omitempty"` - - // Spec is the desired state of the Domain. - // More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional - Spec DomainSpec `json:"spec,omitempty"` - - // Status is the current state of the Domain. - // More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional - Status DomainStatus `json:"status,omitempty"` -} - -// Verify that Domain adheres to the appropriate interfaces. -var ( - // Check that Domain may be validated and defaulted. - _ apis.Validatable = (*Domain)(nil) - _ apis.Defaultable = (*Domain)(nil) - - // Check that we can create OwnerReferences to a Domain. - _ kmeta.OwnerRefable = (*Domain)(nil) - - // Check that the type conforms to the duck Knative Resource shape. - _ duckv1.KRShaped = (*Domain)(nil) -) - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// DomainList is a collection of Domain objects. -type DomainList struct { - metav1.TypeMeta `json:",inline"` - // Standard object metadata. - // More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata - // +optional - metav1.ListMeta `json:"metadata,omitempty"` - - // Items is the list of Domain objects. - Items []Domain `json:"items"` -} - -// DomainSpec describes the Ingress the user wishes to exist. -// -// In general this follows the same shape as K8s Ingress. -// Some notable differences: -// - Backends now can have namespace: -// - Traffic can be split across multiple backends. -// - Timeout & Retry can be configured. -// - Headers can be appended. -// DomainSpec contains the specification of the Domain CRD. -type DomainSpec struct { - // IngressClass tells what Ingress class annotation to use for Routes associated - // with this Realm. - IngressClass string `json:"ingressClass"` - - // Suffix specifies the domain suffix to be used. This field replaces the - // existing config-domain ConfigMap. Internal Domains can omit this, in - // which case we will default to the cluster suffix. - // +optional - Suffix string `json:"suffix,omitempty"` - - // LoadBalancers provide addresses (IP addresses, domains) of the load balancers - // associated with this Domain. This is used in automatic DNS provisioning like - // configuration of magic DNS or creating ExternalName services for cluster-local - // access. - LoadBalancers []LoadBalancerIngressSpec `json:"loadBalancers"` - - // Configs contains additional pieces of information to configure ingress proxies. - // +optional - Configs []IngressConfig `json:"configs,omitempty"` -} - -// IngressConfig allows KIngress implementations to add additional information needed -// for configuring the proxies associated with this Domain. -// For examples, in our Istio-based Ingress this will contains all references of -// Istio Gateways associated with this Domain. This could be a reference of a ConfigMap -// owned by the implementation as well. -type IngressConfig struct { - // Name of the Kingress implementation resource - // +optional - Name string `json:"name,omitempty"` - // Namespace of the Kingress implementation resource - // +optional - Namespace string `json:"namespace,omitempty"` - // Type of the Kingress implementation resource - // +optional - Type string `json:"type,omitempty"` -} - -// LoadBalancerIngressSpec represents the spec of a load-balancer ingress point: -// traffic intended for the service should be sent to an ingress point. -type LoadBalancerIngressSpec struct { - // IP is set for load-balancer ingress points that are IP based - // (typically GCE or OpenStack load-balancers) - // +optional - IP string `json:"ip,omitempty"` - - // Domain is set for load-balancer ingress points that are DNS based - // (typically AWS load-balancers) - // +optional - Domain string `json:"domain,omitempty"` - - // DomainInternal is set if there is a cluster-local DNS name to access the Ingress. - // - // NOTE: This differs from K8s Ingress, since we also desire to have a cluster-local - // DNS name to allow routing in case of not having a mesh. - // - // +optional - DomainInternal string `json:"domainInternal,omitempty"` - - // MeshOnly is set if the Ingress is only load-balanced through a Service mesh. - // +optional - MeshOnly bool `json:"meshOnly,omitempty"` -} - -// DomainStatus will reflect Ready=True if the implementation accepts the Domain data -// as valid. -type DomainStatus struct { - duckv1.Status `json:",inline"` -} - -// GetStatus retrieves the status of the Domain. Implements the KRShaped interface. -func (d *Domain) GetStatus() *duckv1.Status { - return &d.Status.Status -} diff --git a/pkg/apis/networking/v1alpha1/domain_types_test.go b/pkg/apis/networking/v1alpha1/domain_types_test.go deleted file mode 100644 index 6cd3d77a9..000000000 --- a/pkg/apis/networking/v1alpha1/domain_types_test.go +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright 2020 The Knative 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 - - https://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 "testing" - -func TestDomainGetStatus(t *testing.T) { - r := &Domain{ - Status: DomainStatus{}, - } - - if got, want := r.GetStatus(), &r.Status.Status; got != want { - t.Errorf("GetStatus=%v, want=%v", got, want) - } -} diff --git a/pkg/apis/networking/v1alpha1/domain_validation.go b/pkg/apis/networking/v1alpha1/domain_validation.go deleted file mode 100644 index 85d556972..000000000 --- a/pkg/apis/networking/v1alpha1/domain_validation.go +++ /dev/null @@ -1,70 +0,0 @@ -/* -Copyright 2020 The Knative 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 - - https://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 ( - "context" - - "k8s.io/apimachinery/pkg/api/equality" - "knative.dev/pkg/apis" -) - -// Validate inspects and validates Domain object. -func (d *Domain) Validate(ctx context.Context) *apis.FieldError { - return d.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec") -} - -// Validate inspects and validates DomainSpec object. -func (ds *DomainSpec) Validate(ctx context.Context) *apis.FieldError { - // Spec must not be empty. - if equality.Semantic.DeepEqual(ds, &DomainSpec{}) { - return apis.ErrMissingField(apis.CurrentField) - } - var all *apis.FieldError - if ds.IngressClass == "" { - all = all.Also(apis.ErrMissingField("ingressClass")) - } - if len(ds.LoadBalancers) == 0 { - all = all.Also(apis.ErrMissingField("loadBalancers")) - } - for idx, lbSpec := range ds.LoadBalancers { - all = all.Also(lbSpec.Validate(ctx).ViaFieldIndex("loadBalancers", idx)) - } - for idx, cfg := range ds.Configs { - all = all.Also(cfg.Validate(ctx).ViaFieldIndex("configs", idx)) - } - return all -} - -func (lb *LoadBalancerIngressSpec) Validate(_ context.Context) *apis.FieldError { - var all *apis.FieldError - if lb.Domain == "" && lb.DomainInternal == "" && lb.IP == "" && !lb.MeshOnly { - return all.Also(apis.ErrMissingOneOf("domain", "domainInternal", "ip", "meshOnly")) - } - return all -} - -func (cfg *IngressConfig) Validate(_ context.Context) *apis.FieldError { - var all *apis.FieldError - if cfg.Name == "" { - all = all.Also(apis.ErrMissingField("name")) - } - if cfg.Type == "" { - all = all.Also(apis.ErrMissingField("type")) - } - return all -} diff --git a/pkg/apis/networking/v1alpha1/domain_validation_test.go b/pkg/apis/networking/v1alpha1/domain_validation_test.go deleted file mode 100644 index 4afd3f7e3..000000000 --- a/pkg/apis/networking/v1alpha1/domain_validation_test.go +++ /dev/null @@ -1,108 +0,0 @@ -/* -Copyright 2020 The Knative 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 - - https://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 ( - "context" - "testing" - - "github.com/google/go-cmp/cmp" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "knative.dev/pkg/apis" -) - -func TestDomainSpecValidation(t *testing.T) { - tests := []struct { - name string - ds DomainSpec - want *apis.FieldError - }{{ - name: "all good", - ds: DomainSpec{ - IngressClass: "test-ingress-class", - LoadBalancers: []LoadBalancerIngressSpec{{ - Domain: "test-domain", - }}, - }, - }, { - name: "no spec", - ds: DomainSpec{}, - want: apis.ErrMissingField("spec"), - }, { - name: "ingress class isnt specified", - ds: DomainSpec{ - LoadBalancers: []LoadBalancerIngressSpec{{ - Domain: "test-domain", - }}, - }, - want: apis.ErrMissingField("spec.ingressClass"), - }, { - name: "loadbalancers arent specified", - ds: DomainSpec{ - IngressClass: "test-ingress-class", - }, - want: apis.ErrMissingField("spec.loadBalancers"), - }, { - name: "at least one field in loadbalancer is specified", - ds: DomainSpec{ - IngressClass: "test-ingress-class", - LoadBalancers: []LoadBalancerIngressSpec{{ - Domain: "some-domain", - }}, - }, - }, { - name: "none of the fields are specified in a loadbalancer", - ds: DomainSpec{ - IngressClass: "test-ingress-class", - LoadBalancers: []LoadBalancerIngressSpec{{}}, - }, - want: apis.ErrMissingOneOf("spec.loadBalancers[0].domain", "spec.loadBalancers[0].domainInternal", - "spec.loadBalancers[0].ip", "spec.loadBalancers[0].meshOnly"), - }, { - name: "name is missing from ingressConfig", - ds: DomainSpec{ - IngressClass: "test-ingress-class", - Configs: []IngressConfig{{Namespace: "ns", Type: "my-type"}}, - LoadBalancers: []LoadBalancerIngressSpec{{ - Domain: "some-domain", - }}, - }, - want: apis.ErrMissingField("spec.configs[0].name"), - }, { - name: "type is missing from ingressConfig", - ds: DomainSpec{ - IngressClass: "test-ingress-class", - Configs: []IngressConfig{{Namespace: "ns", Name: "my-name"}}, - LoadBalancers: []LoadBalancerIngressSpec{{ - Domain: "some-domain", - }}, - }, - want: apis.ErrMissingField("spec.configs[0].type"), - }} - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - ds := Domain{ - ObjectMeta: metav1.ObjectMeta{Name: "test-ds"}, - Spec: test.ds, - } - got := ds.Validate(context.Background()) - if !cmp.Equal(test.want.Error(), got.Error()) { - t.Errorf("Validate (-want, +got) = \n%s", cmp.Diff(test.want.Error(), got.Error())) - } - }) - } -} diff --git a/pkg/apis/networking/v1alpha1/realm_defaults.go b/pkg/apis/networking/v1alpha1/realm_defaults.go deleted file mode 100644 index 5614104be..000000000 --- a/pkg/apis/networking/v1alpha1/realm_defaults.go +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright 2020 The Knative 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 - - https://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 ( - "context" - - "knative.dev/pkg/apis" -) - -// SetDefaults populates default values in Realm -func (r *Realm) SetDefaults(ctx context.Context) { - r.Spec.SetDefaults(apis.WithinSpec(ctx)) -} - -// SetDefaults populates default values in RealmSpec -func (*RealmSpec) SetDefaults(_ context.Context) { -} diff --git a/pkg/apis/networking/v1alpha1/realm_defaults_test.go b/pkg/apis/networking/v1alpha1/realm_defaults_test.go deleted file mode 100644 index ce2cee698..000000000 --- a/pkg/apis/networking/v1alpha1/realm_defaults_test.go +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright 2020 The Knative 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 - - https://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 ( - "context" - "testing" - - "github.com/google/go-cmp/cmp" -) - -func TestRealmDefaults(t *testing.T) { - r := Realm{} - r.SetDefaults(context.Background()) - - if !cmp.Equal(Realm{}, r) { - t.Errorf("SetDefaults (-want, +got) = \n%s", cmp.Diff(Realm{}, r)) - } -} diff --git a/pkg/apis/networking/v1alpha1/realm_lifecycle.go b/pkg/apis/networking/v1alpha1/realm_lifecycle.go deleted file mode 100644 index e53df392c..000000000 --- a/pkg/apis/networking/v1alpha1/realm_lifecycle.go +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright 2020 The Knative 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 - - https://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 ( - "k8s.io/apimachinery/pkg/runtime/schema" - "knative.dev/pkg/apis" -) - -var realmCondSet = apis.NewLivingConditionSet() - -// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface. -func (*Realm) GetConditionSet() apis.ConditionSet { - return realmCondSet -} - -// GetGroupVersionKind returns SchemeGroupVersion of an Realm -func (*Realm) GetGroupVersionKind() schema.GroupVersionKind { - return SchemeGroupVersion.WithKind("Realm") -} diff --git a/pkg/apis/networking/v1alpha1/realm_lifecycle_test.go b/pkg/apis/networking/v1alpha1/realm_lifecycle_test.go deleted file mode 100644 index 27fc4c77b..000000000 --- a/pkg/apis/networking/v1alpha1/realm_lifecycle_test.go +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright 2020 The Knative 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 - - https://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 ( - "testing" - - "github.com/google/go-cmp/cmp" - "knative.dev/pkg/apis" -) - -func TestRealmGetConditionSet(t *testing.T) { - r := Realm{} - - if got, want := r.GetConditionSet().GetTopLevelConditionType(), apis.ConditionReady; got != want { - t.Errorf("GetConditionSet=%v, want=%v", got, want) - } -} - -func TestRealmGetGroupVersionKind(t *testing.T) { - r := Realm{} - expected := SchemeGroupVersion.WithKind("Realm") - if !cmp.Equal(expected, r.GetGroupVersionKind()) { - t.Error("Unexpected diff (-want, +got) =", cmp.Diff(expected, r.GetGroupVersionKind())) - } -} diff --git a/pkg/apis/networking/v1alpha1/realm_types.go b/pkg/apis/networking/v1alpha1/realm_types.go deleted file mode 100644 index bfb2df920..000000000 --- a/pkg/apis/networking/v1alpha1/realm_types.go +++ /dev/null @@ -1,108 +0,0 @@ -/* -Copyright 2020 The Knative 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 - - https://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" - "knative.dev/pkg/apis" - duckv1 "knative.dev/pkg/apis/duck/v1" - "knative.dev/pkg/kmeta" -) - -// +genclient -// +genclient:nonNamespaced -// +genreconciler:krshapedlogic=true -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// Realm is a cluster-scoped resource that specifies a Route visibility. -type Realm struct { - metav1.TypeMeta `json:",inline"` - // Standard object's metadata. - // More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata - // +optional - metav1.ObjectMeta `json:"metadata,omitempty"` - - // Spec is the desired state of the Realm. - // More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional - Spec RealmSpec `json:"spec,omitempty"` - - // Status is the current state of the Realm. - // More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional - Status RealmStatus `json:"status,omitempty"` -} - -// Verify that Realm adheres to the appropriate interfaces. -var ( - // Check that Realm may be validated and defaulted. - _ apis.Validatable = (*Realm)(nil) - _ apis.Defaultable = (*Realm)(nil) - - // Check that we can create OwnerReferences to a Realm. - _ kmeta.OwnerRefable = (*Realm)(nil) - - // Check that the type conforms to the duck Knative Resource shape. - _ duckv1.KRShaped = (*Realm)(nil) -) - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// RealmList is a collection of Realm objects. -type RealmList struct { - metav1.TypeMeta `json:",inline"` - // Standard object metadata. - // More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata - // +optional - metav1.ListMeta `json:"metadata,omitempty"` - - // Items is the list of Realm objects. - Items []Realm `json:"items"` -} - -// RealmSpec defines the specifications of a Realm. -// Realms specify an internal and external Domain, but disallow arbitrary combinations. -// Operators can create combinations of Domains that makes sense for their clusters, -// and developers can only switch between these predefined Realms. -// -// Conditions: Currently each Realm can have only two Domains. -// That fits well with the way we assign Route.Status.URL and Route.Status.Domain. -// All Domains in the same Realm must share the same ingress class annotation. -type RealmSpec struct { - // External contains the name of the Domain resource corresponding with traffic - // originating from outside of the cluster. Could be omitted for a Realm without - // external access. - // +optional - External string `json:"external,omitempty"` - - // Internal contains the name of the Domain resource corresponding with traffic - // originating from inside of the cluster. Could be omitted for a Realm without - // internal access. - // +optional - Internal string `json:"internal,omitempty"` -} - -// RealmStatus will reflect Ready=True if the implementation accepts the Realm data -// as valid. -type RealmStatus struct { - duckv1.Status `json:",inline"` -} - -// GetStatus retrieves the status of the Realm. Implements the KRShaped interface. -func (r *Realm) GetStatus() *duckv1.Status { - return &r.Status.Status -} diff --git a/pkg/apis/networking/v1alpha1/realm_types_test.go b/pkg/apis/networking/v1alpha1/realm_types_test.go deleted file mode 100644 index 80d996d9b..000000000 --- a/pkg/apis/networking/v1alpha1/realm_types_test.go +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright 2020 The Knative 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 - - https://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 "testing" - -func TestRealmGetStatus(t *testing.T) { - r := &Realm{ - Status: RealmStatus{}, - } - - if got, want := r.GetStatus(), &r.Status.Status; got != want { - t.Errorf("GetStatus=%v, want=%v", got, want) - } -} diff --git a/pkg/apis/networking/v1alpha1/realm_validation.go b/pkg/apis/networking/v1alpha1/realm_validation.go deleted file mode 100644 index 93caf7016..000000000 --- a/pkg/apis/networking/v1alpha1/realm_validation.go +++ /dev/null @@ -1,37 +0,0 @@ -/* -Copyright 2020 The Knative 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 - - https://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 ( - "context" - - "knative.dev/pkg/apis" -) - -// Validate inspects and validates Realm object. -func (r *Realm) Validate(ctx context.Context) *apis.FieldError { - return r.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec") -} - -// Validate inspects and validates RealmSpec object. -func (rs *RealmSpec) Validate(_ context.Context) *apis.FieldError { - var all *apis.FieldError - if rs.External == "" && rs.Internal == "" { - all = all.Also(apis.ErrMissingOneOf("external", "internal")) - } - return all -} diff --git a/pkg/apis/networking/v1alpha1/realm_validation_test.go b/pkg/apis/networking/v1alpha1/realm_validation_test.go deleted file mode 100644 index 448d8aa3f..000000000 --- a/pkg/apis/networking/v1alpha1/realm_validation_test.go +++ /dev/null @@ -1,60 +0,0 @@ -/* -Copyright 2020 The Knative 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 - - https://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 ( - "context" - "testing" - - "github.com/google/go-cmp/cmp" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "knative.dev/pkg/apis" -) - -func TestRealmSpecValidation(t *testing.T) { - tests := []struct { - name string - rs RealmSpec - want *apis.FieldError - }{{ - name: "external domain is specified", - rs: RealmSpec{ - External: "test-ext", - }, - }, { - name: "internal domain is specified", - rs: RealmSpec{ - Internal: "test-cluster", - }, - }, { - name: "neither internal nor external domain is specified", - rs: RealmSpec{}, - want: apis.ErrMissingOneOf("spec.internal", "spec.external"), - }} - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - rs := Realm{ - ObjectMeta: metav1.ObjectMeta{Name: "test-realm"}, - Spec: test.rs, - } - got := rs.Validate(context.Background()) - if !cmp.Equal(test.want.Error(), got.Error()) { - t.Errorf("Validate (-want, +got) = \n%s", cmp.Diff(test.want.Error(), got.Error())) - } - }) - } -} diff --git a/pkg/apis/networking/v1alpha1/register.go b/pkg/apis/networking/v1alpha1/register.go index 19a1b907f..6d54c4e6a 100644 --- a/pkg/apis/networking/v1alpha1/register.go +++ b/pkg/apis/networking/v1alpha1/register.go @@ -46,12 +46,8 @@ var ( // Adds the list of known types to Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, - &Domain{}, - &DomainList{}, &Ingress{}, &IngressList{}, - &Realm{}, - &RealmList{}, &ServerlessService{}, &ServerlessServiceList{}, &Certificate{}, diff --git a/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go index 7f93cd337..64bf6351b 100644 --- a/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go @@ -213,110 +213,6 @@ func (in *ClusterDomainClaimSpec) DeepCopy() *ClusterDomainClaimSpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Domain) DeepCopyInto(out *Domain) { - *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 Domain. -func (in *Domain) DeepCopy() *Domain { - if in == nil { - return nil - } - out := new(Domain) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Domain) 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 *DomainList) DeepCopyInto(out *DomainList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Domain, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DomainList. -func (in *DomainList) DeepCopy() *DomainList { - if in == nil { - return nil - } - out := new(DomainList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *DomainList) 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 *DomainSpec) DeepCopyInto(out *DomainSpec) { - *out = *in - if in.LoadBalancers != nil { - in, out := &in.LoadBalancers, &out.LoadBalancers - *out = make([]LoadBalancerIngressSpec, len(*in)) - copy(*out, *in) - } - if in.Configs != nil { - in, out := &in.Configs, &out.Configs - *out = make([]IngressConfig, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DomainSpec. -func (in *DomainSpec) DeepCopy() *DomainSpec { - if in == nil { - return nil - } - out := new(DomainSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DomainStatus) DeepCopyInto(out *DomainStatus) { - *out = *in - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DomainStatus. -func (in *DomainStatus) DeepCopy() *DomainStatus { - if in == nil { - return nil - } - out := new(DomainStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HTTP01Challenge) DeepCopyInto(out *HTTP01Challenge) { *out = *in @@ -505,22 +401,6 @@ func (in *IngressBackendSplit) DeepCopy() *IngressBackendSplit { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *IngressConfig) DeepCopyInto(out *IngressConfig) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressConfig. -func (in *IngressConfig) DeepCopy() *IngressConfig { - if in == nil { - return nil - } - out := new(IngressConfig) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IngressList) DeepCopyInto(out *IngressList) { *out = *in @@ -658,22 +538,6 @@ func (in *IngressTLS) DeepCopy() *IngressTLS { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LoadBalancerIngressSpec) DeepCopyInto(out *LoadBalancerIngressSpec) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerIngressSpec. -func (in *LoadBalancerIngressSpec) DeepCopy() *LoadBalancerIngressSpec { - if in == nil { - return nil - } - out := new(LoadBalancerIngressSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LoadBalancerIngressStatus) DeepCopyInto(out *LoadBalancerIngressStatus) { *out = *in @@ -711,100 +575,6 @@ func (in *LoadBalancerStatus) DeepCopy() *LoadBalancerStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Realm) DeepCopyInto(out *Realm) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Realm. -func (in *Realm) DeepCopy() *Realm { - if in == nil { - return nil - } - out := new(Realm) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Realm) 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 *RealmList) DeepCopyInto(out *RealmList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Realm, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RealmList. -func (in *RealmList) DeepCopy() *RealmList { - if in == nil { - return nil - } - out := new(RealmList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *RealmList) 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 *RealmSpec) DeepCopyInto(out *RealmSpec) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RealmSpec. -func (in *RealmSpec) DeepCopy() *RealmSpec { - if in == nil { - return nil - } - out := new(RealmSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RealmStatus) DeepCopyInto(out *RealmStatus) { - *out = *in - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RealmStatus. -func (in *RealmStatus) DeepCopy() *RealmStatus { - if in == nil { - return nil - } - out := new(RealmStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServerlessService) DeepCopyInto(out *ServerlessService) { *out = *in diff --git a/pkg/client/clientset/versioned/typed/networking/v1alpha1/domain.go b/pkg/client/clientset/versioned/typed/networking/v1alpha1/domain.go deleted file mode 100644 index 3ad1e79ed..000000000 --- a/pkg/client/clientset/versioned/typed/networking/v1alpha1/domain.go +++ /dev/null @@ -1,184 +0,0 @@ -/* -Copyright 2020 The Knative 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 ( - "context" - "time" - - 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" - v1alpha1 "knative.dev/networking/pkg/apis/networking/v1alpha1" - scheme "knative.dev/networking/pkg/client/clientset/versioned/scheme" -) - -// DomainsGetter has a method to return a DomainInterface. -// A group's client should implement this interface. -type DomainsGetter interface { - Domains() DomainInterface -} - -// DomainInterface has methods to work with Domain resources. -type DomainInterface interface { - Create(ctx context.Context, domain *v1alpha1.Domain, opts v1.CreateOptions) (*v1alpha1.Domain, error) - Update(ctx context.Context, domain *v1alpha1.Domain, opts v1.UpdateOptions) (*v1alpha1.Domain, error) - UpdateStatus(ctx context.Context, domain *v1alpha1.Domain, opts v1.UpdateOptions) (*v1alpha1.Domain, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Domain, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.DomainList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Domain, err error) - DomainExpansion -} - -// domains implements DomainInterface -type domains struct { - client rest.Interface -} - -// newDomains returns a Domains -func newDomains(c *NetworkingV1alpha1Client) *domains { - return &domains{ - client: c.RESTClient(), - } -} - -// Get takes name of the domain, and returns the corresponding domain object, and an error if there is any. -func (c *domains) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Domain, err error) { - result = &v1alpha1.Domain{} - err = c.client.Get(). - Resource("domains"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Domains that match those selectors. -func (c *domains) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.DomainList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.DomainList{} - err = c.client.Get(). - Resource("domains"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested domains. -func (c *domains) Watch(ctx context.Context, 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(). - Resource("domains"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a domain and creates it. Returns the server's representation of the domain, and an error, if there is any. -func (c *domains) Create(ctx context.Context, domain *v1alpha1.Domain, opts v1.CreateOptions) (result *v1alpha1.Domain, err error) { - result = &v1alpha1.Domain{} - err = c.client.Post(). - Resource("domains"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(domain). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a domain and updates it. Returns the server's representation of the domain, and an error, if there is any. -func (c *domains) Update(ctx context.Context, domain *v1alpha1.Domain, opts v1.UpdateOptions) (result *v1alpha1.Domain, err error) { - result = &v1alpha1.Domain{} - err = c.client.Put(). - Resource("domains"). - Name(domain.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(domain). - Do(ctx). - 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 *domains) UpdateStatus(ctx context.Context, domain *v1alpha1.Domain, opts v1.UpdateOptions) (result *v1alpha1.Domain, err error) { - result = &v1alpha1.Domain{} - err = c.client.Put(). - Resource("domains"). - Name(domain.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(domain). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the domain and deletes it. Returns an error if one occurs. -func (c *domains) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Resource("domains"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *domains) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Resource("domains"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched domain. -func (c *domains) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Domain, err error) { - result = &v1alpha1.Domain{} - err = c.client.Patch(pt). - Resource("domains"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_domain.go b/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_domain.go deleted file mode 100644 index e51f59545..000000000 --- a/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_domain.go +++ /dev/null @@ -1,132 +0,0 @@ -/* -Copyright 2020 The Knative 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 ( - "context" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" - v1alpha1 "knative.dev/networking/pkg/apis/networking/v1alpha1" -) - -// FakeDomains implements DomainInterface -type FakeDomains struct { - Fake *FakeNetworkingV1alpha1 -} - -var domainsResource = v1alpha1.SchemeGroupVersion.WithResource("domains") - -var domainsKind = v1alpha1.SchemeGroupVersion.WithKind("Domain") - -// Get takes name of the domain, and returns the corresponding domain object, and an error if there is any. -func (c *FakeDomains) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Domain, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootGetAction(domainsResource, name), &v1alpha1.Domain{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Domain), err -} - -// List takes label and field selectors, and returns the list of Domains that match those selectors. -func (c *FakeDomains) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.DomainList, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootListAction(domainsResource, domainsKind, opts), &v1alpha1.DomainList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha1.DomainList{ListMeta: obj.(*v1alpha1.DomainList).ListMeta} - for _, item := range obj.(*v1alpha1.DomainList).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 domains. -func (c *FakeDomains) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewRootWatchAction(domainsResource, opts)) -} - -// Create takes the representation of a domain and creates it. Returns the server's representation of the domain, and an error, if there is any. -func (c *FakeDomains) Create(ctx context.Context, domain *v1alpha1.Domain, opts v1.CreateOptions) (result *v1alpha1.Domain, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootCreateAction(domainsResource, domain), &v1alpha1.Domain{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Domain), err -} - -// Update takes the representation of a domain and updates it. Returns the server's representation of the domain, and an error, if there is any. -func (c *FakeDomains) Update(ctx context.Context, domain *v1alpha1.Domain, opts v1.UpdateOptions) (result *v1alpha1.Domain, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootUpdateAction(domainsResource, domain), &v1alpha1.Domain{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Domain), 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 *FakeDomains) UpdateStatus(ctx context.Context, domain *v1alpha1.Domain, opts v1.UpdateOptions) (*v1alpha1.Domain, error) { - obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceAction(domainsResource, "status", domain), &v1alpha1.Domain{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Domain), err -} - -// Delete takes name of the domain and deletes it. Returns an error if one occurs. -func (c *FakeDomains) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewRootDeleteActionWithOptions(domainsResource, name, opts), &v1alpha1.Domain{}) - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeDomains) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewRootDeleteCollectionAction(domainsResource, listOpts) - - _, err := c.Fake.Invokes(action, &v1alpha1.DomainList{}) - return err -} - -// Patch applies the patch and returns the patched domain. -func (c *FakeDomains) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Domain, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(domainsResource, name, pt, data, subresources...), &v1alpha1.Domain{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Domain), err -} diff --git a/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_networking_client.go b/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_networking_client.go index 88f0cd5cd..9e395456f 100644 --- a/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_networking_client.go +++ b/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_networking_client.go @@ -36,18 +36,10 @@ func (c *FakeNetworkingV1alpha1) ClusterDomainClaims() v1alpha1.ClusterDomainCla return &FakeClusterDomainClaims{c} } -func (c *FakeNetworkingV1alpha1) Domains() v1alpha1.DomainInterface { - return &FakeDomains{c} -} - func (c *FakeNetworkingV1alpha1) Ingresses(namespace string) v1alpha1.IngressInterface { return &FakeIngresses{c, namespace} } -func (c *FakeNetworkingV1alpha1) Realms() v1alpha1.RealmInterface { - return &FakeRealms{c} -} - func (c *FakeNetworkingV1alpha1) ServerlessServices(namespace string) v1alpha1.ServerlessServiceInterface { return &FakeServerlessServices{c, namespace} } diff --git a/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_realm.go b/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_realm.go deleted file mode 100644 index 69fcb1479..000000000 --- a/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_realm.go +++ /dev/null @@ -1,132 +0,0 @@ -/* -Copyright 2020 The Knative 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 ( - "context" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" - v1alpha1 "knative.dev/networking/pkg/apis/networking/v1alpha1" -) - -// FakeRealms implements RealmInterface -type FakeRealms struct { - Fake *FakeNetworkingV1alpha1 -} - -var realmsResource = v1alpha1.SchemeGroupVersion.WithResource("realms") - -var realmsKind = v1alpha1.SchemeGroupVersion.WithKind("Realm") - -// Get takes name of the realm, and returns the corresponding realm object, and an error if there is any. -func (c *FakeRealms) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Realm, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootGetAction(realmsResource, name), &v1alpha1.Realm{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Realm), err -} - -// List takes label and field selectors, and returns the list of Realms that match those selectors. -func (c *FakeRealms) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.RealmList, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootListAction(realmsResource, realmsKind, opts), &v1alpha1.RealmList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha1.RealmList{ListMeta: obj.(*v1alpha1.RealmList).ListMeta} - for _, item := range obj.(*v1alpha1.RealmList).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 realms. -func (c *FakeRealms) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewRootWatchAction(realmsResource, opts)) -} - -// Create takes the representation of a realm and creates it. Returns the server's representation of the realm, and an error, if there is any. -func (c *FakeRealms) Create(ctx context.Context, realm *v1alpha1.Realm, opts v1.CreateOptions) (result *v1alpha1.Realm, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootCreateAction(realmsResource, realm), &v1alpha1.Realm{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Realm), err -} - -// Update takes the representation of a realm and updates it. Returns the server's representation of the realm, and an error, if there is any. -func (c *FakeRealms) Update(ctx context.Context, realm *v1alpha1.Realm, opts v1.UpdateOptions) (result *v1alpha1.Realm, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootUpdateAction(realmsResource, realm), &v1alpha1.Realm{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Realm), 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 *FakeRealms) UpdateStatus(ctx context.Context, realm *v1alpha1.Realm, opts v1.UpdateOptions) (*v1alpha1.Realm, error) { - obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceAction(realmsResource, "status", realm), &v1alpha1.Realm{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Realm), err -} - -// Delete takes name of the realm and deletes it. Returns an error if one occurs. -func (c *FakeRealms) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewRootDeleteActionWithOptions(realmsResource, name, opts), &v1alpha1.Realm{}) - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeRealms) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewRootDeleteCollectionAction(realmsResource, listOpts) - - _, err := c.Fake.Invokes(action, &v1alpha1.RealmList{}) - return err -} - -// Patch applies the patch and returns the patched realm. -func (c *FakeRealms) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Realm, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(realmsResource, name, pt, data, subresources...), &v1alpha1.Realm{}) - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.Realm), err -} diff --git a/pkg/client/clientset/versioned/typed/networking/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/networking/v1alpha1/generated_expansion.go index 3bd2cbaa4..5fcaeb63a 100644 --- a/pkg/client/clientset/versioned/typed/networking/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/networking/v1alpha1/generated_expansion.go @@ -22,10 +22,6 @@ type CertificateExpansion interface{} type ClusterDomainClaimExpansion interface{} -type DomainExpansion interface{} - type IngressExpansion interface{} -type RealmExpansion interface{} - type ServerlessServiceExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/networking/v1alpha1/networking_client.go b/pkg/client/clientset/versioned/typed/networking/v1alpha1/networking_client.go index 334a0a8cc..ab3f56ad8 100644 --- a/pkg/client/clientset/versioned/typed/networking/v1alpha1/networking_client.go +++ b/pkg/client/clientset/versioned/typed/networking/v1alpha1/networking_client.go @@ -30,9 +30,7 @@ type NetworkingV1alpha1Interface interface { RESTClient() rest.Interface CertificatesGetter ClusterDomainClaimsGetter - DomainsGetter IngressesGetter - RealmsGetter ServerlessServicesGetter } @@ -49,18 +47,10 @@ func (c *NetworkingV1alpha1Client) ClusterDomainClaims() ClusterDomainClaimInter return newClusterDomainClaims(c) } -func (c *NetworkingV1alpha1Client) Domains() DomainInterface { - return newDomains(c) -} - func (c *NetworkingV1alpha1Client) Ingresses(namespace string) IngressInterface { return newIngresses(c, namespace) } -func (c *NetworkingV1alpha1Client) Realms() RealmInterface { - return newRealms(c) -} - func (c *NetworkingV1alpha1Client) ServerlessServices(namespace string) ServerlessServiceInterface { return newServerlessServices(c, namespace) } diff --git a/pkg/client/clientset/versioned/typed/networking/v1alpha1/realm.go b/pkg/client/clientset/versioned/typed/networking/v1alpha1/realm.go deleted file mode 100644 index b1abbea4c..000000000 --- a/pkg/client/clientset/versioned/typed/networking/v1alpha1/realm.go +++ /dev/null @@ -1,184 +0,0 @@ -/* -Copyright 2020 The Knative 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 ( - "context" - "time" - - 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" - v1alpha1 "knative.dev/networking/pkg/apis/networking/v1alpha1" - scheme "knative.dev/networking/pkg/client/clientset/versioned/scheme" -) - -// RealmsGetter has a method to return a RealmInterface. -// A group's client should implement this interface. -type RealmsGetter interface { - Realms() RealmInterface -} - -// RealmInterface has methods to work with Realm resources. -type RealmInterface interface { - Create(ctx context.Context, realm *v1alpha1.Realm, opts v1.CreateOptions) (*v1alpha1.Realm, error) - Update(ctx context.Context, realm *v1alpha1.Realm, opts v1.UpdateOptions) (*v1alpha1.Realm, error) - UpdateStatus(ctx context.Context, realm *v1alpha1.Realm, opts v1.UpdateOptions) (*v1alpha1.Realm, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Realm, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.RealmList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Realm, err error) - RealmExpansion -} - -// realms implements RealmInterface -type realms struct { - client rest.Interface -} - -// newRealms returns a Realms -func newRealms(c *NetworkingV1alpha1Client) *realms { - return &realms{ - client: c.RESTClient(), - } -} - -// Get takes name of the realm, and returns the corresponding realm object, and an error if there is any. -func (c *realms) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Realm, err error) { - result = &v1alpha1.Realm{} - err = c.client.Get(). - Resource("realms"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Realms that match those selectors. -func (c *realms) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.RealmList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.RealmList{} - err = c.client.Get(). - Resource("realms"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested realms. -func (c *realms) Watch(ctx context.Context, 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(). - Resource("realms"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a realm and creates it. Returns the server's representation of the realm, and an error, if there is any. -func (c *realms) Create(ctx context.Context, realm *v1alpha1.Realm, opts v1.CreateOptions) (result *v1alpha1.Realm, err error) { - result = &v1alpha1.Realm{} - err = c.client.Post(). - Resource("realms"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(realm). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a realm and updates it. Returns the server's representation of the realm, and an error, if there is any. -func (c *realms) Update(ctx context.Context, realm *v1alpha1.Realm, opts v1.UpdateOptions) (result *v1alpha1.Realm, err error) { - result = &v1alpha1.Realm{} - err = c.client.Put(). - Resource("realms"). - Name(realm.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(realm). - Do(ctx). - 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 *realms) UpdateStatus(ctx context.Context, realm *v1alpha1.Realm, opts v1.UpdateOptions) (result *v1alpha1.Realm, err error) { - result = &v1alpha1.Realm{} - err = c.client.Put(). - Resource("realms"). - Name(realm.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(realm). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the realm and deletes it. Returns an error if one occurs. -func (c *realms) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Resource("realms"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *realms) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Resource("realms"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched realm. -func (c *realms) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Realm, err error) { - result = &v1alpha1.Realm{} - err = c.client.Patch(pt). - Resource("realms"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 90c50f3a4..44cfc2992 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -57,12 +57,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha1().Certificates().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("clusterdomainclaims"): return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha1().ClusterDomainClaims().Informer()}, nil - case v1alpha1.SchemeGroupVersion.WithResource("domains"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha1().Domains().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("ingresses"): return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha1().Ingresses().Informer()}, nil - case v1alpha1.SchemeGroupVersion.WithResource("realms"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha1().Realms().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("serverlessservices"): return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha1().ServerlessServices().Informer()}, nil diff --git a/pkg/client/informers/externalversions/networking/v1alpha1/domain.go b/pkg/client/informers/externalversions/networking/v1alpha1/domain.go deleted file mode 100644 index 7b477de94..000000000 --- a/pkg/client/informers/externalversions/networking/v1alpha1/domain.go +++ /dev/null @@ -1,89 +0,0 @@ -/* -Copyright 2020 The Knative 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 ( - "context" - time "time" - - 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" - networkingv1alpha1 "knative.dev/networking/pkg/apis/networking/v1alpha1" - versioned "knative.dev/networking/pkg/client/clientset/versioned" - internalinterfaces "knative.dev/networking/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "knative.dev/networking/pkg/client/listers/networking/v1alpha1" -) - -// DomainInformer provides access to a shared informer and lister for -// Domains. -type DomainInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1alpha1.DomainLister -} - -type domainInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// NewDomainInformer constructs a new informer for Domain 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 NewDomainInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredDomainInformer(client, resyncPeriod, indexers, nil) -} - -// NewFilteredDomainInformer constructs a new informer for Domain 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 NewFilteredDomainInformer(client versioned.Interface, 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.NetworkingV1alpha1().Domains().List(context.TODO(), options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.NetworkingV1alpha1().Domains().Watch(context.TODO(), options) - }, - }, - &networkingv1alpha1.Domain{}, - resyncPeriod, - indexers, - ) -} - -func (f *domainInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredDomainInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *domainInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&networkingv1alpha1.Domain{}, f.defaultInformer) -} - -func (f *domainInformer) Lister() v1alpha1.DomainLister { - return v1alpha1.NewDomainLister(f.Informer().GetIndexer()) -} diff --git a/pkg/client/informers/externalversions/networking/v1alpha1/interface.go b/pkg/client/informers/externalversions/networking/v1alpha1/interface.go index fba5f09bc..240f43c25 100644 --- a/pkg/client/informers/externalversions/networking/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/networking/v1alpha1/interface.go @@ -28,12 +28,8 @@ type Interface interface { Certificates() CertificateInformer // ClusterDomainClaims returns a ClusterDomainClaimInformer. ClusterDomainClaims() ClusterDomainClaimInformer - // Domains returns a DomainInformer. - Domains() DomainInformer // Ingresses returns a IngressInformer. Ingresses() IngressInformer - // Realms returns a RealmInformer. - Realms() RealmInformer // ServerlessServices returns a ServerlessServiceInformer. ServerlessServices() ServerlessServiceInformer } @@ -59,21 +55,11 @@ func (v *version) ClusterDomainClaims() ClusterDomainClaimInformer { return &clusterDomainClaimInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } -// Domains returns a DomainInformer. -func (v *version) Domains() DomainInformer { - return &domainInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - // Ingresses returns a IngressInformer. func (v *version) Ingresses() IngressInformer { return &ingressInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } -// Realms returns a RealmInformer. -func (v *version) Realms() RealmInformer { - return &realmInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - // ServerlessServices returns a ServerlessServiceInformer. func (v *version) ServerlessServices() ServerlessServiceInformer { return &serverlessServiceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/informers/externalversions/networking/v1alpha1/realm.go b/pkg/client/informers/externalversions/networking/v1alpha1/realm.go deleted file mode 100644 index 313cb6cad..000000000 --- a/pkg/client/informers/externalversions/networking/v1alpha1/realm.go +++ /dev/null @@ -1,89 +0,0 @@ -/* -Copyright 2020 The Knative 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 ( - "context" - time "time" - - 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" - networkingv1alpha1 "knative.dev/networking/pkg/apis/networking/v1alpha1" - versioned "knative.dev/networking/pkg/client/clientset/versioned" - internalinterfaces "knative.dev/networking/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "knative.dev/networking/pkg/client/listers/networking/v1alpha1" -) - -// RealmInformer provides access to a shared informer and lister for -// Realms. -type RealmInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1alpha1.RealmLister -} - -type realmInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// NewRealmInformer constructs a new informer for Realm 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 NewRealmInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredRealmInformer(client, resyncPeriod, indexers, nil) -} - -// NewFilteredRealmInformer constructs a new informer for Realm 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 NewFilteredRealmInformer(client versioned.Interface, 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.NetworkingV1alpha1().Realms().List(context.TODO(), options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.NetworkingV1alpha1().Realms().Watch(context.TODO(), options) - }, - }, - &networkingv1alpha1.Realm{}, - resyncPeriod, - indexers, - ) -} - -func (f *realmInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredRealmInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *realmInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&networkingv1alpha1.Realm{}, f.defaultInformer) -} - -func (f *realmInformer) Lister() v1alpha1.RealmLister { - return v1alpha1.NewRealmLister(f.Informer().GetIndexer()) -} diff --git a/pkg/client/injection/informers/networking/v1alpha1/domain/domain.go b/pkg/client/injection/informers/networking/v1alpha1/domain/domain.go deleted file mode 100644 index ec8472435..000000000 --- a/pkg/client/injection/informers/networking/v1alpha1/domain/domain.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2020 The Knative 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 injection-gen. DO NOT EDIT. - -package domain - -import ( - context "context" - - v1alpha1 "knative.dev/networking/pkg/client/informers/externalversions/networking/v1alpha1" - factory "knative.dev/networking/pkg/client/injection/informers/factory" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -func init() { - injection.Default.RegisterInformer(withInformer) -} - -// Key is used for associating the Informer inside the context.Context. -type Key struct{} - -func withInformer(ctx context.Context) (context.Context, controller.Informer) { - f := factory.Get(ctx) - inf := f.Networking().V1alpha1().Domains() - return context.WithValue(ctx, Key{}, inf), inf.Informer() -} - -// Get extracts the typed informer from the context. -func Get(ctx context.Context) v1alpha1.DomainInformer { - untyped := ctx.Value(Key{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch knative.dev/networking/pkg/client/informers/externalversions/networking/v1alpha1.DomainInformer from context.") - } - return untyped.(v1alpha1.DomainInformer) -} diff --git a/pkg/client/injection/informers/networking/v1alpha1/domain/fake/fake.go b/pkg/client/injection/informers/networking/v1alpha1/domain/fake/fake.go deleted file mode 100644 index 4b52bd867..000000000 --- a/pkg/client/injection/informers/networking/v1alpha1/domain/fake/fake.go +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright 2020 The Knative 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 injection-gen. DO NOT EDIT. - -package fake - -import ( - context "context" - - fake "knative.dev/networking/pkg/client/injection/informers/factory/fake" - domain "knative.dev/networking/pkg/client/injection/informers/networking/v1alpha1/domain" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" -) - -var Get = domain.Get - -func init() { - injection.Fake.RegisterInformer(withInformer) -} - -func withInformer(ctx context.Context) (context.Context, controller.Informer) { - f := fake.Get(ctx) - inf := f.Networking().V1alpha1().Domains() - return context.WithValue(ctx, domain.Key{}, inf), inf.Informer() -} diff --git a/pkg/client/injection/informers/networking/v1alpha1/domain/filtered/domain.go b/pkg/client/injection/informers/networking/v1alpha1/domain/filtered/domain.go deleted file mode 100644 index 3f08b6948..000000000 --- a/pkg/client/injection/informers/networking/v1alpha1/domain/filtered/domain.go +++ /dev/null @@ -1,65 +0,0 @@ -/* -Copyright 2020 The Knative 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 injection-gen. DO NOT EDIT. - -package filtered - -import ( - context "context" - - v1alpha1 "knative.dev/networking/pkg/client/informers/externalversions/networking/v1alpha1" - filtered "knative.dev/networking/pkg/client/injection/informers/factory/filtered" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -func init() { - injection.Default.RegisterFilteredInformers(withInformer) -} - -// Key is used for associating the Informer inside the context.Context. -type Key struct { - Selector string -} - -func withInformer(ctx context.Context) (context.Context, []controller.Informer) { - untyped := ctx.Value(filtered.LabelKey{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch labelkey from context.") - } - labelSelectors := untyped.([]string) - infs := []controller.Informer{} - for _, selector := range labelSelectors { - f := filtered.Get(ctx, selector) - inf := f.Networking().V1alpha1().Domains() - ctx = context.WithValue(ctx, Key{Selector: selector}, inf) - infs = append(infs, inf.Informer()) - } - return ctx, infs -} - -// Get extracts the typed informer from the context. -func Get(ctx context.Context, selector string) v1alpha1.DomainInformer { - untyped := ctx.Value(Key{Selector: selector}) - if untyped == nil { - logging.FromContext(ctx).Panicf( - "Unable to fetch knative.dev/networking/pkg/client/informers/externalversions/networking/v1alpha1.DomainInformer with selector %s from context.", selector) - } - return untyped.(v1alpha1.DomainInformer) -} diff --git a/pkg/client/injection/informers/networking/v1alpha1/domain/filtered/fake/fake.go b/pkg/client/injection/informers/networking/v1alpha1/domain/filtered/fake/fake.go deleted file mode 100644 index 1ec8a3f2e..000000000 --- a/pkg/client/injection/informers/networking/v1alpha1/domain/filtered/fake/fake.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2020 The Knative 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 injection-gen. DO NOT EDIT. - -package fake - -import ( - context "context" - - factoryfiltered "knative.dev/networking/pkg/client/injection/informers/factory/filtered" - filtered "knative.dev/networking/pkg/client/injection/informers/networking/v1alpha1/domain/filtered" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -var Get = filtered.Get - -func init() { - injection.Fake.RegisterFilteredInformers(withInformer) -} - -func withInformer(ctx context.Context) (context.Context, []controller.Informer) { - untyped := ctx.Value(factoryfiltered.LabelKey{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch labelkey from context.") - } - labelSelectors := untyped.([]string) - infs := []controller.Informer{} - for _, selector := range labelSelectors { - f := factoryfiltered.Get(ctx, selector) - inf := f.Networking().V1alpha1().Domains() - ctx = context.WithValue(ctx, filtered.Key{Selector: selector}, inf) - infs = append(infs, inf.Informer()) - } - return ctx, infs -} diff --git a/pkg/client/injection/informers/networking/v1alpha1/realm/fake/fake.go b/pkg/client/injection/informers/networking/v1alpha1/realm/fake/fake.go deleted file mode 100644 index 10e2f6e17..000000000 --- a/pkg/client/injection/informers/networking/v1alpha1/realm/fake/fake.go +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright 2020 The Knative 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 injection-gen. DO NOT EDIT. - -package fake - -import ( - context "context" - - fake "knative.dev/networking/pkg/client/injection/informers/factory/fake" - realm "knative.dev/networking/pkg/client/injection/informers/networking/v1alpha1/realm" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" -) - -var Get = realm.Get - -func init() { - injection.Fake.RegisterInformer(withInformer) -} - -func withInformer(ctx context.Context) (context.Context, controller.Informer) { - f := fake.Get(ctx) - inf := f.Networking().V1alpha1().Realms() - return context.WithValue(ctx, realm.Key{}, inf), inf.Informer() -} diff --git a/pkg/client/injection/informers/networking/v1alpha1/realm/filtered/fake/fake.go b/pkg/client/injection/informers/networking/v1alpha1/realm/filtered/fake/fake.go deleted file mode 100644 index 1907299fc..000000000 --- a/pkg/client/injection/informers/networking/v1alpha1/realm/filtered/fake/fake.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2020 The Knative 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 injection-gen. DO NOT EDIT. - -package fake - -import ( - context "context" - - factoryfiltered "knative.dev/networking/pkg/client/injection/informers/factory/filtered" - filtered "knative.dev/networking/pkg/client/injection/informers/networking/v1alpha1/realm/filtered" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -var Get = filtered.Get - -func init() { - injection.Fake.RegisterFilteredInformers(withInformer) -} - -func withInformer(ctx context.Context) (context.Context, []controller.Informer) { - untyped := ctx.Value(factoryfiltered.LabelKey{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch labelkey from context.") - } - labelSelectors := untyped.([]string) - infs := []controller.Informer{} - for _, selector := range labelSelectors { - f := factoryfiltered.Get(ctx, selector) - inf := f.Networking().V1alpha1().Realms() - ctx = context.WithValue(ctx, filtered.Key{Selector: selector}, inf) - infs = append(infs, inf.Informer()) - } - return ctx, infs -} diff --git a/pkg/client/injection/informers/networking/v1alpha1/realm/filtered/realm.go b/pkg/client/injection/informers/networking/v1alpha1/realm/filtered/realm.go deleted file mode 100644 index 86524dd15..000000000 --- a/pkg/client/injection/informers/networking/v1alpha1/realm/filtered/realm.go +++ /dev/null @@ -1,65 +0,0 @@ -/* -Copyright 2020 The Knative 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 injection-gen. DO NOT EDIT. - -package filtered - -import ( - context "context" - - v1alpha1 "knative.dev/networking/pkg/client/informers/externalversions/networking/v1alpha1" - filtered "knative.dev/networking/pkg/client/injection/informers/factory/filtered" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -func init() { - injection.Default.RegisterFilteredInformers(withInformer) -} - -// Key is used for associating the Informer inside the context.Context. -type Key struct { - Selector string -} - -func withInformer(ctx context.Context) (context.Context, []controller.Informer) { - untyped := ctx.Value(filtered.LabelKey{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch labelkey from context.") - } - labelSelectors := untyped.([]string) - infs := []controller.Informer{} - for _, selector := range labelSelectors { - f := filtered.Get(ctx, selector) - inf := f.Networking().V1alpha1().Realms() - ctx = context.WithValue(ctx, Key{Selector: selector}, inf) - infs = append(infs, inf.Informer()) - } - return ctx, infs -} - -// Get extracts the typed informer from the context. -func Get(ctx context.Context, selector string) v1alpha1.RealmInformer { - untyped := ctx.Value(Key{Selector: selector}) - if untyped == nil { - logging.FromContext(ctx).Panicf( - "Unable to fetch knative.dev/networking/pkg/client/informers/externalversions/networking/v1alpha1.RealmInformer with selector %s from context.", selector) - } - return untyped.(v1alpha1.RealmInformer) -} diff --git a/pkg/client/injection/informers/networking/v1alpha1/realm/realm.go b/pkg/client/injection/informers/networking/v1alpha1/realm/realm.go deleted file mode 100644 index 69599b4a8..000000000 --- a/pkg/client/injection/informers/networking/v1alpha1/realm/realm.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2020 The Knative 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 injection-gen. DO NOT EDIT. - -package realm - -import ( - context "context" - - v1alpha1 "knative.dev/networking/pkg/client/informers/externalversions/networking/v1alpha1" - factory "knative.dev/networking/pkg/client/injection/informers/factory" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -func init() { - injection.Default.RegisterInformer(withInformer) -} - -// Key is used for associating the Informer inside the context.Context. -type Key struct{} - -func withInformer(ctx context.Context) (context.Context, controller.Informer) { - f := factory.Get(ctx) - inf := f.Networking().V1alpha1().Realms() - return context.WithValue(ctx, Key{}, inf), inf.Informer() -} - -// Get extracts the typed informer from the context. -func Get(ctx context.Context) v1alpha1.RealmInformer { - untyped := ctx.Value(Key{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch knative.dev/networking/pkg/client/informers/externalversions/networking/v1alpha1.RealmInformer from context.") - } - return untyped.(v1alpha1.RealmInformer) -} diff --git a/pkg/client/injection/reconciler/networking/v1alpha1/domain/controller.go b/pkg/client/injection/reconciler/networking/v1alpha1/domain/controller.go deleted file mode 100644 index 1f140aa21..000000000 --- a/pkg/client/injection/reconciler/networking/v1alpha1/domain/controller.go +++ /dev/null @@ -1,170 +0,0 @@ -/* -Copyright 2020 The Knative 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 injection-gen. DO NOT EDIT. - -package domain - -import ( - context "context" - fmt "fmt" - reflect "reflect" - strings "strings" - - zap "go.uber.org/zap" - corev1 "k8s.io/api/core/v1" - labels "k8s.io/apimachinery/pkg/labels" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - scheme "k8s.io/client-go/kubernetes/scheme" - v1 "k8s.io/client-go/kubernetes/typed/core/v1" - record "k8s.io/client-go/tools/record" - versionedscheme "knative.dev/networking/pkg/client/clientset/versioned/scheme" - client "knative.dev/networking/pkg/client/injection/client" - domain "knative.dev/networking/pkg/client/injection/informers/networking/v1alpha1/domain" - kubeclient "knative.dev/pkg/client/injection/kube/client" - controller "knative.dev/pkg/controller" - logging "knative.dev/pkg/logging" - logkey "knative.dev/pkg/logging/logkey" - reconciler "knative.dev/pkg/reconciler" -) - -const ( - defaultControllerAgentName = "domain-controller" - defaultFinalizerName = "domains.networking.internal.knative.dev" -) - -// NewImpl returns a controller.Impl that handles queuing and feeding work from -// the queue through an implementation of controller.Reconciler, delegating to -// the provided Interface and optional Finalizer methods. OptionsFn is used to return -// controller.ControllerOptions to be used by the internal reconciler. -func NewImpl(ctx context.Context, r Interface, optionsFns ...controller.OptionsFn) *controller.Impl { - logger := logging.FromContext(ctx) - - // Check the options function input. It should be 0 or 1. - if len(optionsFns) > 1 { - logger.Fatal("Up to one options function is supported, found: ", len(optionsFns)) - } - - domainInformer := domain.Get(ctx) - - lister := domainInformer.Lister() - - var promoteFilterFunc func(obj interface{}) bool - var promoteFunc = func(bkt reconciler.Bucket) {} - - rec := &reconcilerImpl{ - LeaderAwareFuncs: reconciler.LeaderAwareFuncs{ - PromoteFunc: func(bkt reconciler.Bucket, enq func(reconciler.Bucket, types.NamespacedName)) error { - - // Signal promotion event - promoteFunc(bkt) - - all, err := lister.List(labels.Everything()) - if err != nil { - return err - } - for _, elt := range all { - if promoteFilterFunc != nil { - if ok := promoteFilterFunc(elt); !ok { - continue - } - } - enq(bkt, types.NamespacedName{ - Namespace: elt.GetNamespace(), - Name: elt.GetName(), - }) - } - return nil - }, - }, - Client: client.Get(ctx), - Lister: lister, - reconciler: r, - finalizerName: defaultFinalizerName, - } - - ctrType := reflect.TypeOf(r).Elem() - ctrTypeName := fmt.Sprintf("%s.%s", ctrType.PkgPath(), ctrType.Name()) - ctrTypeName = strings.ReplaceAll(ctrTypeName, "/", ".") - - logger = logger.With( - zap.String(logkey.ControllerType, ctrTypeName), - zap.String(logkey.Kind, "networking.internal.knative.dev.Domain"), - ) - - impl := controller.NewContext(ctx, rec, controller.ControllerOptions{WorkQueueName: ctrTypeName, Logger: logger}) - agentName := defaultControllerAgentName - - // Pass impl to the options. Save any optional results. - for _, fn := range optionsFns { - opts := fn(impl) - if opts.ConfigStore != nil { - rec.configStore = opts.ConfigStore - } - if opts.FinalizerName != "" { - rec.finalizerName = opts.FinalizerName - } - if opts.AgentName != "" { - agentName = opts.AgentName - } - if opts.SkipStatusUpdates { - rec.skipStatusUpdates = true - } - if opts.DemoteFunc != nil { - rec.DemoteFunc = opts.DemoteFunc - } - if opts.PromoteFilterFunc != nil { - promoteFilterFunc = opts.PromoteFilterFunc - } - if opts.PromoteFunc != nil { - promoteFunc = opts.PromoteFunc - } - } - - rec.Recorder = createRecorder(ctx, agentName) - - return impl -} - -func createRecorder(ctx context.Context, agentName string) record.EventRecorder { - logger := logging.FromContext(ctx) - - recorder := controller.GetEventRecorder(ctx) - if recorder == nil { - // Create event broadcaster - logger.Debug("Creating event broadcaster") - eventBroadcaster := record.NewBroadcaster() - watches := []watch.Interface{ - eventBroadcaster.StartLogging(logger.Named("event-broadcaster").Infof), - eventBroadcaster.StartRecordingToSink( - &v1.EventSinkImpl{Interface: kubeclient.Get(ctx).CoreV1().Events("")}), - } - recorder = eventBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: agentName}) - go func() { - <-ctx.Done() - for _, w := range watches { - w.Stop() - } - }() - } - - return recorder -} - -func init() { - versionedscheme.AddToScheme(scheme.Scheme) -} diff --git a/pkg/client/injection/reconciler/networking/v1alpha1/domain/reconciler.go b/pkg/client/injection/reconciler/networking/v1alpha1/domain/reconciler.go deleted file mode 100644 index 27a13dd4d..000000000 --- a/pkg/client/injection/reconciler/networking/v1alpha1/domain/reconciler.go +++ /dev/null @@ -1,440 +0,0 @@ -/* -Copyright 2020 The Knative 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 injection-gen. DO NOT EDIT. - -package domain - -import ( - context "context" - json "encoding/json" - fmt "fmt" - - zap "go.uber.org/zap" - "go.uber.org/zap/zapcore" - v1 "k8s.io/api/core/v1" - equality "k8s.io/apimachinery/pkg/api/equality" - errors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - types "k8s.io/apimachinery/pkg/types" - sets "k8s.io/apimachinery/pkg/util/sets" - record "k8s.io/client-go/tools/record" - v1alpha1 "knative.dev/networking/pkg/apis/networking/v1alpha1" - versioned "knative.dev/networking/pkg/client/clientset/versioned" - networkingv1alpha1 "knative.dev/networking/pkg/client/listers/networking/v1alpha1" - controller "knative.dev/pkg/controller" - kmp "knative.dev/pkg/kmp" - logging "knative.dev/pkg/logging" - reconciler "knative.dev/pkg/reconciler" -) - -// Interface defines the strongly typed interfaces to be implemented by a -// controller reconciling v1alpha1.Domain. -type Interface interface { - // ReconcileKind implements custom logic to reconcile v1alpha1.Domain. Any changes - // to the objects .Status or .Finalizers will be propagated to the stored - // object. It is recommended that implementors do not call any update calls - // for the Kind inside of ReconcileKind, it is the responsibility of the calling - // controller to propagate those properties. The resource passed to ReconcileKind - // will always have an empty deletion timestamp. - ReconcileKind(ctx context.Context, o *v1alpha1.Domain) reconciler.Event -} - -// Finalizer defines the strongly typed interfaces to be implemented by a -// controller finalizing v1alpha1.Domain. -type Finalizer interface { - // FinalizeKind implements custom logic to finalize v1alpha1.Domain. Any changes - // to the objects .Status or .Finalizers will be ignored. Returning a nil or - // Normal type reconciler.Event will allow the finalizer to be deleted on - // the resource. The resource passed to FinalizeKind will always have a set - // deletion timestamp. - FinalizeKind(ctx context.Context, o *v1alpha1.Domain) reconciler.Event -} - -// ReadOnlyInterface defines the strongly typed interfaces to be implemented by a -// controller reconciling v1alpha1.Domain if they want to process resources for which -// they are not the leader. -type ReadOnlyInterface interface { - // ObserveKind implements logic to observe v1alpha1.Domain. - // This method should not write to the API. - ObserveKind(ctx context.Context, o *v1alpha1.Domain) reconciler.Event -} - -type doReconcile func(ctx context.Context, o *v1alpha1.Domain) reconciler.Event - -// reconcilerImpl implements controller.Reconciler for v1alpha1.Domain resources. -type reconcilerImpl struct { - // LeaderAwareFuncs is inlined to help us implement reconciler.LeaderAware. - reconciler.LeaderAwareFuncs - - // Client is used to write back status updates. - Client versioned.Interface - - // Listers index properties about resources. - Lister networkingv1alpha1.DomainLister - - // Recorder is an event recorder for recording Event resources to the - // Kubernetes API. - Recorder record.EventRecorder - - // configStore allows for decorating a context with config maps. - // +optional - configStore reconciler.ConfigStore - - // reconciler is the implementation of the business logic of the resource. - reconciler Interface - - // finalizerName is the name of the finalizer to reconcile. - finalizerName string - - // skipStatusUpdates configures whether or not this reconciler automatically updates - // the status of the reconciled resource. - skipStatusUpdates bool -} - -// Check that our Reconciler implements controller.Reconciler. -var _ controller.Reconciler = (*reconcilerImpl)(nil) - -// Check that our generated Reconciler is always LeaderAware. -var _ reconciler.LeaderAware = (*reconcilerImpl)(nil) - -func NewReconciler(ctx context.Context, logger *zap.SugaredLogger, client versioned.Interface, lister networkingv1alpha1.DomainLister, recorder record.EventRecorder, r Interface, options ...controller.Options) controller.Reconciler { - // Check the options function input. It should be 0 or 1. - if len(options) > 1 { - logger.Fatal("Up to one options struct is supported, found: ", len(options)) - } - - // Fail fast when users inadvertently implement the other LeaderAware interface. - // For the typed reconcilers, Promote shouldn't take any arguments. - if _, ok := r.(reconciler.LeaderAware); ok { - logger.Fatalf("%T implements the incorrect LeaderAware interface. Promote() should not take an argument as genreconciler handles the enqueuing automatically.", r) - } - - rec := &reconcilerImpl{ - LeaderAwareFuncs: reconciler.LeaderAwareFuncs{ - PromoteFunc: func(bkt reconciler.Bucket, enq func(reconciler.Bucket, types.NamespacedName)) error { - all, err := lister.List(labels.Everything()) - if err != nil { - return err - } - for _, elt := range all { - // TODO: Consider letting users specify a filter in options. - enq(bkt, types.NamespacedName{ - Namespace: elt.GetNamespace(), - Name: elt.GetName(), - }) - } - return nil - }, - }, - Client: client, - Lister: lister, - Recorder: recorder, - reconciler: r, - finalizerName: defaultFinalizerName, - } - - for _, opts := range options { - if opts.ConfigStore != nil { - rec.configStore = opts.ConfigStore - } - if opts.FinalizerName != "" { - rec.finalizerName = opts.FinalizerName - } - if opts.SkipStatusUpdates { - rec.skipStatusUpdates = true - } - if opts.DemoteFunc != nil { - rec.DemoteFunc = opts.DemoteFunc - } - } - - return rec -} - -// Reconcile implements controller.Reconciler -func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { - logger := logging.FromContext(ctx) - - // Initialize the reconciler state. This will convert the namespace/name - // string into a distinct namespace and name, determine if this instance of - // the reconciler is the leader, and any additional interfaces implemented - // by the reconciler. Returns an error is the resource key is invalid. - s, err := newState(key, r) - if err != nil { - logger.Error("Invalid resource key: ", key) - return nil - } - - // If we are not the leader, and we don't implement either ReadOnly - // observer interfaces, then take a fast-path out. - if s.isNotLeaderNorObserver() { - return controller.NewSkipKey(key) - } - - // If configStore is set, attach the frozen configuration to the context. - if r.configStore != nil { - ctx = r.configStore.ToContext(ctx) - } - - // Add the recorder to context. - ctx = controller.WithEventRecorder(ctx, r.Recorder) - - // Get the resource with this namespace/name. - - getter := r.Lister - - original, err := getter.Get(s.name) - - if errors.IsNotFound(err) { - // The resource may no longer exist, in which case we stop processing and call - // the ObserveDeletion handler if appropriate. - logger.Debugf("Resource %q no longer exists", key) - if del, ok := r.reconciler.(reconciler.OnDeletionInterface); ok { - return del.ObserveDeletion(ctx, types.NamespacedName{ - Namespace: s.namespace, - Name: s.name, - }) - } - return nil - } else if err != nil { - return err - } - - // Don't modify the informers copy. - resource := original.DeepCopy() - - var reconcileEvent reconciler.Event - - name, do := s.reconcileMethodFor(resource) - // Append the target method to the logger. - logger = logger.With(zap.String("targetMethod", name)) - switch name { - case reconciler.DoReconcileKind: - // Set and update the finalizer on resource if r.reconciler - // implements Finalizer. - if resource, err = r.setFinalizerIfFinalizer(ctx, resource); err != nil { - return fmt.Errorf("failed to set finalizers: %w", err) - } - - if !r.skipStatusUpdates { - reconciler.PreProcessReconcile(ctx, resource) - } - - // Reconcile this copy of the resource and then write back any status - // updates regardless of whether the reconciliation errored out. - reconcileEvent = do(ctx, resource) - - if !r.skipStatusUpdates { - reconciler.PostProcessReconcile(ctx, resource, original) - } - - case reconciler.DoFinalizeKind: - // For finalizing reconcilers, if this resource being marked for deletion - // and reconciled cleanly (nil or normal event), remove the finalizer. - reconcileEvent = do(ctx, resource) - - if resource, err = r.clearFinalizer(ctx, resource, reconcileEvent); err != nil { - return fmt.Errorf("failed to clear finalizers: %w", err) - } - - case reconciler.DoObserveKind: - // Observe any changes to this resource, since we are not the leader. - reconcileEvent = do(ctx, resource) - - } - - // Synchronize the status. - switch { - case r.skipStatusUpdates: - // This reconciler implementation is configured to skip resource updates. - // This may mean this reconciler does not observe spec, but reconciles external changes. - case equality.Semantic.DeepEqual(original.Status, resource.Status): - // If we didn't change anything then don't call updateStatus. - // This is important because the copy we loaded from the injectionInformer's - // cache may be stale and we don't want to overwrite a prior update - // to status with this stale state. - case !s.isLeader: - // High-availability reconcilers may have many replicas watching the resource, but only - // the elected leader is expected to write modifications. - logger.Warn("Saw status changes when we aren't the leader!") - default: - if err = r.updateStatus(ctx, logger, original, resource); err != nil { - logger.Warnw("Failed to update resource status", zap.Error(err)) - r.Recorder.Eventf(resource, v1.EventTypeWarning, "UpdateFailed", - "Failed to update status for %q: %v", resource.Name, err) - return err - } - } - - // Report the reconciler event, if any. - if reconcileEvent != nil { - var event *reconciler.ReconcilerEvent - if reconciler.EventAs(reconcileEvent, &event) { - logger.Infow("Returned an event", zap.Any("event", reconcileEvent)) - r.Recorder.Event(resource, event.EventType, event.Reason, event.Error()) - - // the event was wrapped inside an error, consider the reconciliation as failed - if _, isEvent := reconcileEvent.(*reconciler.ReconcilerEvent); !isEvent { - return reconcileEvent - } - return nil - } - - if controller.IsSkipKey(reconcileEvent) { - // This is a wrapped error, don't emit an event. - } else if ok, _ := controller.IsRequeueKey(reconcileEvent); ok { - // This is a wrapped error, don't emit an event. - } else { - logger.Errorw("Returned an error", zap.Error(reconcileEvent)) - r.Recorder.Event(resource, v1.EventTypeWarning, "InternalError", reconcileEvent.Error()) - } - return reconcileEvent - } - - return nil -} - -func (r *reconcilerImpl) updateStatus(ctx context.Context, logger *zap.SugaredLogger, existing *v1alpha1.Domain, desired *v1alpha1.Domain) error { - existing = existing.DeepCopy() - return reconciler.RetryUpdateConflicts(func(attempts int) (err error) { - // The first iteration tries to use the injectionInformer's state, subsequent attempts fetch the latest state via API. - if attempts > 0 { - - getter := r.Client.NetworkingV1alpha1().Domains() - - existing, err = getter.Get(ctx, desired.Name, metav1.GetOptions{}) - if err != nil { - return err - } - } - - // If there's nothing to update, just return. - if equality.Semantic.DeepEqual(existing.Status, desired.Status) { - return nil - } - - if logger.Desugar().Core().Enabled(zapcore.DebugLevel) { - if diff, err := kmp.SafeDiff(existing.Status, desired.Status); err == nil && diff != "" { - logger.Debug("Updating status with: ", diff) - } - } - - existing.Status = desired.Status - - updater := r.Client.NetworkingV1alpha1().Domains() - - _, err = updater.UpdateStatus(ctx, existing, metav1.UpdateOptions{}) - return err - }) -} - -// updateFinalizersFiltered will update the Finalizers of the resource. -// TODO: this method could be generic and sync all finalizers. For now it only -// updates defaultFinalizerName or its override. -func (r *reconcilerImpl) updateFinalizersFiltered(ctx context.Context, resource *v1alpha1.Domain, desiredFinalizers sets.Set[string]) (*v1alpha1.Domain, error) { - // Don't modify the informers copy. - existing := resource.DeepCopy() - - var finalizers []string - - // If there's nothing to update, just return. - existingFinalizers := sets.New[string](existing.Finalizers...) - - if desiredFinalizers.Has(r.finalizerName) { - if existingFinalizers.Has(r.finalizerName) { - // Nothing to do. - return resource, nil - } - // Add the finalizer. - finalizers = append(existing.Finalizers, r.finalizerName) - } else { - if !existingFinalizers.Has(r.finalizerName) { - // Nothing to do. - return resource, nil - } - // Remove the finalizer. - existingFinalizers.Delete(r.finalizerName) - finalizers = sets.List(existingFinalizers) - } - - mergePatch := map[string]interface{}{ - "metadata": map[string]interface{}{ - "finalizers": finalizers, - "resourceVersion": existing.ResourceVersion, - }, - } - - patch, err := json.Marshal(mergePatch) - if err != nil { - return resource, err - } - - patcher := r.Client.NetworkingV1alpha1().Domains() - - resourceName := resource.Name - updated, err := patcher.Patch(ctx, resourceName, types.MergePatchType, patch, metav1.PatchOptions{}) - if err != nil { - r.Recorder.Eventf(existing, v1.EventTypeWarning, "FinalizerUpdateFailed", - "Failed to update finalizers for %q: %v", resourceName, err) - } else { - r.Recorder.Eventf(updated, v1.EventTypeNormal, "FinalizerUpdate", - "Updated %q finalizers", resource.GetName()) - } - return updated, err -} - -func (r *reconcilerImpl) setFinalizerIfFinalizer(ctx context.Context, resource *v1alpha1.Domain) (*v1alpha1.Domain, error) { - if _, ok := r.reconciler.(Finalizer); !ok { - return resource, nil - } - - finalizers := sets.New[string](resource.Finalizers...) - - // If this resource is not being deleted, mark the finalizer. - if resource.GetDeletionTimestamp().IsZero() { - finalizers.Insert(r.finalizerName) - } - - // Synchronize the finalizers filtered by r.finalizerName. - return r.updateFinalizersFiltered(ctx, resource, finalizers) -} - -func (r *reconcilerImpl) clearFinalizer(ctx context.Context, resource *v1alpha1.Domain, reconcileEvent reconciler.Event) (*v1alpha1.Domain, error) { - if _, ok := r.reconciler.(Finalizer); !ok { - return resource, nil - } - if resource.GetDeletionTimestamp().IsZero() { - return resource, nil - } - - finalizers := sets.New[string](resource.Finalizers...) - - if reconcileEvent != nil { - var event *reconciler.ReconcilerEvent - if reconciler.EventAs(reconcileEvent, &event) { - if event.EventType == v1.EventTypeNormal { - finalizers.Delete(r.finalizerName) - } - } - } else { - finalizers.Delete(r.finalizerName) - } - - // Synchronize the finalizers filtered by r.finalizerName. - return r.updateFinalizersFiltered(ctx, resource, finalizers) -} diff --git a/pkg/client/injection/reconciler/networking/v1alpha1/domain/state.go b/pkg/client/injection/reconciler/networking/v1alpha1/domain/state.go deleted file mode 100644 index 4d2a1723e..000000000 --- a/pkg/client/injection/reconciler/networking/v1alpha1/domain/state.go +++ /dev/null @@ -1,97 +0,0 @@ -/* -Copyright 2020 The Knative 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 injection-gen. DO NOT EDIT. - -package domain - -import ( - fmt "fmt" - - types "k8s.io/apimachinery/pkg/types" - cache "k8s.io/client-go/tools/cache" - v1alpha1 "knative.dev/networking/pkg/apis/networking/v1alpha1" - reconciler "knative.dev/pkg/reconciler" -) - -// state is used to track the state of a reconciler in a single run. -type state struct { - // key is the original reconciliation key from the queue. - key string - // namespace is the namespace split from the reconciliation key. - namespace string - // name is the name split from the reconciliation key. - name string - // reconciler is the reconciler. - reconciler Interface - // roi is the read only interface cast of the reconciler. - roi ReadOnlyInterface - // isROI (Read Only Interface) the reconciler only observes reconciliation. - isROI bool - // isLeader the instance of the reconciler is the elected leader. - isLeader bool -} - -func newState(key string, r *reconcilerImpl) (*state, error) { - // Convert the namespace/name string into a distinct namespace and name. - namespace, name, err := cache.SplitMetaNamespaceKey(key) - if err != nil { - return nil, fmt.Errorf("invalid resource key: %s", key) - } - - roi, isROI := r.reconciler.(ReadOnlyInterface) - - isLeader := r.IsLeaderFor(types.NamespacedName{ - Namespace: namespace, - Name: name, - }) - - return &state{ - key: key, - namespace: namespace, - name: name, - reconciler: r.reconciler, - roi: roi, - isROI: isROI, - isLeader: isLeader, - }, nil -} - -// isNotLeaderNorObserver checks to see if this reconciler with the current -// state is enabled to do any work or not. -// isNotLeaderNorObserver returns true when there is no work possible for the -// reconciler. -func (s *state) isNotLeaderNorObserver() bool { - if !s.isLeader && !s.isROI { - // If we are not the leader, and we don't implement the ReadOnly - // interface, then take a fast-path out. - return true - } - return false -} - -func (s *state) reconcileMethodFor(o *v1alpha1.Domain) (string, doReconcile) { - if o.GetDeletionTimestamp().IsZero() { - if s.isLeader { - return reconciler.DoReconcileKind, s.reconciler.ReconcileKind - } else if s.isROI { - return reconciler.DoObserveKind, s.roi.ObserveKind - } - } else if fin, ok := s.reconciler.(Finalizer); s.isLeader && ok { - return reconciler.DoFinalizeKind, fin.FinalizeKind - } - return "unknown", nil -} diff --git a/pkg/client/injection/reconciler/networking/v1alpha1/realm/controller.go b/pkg/client/injection/reconciler/networking/v1alpha1/realm/controller.go deleted file mode 100644 index 8b7b51dc7..000000000 --- a/pkg/client/injection/reconciler/networking/v1alpha1/realm/controller.go +++ /dev/null @@ -1,170 +0,0 @@ -/* -Copyright 2020 The Knative 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 injection-gen. DO NOT EDIT. - -package realm - -import ( - context "context" - fmt "fmt" - reflect "reflect" - strings "strings" - - zap "go.uber.org/zap" - corev1 "k8s.io/api/core/v1" - labels "k8s.io/apimachinery/pkg/labels" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - scheme "k8s.io/client-go/kubernetes/scheme" - v1 "k8s.io/client-go/kubernetes/typed/core/v1" - record "k8s.io/client-go/tools/record" - versionedscheme "knative.dev/networking/pkg/client/clientset/versioned/scheme" - client "knative.dev/networking/pkg/client/injection/client" - realm "knative.dev/networking/pkg/client/injection/informers/networking/v1alpha1/realm" - kubeclient "knative.dev/pkg/client/injection/kube/client" - controller "knative.dev/pkg/controller" - logging "knative.dev/pkg/logging" - logkey "knative.dev/pkg/logging/logkey" - reconciler "knative.dev/pkg/reconciler" -) - -const ( - defaultControllerAgentName = "realm-controller" - defaultFinalizerName = "realms.networking.internal.knative.dev" -) - -// NewImpl returns a controller.Impl that handles queuing and feeding work from -// the queue through an implementation of controller.Reconciler, delegating to -// the provided Interface and optional Finalizer methods. OptionsFn is used to return -// controller.ControllerOptions to be used by the internal reconciler. -func NewImpl(ctx context.Context, r Interface, optionsFns ...controller.OptionsFn) *controller.Impl { - logger := logging.FromContext(ctx) - - // Check the options function input. It should be 0 or 1. - if len(optionsFns) > 1 { - logger.Fatal("Up to one options function is supported, found: ", len(optionsFns)) - } - - realmInformer := realm.Get(ctx) - - lister := realmInformer.Lister() - - var promoteFilterFunc func(obj interface{}) bool - var promoteFunc = func(bkt reconciler.Bucket) {} - - rec := &reconcilerImpl{ - LeaderAwareFuncs: reconciler.LeaderAwareFuncs{ - PromoteFunc: func(bkt reconciler.Bucket, enq func(reconciler.Bucket, types.NamespacedName)) error { - - // Signal promotion event - promoteFunc(bkt) - - all, err := lister.List(labels.Everything()) - if err != nil { - return err - } - for _, elt := range all { - if promoteFilterFunc != nil { - if ok := promoteFilterFunc(elt); !ok { - continue - } - } - enq(bkt, types.NamespacedName{ - Namespace: elt.GetNamespace(), - Name: elt.GetName(), - }) - } - return nil - }, - }, - Client: client.Get(ctx), - Lister: lister, - reconciler: r, - finalizerName: defaultFinalizerName, - } - - ctrType := reflect.TypeOf(r).Elem() - ctrTypeName := fmt.Sprintf("%s.%s", ctrType.PkgPath(), ctrType.Name()) - ctrTypeName = strings.ReplaceAll(ctrTypeName, "/", ".") - - logger = logger.With( - zap.String(logkey.ControllerType, ctrTypeName), - zap.String(logkey.Kind, "networking.internal.knative.dev.Realm"), - ) - - impl := controller.NewContext(ctx, rec, controller.ControllerOptions{WorkQueueName: ctrTypeName, Logger: logger}) - agentName := defaultControllerAgentName - - // Pass impl to the options. Save any optional results. - for _, fn := range optionsFns { - opts := fn(impl) - if opts.ConfigStore != nil { - rec.configStore = opts.ConfigStore - } - if opts.FinalizerName != "" { - rec.finalizerName = opts.FinalizerName - } - if opts.AgentName != "" { - agentName = opts.AgentName - } - if opts.SkipStatusUpdates { - rec.skipStatusUpdates = true - } - if opts.DemoteFunc != nil { - rec.DemoteFunc = opts.DemoteFunc - } - if opts.PromoteFilterFunc != nil { - promoteFilterFunc = opts.PromoteFilterFunc - } - if opts.PromoteFunc != nil { - promoteFunc = opts.PromoteFunc - } - } - - rec.Recorder = createRecorder(ctx, agentName) - - return impl -} - -func createRecorder(ctx context.Context, agentName string) record.EventRecorder { - logger := logging.FromContext(ctx) - - recorder := controller.GetEventRecorder(ctx) - if recorder == nil { - // Create event broadcaster - logger.Debug("Creating event broadcaster") - eventBroadcaster := record.NewBroadcaster() - watches := []watch.Interface{ - eventBroadcaster.StartLogging(logger.Named("event-broadcaster").Infof), - eventBroadcaster.StartRecordingToSink( - &v1.EventSinkImpl{Interface: kubeclient.Get(ctx).CoreV1().Events("")}), - } - recorder = eventBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: agentName}) - go func() { - <-ctx.Done() - for _, w := range watches { - w.Stop() - } - }() - } - - return recorder -} - -func init() { - versionedscheme.AddToScheme(scheme.Scheme) -} diff --git a/pkg/client/injection/reconciler/networking/v1alpha1/realm/reconciler.go b/pkg/client/injection/reconciler/networking/v1alpha1/realm/reconciler.go deleted file mode 100644 index df7eef178..000000000 --- a/pkg/client/injection/reconciler/networking/v1alpha1/realm/reconciler.go +++ /dev/null @@ -1,440 +0,0 @@ -/* -Copyright 2020 The Knative 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 injection-gen. DO NOT EDIT. - -package realm - -import ( - context "context" - json "encoding/json" - fmt "fmt" - - zap "go.uber.org/zap" - "go.uber.org/zap/zapcore" - v1 "k8s.io/api/core/v1" - equality "k8s.io/apimachinery/pkg/api/equality" - errors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - types "k8s.io/apimachinery/pkg/types" - sets "k8s.io/apimachinery/pkg/util/sets" - record "k8s.io/client-go/tools/record" - v1alpha1 "knative.dev/networking/pkg/apis/networking/v1alpha1" - versioned "knative.dev/networking/pkg/client/clientset/versioned" - networkingv1alpha1 "knative.dev/networking/pkg/client/listers/networking/v1alpha1" - controller "knative.dev/pkg/controller" - kmp "knative.dev/pkg/kmp" - logging "knative.dev/pkg/logging" - reconciler "knative.dev/pkg/reconciler" -) - -// Interface defines the strongly typed interfaces to be implemented by a -// controller reconciling v1alpha1.Realm. -type Interface interface { - // ReconcileKind implements custom logic to reconcile v1alpha1.Realm. Any changes - // to the objects .Status or .Finalizers will be propagated to the stored - // object. It is recommended that implementors do not call any update calls - // for the Kind inside of ReconcileKind, it is the responsibility of the calling - // controller to propagate those properties. The resource passed to ReconcileKind - // will always have an empty deletion timestamp. - ReconcileKind(ctx context.Context, o *v1alpha1.Realm) reconciler.Event -} - -// Finalizer defines the strongly typed interfaces to be implemented by a -// controller finalizing v1alpha1.Realm. -type Finalizer interface { - // FinalizeKind implements custom logic to finalize v1alpha1.Realm. Any changes - // to the objects .Status or .Finalizers will be ignored. Returning a nil or - // Normal type reconciler.Event will allow the finalizer to be deleted on - // the resource. The resource passed to FinalizeKind will always have a set - // deletion timestamp. - FinalizeKind(ctx context.Context, o *v1alpha1.Realm) reconciler.Event -} - -// ReadOnlyInterface defines the strongly typed interfaces to be implemented by a -// controller reconciling v1alpha1.Realm if they want to process resources for which -// they are not the leader. -type ReadOnlyInterface interface { - // ObserveKind implements logic to observe v1alpha1.Realm. - // This method should not write to the API. - ObserveKind(ctx context.Context, o *v1alpha1.Realm) reconciler.Event -} - -type doReconcile func(ctx context.Context, o *v1alpha1.Realm) reconciler.Event - -// reconcilerImpl implements controller.Reconciler for v1alpha1.Realm resources. -type reconcilerImpl struct { - // LeaderAwareFuncs is inlined to help us implement reconciler.LeaderAware. - reconciler.LeaderAwareFuncs - - // Client is used to write back status updates. - Client versioned.Interface - - // Listers index properties about resources. - Lister networkingv1alpha1.RealmLister - - // Recorder is an event recorder for recording Event resources to the - // Kubernetes API. - Recorder record.EventRecorder - - // configStore allows for decorating a context with config maps. - // +optional - configStore reconciler.ConfigStore - - // reconciler is the implementation of the business logic of the resource. - reconciler Interface - - // finalizerName is the name of the finalizer to reconcile. - finalizerName string - - // skipStatusUpdates configures whether or not this reconciler automatically updates - // the status of the reconciled resource. - skipStatusUpdates bool -} - -// Check that our Reconciler implements controller.Reconciler. -var _ controller.Reconciler = (*reconcilerImpl)(nil) - -// Check that our generated Reconciler is always LeaderAware. -var _ reconciler.LeaderAware = (*reconcilerImpl)(nil) - -func NewReconciler(ctx context.Context, logger *zap.SugaredLogger, client versioned.Interface, lister networkingv1alpha1.RealmLister, recorder record.EventRecorder, r Interface, options ...controller.Options) controller.Reconciler { - // Check the options function input. It should be 0 or 1. - if len(options) > 1 { - logger.Fatal("Up to one options struct is supported, found: ", len(options)) - } - - // Fail fast when users inadvertently implement the other LeaderAware interface. - // For the typed reconcilers, Promote shouldn't take any arguments. - if _, ok := r.(reconciler.LeaderAware); ok { - logger.Fatalf("%T implements the incorrect LeaderAware interface. Promote() should not take an argument as genreconciler handles the enqueuing automatically.", r) - } - - rec := &reconcilerImpl{ - LeaderAwareFuncs: reconciler.LeaderAwareFuncs{ - PromoteFunc: func(bkt reconciler.Bucket, enq func(reconciler.Bucket, types.NamespacedName)) error { - all, err := lister.List(labels.Everything()) - if err != nil { - return err - } - for _, elt := range all { - // TODO: Consider letting users specify a filter in options. - enq(bkt, types.NamespacedName{ - Namespace: elt.GetNamespace(), - Name: elt.GetName(), - }) - } - return nil - }, - }, - Client: client, - Lister: lister, - Recorder: recorder, - reconciler: r, - finalizerName: defaultFinalizerName, - } - - for _, opts := range options { - if opts.ConfigStore != nil { - rec.configStore = opts.ConfigStore - } - if opts.FinalizerName != "" { - rec.finalizerName = opts.FinalizerName - } - if opts.SkipStatusUpdates { - rec.skipStatusUpdates = true - } - if opts.DemoteFunc != nil { - rec.DemoteFunc = opts.DemoteFunc - } - } - - return rec -} - -// Reconcile implements controller.Reconciler -func (r *reconcilerImpl) Reconcile(ctx context.Context, key string) error { - logger := logging.FromContext(ctx) - - // Initialize the reconciler state. This will convert the namespace/name - // string into a distinct namespace and name, determine if this instance of - // the reconciler is the leader, and any additional interfaces implemented - // by the reconciler. Returns an error is the resource key is invalid. - s, err := newState(key, r) - if err != nil { - logger.Error("Invalid resource key: ", key) - return nil - } - - // If we are not the leader, and we don't implement either ReadOnly - // observer interfaces, then take a fast-path out. - if s.isNotLeaderNorObserver() { - return controller.NewSkipKey(key) - } - - // If configStore is set, attach the frozen configuration to the context. - if r.configStore != nil { - ctx = r.configStore.ToContext(ctx) - } - - // Add the recorder to context. - ctx = controller.WithEventRecorder(ctx, r.Recorder) - - // Get the resource with this namespace/name. - - getter := r.Lister - - original, err := getter.Get(s.name) - - if errors.IsNotFound(err) { - // The resource may no longer exist, in which case we stop processing and call - // the ObserveDeletion handler if appropriate. - logger.Debugf("Resource %q no longer exists", key) - if del, ok := r.reconciler.(reconciler.OnDeletionInterface); ok { - return del.ObserveDeletion(ctx, types.NamespacedName{ - Namespace: s.namespace, - Name: s.name, - }) - } - return nil - } else if err != nil { - return err - } - - // Don't modify the informers copy. - resource := original.DeepCopy() - - var reconcileEvent reconciler.Event - - name, do := s.reconcileMethodFor(resource) - // Append the target method to the logger. - logger = logger.With(zap.String("targetMethod", name)) - switch name { - case reconciler.DoReconcileKind: - // Set and update the finalizer on resource if r.reconciler - // implements Finalizer. - if resource, err = r.setFinalizerIfFinalizer(ctx, resource); err != nil { - return fmt.Errorf("failed to set finalizers: %w", err) - } - - if !r.skipStatusUpdates { - reconciler.PreProcessReconcile(ctx, resource) - } - - // Reconcile this copy of the resource and then write back any status - // updates regardless of whether the reconciliation errored out. - reconcileEvent = do(ctx, resource) - - if !r.skipStatusUpdates { - reconciler.PostProcessReconcile(ctx, resource, original) - } - - case reconciler.DoFinalizeKind: - // For finalizing reconcilers, if this resource being marked for deletion - // and reconciled cleanly (nil or normal event), remove the finalizer. - reconcileEvent = do(ctx, resource) - - if resource, err = r.clearFinalizer(ctx, resource, reconcileEvent); err != nil { - return fmt.Errorf("failed to clear finalizers: %w", err) - } - - case reconciler.DoObserveKind: - // Observe any changes to this resource, since we are not the leader. - reconcileEvent = do(ctx, resource) - - } - - // Synchronize the status. - switch { - case r.skipStatusUpdates: - // This reconciler implementation is configured to skip resource updates. - // This may mean this reconciler does not observe spec, but reconciles external changes. - case equality.Semantic.DeepEqual(original.Status, resource.Status): - // If we didn't change anything then don't call updateStatus. - // This is important because the copy we loaded from the injectionInformer's - // cache may be stale and we don't want to overwrite a prior update - // to status with this stale state. - case !s.isLeader: - // High-availability reconcilers may have many replicas watching the resource, but only - // the elected leader is expected to write modifications. - logger.Warn("Saw status changes when we aren't the leader!") - default: - if err = r.updateStatus(ctx, logger, original, resource); err != nil { - logger.Warnw("Failed to update resource status", zap.Error(err)) - r.Recorder.Eventf(resource, v1.EventTypeWarning, "UpdateFailed", - "Failed to update status for %q: %v", resource.Name, err) - return err - } - } - - // Report the reconciler event, if any. - if reconcileEvent != nil { - var event *reconciler.ReconcilerEvent - if reconciler.EventAs(reconcileEvent, &event) { - logger.Infow("Returned an event", zap.Any("event", reconcileEvent)) - r.Recorder.Event(resource, event.EventType, event.Reason, event.Error()) - - // the event was wrapped inside an error, consider the reconciliation as failed - if _, isEvent := reconcileEvent.(*reconciler.ReconcilerEvent); !isEvent { - return reconcileEvent - } - return nil - } - - if controller.IsSkipKey(reconcileEvent) { - // This is a wrapped error, don't emit an event. - } else if ok, _ := controller.IsRequeueKey(reconcileEvent); ok { - // This is a wrapped error, don't emit an event. - } else { - logger.Errorw("Returned an error", zap.Error(reconcileEvent)) - r.Recorder.Event(resource, v1.EventTypeWarning, "InternalError", reconcileEvent.Error()) - } - return reconcileEvent - } - - return nil -} - -func (r *reconcilerImpl) updateStatus(ctx context.Context, logger *zap.SugaredLogger, existing *v1alpha1.Realm, desired *v1alpha1.Realm) error { - existing = existing.DeepCopy() - return reconciler.RetryUpdateConflicts(func(attempts int) (err error) { - // The first iteration tries to use the injectionInformer's state, subsequent attempts fetch the latest state via API. - if attempts > 0 { - - getter := r.Client.NetworkingV1alpha1().Realms() - - existing, err = getter.Get(ctx, desired.Name, metav1.GetOptions{}) - if err != nil { - return err - } - } - - // If there's nothing to update, just return. - if equality.Semantic.DeepEqual(existing.Status, desired.Status) { - return nil - } - - if logger.Desugar().Core().Enabled(zapcore.DebugLevel) { - if diff, err := kmp.SafeDiff(existing.Status, desired.Status); err == nil && diff != "" { - logger.Debug("Updating status with: ", diff) - } - } - - existing.Status = desired.Status - - updater := r.Client.NetworkingV1alpha1().Realms() - - _, err = updater.UpdateStatus(ctx, existing, metav1.UpdateOptions{}) - return err - }) -} - -// updateFinalizersFiltered will update the Finalizers of the resource. -// TODO: this method could be generic and sync all finalizers. For now it only -// updates defaultFinalizerName or its override. -func (r *reconcilerImpl) updateFinalizersFiltered(ctx context.Context, resource *v1alpha1.Realm, desiredFinalizers sets.Set[string]) (*v1alpha1.Realm, error) { - // Don't modify the informers copy. - existing := resource.DeepCopy() - - var finalizers []string - - // If there's nothing to update, just return. - existingFinalizers := sets.New[string](existing.Finalizers...) - - if desiredFinalizers.Has(r.finalizerName) { - if existingFinalizers.Has(r.finalizerName) { - // Nothing to do. - return resource, nil - } - // Add the finalizer. - finalizers = append(existing.Finalizers, r.finalizerName) - } else { - if !existingFinalizers.Has(r.finalizerName) { - // Nothing to do. - return resource, nil - } - // Remove the finalizer. - existingFinalizers.Delete(r.finalizerName) - finalizers = sets.List(existingFinalizers) - } - - mergePatch := map[string]interface{}{ - "metadata": map[string]interface{}{ - "finalizers": finalizers, - "resourceVersion": existing.ResourceVersion, - }, - } - - patch, err := json.Marshal(mergePatch) - if err != nil { - return resource, err - } - - patcher := r.Client.NetworkingV1alpha1().Realms() - - resourceName := resource.Name - updated, err := patcher.Patch(ctx, resourceName, types.MergePatchType, patch, metav1.PatchOptions{}) - if err != nil { - r.Recorder.Eventf(existing, v1.EventTypeWarning, "FinalizerUpdateFailed", - "Failed to update finalizers for %q: %v", resourceName, err) - } else { - r.Recorder.Eventf(updated, v1.EventTypeNormal, "FinalizerUpdate", - "Updated %q finalizers", resource.GetName()) - } - return updated, err -} - -func (r *reconcilerImpl) setFinalizerIfFinalizer(ctx context.Context, resource *v1alpha1.Realm) (*v1alpha1.Realm, error) { - if _, ok := r.reconciler.(Finalizer); !ok { - return resource, nil - } - - finalizers := sets.New[string](resource.Finalizers...) - - // If this resource is not being deleted, mark the finalizer. - if resource.GetDeletionTimestamp().IsZero() { - finalizers.Insert(r.finalizerName) - } - - // Synchronize the finalizers filtered by r.finalizerName. - return r.updateFinalizersFiltered(ctx, resource, finalizers) -} - -func (r *reconcilerImpl) clearFinalizer(ctx context.Context, resource *v1alpha1.Realm, reconcileEvent reconciler.Event) (*v1alpha1.Realm, error) { - if _, ok := r.reconciler.(Finalizer); !ok { - return resource, nil - } - if resource.GetDeletionTimestamp().IsZero() { - return resource, nil - } - - finalizers := sets.New[string](resource.Finalizers...) - - if reconcileEvent != nil { - var event *reconciler.ReconcilerEvent - if reconciler.EventAs(reconcileEvent, &event) { - if event.EventType == v1.EventTypeNormal { - finalizers.Delete(r.finalizerName) - } - } - } else { - finalizers.Delete(r.finalizerName) - } - - // Synchronize the finalizers filtered by r.finalizerName. - return r.updateFinalizersFiltered(ctx, resource, finalizers) -} diff --git a/pkg/client/injection/reconciler/networking/v1alpha1/realm/state.go b/pkg/client/injection/reconciler/networking/v1alpha1/realm/state.go deleted file mode 100644 index ebc569d7f..000000000 --- a/pkg/client/injection/reconciler/networking/v1alpha1/realm/state.go +++ /dev/null @@ -1,97 +0,0 @@ -/* -Copyright 2020 The Knative 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 injection-gen. DO NOT EDIT. - -package realm - -import ( - fmt "fmt" - - types "k8s.io/apimachinery/pkg/types" - cache "k8s.io/client-go/tools/cache" - v1alpha1 "knative.dev/networking/pkg/apis/networking/v1alpha1" - reconciler "knative.dev/pkg/reconciler" -) - -// state is used to track the state of a reconciler in a single run. -type state struct { - // key is the original reconciliation key from the queue. - key string - // namespace is the namespace split from the reconciliation key. - namespace string - // name is the name split from the reconciliation key. - name string - // reconciler is the reconciler. - reconciler Interface - // roi is the read only interface cast of the reconciler. - roi ReadOnlyInterface - // isROI (Read Only Interface) the reconciler only observes reconciliation. - isROI bool - // isLeader the instance of the reconciler is the elected leader. - isLeader bool -} - -func newState(key string, r *reconcilerImpl) (*state, error) { - // Convert the namespace/name string into a distinct namespace and name. - namespace, name, err := cache.SplitMetaNamespaceKey(key) - if err != nil { - return nil, fmt.Errorf("invalid resource key: %s", key) - } - - roi, isROI := r.reconciler.(ReadOnlyInterface) - - isLeader := r.IsLeaderFor(types.NamespacedName{ - Namespace: namespace, - Name: name, - }) - - return &state{ - key: key, - namespace: namespace, - name: name, - reconciler: r.reconciler, - roi: roi, - isROI: isROI, - isLeader: isLeader, - }, nil -} - -// isNotLeaderNorObserver checks to see if this reconciler with the current -// state is enabled to do any work or not. -// isNotLeaderNorObserver returns true when there is no work possible for the -// reconciler. -func (s *state) isNotLeaderNorObserver() bool { - if !s.isLeader && !s.isROI { - // If we are not the leader, and we don't implement the ReadOnly - // interface, then take a fast-path out. - return true - } - return false -} - -func (s *state) reconcileMethodFor(o *v1alpha1.Realm) (string, doReconcile) { - if o.GetDeletionTimestamp().IsZero() { - if s.isLeader { - return reconciler.DoReconcileKind, s.reconciler.ReconcileKind - } else if s.isROI { - return reconciler.DoObserveKind, s.roi.ObserveKind - } - } else if fin, ok := s.reconciler.(Finalizer); s.isLeader && ok { - return reconciler.DoFinalizeKind, fin.FinalizeKind - } - return "unknown", nil -} diff --git a/pkg/client/listers/networking/v1alpha1/domain.go b/pkg/client/listers/networking/v1alpha1/domain.go deleted file mode 100644 index 8a25beb0c..000000000 --- a/pkg/client/listers/networking/v1alpha1/domain.go +++ /dev/null @@ -1,68 +0,0 @@ -/* -Copyright 2020 The Knative 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 ( - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" - v1alpha1 "knative.dev/networking/pkg/apis/networking/v1alpha1" -) - -// DomainLister helps list Domains. -// All objects returned here must be treated as read-only. -type DomainLister interface { - // List lists all Domains in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.Domain, err error) - // Get retrieves the Domain from the index for a given name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1alpha1.Domain, error) - DomainListerExpansion -} - -// domainLister implements the DomainLister interface. -type domainLister struct { - indexer cache.Indexer -} - -// NewDomainLister returns a new DomainLister. -func NewDomainLister(indexer cache.Indexer) DomainLister { - return &domainLister{indexer: indexer} -} - -// List lists all Domains in the indexer. -func (s *domainLister) List(selector labels.Selector) (ret []*v1alpha1.Domain, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.Domain)) - }) - return ret, err -} - -// Get retrieves the Domain from the index for a given name. -func (s *domainLister) Get(name string) (*v1alpha1.Domain, error) { - obj, exists, err := s.indexer.GetByKey(name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("domain"), name) - } - return obj.(*v1alpha1.Domain), nil -} diff --git a/pkg/client/listers/networking/v1alpha1/expansion_generated.go b/pkg/client/listers/networking/v1alpha1/expansion_generated.go index 5faa077ad..739b7b43c 100644 --- a/pkg/client/listers/networking/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/networking/v1alpha1/expansion_generated.go @@ -30,10 +30,6 @@ type CertificateNamespaceListerExpansion interface{} // ClusterDomainClaimLister. type ClusterDomainClaimListerExpansion interface{} -// DomainListerExpansion allows custom methods to be added to -// DomainLister. -type DomainListerExpansion interface{} - // IngressListerExpansion allows custom methods to be added to // IngressLister. type IngressListerExpansion interface{} @@ -42,10 +38,6 @@ type IngressListerExpansion interface{} // IngressNamespaceLister. type IngressNamespaceListerExpansion interface{} -// RealmListerExpansion allows custom methods to be added to -// RealmLister. -type RealmListerExpansion interface{} - // ServerlessServiceListerExpansion allows custom methods to be added to // ServerlessServiceLister. type ServerlessServiceListerExpansion interface{} diff --git a/pkg/client/listers/networking/v1alpha1/realm.go b/pkg/client/listers/networking/v1alpha1/realm.go deleted file mode 100644 index 88da2c86d..000000000 --- a/pkg/client/listers/networking/v1alpha1/realm.go +++ /dev/null @@ -1,68 +0,0 @@ -/* -Copyright 2020 The Knative 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 ( - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" - v1alpha1 "knative.dev/networking/pkg/apis/networking/v1alpha1" -) - -// RealmLister helps list Realms. -// All objects returned here must be treated as read-only. -type RealmLister interface { - // List lists all Realms in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.Realm, err error) - // Get retrieves the Realm from the index for a given name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1alpha1.Realm, error) - RealmListerExpansion -} - -// realmLister implements the RealmLister interface. -type realmLister struct { - indexer cache.Indexer -} - -// NewRealmLister returns a new RealmLister. -func NewRealmLister(indexer cache.Indexer) RealmLister { - return &realmLister{indexer: indexer} -} - -// List lists all Realms in the indexer. -func (s *realmLister) List(selector labels.Selector) (ret []*v1alpha1.Realm, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.Realm)) - }) - return ret, err -} - -// Get retrieves the Realm from the index for a given name. -func (s *realmLister) Get(name string) (*v1alpha1.Realm, error) { - obj, exists, err := s.indexer.GetByKey(name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("realm"), name) - } - return obj.(*v1alpha1.Realm), nil -}