Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/apis/autoscaling/v1alpha1/metric_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ var condSet = apis.NewLivingConditionSet(
MetricConditionReady,
)

// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface.
func (*Metric) GetConditionSet() apis.ConditionSet {
return condSet
}

// GetGroupVersionKind implements OwnerRefable.
func (m *Metric) GetGroupVersionKind() schema.GroupVersionKind {
return SchemeGroupVersion.WithKind("Metric")
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/autoscaling/v1alpha1/metric_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ func TestMetricDuckTypes(t *testing.T) {
}
}

func TestMetricGetConditionSet(t *testing.T) {
r := &Metric{}
want := apis.ConditionReady
if got := r.GetConditionSet().GetTopLevelConditionType(); got != want {
t.Errorf("got: %v, want: %v", got, want)
}
}

func TestMetricIsReady(t *testing.T) {
cases := []struct {
name string
Expand Down
13 changes: 13 additions & 0 deletions pkg/apis/autoscaling/v1alpha1/metric_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ var (

// Check that we can create OwnerReferences to a Metric.
_ kmeta.OwnerRefable = (*Metric)(nil)

// Check that the type conforms to the duck Knative Resource shape.
_ duckv1.KRShaped = (*Metric)(nil)
)

// MetricSpec contains all values a metric collector needs to operate.
Expand All @@ -78,3 +81,13 @@ type MetricList struct {

Items []Metric `json:"items"`
}

// GetTypeMeta retrieves the ObjectMeta of the Metric. Implements the KRShaped interface.
func (t *Metric) GetTypeMeta() *metav1.TypeMeta {
return &t.TypeMeta
}

// GetStatus retrieves the status of the Metric. Implements the KRShaped interface.
func (t *Metric) GetStatus() *duckv1.Status {
return &t.Status.Status
}
42 changes: 42 additions & 0 deletions pkg/apis/autoscaling/v1alpha1/metric_types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright 2020 The Knative Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1

import (
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestMetricGetStatus(t *testing.T) {
r := &Metric{
Status: MetricStatus{},
}
want := &r.Status.Status
if got := r.GetStatus(); got != want {
t.Errorf("got: %v, want: %v", got, want)
}
}

func TestMetricGetObjectMeta(t *testing.T) {
r := &Metric{
TypeMeta: metav1.TypeMeta{},
}
want := &r.TypeMeta
if got := r.GetTypeMeta(); got != want {
t.Errorf("got: %v, want: %v", got, want)
}
}
5 changes: 5 additions & 0 deletions pkg/apis/autoscaling/v1alpha1/pa_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ var podCondSet = apis.NewLivingConditionSet(
PodAutoscalerConditionActive,
)

// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface.
func (*PodAutoscaler) GetConditionSet() apis.ConditionSet {
return podCondSet
}

func (pa *PodAutoscaler) GetGroupVersionKind() schema.GroupVersionKind {
return SchemeGroupVersion.WithKind("PodAutoscaler")
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/autoscaling/v1alpha1/pa_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ func TestPodAutoscalerDuckTypes(t *testing.T) {
}
}

func TestPodAutoscalerGetConditionSet(t *testing.T) {
r := &PodAutoscaler{}
want := apis.ConditionReady
if got := r.GetConditionSet().GetTopLevelConditionType(); got != want {
t.Errorf("got: %v, want: %v", got, want)
}
}

func TestGeneration(t *testing.T) {
r := PodAutoscaler{}
if a := r.GetGeneration(); a != 0 {
Expand Down
15 changes: 14 additions & 1 deletion pkg/apis/autoscaling/v1alpha1/pa_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ var (

// Check that we can create OwnerReferences to a PodAutoscaler.
_ kmeta.OwnerRefable = (*PodAutoscaler)(nil)

// Check that the type conforms to the duck Knative Resource shape.
_ duckv1.KRShaped = (*PodAutoscaler)(nil)
)

// ReachabilityType is the enumeration type for the different states of reachability
Expand All @@ -69,7 +72,7 @@ const (
// ReachabilityReachable means the `ScaleTarget` is reachable, ie. it has an active route.
ReachabilityReachable ReachabilityType = "Reachable"

// ReachabilityReachable means the `ScaleTarget` is not reachable, ie. it does not have an active route.
// ReachabilityUnreachable means the `ScaleTarget` is not reachable, ie. it does not have an active route.
ReachabilityUnreachable ReachabilityType = "Unreachable"
)

Expand Down Expand Up @@ -141,3 +144,13 @@ type PodAutoscalerList struct {

Items []PodAutoscaler `json:"items"`
}

// GetTypeMeta retrieves the ObjectMeta of the PodAutoscaler. Implements the KRShaped interface.
func (t *PodAutoscaler) GetTypeMeta() *metav1.TypeMeta {
return &t.TypeMeta
}

// GetStatus retrieves the status of the PodAutoscaler. Implements the KRShaped interface.
func (t *PodAutoscaler) GetStatus() *duckv1.Status {
return &t.Status.Status
}
42 changes: 42 additions & 0 deletions pkg/apis/autoscaling/v1alpha1/pa_types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright 2020 The Knative Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1

import (
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestPodAutoscalerGetStatus(t *testing.T) {
r := &PodAutoscaler{
Status: PodAutoscalerStatus{},
}
want := &r.Status.Status
if got := r.GetStatus(); got != want {
t.Errorf("got: %v, want: %v", got, want)
}
}

func TestPodAutoscalerGetObjectMeta(t *testing.T) {
r := &PodAutoscaler{
TypeMeta: metav1.TypeMeta{},
}
want := &r.TypeMeta
if got := r.GetTypeMeta(); got != want {
t.Errorf("got: %v, want: %v", got, want)
}
}
5 changes: 5 additions & 0 deletions pkg/apis/networking/v1alpha1/certificate_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ const (

var certificateCondSet = apis.NewLivingConditionSet(CertificateConditionReady)

// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface.
func (*Certificate) GetConditionSet() apis.ConditionSet {
return certificateCondSet
}

// GetGroupVersionKind returns the GroupVersionKind of Certificate.
func (c *Certificate) GetGroupVersionKind() schema.GroupVersionKind {
return SchemeGroupVersion.WithKind("Certificate")
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/networking/v1alpha1/certificate_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ func TestCertificateDuckTypes(t *testing.T) {
}
}

func TestCertificateGetConditionSet(t *testing.T) {
r := &Certificate{}
want := apis.ConditionReady
if got := r.GetConditionSet().GetTopLevelConditionType(); got != want {
t.Errorf("got: %v, want: %v", got, want)
}
}

func TestCertificateGetGroupVersionKind(t *testing.T) {
c := Certificate{}
expected := SchemeGroupVersion.WithKind("Certificate")
Expand Down
13 changes: 13 additions & 0 deletions pkg/apis/networking/v1alpha1/certificate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ var (

// Check that we can create OwnerReferences to a Certificate..
_ kmeta.OwnerRefable = (*Certificate)(nil)

// Check that the type conforms to the duck Knative Resource shape.
_ duckv1.KRShaped = (*Certificate)(nil)
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down Expand Up @@ -116,3 +119,13 @@ type HTTP01Challenge struct {
// ServicePort is the port of the service to serve HTTP01 challenge requests.
ServicePort intstr.IntOrString `json:"servicePort,omitempty"`
}

// GetTypeMeta retrieves the ObjectMeta of the Certificate. Implements the KRShaped interface.
func (t *Certificate) GetTypeMeta() *metav1.TypeMeta {
return &t.TypeMeta
}

// GetStatus retrieves the status of the Certificate. Implements the KRShaped interface.
func (t *Certificate) GetStatus() *duckv1.Status {
return &t.Status.Status
}
42 changes: 42 additions & 0 deletions pkg/apis/networking/v1alpha1/certificate_types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright 2020 The Knative Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1

import (
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestCertificateGetStatus(t *testing.T) {
r := &Certificate{
Status: CertificateStatus{},
}
want := &r.Status.Status
if got := r.GetStatus(); got != want {
t.Errorf("got: %v, want: %v", got, want)
}
}

func TestCertificateGetObjectMeta(t *testing.T) {
r := &Certificate{
TypeMeta: metav1.TypeMeta{},
}
want := &r.TypeMeta
if got := r.GetTypeMeta(); got != want {
t.Errorf("got: %v, want: %v", got, want)
}
}
5 changes: 5 additions & 0 deletions pkg/apis/networking/v1alpha1/ingress_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ var ingressCondSet = apis.NewLivingConditionSet(
IngressConditionLoadBalancerReady,
)

// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface.
func (*Ingress) GetConditionSet() apis.ConditionSet {
return ingressCondSet
}

// GetGroupVersionKind returns SchemeGroupVersion of an Ingress
func (i *Ingress) GetGroupVersionKind() schema.GroupVersionKind {
return SchemeGroupVersion.WithKind("Ingress")
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/networking/v1alpha1/ingress_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ func TestIngressDuckTypes(t *testing.T) {
}
}

func TestIngressGetConditionSet(t *testing.T) {
r := &Ingress{}
want := apis.ConditionReady
if got := r.GetConditionSet().GetTopLevelConditionType(); got != want {
t.Errorf("got: %v, want: %v", got, want)
}
}

func TestIngressGetGroupVersionKind(t *testing.T) {
ci := Ingress{}
expected := SchemeGroupVersion.WithKind("Ingress")
Expand Down
13 changes: 13 additions & 0 deletions pkg/apis/networking/v1alpha1/ingress_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ var (

// Check that we can create OwnerReferences to a Ingress.
_ kmeta.OwnerRefable = (*Ingress)(nil)

// Check that the type conforms to the duck Knative Resource shape.
_ duckv1.KRShaped = (*Ingress)(nil)
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down Expand Up @@ -342,3 +345,13 @@ const (
// IngressConditionLoadBalancerReady is set when the Ingress has a ready LoadBalancer.
IngressConditionLoadBalancerReady apis.ConditionType = "LoadBalancerReady"
)

// GetTypeMeta retrieves the ObjectMeta of the Ingress. Implements the KRShaped interface.
func (t *Ingress) GetTypeMeta() *metav1.TypeMeta {
return &t.TypeMeta
}

// GetStatus retrieves the status of the Ingress. Implements the KRShaped interface.
func (t *Ingress) GetStatus() *duckv1.Status {
return &t.Status.Status
}
42 changes: 42 additions & 0 deletions pkg/apis/networking/v1alpha1/ingress_types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright 2020 The Knative Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1

import (
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestIngressGetStatus(t *testing.T) {
r := &Ingress{
Status: IngressStatus{},
}
want := &r.Status.Status
if got := r.GetStatus(); got != want {
t.Errorf("got: %v, want: %v", got, want)
}
}

func TestIngressGetObjectMeta(t *testing.T) {
r := &Ingress{
TypeMeta: metav1.TypeMeta{},
}
want := &r.TypeMeta
if got := r.GetTypeMeta(); got != want {
t.Errorf("got: %v, want: %v", got, want)
}
}
5 changes: 5 additions & 0 deletions pkg/apis/networking/v1alpha1/serverlessservice_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ var serverlessServiceCondSet = apis.NewLivingConditionSet(
ServerlessServiceConditionEndspointsPopulated,
)

// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface.
func (*ServerlessService) GetConditionSet() apis.ConditionSet {
return serverlessServiceCondSet
}

// GetGroupVersionKind returns the GVK for the ServerlessService.
func (ss *ServerlessService) GetGroupVersionKind() schema.GroupVersionKind {
return SchemeGroupVersion.WithKind("ServerlessService")
Expand Down
Loading