Skip to content

Commit

Permalink
Use v1beta1 DomainMapping CRD
Browse files Browse the repository at this point in the history
  • Loading branch information
nak3 committed Sep 4, 2023
1 parent ff329d5 commit 823e45f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions serving/metadata-webhook/cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (
"knative.dev/pkg/webhook/resourcesemantics"
"knative.dev/pkg/webhook/resourcesemantics/defaulting"
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
servingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1"
servingv1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1"
)

var types = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{
servingv1.SchemeGroupVersion.WithKind("Service"): &defaults.TargetKService{},
servingv1.SchemeGroupVersion.WithKind("Route"): &defaults.TargetRoute{},
servingv1.SchemeGroupVersion.WithKind("Configuration"): &defaults.TargetConfiguration{},
servingv1alpha1.SchemeGroupVersion.WithKind("DomainMapping"): &defaults.TargetDomainMapping{},
servingv1.SchemeGroupVersion.WithKind("Service"): &defaults.TargetKService{},
servingv1.SchemeGroupVersion.WithKind("Route"): &defaults.TargetRoute{},
servingv1.SchemeGroupVersion.WithKind("Configurtion"): &defaults.TargetConfiguration{},
servingv1beta1.SchemeGroupVersion.WithKind("DomainMappig"): &defaults.TargetDomainMapping{},
}

func NewDefaultingAdmissionController(ctx context.Context, _ configmap.Watcher) *controller.Impl {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"context"

"knative.dev/pkg/apis"
servingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1"
servingv1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// TargetDomainMapping is a wrapper around Configuration.
type TargetDomainMapping struct {
servingv1alpha1.DomainMapping `json:",inline"`
servingv1beta1.DomainMapping `json:",inline"`
}

// Verify that Deployment adheres to the appropriate interfaces.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
servingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1"
servingv1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1"

"github.com/google/go-cmp/cmp"
)
Expand All @@ -19,7 +19,7 @@ func TestTargetDomainMappingDefaulting(t *testing.T) {
name: "empty",
in: &TargetDomainMapping{},
want: &TargetDomainMapping{
servingv1alpha1.DomainMapping{
servingv1beta1.DomainMapping{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
openshiftPassthrough: "true",
Expand All @@ -30,7 +30,7 @@ func TestTargetDomainMappingDefaulting(t *testing.T) {
}, {
name: "override",
in: &TargetDomainMapping{
servingv1alpha1.DomainMapping{
servingv1beta1.DomainMapping{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
openshiftPassthrough: "false",
Expand All @@ -39,7 +39,7 @@ func TestTargetDomainMappingDefaulting(t *testing.T) {
},
},
want: &TargetDomainMapping{
servingv1alpha1.DomainMapping{
servingv1beta1.DomainMapping{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
openshiftPassthrough: "true",
Expand Down Expand Up @@ -77,7 +77,7 @@ func TestDeepCopyObjectDomainMapping(t *testing.T) {
}{{
name: "with name",
in: &TargetDomainMapping{
servingv1alpha1.DomainMapping{
servingv1beta1.DomainMapping{
ObjectMeta: metav1.ObjectMeta{
Name: "foo-deployment",
},
Expand Down
8 changes: 4 additions & 4 deletions test/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
servingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1"
servingv1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1"
)

type ServiceCfgFunc func(*servingv1.Service)
Expand Down Expand Up @@ -140,9 +140,9 @@ func WaitForReadyServices(ctx *Context, namespace string) error {
return nil
}

func WaitForDomainMappingState(ctx *Context, name, namespace string, inState func(dm *servingv1alpha1.DomainMapping, err error) (bool, error)) (*servingv1alpha1.DomainMapping, error) {
func WaitForDomainMappingState(ctx *Context, name, namespace string, inState func(dm *servingv1beta1.DomainMapping, err error) (bool, error)) (*servingv1beta1.DomainMapping, error) {
var (
lastState *servingv1alpha1.DomainMapping
lastState *servingv1beta1.DomainMapping
err error
)
waitErr := wait.PollImmediate(Interval, Timeout, func() (bool, error) {
Expand All @@ -160,7 +160,7 @@ func IsServiceReady(s *servingv1.Service, err error) (bool, error) {
return s.IsReady() && s.Status.URL != nil && s.Status.URL.Host != "", err
}

func IsDomainMappingReady(dm *servingv1alpha1.DomainMapping, err error) (bool, error) {
func IsDomainMappingReady(dm *servingv1beta1.DomainMapping, err error) (bool, error) {
return dm.IsReady() && dm.Status.URL != nil && dm.Status.URL.Host != "", err
}

Expand Down
6 changes: 3 additions & 3 deletions test/servinge2e/kourier/custom_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
duckv1 "knative.dev/pkg/apis/duck/v1"
pkgTest "knative.dev/pkg/test"
"knative.dev/pkg/test/spoof"
servingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1"
servingv1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1"
)

const (
Expand Down Expand Up @@ -88,13 +88,13 @@ func TestCustomOpenShiftRoute(t *testing.T) {
servinge2e.WaitForRouteServingText(t, caCtx, ksvc.Status.URL.URL(), helloworldText)

// Create DomainMapping with disable Annotation.
dm := &servingv1alpha1.DomainMapping{
dm := &servingv1beta1.DomainMapping{
ObjectMeta: metav1.ObjectMeta{
Name: domainMappingName,
Namespace: test.Namespace,
Annotations: map[string]string{resources.DisableRouteAnnotation: "true"},
},
Spec: servingv1alpha1.DomainMappingSpec{
Spec: servingv1beta1.DomainMappingSpec{
Ref: duckv1.KReference{
Kind: "Service",
Name: serviceName,
Expand Down
4 changes: 2 additions & 2 deletions test/servinge2e/kourier/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (

"github.com/openshift-knative/serverless-operator/test"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
servingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1"
servingv1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1"
)

const (
helloworldText = "Hello World!"
)

func withDomainMappingReadyOrFail(ctx *test.Context, dm *servingv1alpha1.DomainMapping) *servingv1alpha1.DomainMapping {
func withDomainMappingReadyOrFail(ctx *test.Context, dm *servingv1beta1.DomainMapping) *servingv1beta1.DomainMapping {
dm, err := ctx.Clients.Serving.ServingV1alpha1().DomainMappings(dm.Namespace).Create(context.Background(), dm, metav1.CreateOptions{})
if err != nil {
ctx.T.Fatalf("Error creating ksvc: %v", err)
Expand Down

0 comments on commit 823e45f

Please sign in to comment.