diff --git a/pkg/apis/sources/v1alpha2/apiserver_lifecycle.go b/pkg/apis/sources/v1alpha2/apiserver_lifecycle.go index e3b558add92..0d143cc7f87 100644 --- a/pkg/apis/sources/v1alpha2/apiserver_lifecycle.go +++ b/pkg/apis/sources/v1alpha2/apiserver_lifecycle.go @@ -48,8 +48,13 @@ var apiserverCondSet = apis.NewLivingConditionSet( ApiServerConditionSufficientPermissions, ) +// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface. +func (*ApiServerSource) GetConditionSet() apis.ConditionSet { + return apiserverCondSet +} + // GetGroupVersionKind returns the GroupVersionKind. -func (s *ApiServerSource) GetGroupVersionKind() schema.GroupVersionKind { +func (*ApiServerSource) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind("ApiServerSource") } diff --git a/pkg/apis/sources/v1alpha2/apiserver_lifecycle_test.go b/pkg/apis/sources/v1alpha2/apiserver_lifecycle_test.go index 5e59a301166..63db4bede41 100644 --- a/pkg/apis/sources/v1alpha2/apiserver_lifecycle_test.go +++ b/pkg/apis/sources/v1alpha2/apiserver_lifecycle_test.go @@ -42,6 +42,14 @@ var ( } ) +func TestApiServerSourceGetConditionSet(t *testing.T) { + r := &ApiServerSource{} + + if got, want := r.GetConditionSet().GetTopLevelConditionType(), apis.ConditionReady; got != want { + t.Errorf("GetTopLevelCondition=%v, want=%v", got, want) + } +} + func TestApiServerSourceGetGroupVersionKind(t *testing.T) { r := &ApiServerSource{} want := schema.GroupVersionKind{ diff --git a/pkg/apis/sources/v1alpha2/apiserver_types.go b/pkg/apis/sources/v1alpha2/apiserver_types.go index f0fa827f7f1..a31b2bfb875 100644 --- a/pkg/apis/sources/v1alpha2/apiserver_types.go +++ b/pkg/apis/sources/v1alpha2/apiserver_types.go @@ -45,6 +45,7 @@ var ( _ apis.Validatable = (*ApiServerSource)(nil) _ apis.Defaultable = (*ApiServerSource)(nil) _ apis.HasSpec = (*ApiServerSource)(nil) + _ duckv1.KRShaped = (*ApiServerSource)(nil) ) const ( @@ -153,3 +154,8 @@ type ApiServerSourceList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []ApiServerSource `json:"items"` } + +// GetStatus retrieves the status of the ApiServerSource . Implements the KRShaped interface. +func (a *ApiServerSource) GetStatus() *duckv1.Status { + return &a.Status.Status +} diff --git a/pkg/apis/sources/v1alpha2/apiserver_types_test.go b/pkg/apis/sources/v1alpha2/apiserver_types_test.go index 905c7224779..ce9e2b2ac1a 100644 --- a/pkg/apis/sources/v1alpha2/apiserver_types_test.go +++ b/pkg/apis/sources/v1alpha2/apiserver_types_test.go @@ -18,6 +18,15 @@ package v1alpha2 import "testing" +func TestApiServerSource_GetStatus(t *testing.T) { + r := &ApiServerSource{ + Status: ApiServerSourceStatus{}, + } + if got, want := r.GetStatus(), &r.Status.Status; got != want { + t.Errorf("GetStatus=%v, want=%v", got, want) + } +} + func TestApiServerSource_GetGroupVersionKind(t *testing.T) { ass := ApiServerSource{} gvk := ass.GetGroupVersionKind() diff --git a/pkg/apis/sources/v1alpha2/container_lifecycle.go b/pkg/apis/sources/v1alpha2/container_lifecycle.go index 7cecfd380d5..8b6920299c7 100644 --- a/pkg/apis/sources/v1alpha2/container_lifecycle.go +++ b/pkg/apis/sources/v1alpha2/container_lifecycle.go @@ -39,6 +39,11 @@ var containerCondSet = apis.NewLivingConditionSet( ContainerSourceConditionReceiveAdapterReady, ) +// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface. +func (*ContainerSource) GetConditionSet() apis.ConditionSet { + return containerCondSet +} + // GetCondition returns the condition currently associated with the given type, or nil. func (s *ContainerSourceStatus) GetCondition(t apis.ConditionType) *apis.Condition { return containerCondSet.Manage(s).GetCondition(t) diff --git a/pkg/apis/sources/v1alpha2/container_lifecycle_test.go b/pkg/apis/sources/v1alpha2/container_lifecycle_test.go index 8c6bd4ff7f2..4c78eabb58a 100644 --- a/pkg/apis/sources/v1alpha2/container_lifecycle_test.go +++ b/pkg/apis/sources/v1alpha2/container_lifecycle_test.go @@ -84,6 +84,14 @@ var ( } ) +func TestContainerSourceGetConditionSet(t *testing.T) { + r := &ContainerSource{} + + if got, want := r.GetConditionSet().GetTopLevelConditionType(), apis.ConditionReady; got != want { + t.Errorf("GetTopLevelCondition=%v, want=%v", got, want) + } +} + func TestContainerSourceStatusIsReady(t *testing.T) { tests := []struct { name string diff --git a/pkg/apis/sources/v1alpha2/container_types.go b/pkg/apis/sources/v1alpha2/container_types.go index 795fdd97e15..6b761aeff63 100644 --- a/pkg/apis/sources/v1alpha2/container_types.go +++ b/pkg/apis/sources/v1alpha2/container_types.go @@ -45,6 +45,7 @@ var ( _ apis.Validatable = (*ContainerSource)(nil) _ apis.Defaultable = (*ContainerSource)(nil) _ apis.HasSpec = (*ContainerSource)(nil) + _ duckv1.KRShaped = (*ContainerSource)(nil) ) // ContainerSourceSpec defines the desired state of ContainerSource @@ -61,7 +62,7 @@ type ContainerSourceSpec struct { } // GetGroupVersionKind returns the GroupVersionKind. -func (s *ContainerSource) GetGroupVersionKind() schema.GroupVersionKind { +func (*ContainerSource) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind("ContainerSource") } @@ -90,3 +91,8 @@ type ContainerSourceList struct { func (c *ContainerSource) GetUntypedSpec() interface{} { return c.Spec } + +// GetStatus retrieves the status of the ContainerSource. Implements the KRShaped interface. +func (c *ContainerSource) GetStatus() *duckv1.Status { + return &c.Status.Status +} diff --git a/pkg/apis/sources/v1alpha2/ping_lifecycle.go b/pkg/apis/sources/v1alpha2/ping_lifecycle.go index a139cb58c64..75ca99c37ff 100644 --- a/pkg/apis/sources/v1alpha2/ping_lifecycle.go +++ b/pkg/apis/sources/v1alpha2/ping_lifecycle.go @@ -57,6 +57,11 @@ const ( PingSourceEventType = "dev.knative.sources.ping" ) +// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface. +func (*PingSource) GetConditionSet() apis.ConditionSet { + return PingSourceCondSet +} + // PingSourceSource returns the PingSource CloudEvent source. func PingSourceSource(namespace, name string) string { return fmt.Sprintf("/apis/v1/namespaces/%s/pingsources/%s", namespace, name) diff --git a/pkg/apis/sources/v1alpha2/ping_lifecycle_test.go b/pkg/apis/sources/v1alpha2/ping_lifecycle_test.go index c13a69bfef1..7f2242dfbdf 100644 --- a/pkg/apis/sources/v1alpha2/ping_lifecycle_test.go +++ b/pkg/apis/sources/v1alpha2/ping_lifecycle_test.go @@ -41,6 +41,14 @@ var ( } ) +func TestPingSourceGetConditionSet(t *testing.T) { + r := &v1alpha2.PingSource{} + + if got, want := r.GetConditionSet().GetTopLevelConditionType(), apis.ConditionReady; got != want { + t.Errorf("GetTopLevelCondition=%v, want=%v", got, want) + } +} + func TestPingSource_GetGroupVersionKind(t *testing.T) { src := v1alpha2.PingSource{} gvk := src.GetGroupVersionKind() diff --git a/pkg/apis/sources/v1alpha2/ping_types.go b/pkg/apis/sources/v1alpha2/ping_types.go index bd5823ae837..4d3921f2fca 100644 --- a/pkg/apis/sources/v1alpha2/ping_types.go +++ b/pkg/apis/sources/v1alpha2/ping_types.go @@ -46,6 +46,7 @@ var ( _ apis.Validatable = (*PingSource)(nil) _ apis.Defaultable = (*PingSource)(nil) _ apis.HasSpec = (*PingSource)(nil) + _ duckv1.KRShaped = (*PingSource)(nil) ) // PingSourceSpec defines the desired state of the PingSource. @@ -88,3 +89,8 @@ type PingSourceList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []PingSource `json:"items"` } + +// GetStatus retrieves the status of the PingSource. Implements the KRShaped interface. +func (p *PingSource) GetStatus() *duckv1.Status { + return &p.Status.Status +} diff --git a/pkg/apis/sources/v1alpha2/sinkbinding_lifecycle.go b/pkg/apis/sources/v1alpha2/sinkbinding_lifecycle.go index 0a9758fd5c1..cb2e28747fc 100644 --- a/pkg/apis/sources/v1alpha2/sinkbinding_lifecycle.go +++ b/pkg/apis/sources/v1alpha2/sinkbinding_lifecycle.go @@ -32,8 +32,13 @@ import ( var sbCondSet = apis.NewLivingConditionSet() +// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface. +func (*SinkBinding) GetConditionSet() apis.ConditionSet { + return sbCondSet +} + // GetGroupVersionKind returns the GroupVersionKind. -func (s *SinkBinding) GetGroupVersionKind() schema.GroupVersionKind { +func (*SinkBinding) GetGroupVersionKind() schema.GroupVersionKind { return SchemeGroupVersion.WithKind("SinkBinding") } diff --git a/pkg/apis/sources/v1alpha2/sinkbinding_lifecycle_test.go b/pkg/apis/sources/v1alpha2/sinkbinding_lifecycle_test.go index f6e435876a2..4ebd5121356 100644 --- a/pkg/apis/sources/v1alpha2/sinkbinding_lifecycle_test.go +++ b/pkg/apis/sources/v1alpha2/sinkbinding_lifecycle_test.go @@ -30,6 +30,14 @@ import ( "knative.dev/pkg/tracker" ) +func TestSinkBindingGetConditionSet(t *testing.T) { + r := &SinkBinding{} + + if got, want := r.GetConditionSet().GetTopLevelConditionType(), apis.ConditionReady; got != want { + t.Errorf("GetTopLevelCondition=%v, want=%v", got, want) + } +} + func TestSinkBindingGetGroupVersionKind(t *testing.T) { r := &SinkBinding{} want := schema.GroupVersionKind{ diff --git a/pkg/apis/sources/v1alpha2/sinkbinding_types.go b/pkg/apis/sources/v1alpha2/sinkbinding_types.go index 103472c8bf0..c05c2f52da9 100644 --- a/pkg/apis/sources/v1alpha2/sinkbinding_types.go +++ b/pkg/apis/sources/v1alpha2/sinkbinding_types.go @@ -50,6 +50,7 @@ var ( _ apis.Validatable = (*SinkBinding)(nil) _ apis.Defaultable = (*SinkBinding)(nil) _ apis.HasSpec = (*SinkBinding)(nil) + _ duckv1.KRShaped = (*SinkBinding)(nil) ) // SinkBindingSpec holds the desired state of the SinkBinding (from the client). @@ -93,3 +94,8 @@ type SinkBindingList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []SinkBinding `json:"items"` } + +// GetStatus retrieves the status of the SinkBinding. Implements the KRShaped interface. +func (s *SinkBinding) GetStatus() *duckv1.Status { + return &s.Status.Status +} diff --git a/pkg/apis/sources/v1alpha2/sinkbinding_types_test.go b/pkg/apis/sources/v1alpha2/sinkbinding_types_test.go index 20aec670555..1b0fb2bf68d 100644 --- a/pkg/apis/sources/v1alpha2/sinkbinding_types_test.go +++ b/pkg/apis/sources/v1alpha2/sinkbinding_types_test.go @@ -18,6 +18,15 @@ package v1alpha2 import "testing" +func TestSinkBinding_GetStatus(t *testing.T) { + r := &SinkBinding{ + Status: SinkBindingStatus{}, + } + if got, want := r.GetStatus(), &r.Status.Status; got != want { + t.Errorf("GetStatus=%v, want=%v", got, want) + } +} + func TestSinkBinding_GetGroupVersionKind(t *testing.T) { sb := SinkBinding{} gvk := sb.GetGroupVersionKind()