Skip to content
This repository has been archived by the owner on Jun 19, 2022. It is now read-only.

Remove v1alpha1 support for knative-gcp sources and Pub/Sub core resources #1858

Merged
merged 1 commit into from
Oct 26, 2020
Merged
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
97 changes: 40 additions & 57 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/google/knative-gcp/pkg/apis/configs/gcpauth"
"github.com/google/knative-gcp/pkg/apis/events"
eventsv1 "github.com/google/knative-gcp/pkg/apis/events/v1"
eventsv1alpha1 "github.com/google/knative-gcp/pkg/apis/events/v1alpha1"
eventsv1beta1 "github.com/google/knative-gcp/pkg/apis/events/v1beta1"
"github.com/google/knative-gcp/pkg/apis/intevents"
inteventsv1 "github.com/google/knative-gcp/pkg/apis/intevents/v1"
Expand Down Expand Up @@ -60,30 +59,23 @@ var types = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{
messagingv1beta1.SchemeGroupVersion.WithKind("Channel"): &messagingv1beta1.Channel{},

// For group events.cloud.google.com.
eventsv1alpha1.SchemeGroupVersion.WithKind("CloudStorageSource"): &eventsv1alpha1.CloudStorageSource{},
eventsv1alpha1.SchemeGroupVersion.WithKind("CloudSchedulerSource"): &eventsv1alpha1.CloudSchedulerSource{},
eventsv1alpha1.SchemeGroupVersion.WithKind("CloudPubSubSource"): &eventsv1alpha1.CloudPubSubSource{},
eventsv1alpha1.SchemeGroupVersion.WithKind("CloudAuditLogsSource"): &eventsv1alpha1.CloudAuditLogsSource{},
eventsv1alpha1.SchemeGroupVersion.WithKind("CloudBuildSource"): &eventsv1alpha1.CloudBuildSource{},
eventsv1beta1.SchemeGroupVersion.WithKind("CloudStorageSource"): &eventsv1beta1.CloudStorageSource{},
eventsv1beta1.SchemeGroupVersion.WithKind("CloudSchedulerSource"): &eventsv1beta1.CloudSchedulerSource{},
eventsv1beta1.SchemeGroupVersion.WithKind("CloudPubSubSource"): &eventsv1beta1.CloudPubSubSource{},
eventsv1beta1.SchemeGroupVersion.WithKind("CloudAuditLogsSource"): &eventsv1beta1.CloudAuditLogsSource{},
eventsv1beta1.SchemeGroupVersion.WithKind("CloudBuildSource"): &eventsv1beta1.CloudBuildSource{},
eventsv1.SchemeGroupVersion.WithKind("CloudStorageSource"): &eventsv1.CloudStorageSource{},
eventsv1.SchemeGroupVersion.WithKind("CloudSchedulerSource"): &eventsv1.CloudSchedulerSource{},
eventsv1.SchemeGroupVersion.WithKind("CloudPubSubSource"): &eventsv1.CloudPubSubSource{},
eventsv1.SchemeGroupVersion.WithKind("CloudAuditLogsSource"): &eventsv1.CloudAuditLogsSource{},
eventsv1.SchemeGroupVersion.WithKind("CloudBuildSource"): &eventsv1.CloudBuildSource{},
eventsv1beta1.SchemeGroupVersion.WithKind("CloudStorageSource"): &eventsv1beta1.CloudStorageSource{},
eventsv1beta1.SchemeGroupVersion.WithKind("CloudSchedulerSource"): &eventsv1beta1.CloudSchedulerSource{},
eventsv1beta1.SchemeGroupVersion.WithKind("CloudPubSubSource"): &eventsv1beta1.CloudPubSubSource{},
eventsv1beta1.SchemeGroupVersion.WithKind("CloudAuditLogsSource"): &eventsv1beta1.CloudAuditLogsSource{},
eventsv1beta1.SchemeGroupVersion.WithKind("CloudBuildSource"): &eventsv1beta1.CloudBuildSource{},
eventsv1.SchemeGroupVersion.WithKind("CloudStorageSource"): &eventsv1.CloudStorageSource{},
eventsv1.SchemeGroupVersion.WithKind("CloudSchedulerSource"): &eventsv1.CloudSchedulerSource{},
eventsv1.SchemeGroupVersion.WithKind("CloudPubSubSource"): &eventsv1.CloudPubSubSource{},
eventsv1.SchemeGroupVersion.WithKind("CloudAuditLogsSource"): &eventsv1.CloudAuditLogsSource{},
eventsv1.SchemeGroupVersion.WithKind("CloudBuildSource"): &eventsv1.CloudBuildSource{},

// For group internal.events.cloud.google.com.
inteventsv1alpha1.SchemeGroupVersion.WithKind("PullSubscription"): &inteventsv1alpha1.PullSubscription{},
inteventsv1alpha1.SchemeGroupVersion.WithKind("Topic"): &inteventsv1alpha1.Topic{},
inteventsv1beta1.SchemeGroupVersion.WithKind("PullSubscription"): &inteventsv1beta1.PullSubscription{},
inteventsv1beta1.SchemeGroupVersion.WithKind("Topic"): &inteventsv1beta1.Topic{},
inteventsv1.SchemeGroupVersion.WithKind("PullSubscription"): &inteventsv1.PullSubscription{},
inteventsv1.SchemeGroupVersion.WithKind("Topic"): &inteventsv1.Topic{},
inteventsv1alpha1.SchemeGroupVersion.WithKind("BrokerCell"): &inteventsv1alpha1.BrokerCell{},
inteventsv1beta1.SchemeGroupVersion.WithKind("PullSubscription"): &inteventsv1beta1.PullSubscription{},
inteventsv1beta1.SchemeGroupVersion.WithKind("Topic"): &inteventsv1beta1.Topic{},
inteventsv1.SchemeGroupVersion.WithKind("PullSubscription"): &inteventsv1.PullSubscription{},
inteventsv1.SchemeGroupVersion.WithKind("Topic"): &inteventsv1.Topic{},
inteventsv1alpha1.SchemeGroupVersion.WithKind("BrokerCell"): &inteventsv1alpha1.BrokerCell{},
}

type defaultingAdmissionController func(context.Context, configmap.Watcher) *controller.Impl
Expand Down Expand Up @@ -185,12 +177,10 @@ func newConversionConstructor(brokers *broker.StoreSingleton, gcpas *gcpauth.Sto

func newConversionController(ctx context.Context, cmw configmap.Watcher, brokers *broker.Store, gcpas *gcpauth.Store) *controller.Impl {
var (
eventsv1alpha1_ = eventsv1alpha1.SchemeGroupVersion.Version
eventsv1beta1_ = eventsv1beta1.SchemeGroupVersion.Version
eventsv1_ = eventsv1.SchemeGroupVersion.Version
inteventsv1alpha1_ = inteventsv1alpha1.SchemeGroupVersion.Version
inteventsv1beta1_ = inteventsv1beta1.SchemeGroupVersion.Version
inteventsv1_ = inteventsv1.SchemeGroupVersion.Version
eventsv1beta1_ = eventsv1beta1.SchemeGroupVersion.Version
eventsv1_ = eventsv1.SchemeGroupVersion.Version
inteventsv1beta1_ = inteventsv1beta1.SchemeGroupVersion.Version
inteventsv1_ = inteventsv1.SchemeGroupVersion.Version
)

// Decorate contexts with the current state of the config.
Expand All @@ -207,66 +197,59 @@ func newConversionController(ctx context.Context, cmw configmap.Watcher, brokers
// events
eventsv1.Kind("CloudAuditLogsSource"): {
DefinitionName: events.CloudAuditLogsSourcesResource.String(),
HubVersion: eventsv1alpha1_,
HubVersion: eventsv1beta1_,
Zygotes: map[string]conversion.ConvertibleObject{
eventsv1alpha1_: &eventsv1alpha1.CloudAuditLogsSource{},
eventsv1beta1_: &eventsv1beta1.CloudAuditLogsSource{},
eventsv1_: &eventsv1.CloudAuditLogsSource{},
eventsv1beta1_: &eventsv1beta1.CloudAuditLogsSource{},
eventsv1_: &eventsv1.CloudAuditLogsSource{},
},
},
eventsv1.Kind("CloudPubSubSource"): {
DefinitionName: events.CloudPubSubSourcesResource.String(),
HubVersion: eventsv1alpha1_,
HubVersion: eventsv1beta1_,
Zygotes: map[string]conversion.ConvertibleObject{
eventsv1alpha1_: &eventsv1alpha1.CloudPubSubSource{},
eventsv1beta1_: &eventsv1beta1.CloudPubSubSource{},
eventsv1_: &eventsv1.CloudPubSubSource{},
eventsv1beta1_: &eventsv1beta1.CloudPubSubSource{},
eventsv1_: &eventsv1.CloudPubSubSource{},
},
},
eventsv1.Kind("CloudSchedulerSource"): {
DefinitionName: events.CloudSchedulerSourcesResource.String(),
HubVersion: eventsv1alpha1_,
HubVersion: eventsv1beta1_,
Zygotes: map[string]conversion.ConvertibleObject{
eventsv1alpha1_: &eventsv1alpha1.CloudSchedulerSource{},
eventsv1beta1_: &eventsv1beta1.CloudSchedulerSource{},
eventsv1_: &eventsv1.CloudSchedulerSource{},
eventsv1beta1_: &eventsv1beta1.CloudSchedulerSource{},
eventsv1_: &eventsv1.CloudSchedulerSource{},
},
},
eventsv1.Kind("CloudStorageSource"): {
DefinitionName: events.CloudStorageSourcesResource.String(),
HubVersion: eventsv1alpha1_,
HubVersion: eventsv1beta1_,
Zygotes: map[string]conversion.ConvertibleObject{
eventsv1alpha1_: &eventsv1alpha1.CloudStorageSource{},
eventsv1beta1_: &eventsv1beta1.CloudStorageSource{},
eventsv1_: &eventsv1.CloudStorageSource{},
eventsv1beta1_: &eventsv1beta1.CloudStorageSource{},
eventsv1_: &eventsv1.CloudStorageSource{},
},
},
eventsv1.Kind("CloudBuildSource"): {
DefinitionName: events.CloudBuildSourcesResource.String(),
HubVersion: eventsv1alpha1_,
HubVersion: eventsv1beta1_,
Zygotes: map[string]conversion.ConvertibleObject{
eventsv1alpha1_: &eventsv1alpha1.CloudBuildSource{},
eventsv1beta1_: &eventsv1beta1.CloudBuildSource{},
eventsv1_: &eventsv1.CloudBuildSource{},
eventsv1beta1_: &eventsv1beta1.CloudBuildSource{},
eventsv1_: &eventsv1.CloudBuildSource{},
},
},
// intevents
inteventsv1.Kind("PullSubscription"): {
DefinitionName: intevents.PullSubscriptionsResource.String(),
HubVersion: inteventsv1alpha1_,
HubVersion: inteventsv1beta1_,
Zygotes: map[string]conversion.ConvertibleObject{
inteventsv1alpha1_: &inteventsv1alpha1.PullSubscription{},
inteventsv1beta1_: &inteventsv1beta1.PullSubscription{},
inteventsv1_: &inteventsv1.PullSubscription{},
inteventsv1beta1_: &inteventsv1beta1.PullSubscription{},
inteventsv1_: &inteventsv1.PullSubscription{},
},
},
inteventsv1.Kind("Topic"): {
DefinitionName: intevents.TopicsResource.String(),
HubVersion: inteventsv1alpha1_,
HubVersion: inteventsv1beta1_,
Zygotes: map[string]conversion.ConvertibleObject{
inteventsv1alpha1_: &inteventsv1alpha1.Topic{},
inteventsv1beta1_: &inteventsv1beta1.Topic{},
inteventsv1_: &inteventsv1.Topic{},
inteventsv1beta1_: &inteventsv1beta1.Topic{},
inteventsv1_: &inteventsv1.Topic{},
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions config/core/resources/channel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# TODO: merge v1alpha1 schema into v1beta1 then remove v1alpha1 schema from CRD

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
Expand Down
4 changes: 2 additions & 2 deletions config/core/resources/cloudauditlogssource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ spec:
description: >
ID of the Stackdriver sink used to publish audit log messages.
- <<: *version
# TODO: remove v1alpha1 schema from CRD
name: v1alpha1
# TODO: Flip served bit of v1alpha1 in https://github.com/google/knative-gcp/issues/1544.
served: true
served: false
Copy link
Contributor

@capri-xiyue capri-xiyue Oct 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked knative-eventing. It looks like knative eventing just deleted v1alpha1 version in crd definition.
Maybe create another issue to clean all v1alpha1 version in crds. It may need addition work to clean the crds if other version schema depends on v1alpha1 schema.

storage: false
# v1alpha1 and v1beta have status.properties.serviceAccountName in the schema
schema: &v1alpha1Schema
Expand Down
4 changes: 2 additions & 2 deletions config/core/resources/cloudbuildsource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ spec:
storage: false
schema: *v1Schema
- <<: *version
# TODO: remove v1alpha1 schema from CRD
name: v1alpha1
# TODO: Flip served bit of v1alpha1 in https://github.com/google/knative-gcp/issues/1544.
served: true
served: false
storage: false
# v1alpha1 have status.properties.serviceAccountName in the schema
schema:
Expand Down
4 changes: 2 additions & 2 deletions config/core/resources/cloudpubsubsource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ spec:
subscriptionId:
type: string
- <<: *version
# TODO: remove v1alpha1 schema from CRD
name: v1alpha1
# TODO: Flip served bit of v1alpha1 in https://github.com/google/knative-gcp/issues/1544.
served: true
served: false
storage: false
# v1alpha1 and v1beta have status.properties.serviceAccountName in the schema
schema: &v1alpha1Schema
Expand Down
4 changes: 2 additions & 2 deletions config/core/resources/cloudschedulersource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ spec:
jobName:
type: string
- << : *version
# TODO: remove v1alpha1 schema from CRD
name: v1alpha1
# TODO: Flip served bit of v1alpha1 in https://github.com/google/knative-gcp/issues/1544.
served: true
served: false
storage: false
# v1alpha1 and v1beta have status.properties.serviceAccountName in the schema
schema: &v1alpha1Schema
Expand Down
4 changes: 2 additions & 2 deletions config/core/resources/cloudstoragesource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ spec:
notificationId:
type: string
- << : *version
# TODO: remove v1alpha1 schema from CRD
name: v1alpha1
# TODO: Flip served bit of v1alpha1 in https://github.com/google/knative-gcp/issues/1544.
served: true
served: false
storage: false
# v1alpha1 and v1beta have spec.properties.payloadFormat and status.properties.serviceAccountName in the schema
schema: &v1alpha1Schema
Expand Down
4 changes: 2 additions & 2 deletions config/core/resources/pullsubscription.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ spec:
transformerUri:
type: string
- << : *version
# TODO: remove v1alpha1 schema from CRD
name: v1alpha1
# TODO: Flip served bit of v1alpha1 in https://github.com/google/knative-gcp/issues/1544.
served: true
served: false
storage: false
# v1alpha1 and v1beta have spec.properties.mode and status.properties.serviceAccountName in the schema
schema: &v1alpha1Schema
Expand Down
4 changes: 2 additions & 2 deletions config/core/resources/topic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ spec:
url:
type: string
- << : *version
# TODO: remove v1alpha1 schema from CRD
name: v1alpha1
# TODO: Flip served bit of v1alpha1 in https://github.com/google/knative-gcp/issues/1544.
served: true
served: false
storage: false
# v1alpha1 and v1beta1 have serviceAccountName in status.properties in the schema
schema: &v1alpha1Schema
Expand Down
4 changes: 2 additions & 2 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ chmod +x "${CODEGEN_PKG}"/generate-groups.sh
# instead of the $GOPATH directly. For normal projects this can be dropped.
"${CODEGEN_PKG}"/generate-groups.sh "deepcopy,client,informer,lister" \
github.com/google/knative-gcp/pkg/client github.com/google/knative-gcp/pkg/apis \
"messaging:v1beta1 events:v1alpha1 events:v1beta1 events:v1 broker:v1beta1 intevents:v1alpha1 intevents:v1beta1 intevents:v1" \
"messaging:v1beta1 events:v1beta1 events:v1 broker:v1beta1 intevents:v1alpha1 intevents:v1beta1 intevents:v1" \
--go-header-file "${REPO_ROOT_DIR}"/hack/boilerplate/boilerplate.go.txt

# Knative Injection
chmod +x "${KNATIVE_CODEGEN_PKG}"/hack/generate-knative.sh
"${KNATIVE_CODEGEN_PKG}"/hack/generate-knative.sh "injection" \
github.com/google/knative-gcp/pkg/client github.com/google/knative-gcp/pkg/apis \
"messaging:v1beta1 events:v1alpha1 events:v1beta1 events:v1 duck:v1alpha1 duck:v1beta1 duck:v1 broker:v1beta1 intevents:v1alpha1 intevents:v1beta1 intevents:v1" \
"messaging:v1beta1 events:v1beta1 events:v1 duck:v1alpha1 duck:v1beta1 duck:v1 broker:v1beta1 intevents:v1alpha1 intevents:v1beta1 intevents:v1" \
--go-header-file "${REPO_ROOT_DIR}"/hack/boilerplate/boilerplate.go.txt

# Deep copy configs.
Expand Down
65 changes: 0 additions & 65 deletions pkg/apis/events/v1alpha1/cloudauditlogssource_conversion.go

This file was deleted.

Loading