diff --git a/Gopkg.lock b/Gopkg.lock index a9a91dea7e0..672fb0528ec 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -268,10 +268,12 @@ revision = "5c1d8c8469d1ed34b2aecf4c2305b3a57fff2ee3" [[projects]] - digest = "1:0b9b785cb35b9e8141b03a673fd9baefc08b6c1c8290de3d44122289a240d55c" + digest = "1:321fbe5b0e77758eca3271807cb003d25b76d99b819f86e01956bb9accea2494" name = "github.com/knative/pkg" packages = [ "apis", + "apis/duck", + "apis/duck/v1alpha1", "apis/istio", "apis/istio/authentication", "apis/istio/authentication/v1alpha1", @@ -280,14 +282,18 @@ "client/clientset/versioned", "client/clientset/versioned/scheme", "client/clientset/versioned/typed/authentication/v1alpha1", + "client/clientset/versioned/typed/duck/v1alpha1", "client/clientset/versioned/typed/istio/v1alpha3", "client/informers/externalversions", "client/informers/externalversions/authentication", "client/informers/externalversions/authentication/v1alpha1", + "client/informers/externalversions/duck", + "client/informers/externalversions/duck/v1alpha1", "client/informers/externalversions/internalinterfaces", "client/informers/externalversions/istio", "client/informers/externalversions/istio/v1alpha3", "client/listers/authentication/v1alpha1", + "client/listers/duck/v1alpha1", "client/listers/istio/v1alpha3", "configmap", "logging", @@ -296,7 +302,7 @@ "webhook", ] pruneopts = "NUT" - revision = "8fc80deb200e7853795e6baf4029f406ca9534b8" + revision = "67830c7a64431edc38ee19628dc7116b0c6d99b5" [[projects]] digest = "1:63f3974f3afe3dc5b6a115c0d53b0897cd01be6880c4bf5d014fc69a95db6ed1" @@ -1037,6 +1043,7 @@ "github.com/google/go-github/github", "github.com/google/uuid", "github.com/knative/pkg/apis", + "github.com/knative/pkg/apis/duck/v1alpha1", "github.com/knative/pkg/apis/istio/v1alpha3", "github.com/knative/pkg/client/clientset/versioned", "github.com/knative/pkg/client/informers/externalversions", diff --git a/Gopkg.toml b/Gopkg.toml index 69717467774..e9e7dba1169 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -75,8 +75,8 @@ required = [ [[constraint]] name = "github.com/knative/pkg" - # HEAD as of 2018-09-12 - revision = "8fc80deb200e7853795e6baf4029f406ca9534b8" + # HEAD as of 2018-09-17 + revision = "67830c7a64431edc38ee19628dc7116b0c6d99b5" [[constraint]] name = "github.com/knative/serving" diff --git a/pkg/apis/eventing/v1alpha1/cluster_provisioner_types.go b/pkg/apis/eventing/v1alpha1/cluster_provisioner_types.go index c3fecdbb364..6a7af95d5d2 100644 --- a/pkg/apis/eventing/v1alpha1/cluster_provisioner_types.go +++ b/pkg/apis/eventing/v1alpha1/cluster_provisioner_types.go @@ -17,12 +17,12 @@ limitations under the License. package v1alpha1 import ( - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "encoding/json" "github.com/knative/pkg/apis" + duck "github.com/knative/pkg/apis/duck/v1alpha1" "github.com/knative/pkg/webhook" ) @@ -52,6 +52,9 @@ var _ apis.Defaultable = (*ClusterProvisioner)(nil) var _ runtime.Object = (*ClusterProvisioner)(nil) var _ webhook.GenericCRD = (*ClusterProvisioner)(nil) +// Check that ConfigurationStatus may have its conditions managed. +var _ duck.ConditionsAccessor = (*ClusterProvisionerStatus)(nil) + // ClusterProvisionerSpec is the spec for a ClusterProvisioner resource. type ClusterProvisionerSpec struct { // TODO: Generation does not work correctly with CRD. They are scrubbed @@ -67,42 +70,12 @@ type ClusterProvisionerSpec struct { Reconciles metav1.GroupKind `json:"reconciles"` } -type ClusterProvisionerConditionType string - -const ( - // ClusterProvisionerConditionReady specifies that the resource is ready. - ClusterProvisionerConditionReady ClusterProvisionerConditionType = "Ready" -) - -// ClusterProvisionerConditionStatus describes the state of this resource at a point in time. -type ClusterProvisionerConditionStatus struct { - // Type of condition. - // +required - Type ClusterProvisionerConditionType `json:"type"` - - // Status of the condition, one of True, False, Unknown. - // +required - Status corev1.ConditionStatus `json:"status"` - - // 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). - // +optional - LastTransitionTime apis.VolatileTime `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another"` - - // The reason for the condition's last transition. - // +optional - Reason string `json:"reason,omitempty"` - - // A human readable message indicating details about the transition. - // +optional - Message string `json:"message,omitempty"` -} +var cProvCondSet = duck.NewLivingConditionSet() // ClusterProvisionerStatus is the status for a ClusterProvisioner resource type ClusterProvisionerStatus struct { // Conditions holds the state of a cluster provisioner at a point in time. - Conditions []ClusterProvisionerConditionStatus `json:"conditions,omitempty"` + Conditions duck.Conditions `json:"conditions,omitempty"` // ObservedGeneration is the 'Generation' of the ClusterProvisioner that // was last reconciled by the controller. @@ -124,3 +97,15 @@ type ClusterProvisionerList struct { Items []ClusterProvisioner `json:"items"` } + +// GetConditions returns the Conditions array. This enables generic handling of +// conditions by implementing the duck.Conditions interface. +func (ps *ClusterProvisionerStatus) GetConditions() duck.Conditions { + return ps.Conditions +} + +// SetConditions sets the Conditions array. This enables generic handling of +// conditions by implementing the duck.Conditions interface. +func (ps *ClusterProvisionerStatus) SetConditions(conditions duck.Conditions) { + ps.Conditions = conditions +} diff --git a/pkg/apis/eventing/v1alpha1/subscription_types.go b/pkg/apis/eventing/v1alpha1/subscription_types.go index 28067323807..30ec0b03354 100644 --- a/pkg/apis/eventing/v1alpha1/subscription_types.go +++ b/pkg/apis/eventing/v1alpha1/subscription_types.go @@ -20,8 +20,8 @@ import ( "encoding/json" "github.com/knative/pkg/apis" + duck "github.com/knative/pkg/apis/duck/v1alpha1" "github.com/knative/pkg/webhook" - "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -48,6 +48,9 @@ var _ apis.Immutable = (*Subscription)(nil) var _ runtime.Object = (*Subscription)(nil) var _ webhook.GenericCRD = (*Subscription)(nil) +// Check that ConfigurationStatus may have its conditions managed. +var _ duck.ConditionsAccessor = (*SubscriptionStatus)(nil) + // SubscriptionSpec specifies the Channel for incoming events, a Call target for // processing those events and where to put the result of the processing. Only // From (where the events are coming from) is always required. You can optionally @@ -160,40 +163,18 @@ type ResultStrategy struct { Target *corev1.ObjectReference `json:"target,omitempty"` } -type SubscriptionConditionType string - -const ( - // SubscriptionReady is when the From,Call and Result have been reconciled successfully. - SubscriptionReady SubscriptionConditionType = "Ready" -) - -// SubscriptionCondition describes the state of a subscription at a point in time. -type SubscriptionCondition struct { - // Type of subscription condition. - Type SubscriptionConditionType `json:"type"` - // Status of the condition, one of True, False, Unknown. - Status v1.ConditionStatus `json:"status"` - // The reason for the condition's last transition. - Reason string `json:"reason,omitempty"` - // A human readable message indicating details about the transition. - Message string `json:"message,omitempty"` -} +var subCondSet = duck.NewLivingConditionSet() // SubscriptionStatus (computed) for a subscription type SubscriptionStatus struct { // Represents the latest available observations of a subscription's current state. // +patchMergeKey=type // +patchStrategy=merge - Conditions []SubscriptionCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` + Conditions duck.Conditions `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` } -func (ss *SubscriptionStatus) GetCondition(t SubscriptionConditionType) *SubscriptionCondition { - for _, cond := range ss.Conditions { - if cond.Type == t { - return &cond - } - } - return nil +func (ss *SubscriptionStatus) GetCondition(t duck.ConditionType) *duck.Condition { + return subCondSet.Manage(ss).GetCondition(t) } func (s *Subscription) GetSpecJSON() ([]byte, error) { @@ -208,3 +189,15 @@ type SubscriptionList struct { metav1.ListMeta `json:"metadata"` Items []Subscription `json:"items"` } + +// GetConditions returns the Conditions array. This enables generic handling of +// conditions by implementing the duck.Conditions interface. +func (ss *SubscriptionStatus) GetConditions() duck.Conditions { + return ss.Conditions +} + +// SetConditions sets the Conditions array. This enables generic handling of +// conditions by implementing the duck.Conditions interface. +func (ss *SubscriptionStatus) SetConditions(conditions duck.Conditions) { + ss.Conditions = conditions +} diff --git a/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go index d9512313469..cd93dc8c5c4 100644 --- a/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go @@ -21,6 +21,7 @@ limitations under the License. package v1alpha1 import ( + duck_v1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -87,23 +88,6 @@ func (in *ClusterProvisioner) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ClusterProvisionerConditionStatus) DeepCopyInto(out *ClusterProvisionerConditionStatus) { - *out = *in - in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterProvisionerConditionStatus. -func (in *ClusterProvisionerConditionStatus) DeepCopy() *ClusterProvisionerConditionStatus { - if in == nil { - return nil - } - out := new(ClusterProvisionerConditionStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterProvisionerList) DeepCopyInto(out *ClusterProvisionerList) { *out = *in @@ -159,7 +143,7 @@ func (in *ClusterProvisionerStatus) DeepCopyInto(out *ClusterProvisionerStatus) *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]ClusterProvisionerConditionStatus, len(*in)) + *out = make(duck_v1alpha1.Conditions, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -230,22 +214,6 @@ func (in *Subscription) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SubscriptionCondition) DeepCopyInto(out *SubscriptionCondition) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionCondition. -func (in *SubscriptionCondition) DeepCopy() *SubscriptionCondition { - if in == nil { - return nil - } - out := new(SubscriptionCondition) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SubscriptionList) DeepCopyInto(out *SubscriptionList) { *out = *in @@ -319,8 +287,10 @@ func (in *SubscriptionStatus) DeepCopyInto(out *SubscriptionStatus) { *out = *in if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions - *out = make([]SubscriptionCondition, len(*in)) - copy(*out, *in) + *out = make(duck_v1alpha1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } return } diff --git a/vendor/github.com/knative/pkg/apis/duck/doc.go b/vendor/github.com/knative/pkg/apis/duck/doc.go new file mode 100644 index 00000000000..e21fe6ddf3d --- /dev/null +++ b/vendor/github.com/knative/pkg/apis/duck/doc.go @@ -0,0 +1,23 @@ +/* +Copyright 2018 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. +*/ + +// Package duck defines logic for defining and consuming "duck typed" +// Kubernetes resources. Producers define partial resource definitions +// that resource authors may choose to implement to interoperate with +// consumers of these "duck typed" interfaces. +// For more information see: +// TODO(mattmoor): Add link to doc. +package duck diff --git a/vendor/github.com/knative/pkg/apis/duck/register.go b/vendor/github.com/knative/pkg/apis/duck/register.go new file mode 100644 index 00000000000..d10adc21ce7 --- /dev/null +++ b/vendor/github.com/knative/pkg/apis/duck/register.go @@ -0,0 +1,21 @@ +/* +Copyright 2018 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. +*/ + +package duck + +const ( + GroupName = "duck.knative.dev" +) diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/condition_set.go b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/condition_set.go new file mode 100644 index 00000000000..510f2dfc33f --- /dev/null +++ b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/condition_set.go @@ -0,0 +1,280 @@ +/* +Copyright 2018 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. +*/ + +package v1alpha1 + +import ( + "reflect" + "sort" + "time" + + "fmt" + + "github.com/knative/pkg/apis" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// Conditions is the interface for a Resource that implements the getter and +// setter for accessing a Condition collection. +// +k8s:deepcopy-gen=true +type ConditionsAccessor interface { + GetConditions() Conditions + SetConditions(Conditions) +} + +// ConditionSet is an abstract collection of the possible ConditionType values +// that a particular resource might expose. It also holds the "happy condition" +// for that resource, which we define to be one of Ready or Succeeded depending +// on whether it is a Living or Batch process respectively. +// +k8s:deepcopy-gen=false +type ConditionSet struct { + happy ConditionType + dependents []ConditionType +} + +// ConditionManager allows a resource to operate on its Conditions using higher +// order operations. +type ConditionManager interface { + // IsHappy looks at the happy condition and returns true if that condition is + // set to true. + IsHappy() bool + + // GetCondition finds and returns the Condition that matches the ConditionType + // previously set on Conditions. + GetCondition(t ConditionType) *Condition + + // SetCondition sets or updates the Condition on Conditions for Condition.Type. + // If there is an update, Conditions are stored back sorted. + SetCondition(new Condition) + + // MarkTrue sets the status of t to true, and then marks the happy condition to + // true if all other dependents are also true. + MarkTrue(t ConditionType) + + // MarkUnknown sets the status of t to Unknown and also sets the happy condition + // to Unknown if no other dependent condition is in an error state. + MarkUnknown(t ConditionType, reason, messageFormat string, messageA ...interface{}) + + // MarkFalse sets the status of t and the happy condition to False. + MarkFalse(t ConditionType, reason, messageFormat string, messageA ...interface{}) + + // InitializeConditions updates all Conditions in the ConditionSet to Unknown + // if not set. + InitializeConditions() + + // InitializeCondition updates a Condition to Unknown if not set. + InitializeCondition(t ConditionType) +} + +// NewLivingConditionSet returns a ConditionSet to hold the conditions for the +// living resource. ConditionReady is used as the happy condition. +func NewLivingConditionSet(d ...ConditionType) ConditionSet { + return newConditionSet(ConditionReady, d...) +} + +// NewBatchConditionSet returns a ConditionSet to hold the conditions for the +// batch resource. ConditionSucceeded is used as the happy condition. +func NewBatchConditionSet(d ...ConditionType) ConditionSet { + return newConditionSet(ConditionSucceeded, d...) +} + +// newConditionSet returns a ConditionSet to hold the conditions that are +// important for the caller. The first ConditionType is the overarching status +// for that will be used to signal the resources' status is Ready or Succeeded. +func newConditionSet(happy ConditionType, dependents ...ConditionType) ConditionSet { + var deps []ConditionType + for _, d := range dependents { + // Skip duplicates + if d == happy || contains(deps, d) { + continue + } + deps = append(deps, d) + } + return ConditionSet{ + happy: happy, + dependents: deps, + } +} + +func contains(ct []ConditionType, t ConditionType) bool { + for _, c := range ct { + if c == t { + return true + } + } + return false +} + +// Check that conditionsImpl implements ConditionManager. +var _ ConditionManager = (*conditionsImpl)(nil) + +// conditionsImpl implements the helper methods for evaluating Conditions. +// +k8s:deepcopy-gen=false +type conditionsImpl struct { + ConditionSet + accessor ConditionsAccessor +} + +// Manage creates a ConditionManager from an object that implements +// ConditionsAccessopr using the original ConditionSet as a reference. +func (r ConditionSet) Manage(accessor ConditionsAccessor) ConditionManager { + return conditionsImpl{ + accessor: accessor, + ConditionSet: r, + } +} + +// IsHappy looks at the happy condition and returns true if that condition is +// set to true. +func (r conditionsImpl) IsHappy() bool { + if c := r.GetCondition(r.happy); c == nil || !c.IsTrue() { + return false + } + return true +} + +// GetCondition finds and returns the Condition that matches the ConditionType +// previously set on Conditions. +func (r conditionsImpl) GetCondition(t ConditionType) *Condition { + if r.accessor == nil { + return nil + } + for _, c := range r.accessor.GetConditions() { + if c.Type == t { + return &c + } + } + return nil +} + +// SetCondition sets or updates the Condition on Conditions for Condition.Type. +// If there is an update, Conditions are stored back sorted. +func (r conditionsImpl) SetCondition(new Condition) { + if r.accessor == nil { + return + } + t := new.Type + var conditions Conditions + for _, c := range r.accessor.GetConditions() { + if c.Type != t { + conditions = append(conditions, c) + } else { + // If we'd only update the LastTransitionTime, then return. + new.LastTransitionTime = c.LastTransitionTime + if reflect.DeepEqual(&new, &c) { + return + } + } + } + new.LastTransitionTime = apis.VolatileTime{Inner: metav1.NewTime(time.Now())} + conditions = append(conditions, new) + // Sorted for convince of the consumer, i.e.: kubectl. + sort.Slice(conditions, func(i, j int) bool { return conditions[i].Type < conditions[j].Type }) + r.accessor.SetConditions(conditions) +} + +// MarkTrue sets the status of t to true, and then marks the happy condition to +// true if all other dependents are also true. +func (r conditionsImpl) MarkTrue(t ConditionType) { + // set the specified condition + r.SetCondition(Condition{ + Type: t, + Status: corev1.ConditionTrue, + }) + + // check the dependents. + for _, cond := range r.dependents { + c := r.GetCondition(cond) + // Failed or Unknown conditions trump true conditions + if !c.IsTrue() { + return + } + } + + // set the happy condition + r.SetCondition(Condition{ + Type: r.happy, + Status: corev1.ConditionTrue, + }) +} + +// MarkUnknown sets the status of t to Unknown and also sets the happy condition +// to Unknown if no other dependent condition is in an error state. +func (r conditionsImpl) MarkUnknown(t ConditionType, reason, messageFormat string, messageA ...interface{}) { + // set the specified condition + r.SetCondition(Condition{ + Type: t, + Status: corev1.ConditionUnknown, + Reason: reason, + Message: fmt.Sprintf(messageFormat, messageA...), + }) + + // check the dependents. + for _, cond := range r.dependents { + c := r.GetCondition(cond) + // Failed conditions trump Unknown conditions + if c.IsFalse() { + // Double check that the happy condition is also false. + happy := r.GetCondition(r.happy) + if !happy.IsFalse() { + r.MarkFalse(r.happy, reason, messageFormat, messageA) + } + return + } + } + + // set the happy condition + r.SetCondition(Condition{ + Type: r.happy, + Status: corev1.ConditionUnknown, + Reason: reason, + Message: fmt.Sprintf(messageFormat, messageA...), + }) +} + +// MarkFalse sets the status of t and the happy condition to False. +func (r conditionsImpl) MarkFalse(t ConditionType, reason, messageFormat string, messageA ...interface{}) { + for _, t := range []ConditionType{ + t, + r.happy, + } { + r.SetCondition(Condition{ + Type: t, + Status: corev1.ConditionFalse, + Reason: reason, + Message: fmt.Sprintf(messageFormat, messageA...), + }) + } +} + +// InitializeConditions updates all Conditions in the ConditionSet to Unknown +// if not set. +func (r conditionsImpl) InitializeConditions() { + for _, t := range append(r.dependents, r.happy) { + r.InitializeCondition(t) + } +} + +// InitializeCondition updates a Condition to Unknown if not set. +func (r conditionsImpl) InitializeCondition(t ConditionType) { + if c := r.GetCondition(t); c == nil { + r.SetCondition(Condition{ + Type: t, + Status: corev1.ConditionUnknown, + }) + } +} diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/conditions_types.go b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/conditions_types.go new file mode 100644 index 00000000000..bde5adf7172 --- /dev/null +++ b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/conditions_types.go @@ -0,0 +1,149 @@ +/* +Copyright 2018 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. +*/ + +package v1alpha1 + +import ( + "time" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/knative/pkg/apis" + "github.com/knative/pkg/apis/duck" +) + +// Conditions is the schema for the conditions portion of the payload +type Conditions []Condition + +// ConditionType is a camel-cased condition type. +type ConditionType string + +const ( + // ConditionReady specifies that the resource is ready. + // For long-running resources. + ConditionReady ConditionType = "Ready" + // ConditionSucceeded specifies that the resource has finished. + // For resource which run to completion. + ConditionSucceeded ConditionType = "Succeeded" +) + +// Conditions defines a readiness condition for a Knative resource. +// See: https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#typical-status-properties +// +k8s:deepcopy-gen=true +type Condition struct { + // Type of condition. + // +required + Type ConditionType `json:"type" description:"type of status condition"` + + // Status of the condition, one of True, False, Unknown. + // +required + Status corev1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"` + + // 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). + // +optional + LastTransitionTime apis.VolatileTime `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another"` + + // The reason for the condition's last transition. + // +optional + Reason string `json:"reason,omitempty" description:"one-word CamelCase reason for the condition's last transition"` + + // A human readable message indicating details about the transition. + // +optional + Message string `json:"message,omitempty" description:"human-readable message indicating details about last transition"` +} + +// IsTrue is true if the condition is True +func (c *Condition) IsTrue() bool { + if c == nil { + return false + } + return c.Status == corev1.ConditionTrue +} + +// IsFalse is true if the condition is False +func (c *Condition) IsFalse() bool { + if c == nil { + return false + } + return c.Status == corev1.ConditionFalse +} + +// IsUnknown is true if the condition is Unknown +func (c *Condition) IsUnknown() bool { + if c == nil { + return true + } + return c.Status == corev1.ConditionUnknown +} + +// Implementations can verify that they implement Conditions via: +var _ = duck.VerifyType(&KResource{}, &Conditions{}) + +// Conditions is an Implementable "duck type". +var _ duck.Implementable = (*Conditions)(nil) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// KResource is a skeleton type wrapping Conditions in the manner we expect +// resource writers defining compatible resources to embed it. We will +// typically use this type to deserialize Conditions ObjectReferences and +// access the Conditions data. This is not a real resource. +type KResource struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Status KResourceStatus `json:"status"` +} + +// KResourceStatus shows how we expect folks to embed Conditions in +// their Status field. +type KResourceStatus struct { + Conditions Conditions `json:"conditions,omitempty"` +} + +// In order for Conditions to be Implementable, KResource must be Populatable. +var _ duck.Populatable = (*KResource)(nil) + +// GetFullType implements duck.Implementable +func (_ *Conditions) GetFullType() duck.Populatable { + return &KResource{} +} + +// Populate implements duck.Populatable +func (t *KResource) Populate() { + t.Status.Conditions = Conditions{{ + // Populate ALL fields + Type: "Birthday", + Status: corev1.ConditionTrue, + LastTransitionTime: apis.VolatileTime{Inner: metav1.NewTime(time.Date(1984, 02, 28, 18, 52, 00, 00, time.UTC))}, + Reason: "Celebrate", + Message: "n3wScott, find your party hat :tada:", + }} +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// KResourceList is a list of KResource resources +type KResourceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []KResource `json:"items"` +} diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/doc.go b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/doc.go new file mode 100644 index 00000000000..3638eb7a308 --- /dev/null +++ b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/doc.go @@ -0,0 +1,23 @@ +/* +Copyright 2018 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. +*/ + +// Api versions allow the api contract for a resource to be changed while keeping +// backward compatibility by support multiple concurrent versions +// of the same resource + +// +k8s:deepcopy-gen=package +// +groupName=duck.knative.dev +package v1alpha1 diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/register.go b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/register.go new file mode 100644 index 00000000000..f197cb560e4 --- /dev/null +++ b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/register.go @@ -0,0 +1,53 @@ +/* +Copyright 2018 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. +*/ + +package v1alpha1 + +import ( + "github.com/knative/pkg/apis/duck" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: duck.GroupName, Version: "v1alpha1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes( + SchemeGroupVersion, + // &VirtualService{}, + // &VirtualServiceList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/subscribable_types.go b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/subscribable_types.go new file mode 100644 index 00000000000..3f295344c81 --- /dev/null +++ b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/subscribable_types.go @@ -0,0 +1,81 @@ +/* +Copyright 2018 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. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/knative/pkg/apis/duck" +) + +// Subscribable is the schema for the subscribable portion of the payload +type Subscribable struct { + // TODO(vaikas): Give me a schema! + Field string `json:"field,omitempty"` +} + +// Implementations can verify that they implement Subscribable via: +var _ = duck.VerifyType(&Topic{}, &Subscribable{}) + +// Subscribable is an Implementable "duck type". +var _ duck.Implementable = (*Subscribable)(nil) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Topic is a skeleton type wrapping Subscribable in the manner we expect +// resource writers defining compatible resources to embed it. We will +// typically use this type to deserialize Subscribable ObjectReferences and +// access the Subscribable data. This is not a real resource. +type Topic struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Status TopicStatus `json:"status"` +} + +// TopicStatus shows how we expect folks to embed Subscribable in +// their Status field. +type TopicStatus struct { + Subscribable *Subscribable `json:"subscribable,omitempty"` +} + +// In order for Subscribable to be Implementable, Topic must be Populatable. +var _ duck.Populatable = (*Topic)(nil) + +// GetFullType implements duck.Implementable +func (_ *Subscribable) GetFullType() duck.Populatable { + return &Topic{} +} + +// Populate implements duck.Populatable +func (t *Topic) Populate() { + t.Status.Subscribable = &Subscribable{ + // Populate ALL fields + Field: "this is not empty", + } +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TopicList is a list of Topic resources +type TopicList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Topic `json:"items"` +} diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/targettable_types.go b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/targettable_types.go new file mode 100644 index 00000000000..372d6a00ad2 --- /dev/null +++ b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/targettable_types.go @@ -0,0 +1,81 @@ +/* +Copyright 2018 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. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/knative/pkg/apis/duck" +) + +// Targettable is the schema for the targettable portion of the payload +type Targettable struct { + // TODO(vaikas): Give me a schema! + Field string `json:"field,omitempty"` +} + +// Implementations can verify that they implement Targettable via: +var _ = duck.VerifyType(&Target{}, &Targettable{}) + +// Targettable is an Implementable "duck type". +var _ duck.Implementable = (*Targettable)(nil) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Target is a skeleton type wrapping Targettable in the manner we expect +// resource writers defining compatible resources to embed it. We will +// typically use this type to deserialize Targettable ObjectReferences and +// access the Targettable data. This is not a real resource. +type Target struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Status TargetStatus `json:"status"` +} + +// TargetStatus shows how we expect folks to embed Targettable in +// their Status field. +type TargetStatus struct { + Targettable *Targettable `json:"targettable,omitempty"` +} + +// In order for Targettable to be Implementable, Target must be Populatable. +var _ duck.Populatable = (*Target)(nil) + +// GetFullType implements duck.Implementable +func (_ *Targettable) GetFullType() duck.Populatable { + return &Target{} +} + +// Populate implements duck.Populatable +func (t *Target) Populate() { + t.Status.Targettable = &Targettable{ + // Populate ALL fields + Field: "this is not empty", + } +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// TargetList is a list of Target resources +type TargetList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Target `json:"items"` +} diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..31041a02f17 --- /dev/null +++ b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,341 @@ +// +build !ignore_autogenerated + +/* +Copyright 2018 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 deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Condition) DeepCopyInto(out *Condition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Condition. +func (in *Condition) DeepCopy() *Condition { + if in == nil { + return nil + } + out := new(Condition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in Conditions) DeepCopyInto(out *Conditions) { + { + in := &in + *out = make(Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Conditions. +func (in Conditions) DeepCopy() Conditions { + if in == nil { + return nil + } + out := new(Conditions) + in.DeepCopyInto(out) + return *out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KResource) DeepCopyInto(out *KResource) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KResource. +func (in *KResource) DeepCopy() *KResource { + if in == nil { + return nil + } + out := new(KResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KResource) 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 *KResourceList) DeepCopyInto(out *KResourceList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]KResource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KResourceList. +func (in *KResourceList) DeepCopy() *KResourceList { + if in == nil { + return nil + } + out := new(KResourceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *KResourceList) 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 *KResourceStatus) DeepCopyInto(out *KResourceStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KResourceStatus. +func (in *KResourceStatus) DeepCopy() *KResourceStatus { + if in == nil { + return nil + } + out := new(KResourceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Subscribable) DeepCopyInto(out *Subscribable) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Subscribable. +func (in *Subscribable) DeepCopy() *Subscribable { + if in == nil { + return nil + } + out := new(Subscribable) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Target) DeepCopyInto(out *Target) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Target. +func (in *Target) DeepCopy() *Target { + if in == nil { + return nil + } + out := new(Target) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Target) 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 *TargetList) DeepCopyInto(out *TargetList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Target, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetList. +func (in *TargetList) DeepCopy() *TargetList { + if in == nil { + return nil + } + out := new(TargetList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TargetList) 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 *TargetStatus) DeepCopyInto(out *TargetStatus) { + *out = *in + if in.Targettable != nil { + in, out := &in.Targettable, &out.Targettable + *out = new(Targettable) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetStatus. +func (in *TargetStatus) DeepCopy() *TargetStatus { + if in == nil { + return nil + } + out := new(TargetStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Targettable) DeepCopyInto(out *Targettable) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Targettable. +func (in *Targettable) DeepCopy() *Targettable { + if in == nil { + return nil + } + out := new(Targettable) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Topic) DeepCopyInto(out *Topic) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Topic. +func (in *Topic) DeepCopy() *Topic { + if in == nil { + return nil + } + out := new(Topic) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Topic) 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 *TopicList) DeepCopyInto(out *TopicList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Topic, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TopicList. +func (in *TopicList) DeepCopy() *TopicList { + if in == nil { + return nil + } + out := new(TopicList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TopicList) 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 *TopicStatus) DeepCopyInto(out *TopicStatus) { + *out = *in + if in.Subscribable != nil { + in, out := &in.Subscribable, &out.Subscribable + *out = new(Subscribable) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TopicStatus. +func (in *TopicStatus) DeepCopy() *TopicStatus { + if in == nil { + return nil + } + out := new(TopicStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/knative/pkg/apis/duck/verify.go b/vendor/github.com/knative/pkg/apis/duck/verify.go new file mode 100644 index 00000000000..2be7976b2cc --- /dev/null +++ b/vendor/github.com/knative/pkg/apis/duck/verify.go @@ -0,0 +1,86 @@ +/* +Copyright 2018 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. +*/ + +package duck + +import ( + "encoding/json" + "fmt" + + "github.com/google/go-cmp/cmp" +) + +// Implementable in implemented by the Fooable duck type that consumers +// are expected to embed as a `.status.fooable` field. +type Implementable interface { + // GetFullType returns an instance of a full resource wrapping + // an instance of this Implementable that can populate its fields + // to verify json roundtripping. + GetFullType() Populatable +} + +// Populatable is implemented by a skeleton resource wrapping an Implementable +// duck type. It will generally have TypeMeta, ObjectMeta, and a Status field +// wrapping a Fooable field. +type Populatable interface { + // Populate fills in all possible fields, so that we can verify that + // they roundtrip properly through JSON. + Populate() +} + +// VerifyType verifies that a particular concrete resource properly implements +// the provided Implementable duck type. It is expected that under the resource +// definition implementing a particular "Fooable" that one would write: +// +// type ConcreteResource struct { ... } +// +// // Check that ConcreteResource properly implement Fooable. +// var _ = duck.VerifyType(&ConcreteResource{}, &something.Fooable{}) +// +// This will panic on startup if the duck typing is not satisfied. The return +// value is purely cosmetic to enable the `var _ = ...` shorthand. +func VerifyType(instance interface{}, iface Implementable) (nothing interface{}) { + // Create instances of the full resource for our input and ultimate result + // that we will compare at the end. + input, output := iface.GetFullType(), iface.GetFullType() + + // Populate our input resource with values we will roundtrip. + input.Populate() + + // Serialize the input to JSON and deserialize that into the provided instance + // of the type that we are checking. + if before, err := json.Marshal(input); err != nil { + panic(fmt.Sprintf("Error serializing duck type %T", input)) + } else if err := json.Unmarshal(before, instance); err != nil { + panic(fmt.Sprintf("Error deserializing duck type %T into %T", input, instance)) + } + + // Serialize the instance we are checking to JSON and deserialize that into the + // output resource. + if after, err := json.Marshal(instance); err != nil { + panic(fmt.Sprintf("Error serializing %T", instance)) + } else if err := json.Unmarshal(after, output); err != nil { + panic(fmt.Sprintf("Error deserializing %T into dock type %T", instance, output)) + } + + // Now verify that we were able to roundtrip all of our fields through the type + // we are checking. + if diff := cmp.Diff(input, output); diff != "" { + panic(fmt.Sprintf("%T does not implement the duck type %T, the following fields were lost: %s", + instance, iface, diff)) + } + return +} diff --git a/vendor/github.com/knative/pkg/apis/field_error.go b/vendor/github.com/knative/pkg/apis/field_error.go index 50a9a25127d..45b3e6bf5cd 100644 --- a/vendor/github.com/knative/pkg/apis/field_error.go +++ b/vendor/github.com/knative/pkg/apis/field_error.go @@ -52,17 +52,76 @@ func (fe *FieldError) ViaField(prefix ...string) *FieldError { } var newPaths []string for _, oldPath := range fe.Paths { - if oldPath == CurrentField { - newPaths = append(newPaths, strings.Join(prefix, ".")) - } else { - newPaths = append(newPaths, - strings.Join(append(prefix, oldPath), ".")) - } + newPaths = append(newPaths, flatten(append(prefix, oldPath))) } fe.Paths = newPaths return fe } +// ViaIndex is used to attach an index to the next ViaField provided. +// For example, if a type recursively validates a parameter that has a collection: +// for i, c := range spec.Collection { +// if err := doValidation(c); err != nil { +// return err.ViaIndex(i).ViaField("collection") +// } +// } +func (fe *FieldError) ViaIndex(index int) *FieldError { + if fe == nil { + return nil + } + return fe.ViaField(fmt.Sprintf("[%d]", index)) +} + +// ViaFieldIndex is the short way to chain: err.ViaIndex(bar).ViaField(foo) +func (fe *FieldError) ViaFieldIndex(field string, index int) *FieldError { + return fe.ViaIndex(index).ViaField(field) +} + +// ViaKey is used to attach a key to the next ViaField provided. +// For example, if a type recursively validates a parameter that has a collection: +// for k, v := range spec.Bag. { +// if err := doValidation(v); err != nil { +// return err.ViaKey(k).ViaField("bag") +// } +// } +func (fe *FieldError) ViaKey(key string) *FieldError { + if fe == nil { + return nil + } + return fe.ViaField(fmt.Sprintf("[%s]", key)) +} + +// ViaFieldKey is the short way to chain: err.ViaKey(bar).ViaField(foo) +func (fe *FieldError) ViaFieldKey(field string, key string) *FieldError { + return fe.ViaKey(key).ViaField(field) +} + +// flatten takes in a array of path components and looks for chances to flatten +// objects that have index prefixes, examples: +// err([0]).ViaField(bar).ViaField(foo) -> foo.bar.[0] converts to foo.bar[0] +// err(bar).ViaIndex(0).ViaField(foo) -> foo.[0].bar converts to foo[0].bar +// err(bar).ViaField(foo).ViaIndex(0) -> [0].foo.bar converts to [0].foo.bar +// err(bar).ViaIndex(0).ViaIndex[1].ViaField(foo) -> foo.[1].[0].bar converts to foo[1][0].bar +func flatten(path []string) string { + var newPath []string + for _, part := range path { + for _, p := range strings.Split(part, ".") { + if p == CurrentField { + continue + } else if len(newPath) > 0 && isIndex(p) { + newPath[len(newPath)-1] = fmt.Sprintf("%s%s", newPath[len(newPath)-1], p) + } else { + newPath = append(newPath, p) + } + } + } + return strings.Join(newPath, ".") +} + +func isIndex(part string) bool { + return strings.HasPrefix(part, "[") && strings.HasSuffix(part, "]") +} + // Error implements error func (fe *FieldError) Error() string { if fe.Details == "" { diff --git a/vendor/github.com/knative/pkg/client/clientset/versioned/clientset.go b/vendor/github.com/knative/pkg/client/clientset/versioned/clientset.go index ba98730a052..b3c0b18fbae 100644 --- a/vendor/github.com/knative/pkg/client/clientset/versioned/clientset.go +++ b/vendor/github.com/knative/pkg/client/clientset/versioned/clientset.go @@ -20,6 +20,10 @@ package versioned import ( authenticationv1alpha1 "github.com/knative/pkg/client/clientset/versioned/typed/authentication/v1alpha1" +<<<<<<< HEAD +======= + duckv1alpha1 "github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1" +>>>>>>> Upgrading knative.eventing resoureces to use knative.pkg.Conditions networkingv1alpha3 "github.com/knative/pkg/client/clientset/versioned/typed/istio/v1alpha3" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" @@ -31,6 +35,12 @@ type Interface interface { AuthenticationV1alpha1() authenticationv1alpha1.AuthenticationV1alpha1Interface // Deprecated: please explicitly pick a version if possible. Authentication() authenticationv1alpha1.AuthenticationV1alpha1Interface +<<<<<<< HEAD +======= + DuckV1alpha1() duckv1alpha1.DuckV1alpha1Interface + // Deprecated: please explicitly pick a version if possible. + Duck() duckv1alpha1.DuckV1alpha1Interface +>>>>>>> Upgrading knative.eventing resoureces to use knative.pkg.Conditions NetworkingV1alpha3() networkingv1alpha3.NetworkingV1alpha3Interface // Deprecated: please explicitly pick a version if possible. Networking() networkingv1alpha3.NetworkingV1alpha3Interface @@ -41,6 +51,10 @@ type Interface interface { type Clientset struct { *discovery.DiscoveryClient authenticationV1alpha1 *authenticationv1alpha1.AuthenticationV1alpha1Client +<<<<<<< HEAD +======= + duckV1alpha1 *duckv1alpha1.DuckV1alpha1Client +>>>>>>> Upgrading knative.eventing resoureces to use knative.pkg.Conditions networkingV1alpha3 *networkingv1alpha3.NetworkingV1alpha3Client } @@ -53,6 +67,20 @@ func (c *Clientset) AuthenticationV1alpha1() authenticationv1alpha1.Authenticati // Please explicitly pick a version. func (c *Clientset) Authentication() authenticationv1alpha1.AuthenticationV1alpha1Interface { return c.authenticationV1alpha1 +<<<<<<< HEAD +======= +} + +// DuckV1alpha1 retrieves the DuckV1alpha1Client +func (c *Clientset) DuckV1alpha1() duckv1alpha1.DuckV1alpha1Interface { + return c.duckV1alpha1 +} + +// Deprecated: Duck retrieves the default version of DuckClient. +// Please explicitly pick a version. +func (c *Clientset) Duck() duckv1alpha1.DuckV1alpha1Interface { + return c.duckV1alpha1 +>>>>>>> Upgrading knative.eventing resoureces to use knative.pkg.Conditions } // NetworkingV1alpha3 retrieves the NetworkingV1alpha3Client @@ -86,6 +114,13 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } +<<<<<<< HEAD +======= + cs.duckV1alpha1, err = duckv1alpha1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } +>>>>>>> Upgrading knative.eventing resoureces to use knative.pkg.Conditions cs.networkingV1alpha3, err = networkingv1alpha3.NewForConfig(&configShallowCopy) if err != nil { return nil, err @@ -103,6 +138,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset cs.authenticationV1alpha1 = authenticationv1alpha1.NewForConfigOrDie(c) +<<<<<<< HEAD +======= + cs.duckV1alpha1 = duckv1alpha1.NewForConfigOrDie(c) +>>>>>>> Upgrading knative.eventing resoureces to use knative.pkg.Conditions cs.networkingV1alpha3 = networkingv1alpha3.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) @@ -113,6 +152,10 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { func New(c rest.Interface) *Clientset { var cs Clientset cs.authenticationV1alpha1 = authenticationv1alpha1.New(c) +<<<<<<< HEAD +======= + cs.duckV1alpha1 = duckv1alpha1.New(c) +>>>>>>> Upgrading knative.eventing resoureces to use knative.pkg.Conditions cs.networkingV1alpha3 = networkingv1alpha3.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) diff --git a/vendor/github.com/knative/pkg/client/clientset/versioned/scheme/register.go b/vendor/github.com/knative/pkg/client/clientset/versioned/scheme/register.go index c796f6a6ad0..b2d9fa9c0a9 100644 --- a/vendor/github.com/knative/pkg/client/clientset/versioned/scheme/register.go +++ b/vendor/github.com/knative/pkg/client/clientset/versioned/scheme/register.go @@ -19,6 +19,10 @@ limitations under the License. package scheme import ( +<<<<<<< HEAD +======= + duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" +>>>>>>> Upgrading knative.eventing resoureces to use knative.pkg.Conditions authenticationv1alpha1 "github.com/knative/pkg/apis/istio/authentication/v1alpha1" networkingv1alpha3 "github.com/knative/pkg/apis/istio/v1alpha3" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -52,5 +56,9 @@ func init() { // correctly. func AddToScheme(scheme *runtime.Scheme) { authenticationv1alpha1.AddToScheme(scheme) +<<<<<<< HEAD +======= + duckv1alpha1.AddToScheme(scheme) +>>>>>>> Upgrading knative.eventing resoureces to use knative.pkg.Conditions networkingv1alpha3.AddToScheme(scheme) } diff --git a/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/doc.go b/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/doc.go new file mode 100644 index 00000000000..75445c17900 --- /dev/null +++ b/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2018 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. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/duck_client.go b/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/duck_client.go new file mode 100644 index 00000000000..3d4c13127b5 --- /dev/null +++ b/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/duck_client.go @@ -0,0 +1,100 @@ +/* +Copyright 2018 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 ( + v1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "github.com/knative/pkg/client/clientset/versioned/scheme" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" +) + +type DuckV1alpha1Interface interface { + RESTClient() rest.Interface + KResourcesGetter + TargetsGetter + TopicsGetter +} + +// DuckV1alpha1Client is used to interact with features provided by the duck.knative.dev group. +type DuckV1alpha1Client struct { + restClient rest.Interface +} + +func (c *DuckV1alpha1Client) KResources(namespace string) KResourceInterface { + return newKResources(c, namespace) +} + +func (c *DuckV1alpha1Client) Targets(namespace string) TargetInterface { + return newTargets(c, namespace) +} + +func (c *DuckV1alpha1Client) Topics(namespace string) TopicInterface { + return newTopics(c, namespace) +} + +// NewForConfig creates a new DuckV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*DuckV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &DuckV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new DuckV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *DuckV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new DuckV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *DuckV1alpha1Client { + return &DuckV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *DuckV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/generated_expansion.go b/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/generated_expansion.go new file mode 100644 index 00000000000..af03cc25e23 --- /dev/null +++ b/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/generated_expansion.go @@ -0,0 +1,25 @@ +/* +Copyright 2018 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 + +type KResourceExpansion interface{} + +type TargetExpansion interface{} + +type TopicExpansion interface{} diff --git a/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/kresource.go b/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/kresource.go new file mode 100644 index 00000000000..032993e0cc5 --- /dev/null +++ b/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/kresource.go @@ -0,0 +1,174 @@ +/* +Copyright 2018 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 ( + v1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + scheme "github.com/knative/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// KResourcesGetter has a method to return a KResourceInterface. +// A group's client should implement this interface. +type KResourcesGetter interface { + KResources(namespace string) KResourceInterface +} + +// KResourceInterface has methods to work with KResource resources. +type KResourceInterface interface { + Create(*v1alpha1.KResource) (*v1alpha1.KResource, error) + Update(*v1alpha1.KResource) (*v1alpha1.KResource, error) + UpdateStatus(*v1alpha1.KResource) (*v1alpha1.KResource, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.KResource, error) + List(opts v1.ListOptions) (*v1alpha1.KResourceList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.KResource, err error) + KResourceExpansion +} + +// kResources implements KResourceInterface +type kResources struct { + client rest.Interface + ns string +} + +// newKResources returns a KResources +func newKResources(c *DuckV1alpha1Client, namespace string) *kResources { + return &kResources{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the kResource, and returns the corresponding kResource object, and an error if there is any. +func (c *kResources) Get(name string, options v1.GetOptions) (result *v1alpha1.KResource, err error) { + result = &v1alpha1.KResource{} + err = c.client.Get(). + Namespace(c.ns). + Resource("kresources"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of KResources that match those selectors. +func (c *kResources) List(opts v1.ListOptions) (result *v1alpha1.KResourceList, err error) { + result = &v1alpha1.KResourceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("kresources"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested kResources. +func (c *kResources) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("kresources"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a kResource and creates it. Returns the server's representation of the kResource, and an error, if there is any. +func (c *kResources) Create(kResource *v1alpha1.KResource) (result *v1alpha1.KResource, err error) { + result = &v1alpha1.KResource{} + err = c.client.Post(). + Namespace(c.ns). + Resource("kresources"). + Body(kResource). + Do(). + Into(result) + return +} + +// Update takes the representation of a kResource and updates it. Returns the server's representation of the kResource, and an error, if there is any. +func (c *kResources) Update(kResource *v1alpha1.KResource) (result *v1alpha1.KResource, err error) { + result = &v1alpha1.KResource{} + err = c.client.Put(). + Namespace(c.ns). + Resource("kresources"). + Name(kResource.Name). + Body(kResource). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *kResources) UpdateStatus(kResource *v1alpha1.KResource) (result *v1alpha1.KResource, err error) { + result = &v1alpha1.KResource{} + err = c.client.Put(). + Namespace(c.ns). + Resource("kresources"). + Name(kResource.Name). + SubResource("status"). + Body(kResource). + Do(). + Into(result) + return +} + +// Delete takes name of the kResource and deletes it. Returns an error if one occurs. +func (c *kResources) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("kresources"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *kResources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("kresources"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched kResource. +func (c *kResources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.KResource, err error) { + result = &v1alpha1.KResource{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("kresources"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/target.go b/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/target.go new file mode 100644 index 00000000000..d8e2da2412c --- /dev/null +++ b/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/target.go @@ -0,0 +1,174 @@ +/* +Copyright 2018 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 ( + v1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + scheme "github.com/knative/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// TargetsGetter has a method to return a TargetInterface. +// A group's client should implement this interface. +type TargetsGetter interface { + Targets(namespace string) TargetInterface +} + +// TargetInterface has methods to work with Target resources. +type TargetInterface interface { + Create(*v1alpha1.Target) (*v1alpha1.Target, error) + Update(*v1alpha1.Target) (*v1alpha1.Target, error) + UpdateStatus(*v1alpha1.Target) (*v1alpha1.Target, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Target, error) + List(opts v1.ListOptions) (*v1alpha1.TargetList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Target, err error) + TargetExpansion +} + +// targets implements TargetInterface +type targets struct { + client rest.Interface + ns string +} + +// newTargets returns a Targets +func newTargets(c *DuckV1alpha1Client, namespace string) *targets { + return &targets{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the target, and returns the corresponding target object, and an error if there is any. +func (c *targets) Get(name string, options v1.GetOptions) (result *v1alpha1.Target, err error) { + result = &v1alpha1.Target{} + err = c.client.Get(). + Namespace(c.ns). + Resource("targets"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Targets that match those selectors. +func (c *targets) List(opts v1.ListOptions) (result *v1alpha1.TargetList, err error) { + result = &v1alpha1.TargetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("targets"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested targets. +func (c *targets) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("targets"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a target and creates it. Returns the server's representation of the target, and an error, if there is any. +func (c *targets) Create(target *v1alpha1.Target) (result *v1alpha1.Target, err error) { + result = &v1alpha1.Target{} + err = c.client.Post(). + Namespace(c.ns). + Resource("targets"). + Body(target). + Do(). + Into(result) + return +} + +// Update takes the representation of a target and updates it. Returns the server's representation of the target, and an error, if there is any. +func (c *targets) Update(target *v1alpha1.Target) (result *v1alpha1.Target, err error) { + result = &v1alpha1.Target{} + err = c.client.Put(). + Namespace(c.ns). + Resource("targets"). + Name(target.Name). + Body(target). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *targets) UpdateStatus(target *v1alpha1.Target) (result *v1alpha1.Target, err error) { + result = &v1alpha1.Target{} + err = c.client.Put(). + Namespace(c.ns). + Resource("targets"). + Name(target.Name). + SubResource("status"). + Body(target). + Do(). + Into(result) + return +} + +// Delete takes name of the target and deletes it. Returns an error if one occurs. +func (c *targets) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("targets"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *targets) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("targets"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched target. +func (c *targets) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Target, err error) { + result = &v1alpha1.Target{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("targets"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/topic.go b/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/topic.go new file mode 100644 index 00000000000..53262a87a4f --- /dev/null +++ b/vendor/github.com/knative/pkg/client/clientset/versioned/typed/duck/v1alpha1/topic.go @@ -0,0 +1,174 @@ +/* +Copyright 2018 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 ( + v1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + scheme "github.com/knative/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// TopicsGetter has a method to return a TopicInterface. +// A group's client should implement this interface. +type TopicsGetter interface { + Topics(namespace string) TopicInterface +} + +// TopicInterface has methods to work with Topic resources. +type TopicInterface interface { + Create(*v1alpha1.Topic) (*v1alpha1.Topic, error) + Update(*v1alpha1.Topic) (*v1alpha1.Topic, error) + UpdateStatus(*v1alpha1.Topic) (*v1alpha1.Topic, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Topic, error) + List(opts v1.ListOptions) (*v1alpha1.TopicList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Topic, err error) + TopicExpansion +} + +// topics implements TopicInterface +type topics struct { + client rest.Interface + ns string +} + +// newTopics returns a Topics +func newTopics(c *DuckV1alpha1Client, namespace string) *topics { + return &topics{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the topic, and returns the corresponding topic object, and an error if there is any. +func (c *topics) Get(name string, options v1.GetOptions) (result *v1alpha1.Topic, err error) { + result = &v1alpha1.Topic{} + err = c.client.Get(). + Namespace(c.ns). + Resource("topics"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Topics that match those selectors. +func (c *topics) List(opts v1.ListOptions) (result *v1alpha1.TopicList, err error) { + result = &v1alpha1.TopicList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("topics"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested topics. +func (c *topics) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("topics"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a topic and creates it. Returns the server's representation of the topic, and an error, if there is any. +func (c *topics) Create(topic *v1alpha1.Topic) (result *v1alpha1.Topic, err error) { + result = &v1alpha1.Topic{} + err = c.client.Post(). + Namespace(c.ns). + Resource("topics"). + Body(topic). + Do(). + Into(result) + return +} + +// Update takes the representation of a topic and updates it. Returns the server's representation of the topic, and an error, if there is any. +func (c *topics) Update(topic *v1alpha1.Topic) (result *v1alpha1.Topic, err error) { + result = &v1alpha1.Topic{} + err = c.client.Put(). + Namespace(c.ns). + Resource("topics"). + Name(topic.Name). + Body(topic). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *topics) UpdateStatus(topic *v1alpha1.Topic) (result *v1alpha1.Topic, err error) { + result = &v1alpha1.Topic{} + err = c.client.Put(). + Namespace(c.ns). + Resource("topics"). + Name(topic.Name). + SubResource("status"). + Body(topic). + Do(). + Into(result) + return +} + +// Delete takes name of the topic and deletes it. Returns an error if one occurs. +func (c *topics) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("topics"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *topics) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("topics"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched topic. +func (c *topics) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Topic, err error) { + result = &v1alpha1.Topic{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("topics"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/github.com/knative/pkg/client/informers/externalversions/duck/interface.go b/vendor/github.com/knative/pkg/client/informers/externalversions/duck/interface.go new file mode 100644 index 00000000000..ff473f65789 --- /dev/null +++ b/vendor/github.com/knative/pkg/client/informers/externalversions/duck/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2018 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 duck + +import ( + v1alpha1 "github.com/knative/pkg/client/informers/externalversions/duck/v1alpha1" + internalinterfaces "github.com/knative/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/vendor/github.com/knative/pkg/client/informers/externalversions/duck/v1alpha1/interface.go b/vendor/github.com/knative/pkg/client/informers/externalversions/duck/v1alpha1/interface.go new file mode 100644 index 00000000000..f0fbd06a56e --- /dev/null +++ b/vendor/github.com/knative/pkg/client/informers/externalversions/duck/v1alpha1/interface.go @@ -0,0 +1,59 @@ +/* +Copyright 2018 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 ( + internalinterfaces "github.com/knative/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // KResources returns a KResourceInformer. + KResources() KResourceInformer + // Targets returns a TargetInformer. + Targets() TargetInformer + // Topics returns a TopicInformer. + Topics() TopicInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// KResources returns a KResourceInformer. +func (v *version) KResources() KResourceInformer { + return &kResourceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Targets returns a TargetInformer. +func (v *version) Targets() TargetInformer { + return &targetInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Topics returns a TopicInformer. +func (v *version) Topics() TopicInformer { + return &topicInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/vendor/github.com/knative/pkg/client/informers/externalversions/duck/v1alpha1/kresource.go b/vendor/github.com/knative/pkg/client/informers/externalversions/duck/v1alpha1/kresource.go new file mode 100644 index 00000000000..91e97b9d0db --- /dev/null +++ b/vendor/github.com/knative/pkg/client/informers/externalversions/duck/v1alpha1/kresource.go @@ -0,0 +1,89 @@ +/* +Copyright 2018 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 ( + time "time" + + duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + versioned "github.com/knative/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/knative/pkg/client/listers/duck/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// KResourceInformer provides access to a shared informer and lister for +// KResources. +type KResourceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.KResourceLister +} + +type kResourceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewKResourceInformer constructs a new informer for KResource 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 NewKResourceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredKResourceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredKResourceInformer constructs a new informer for KResource 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 NewFilteredKResourceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.DuckV1alpha1().KResources(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.DuckV1alpha1().KResources(namespace).Watch(options) + }, + }, + &duckv1alpha1.KResource{}, + resyncPeriod, + indexers, + ) +} + +func (f *kResourceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredKResourceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *kResourceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&duckv1alpha1.KResource{}, f.defaultInformer) +} + +func (f *kResourceInformer) Lister() v1alpha1.KResourceLister { + return v1alpha1.NewKResourceLister(f.Informer().GetIndexer()) +} diff --git a/vendor/github.com/knative/pkg/client/informers/externalversions/duck/v1alpha1/target.go b/vendor/github.com/knative/pkg/client/informers/externalversions/duck/v1alpha1/target.go new file mode 100644 index 00000000000..c53aecc88bf --- /dev/null +++ b/vendor/github.com/knative/pkg/client/informers/externalversions/duck/v1alpha1/target.go @@ -0,0 +1,89 @@ +/* +Copyright 2018 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 ( + time "time" + + duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + versioned "github.com/knative/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/knative/pkg/client/listers/duck/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// TargetInformer provides access to a shared informer and lister for +// Targets. +type TargetInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.TargetLister +} + +type targetInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewTargetInformer constructs a new informer for Target 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 NewTargetInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredTargetInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredTargetInformer constructs a new informer for Target 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 NewFilteredTargetInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.DuckV1alpha1().Targets(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.DuckV1alpha1().Targets(namespace).Watch(options) + }, + }, + &duckv1alpha1.Target{}, + resyncPeriod, + indexers, + ) +} + +func (f *targetInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredTargetInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *targetInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&duckv1alpha1.Target{}, f.defaultInformer) +} + +func (f *targetInformer) Lister() v1alpha1.TargetLister { + return v1alpha1.NewTargetLister(f.Informer().GetIndexer()) +} diff --git a/vendor/github.com/knative/pkg/client/informers/externalversions/duck/v1alpha1/topic.go b/vendor/github.com/knative/pkg/client/informers/externalversions/duck/v1alpha1/topic.go new file mode 100644 index 00000000000..89f1c5ff90e --- /dev/null +++ b/vendor/github.com/knative/pkg/client/informers/externalversions/duck/v1alpha1/topic.go @@ -0,0 +1,89 @@ +/* +Copyright 2018 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 ( + time "time" + + duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + versioned "github.com/knative/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/knative/pkg/client/listers/duck/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// TopicInformer provides access to a shared informer and lister for +// Topics. +type TopicInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.TopicLister +} + +type topicInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewTopicInformer constructs a new informer for Topic 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 NewTopicInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredTopicInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredTopicInformer constructs a new informer for Topic 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 NewFilteredTopicInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.DuckV1alpha1().Topics(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.DuckV1alpha1().Topics(namespace).Watch(options) + }, + }, + &duckv1alpha1.Topic{}, + resyncPeriod, + indexers, + ) +} + +func (f *topicInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredTopicInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *topicInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&duckv1alpha1.Topic{}, f.defaultInformer) +} + +func (f *topicInformer) Lister() v1alpha1.TopicLister { + return v1alpha1.NewTopicLister(f.Informer().GetIndexer()) +} diff --git a/vendor/github.com/knative/pkg/client/informers/externalversions/factory.go b/vendor/github.com/knative/pkg/client/informers/externalversions/factory.go index 297b59402cd..9eb4040f8d5 100644 --- a/vendor/github.com/knative/pkg/client/informers/externalversions/factory.go +++ b/vendor/github.com/knative/pkg/client/informers/externalversions/factory.go @@ -25,6 +25,10 @@ import ( versioned "github.com/knative/pkg/client/clientset/versioned" authentication "github.com/knative/pkg/client/informers/externalversions/authentication" +<<<<<<< HEAD +======= + duck "github.com/knative/pkg/client/informers/externalversions/duck" +>>>>>>> Upgrading knative.eventing resoureces to use knative.pkg.Conditions internalinterfaces "github.com/knative/pkg/client/informers/externalversions/internalinterfaces" istio "github.com/knative/pkg/client/informers/externalversions/istio" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -174,6 +178,10 @@ type SharedInformerFactory interface { WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool Authentication() authentication.Interface +<<<<<<< HEAD +======= + Duck() duck.Interface +>>>>>>> Upgrading knative.eventing resoureces to use knative.pkg.Conditions Networking() istio.Interface } @@ -181,6 +189,13 @@ func (f *sharedInformerFactory) Authentication() authentication.Interface { return authentication.New(f, f.namespace, f.tweakListOptions) } +<<<<<<< HEAD +======= +func (f *sharedInformerFactory) Duck() duck.Interface { + return duck.New(f, f.namespace, f.tweakListOptions) +} + +>>>>>>> Upgrading knative.eventing resoureces to use knative.pkg.Conditions func (f *sharedInformerFactory) Networking() istio.Interface { return istio.New(f, f.namespace, f.tweakListOptions) } diff --git a/vendor/github.com/knative/pkg/client/informers/externalversions/generic.go b/vendor/github.com/knative/pkg/client/informers/externalversions/generic.go index 66737d499af..ab57b7acfe4 100644 --- a/vendor/github.com/knative/pkg/client/informers/externalversions/generic.go +++ b/vendor/github.com/knative/pkg/client/informers/externalversions/generic.go @@ -21,6 +21,10 @@ package externalversions import ( "fmt" +<<<<<<< HEAD +======= + duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" +>>>>>>> Upgrading knative.eventing resoureces to use knative.pkg.Conditions v1alpha1 "github.com/knative/pkg/apis/istio/authentication/v1alpha1" v1alpha3 "github.com/knative/pkg/apis/istio/v1alpha3" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -57,6 +61,17 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1alpha1.SchemeGroupVersion.WithResource("policies"): return &genericInformer{resource: resource.GroupResource(), informer: f.Authentication().V1alpha1().Policies().Informer()}, nil +<<<<<<< HEAD +======= + // Group=duck.knative.dev, Version=v1alpha1 + case duckv1alpha1.SchemeGroupVersion.WithResource("kresources"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Duck().V1alpha1().KResources().Informer()}, nil + case duckv1alpha1.SchemeGroupVersion.WithResource("targets"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Duck().V1alpha1().Targets().Informer()}, nil + case duckv1alpha1.SchemeGroupVersion.WithResource("topics"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Duck().V1alpha1().Topics().Informer()}, nil + +>>>>>>> Upgrading knative.eventing resoureces to use knative.pkg.Conditions // Group=networking.istio.io, Version=v1alpha3 case v1alpha3.SchemeGroupVersion.WithResource("destinationrules"): return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha3().DestinationRules().Informer()}, nil diff --git a/vendor/github.com/knative/pkg/client/listers/duck/v1alpha1/expansion_generated.go b/vendor/github.com/knative/pkg/client/listers/duck/v1alpha1/expansion_generated.go new file mode 100644 index 00000000000..f9e7fe2fb66 --- /dev/null +++ b/vendor/github.com/knative/pkg/client/listers/duck/v1alpha1/expansion_generated.go @@ -0,0 +1,43 @@ +/* +Copyright 2018 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 + +// KResourceListerExpansion allows custom methods to be added to +// KResourceLister. +type KResourceListerExpansion interface{} + +// KResourceNamespaceListerExpansion allows custom methods to be added to +// KResourceNamespaceLister. +type KResourceNamespaceListerExpansion interface{} + +// TargetListerExpansion allows custom methods to be added to +// TargetLister. +type TargetListerExpansion interface{} + +// TargetNamespaceListerExpansion allows custom methods to be added to +// TargetNamespaceLister. +type TargetNamespaceListerExpansion interface{} + +// TopicListerExpansion allows custom methods to be added to +// TopicLister. +type TopicListerExpansion interface{} + +// TopicNamespaceListerExpansion allows custom methods to be added to +// TopicNamespaceLister. +type TopicNamespaceListerExpansion interface{} diff --git a/vendor/github.com/knative/pkg/client/listers/duck/v1alpha1/kresource.go b/vendor/github.com/knative/pkg/client/listers/duck/v1alpha1/kresource.go new file mode 100644 index 00000000000..cf201343938 --- /dev/null +++ b/vendor/github.com/knative/pkg/client/listers/duck/v1alpha1/kresource.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 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 ( + v1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// KResourceLister helps list KResources. +type KResourceLister interface { + // List lists all KResources in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.KResource, err error) + // KResources returns an object that can list and get KResources. + KResources(namespace string) KResourceNamespaceLister + KResourceListerExpansion +} + +// kResourceLister implements the KResourceLister interface. +type kResourceLister struct { + indexer cache.Indexer +} + +// NewKResourceLister returns a new KResourceLister. +func NewKResourceLister(indexer cache.Indexer) KResourceLister { + return &kResourceLister{indexer: indexer} +} + +// List lists all KResources in the indexer. +func (s *kResourceLister) List(selector labels.Selector) (ret []*v1alpha1.KResource, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.KResource)) + }) + return ret, err +} + +// KResources returns an object that can list and get KResources. +func (s *kResourceLister) KResources(namespace string) KResourceNamespaceLister { + return kResourceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// KResourceNamespaceLister helps list and get KResources. +type KResourceNamespaceLister interface { + // List lists all KResources in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.KResource, err error) + // Get retrieves the KResource from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.KResource, error) + KResourceNamespaceListerExpansion +} + +// kResourceNamespaceLister implements the KResourceNamespaceLister +// interface. +type kResourceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all KResources in the indexer for a given namespace. +func (s kResourceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.KResource, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.KResource)) + }) + return ret, err +} + +// Get retrieves the KResource from the indexer for a given namespace and name. +func (s kResourceNamespaceLister) Get(name string) (*v1alpha1.KResource, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("kresource"), name) + } + return obj.(*v1alpha1.KResource), nil +} diff --git a/vendor/github.com/knative/pkg/client/listers/duck/v1alpha1/target.go b/vendor/github.com/knative/pkg/client/listers/duck/v1alpha1/target.go new file mode 100644 index 00000000000..b88a40e4058 --- /dev/null +++ b/vendor/github.com/knative/pkg/client/listers/duck/v1alpha1/target.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 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 ( + v1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// TargetLister helps list Targets. +type TargetLister interface { + // List lists all Targets in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Target, err error) + // Targets returns an object that can list and get Targets. + Targets(namespace string) TargetNamespaceLister + TargetListerExpansion +} + +// targetLister implements the TargetLister interface. +type targetLister struct { + indexer cache.Indexer +} + +// NewTargetLister returns a new TargetLister. +func NewTargetLister(indexer cache.Indexer) TargetLister { + return &targetLister{indexer: indexer} +} + +// List lists all Targets in the indexer. +func (s *targetLister) List(selector labels.Selector) (ret []*v1alpha1.Target, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Target)) + }) + return ret, err +} + +// Targets returns an object that can list and get Targets. +func (s *targetLister) Targets(namespace string) TargetNamespaceLister { + return targetNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// TargetNamespaceLister helps list and get Targets. +type TargetNamespaceLister interface { + // List lists all Targets in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Target, err error) + // Get retrieves the Target from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Target, error) + TargetNamespaceListerExpansion +} + +// targetNamespaceLister implements the TargetNamespaceLister +// interface. +type targetNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Targets in the indexer for a given namespace. +func (s targetNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Target, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Target)) + }) + return ret, err +} + +// Get retrieves the Target from the indexer for a given namespace and name. +func (s targetNamespaceLister) Get(name string) (*v1alpha1.Target, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("target"), name) + } + return obj.(*v1alpha1.Target), nil +} diff --git a/vendor/github.com/knative/pkg/client/listers/duck/v1alpha1/topic.go b/vendor/github.com/knative/pkg/client/listers/duck/v1alpha1/topic.go new file mode 100644 index 00000000000..8a87873c5da --- /dev/null +++ b/vendor/github.com/knative/pkg/client/listers/duck/v1alpha1/topic.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 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 ( + v1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// TopicLister helps list Topics. +type TopicLister interface { + // List lists all Topics in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Topic, err error) + // Topics returns an object that can list and get Topics. + Topics(namespace string) TopicNamespaceLister + TopicListerExpansion +} + +// topicLister implements the TopicLister interface. +type topicLister struct { + indexer cache.Indexer +} + +// NewTopicLister returns a new TopicLister. +func NewTopicLister(indexer cache.Indexer) TopicLister { + return &topicLister{indexer: indexer} +} + +// List lists all Topics in the indexer. +func (s *topicLister) List(selector labels.Selector) (ret []*v1alpha1.Topic, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Topic)) + }) + return ret, err +} + +// Topics returns an object that can list and get Topics. +func (s *topicLister) Topics(namespace string) TopicNamespaceLister { + return topicNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// TopicNamespaceLister helps list and get Topics. +type TopicNamespaceLister interface { + // List lists all Topics in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Topic, err error) + // Get retrieves the Topic from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Topic, error) + TopicNamespaceListerExpansion +} + +// topicNamespaceLister implements the TopicNamespaceLister +// interface. +type topicNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Topics in the indexer for a given namespace. +func (s topicNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Topic, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Topic)) + }) + return ret, err +} + +// Get retrieves the Topic from the indexer for a given namespace and name. +func (s topicNamespaceLister) Get(name string) (*v1alpha1.Topic, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("topic"), name) + } + return obj.(*v1alpha1.Topic), nil +}